@@ -532,6 +532,7 @@ static int cmd_show(int argc, char **argv)
struct btrfs_fs_devices *fs_devices;
struct list_head *cur_uuid;
char *search = NULL;
+ char *real_mp = NULL;
int ret;
int where = BTRFS_SCAN_LBLKID;
int type = 0;
@@ -607,6 +608,11 @@ static int cmd_show(int argc, char **argv)
}
}
}
+
+ if (type == BTRFS_ARG_MNTPOINT) {
+ find_mount_root(search, &real_mp, 1);
+ search = real_mp;
+ }
}
if (where == BTRFS_SCAN_DEV)
@@ -646,6 +652,7 @@ devs_only:
out:
printf("%s\n", BTRFS_BUILD_VERSION);
+ free(real_mp);
free_seen_fsid();
return ret;
}
@@ -700,26 +700,20 @@ int is_block_device(const char *path)
/*
* check if given path is a mount point
- * return 1 if yes. 0 if no. -1 for error
+ * return 1 if yes. 0 if no. <0 for error
*/
int is_mount_point(const char *path)
{
- FILE *f;
- struct mntent *mnt;
- int ret = 0;
-
- f = setmntent("/proc/self/mounts", "r");
- if (f == NULL)
- return -1;
+ int ret;
- while ((mnt = getmntent(f)) != NULL) {
- if (strcmp(mnt->mnt_dir, path))
- continue;
- ret = 1;
- break;
+ ret = find_mount_root(path, NULL, 1);
+ if (ret < 0) {
+ if (ret != -ENOENT)
+ return 0;
+ else
+ return ret;
}
- endmntent(f);
- return ret;
+ return 1;
}
/*
Since find_mount_root now can check mount point quiet good, reuse it to determing arg type and get real mount point Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com> --- cmds-filesystem.c | 7 +++++++ utils.c | 24 +++++++++--------------- 2 files changed, 16 insertions(+), 15 deletions(-)