X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=utils.c;h=d81d49800f4cdf01c15baae2008d7e0e4d33bf71;hb=335b7011352bfe27d59094d622abe111177021d4;hp=775af2946eeaab1e6f261159939b3f5d010cded1;hpb=9005b603d7230a92d0623cb8d8078a8845739fca;p=platform%2Fupstream%2Fbtrfs-progs.git diff --git a/utils.c b/utils.c index 775af29..d81d498 100644 --- a/utils.c +++ b/utils.c @@ -40,6 +40,8 @@ #include #include +#include + #include "kerncompat.h" #include "radix-tree.h" #include "ctree.h" @@ -1048,7 +1050,7 @@ int btrfs_device_already_in_root(struct btrfs_root *root, int fd, * structures. */ if (btrfs_super_magic(disk_super) != BTRFS_MAGIC && - btrfs_super_magic(disk_super) != BTRFS_MAGIC_PARTIAL) + btrfs_super_magic(disk_super) != BTRFS_MAGIC_TEMPORARY) goto brelse; if (!memcmp(disk_super->fsid, root->fs_info->super_copy->fsid, @@ -1453,6 +1455,7 @@ u64 parse_qgroupid(const char *p) char *s = strchr(p, '/'); const char *ptr_src_end = p + strlen(p); char *ptr_parse_end = NULL; + enum btrfs_util_error err; u64 level; u64 id; int fd; @@ -1480,8 +1483,8 @@ u64 parse_qgroupid(const char *p) path: /* Path format like subv at 'my_subvol' is the fallback case */ - ret = test_issubvolume(p); - if (ret < 0 || !ret) + err = btrfs_util_is_subvolume(p); + if (err) goto err; fd = open(p, O_RDONLY); if (fd < 0) @@ -2451,33 +2454,6 @@ int test_issubvolname(const char *name) strcmp(name, ".") && strcmp(name, ".."); } -/* - * Test if path is a subvolume - * Returns: - * 0 - path exists but it is not a subvolume - * 1 - path exists and it is a subvolume - * < 0 - error - */ -int test_issubvolume(const char *path) -{ - struct stat st; - struct statfs stfs; - int res; - - res = stat(path, &st); - if (res < 0) - return -errno; - - 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; -} - const char *subvol_strip_mountpoint(const char *mnt, const char *full_path) { int len = strlen(mnt);