From 7faf96e30aacf927ac18c5a1e5c50921f0ae5eee Mon Sep 17 00:00:00 2001 From: David Sterba Date: Wed, 13 Jan 2016 18:44:59 +0100 Subject: btrfs-progs: also check filesystem type in test_issubvolume A subvolume is a directory with inode number 256 on a btrfs filesytem. Add the missing check to test_issubvolume for completeness, otherwise we always do that in btrfs_open_dir. Signed-off-by: David Sterba --- cmds-subvolume.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/cmds-subvolume.c b/cmds-subvolume.c index d5ec8862..95c23d0a 100644 --- a/cmds-subvolume.c +++ b/cmds-subvolume.c @@ -21,10 +21,12 @@ #include #include #include +#include #include #include #include #include +#include #include "kerncompat.h" #include "ioctl.h" @@ -232,14 +234,21 @@ out: int test_issubvolume(const char *path) { struct stat st; + struct statfs stfs; int res; res = stat(path, &st); if (res < 0) return -errno; - return (st.st_ino == BTRFS_FIRST_FREE_OBJECTID) - && S_ISDIR(st.st_mode); + if (st.st_ino != BTRFS_FIRST_FREE_OBJECTID || !S_ISDIR(st.st_mode)) + return 0; + + res = statfs(path, &stfs); + if (res < 0) + return -errno; + + return (int)stfs.f_type == BTRFS_SUPER_MAGIC; } static int wait_for_commit(int fd) -- cgit v1.2.3