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)