summaryrefslogtreecommitdiff
path: root/utils.c
diff options
context:
space:
mode:
authorQu Wenruo <quwenruo@cn.fujitsu.com>2014-07-23 13:47:35 +0800
committerDavid Sterba <dsterba@suse.cz>2014-08-22 15:07:02 +0200
commitde22c28ef31d9721606ba05965a093a8044be0de (patch)
tree2c5e2c942d927463160bf8c2b46e1c76d548d7be /utils.c
parent10c8f34f519451d763ae6b40bd388d11f4d3d42f (diff)
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 do special error string output in caller. This will suppress a lot of "Inapproiate ioctl for device" error message. Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.cz>
Diffstat (limited to 'utils.c')
-rw-r--r--utils.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/utils.c b/utils.c
index 3d467c56..73fcd15f 100644
--- a/utils.c
+++ b/utils.c
@@ -2324,6 +2324,11 @@ int lookup_ino_rootid(int fd, u64 *rootid)
return 0;
}
+/*
+ * return 0 if a btrfs mount point is found
+ * return 1 if a mount point is found but not btrfs
+ * return <0 if something goes wrong
+ */
int find_mount_root(const char *path, char **mount_root)
{
FILE *mnttab;
@@ -2331,6 +2336,7 @@ int find_mount_root(const char *path, char **mount_root)
struct mntent *ent;
int len;
int ret;
+ int not_btrfs = 1;
int longest_matchlen = 0;
char *longest_match = NULL;
@@ -2351,6 +2357,7 @@ int find_mount_root(const char *path, char **mount_root)
free(longest_match);
longest_matchlen = len;
longest_match = strdup(ent->mnt_dir);
+ not_btrfs = strcmp(ent->mnt_type, "btrfs");
}
}
}
@@ -2358,6 +2365,10 @@ int find_mount_root(const char *path, char **mount_root)
if (!longest_match)
return -ENOENT;
+ if (not_btrfs) {
+ free(longest_match);
+ return 1;
+ }
ret = 0;
*mount_root = realpath(longest_match, NULL);