mountpoint: btrfs fix
authorVladimir Dronnikov <dronnikov@gmail.com>
Sun, 1 Nov 2009 03:33:23 +0000 (04:33 +0100)
committerDenys Vlasenko <vda.linux@googlemail.com>
Sun, 1 Nov 2009 03:33:23 +0000 (04:33 +0100)
Signed-off-by: Vladimir Dronnikov <dronnikov@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
miscutils/mountpoint.c

index b541ce2..a35c389 100644 (file)
@@ -55,8 +55,17 @@ int mountpoint_main(int argc UNUSED_PARAM, char **argv)
 
                        if (opt & OPT_d)
                                printf("%u:%u\n", major(st_dev), minor(st_dev));
-                       if (opt & OPT_n)
-                               printf("%s %s\n", find_block_device(arg), arg);
+                       if (opt & OPT_n) {
+                               const char *d = find_block_device(arg);
+                               /* name is undefined, but device is mounted -> anonymous superblock! */
+                               /* happens with btrfs */
+                               if (!d) {
+                                       d = "UNKNOWN";
+                                       /* TODO: iterate /proc/mounts, or /proc/self/mountinfo
+                                        * to find out the device name */
+                               }
+                               printf("%s %s\n", d, arg);
+                       }
                        if (!(opt & (OPT_q | OPT_d | OPT_n)))
                                printf("%s is %sa mountpoint\n", arg, is_not_mnt ? "not " : "");
                        return is_not_mnt;