From: Lin Feng Shen <shenlinf(a)cn.ibm.com>
"mount [devname | dirname]" showes mount points according to the device
name or directory name. Generally speaking, two path names shouldn't be
different due to additional "/", e.g. /distros and /distros/, but it
seems that mount command doesn't handle it properly, e.g.
----------
crash> mount
VFSMOUNT SUPERBLK TYPE DEVNAME DIRNAME
...
c00000000224eb80 c000000002589800 ext3 /dev/sda2 /boot
...
crash> mount /boot
VFSMOUNT SUPERBLK TYPE DEVNAME DIRNAME
c00000000224eb80 c000000002589800 ext3 /dev/sda2 /boot
crash> mount /boot/
crash>
----------
The patch provides pathcmp() replacing STREQ to compare two path names.
It's created against crash-4.0-25.4 in SLES10_RC3.
Signed-off-by: Lin Feng Shen <shenlinf(a)cn.ibm.com>
---
diff -upNr crash-4.0-2.18.orig/defs.h crash-4.0-2.18/defs.h
--- crash-4.0-2.18.orig/defs.h 2006-07-05 23:46:10.000000000 -0400
+++ crash-4.0-2.18/defs.h 2006-07-06 06:30:12.000000000 -0400
@@ -91,6 +91,7 @@
#define STREQ(A, B) (A && B && (strcmp((char *)(A), (char *)(B)) ==
0))
#define STRNEQ(A, B) (A && B && \
(strncmp((char *)(A), (char *)(B), strlen((char *)(B))) == 0))
+#define PATHEQ(A, B) (A && B && (pathcmp((char *)(A), (char *)(B))
== 0))
#define BZERO(S, N) (memset(S, NULLCHAR, N))
#define BCOPY(S, D, C) (memcpy(D, S, C))
#define BNEG(S, N) (memset(S, 0xff, N))
@@ -2876,6 +2877,7 @@ int empty_list(ulong);
int machine_type(char *);
void command_not_supported(void);
void option_not_supported(int);
+int pathcmp(char* p1, char* p2);
/*
diff -upNr crash-4.0-2.18.orig/filesys.c crash-4.0-2.18/filesys.c
--- crash-4.0-2.18.orig/filesys.c 2006-07-05 23:46:09.000000000 -0400
+++ crash-4.0-2.18/filesys.c 2006-07-06 06:30:22.000000000 -0400
@@ -1193,7 +1193,7 @@ cmd_mount(void)
continue;
for (i = 0; i < c; i++) {
- if (STREQ(arglist[i], spec_string))
+ if (PATHEQ(arglist[i], spec_string))
found = TRUE;
}
if (found) {
diff -upNr crash-4.0-2.18.orig/tools.c crash-4.0-2.18/tools.c
--- crash-4.0-2.18.orig/tools.c 2006-07-05 23:46:10.000000000 -0400
+++ crash-4.0-2.18/tools.c 2006-07-06 06:28:01.000000000 -0400
@@ -4328,3 +4328,23 @@ option_not_supported(int c)
error(FATAL, "-%c option not supported on this architecture or
kernel\n",
(char)c);
}
+
+/*
+ * The function to compare two device paths
+ */
+int
+pathcmp(char* p1, char* p2)
+{
+ char c1, c2;
+
+ do {
+ if ((c1 = *p1++) == '/')
+ while(*p1 == '/'){ p1++; }
+ if ((c2 = *p2++) == '/')
+ while(*p2 == '/'){ p2++; }
+ if (c1 == '\0')
+ return ((c2 == '/') && (*p2 == '\0')) ?
0 : c1 - c2;
+ } while (c1 == c2);
+
+ return ( (c2 == '\0') && (c1 == '/') && (*p1 ==
'\0')) ? 0 : c1 - c2;
+}
-----------------------------------------------------------------------------------------------------------
--
Crash-utility mailing list
Crash-utility(a)redhat.com
https://www.redhat.com/mailman/listinfo/crash-utility