Qu Wenruo
2014-Jul-04 08:38 UTC
[PATCH 1/2] btrfs-progs: Check fstype in find_mount_root()
When calling find_mount_root(), caller in fact wants to find the mount point of *BTRFS*. So also check ent->fstype in find_mount_root() and output proper error messages if needed. This will suppress a lot of "Inapproiate ioctl for device" error message. Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com> --- utils.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/utils.c b/utils.c index 993d085..592a73b 100644 --- a/utils.c +++ b/utils.c @@ -2412,6 +2412,7 @@ int find_mount_root(const char *path, char **mount_root) struct mntent *ent; int len; int ret; + int not_btrfs; int longest_matchlen = 0; char *longest_match = NULL; @@ -2432,6 +2433,10 @@ int find_mount_root(const char *path, char **mount_root) free(longest_match); longest_matchlen = len; longest_match = strdup(ent->mnt_dir); + if (strcmp(ent->mnt_type, "btrfs")) + not_btrfs = 1; + else + not_btrfs = 0; } } } @@ -2443,6 +2448,12 @@ int find_mount_root(const char *path, char **mount_root) path); return -ENOENT; } + if (not_btrfs) { + fprintf(stderr, + "ERROR: %s does not belong to a btrfs mount points.\n", + path); + return -ENOENT; + } ret = 0; *mount_root = realpath(longest_match, NULL); -- 2.0.1 -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html