[Crash-utility] [PATCH] fix command vm/files -d/mount on new kernel

Dave Anderson anderson at redhat.com
Mon Mar 12 19:50:29 UTC 2012



----- Original Message -----
> ...
> If we can continue to have get_pathname() receive a vfsmount pointer,
> it reduces the chance of introducing new bugs like the above, and future
> maintenance will be easier.

Qiao,

Another thing I forgot to mention w/respect to simplifying your 
patch.  You do things like this in a number of places:

@@ -1336,9 +1336,15 @@ show_mounts(ulong one_vfsmount, int flags, struct task_context *namespace_contex
                devlen = strlen("DEVNAME");

                for (m = 0, vfsmnt = mntlist; m < mount_cnt; m++, vfsmnt++) {
-                       readmem(*vfsmnt + OFFSET(vfsmount_mnt_devname),
-                               KVADDR, &devp, sizeof(void *),
-                               "vfsmount mnt_devname", FAULT_ON_ERROR);
+                       if (VALID_STRUCT(mount)) {
+                               readmem(*vfsmnt+OFFSET(mount_mnt_devname),
+                                       KVADDR, &devp, sizeof(void *),
+                                       "mount mnt_devname", FAULT_ON_ERROR);
+                       } else {
+                               readmem(*vfsmnt+OFFSET(vfsmount_mnt_devname),
+                                       KVADDR, &devp, sizeof(void *),
+                                       "vfsmount mnt_devname", FAULT_ON_ERROR);
+                       }

                        if (read_string(devp, buf1, BUFSIZE-1)) {
                                if (strlen(buf1) > devlen)

which could be simplified by a single readmem() call using OFFSET_OPTION():

	readmem(*vfsmnt + OFFSET_OPTION(vfsmount_mnt_devname, mount_mnt_devname),
		KVADDR, &devp, sizeof(void *), "[vfs]mount mnt_devname", FAULT_ON_ERROR);

If the first (older-kernel) option fails, then the second one is used.

Dave





More information about the Crash-utility mailing list