diff options
author | Omar Sandoval <osandov@fb.com> | 2017-12-20 12:37:08 -0800 |
---|---|---|
committer | David Sterba <dsterba@suse.com> | 2018-03-06 11:28:37 +0100 |
commit | 9005b603d7230a92d0623cb8d8078a8845739fca (patch) | |
tree | 72ab8f3cc9a7e3d84fd14448f83e61d97c1a4181 /utils.c | |
parent | afb04260169911c9ecab2524fad03b86bc744dd3 (diff) |
btrfs-progs: use libbtrfsutil for subvol show
Now implemented with btrfs_util_subvolume_path(),
btrfs_util_subvolume_info(), and subvolume iterators.
Signed-off-by: Omar Sandoval <osandov@fb.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Diffstat (limited to 'utils.c')
-rw-r--r-- | utils.c | 118 |
1 files changed, 0 insertions, 118 deletions
@@ -2495,124 +2495,6 @@ const char *subvol_strip_mountpoint(const char *mnt, const char *full_path) return full_path + len; } -/* - * Returns - * <0: Std error - * 0: All fine - * 1: Error; and error info printed to the terminal. Fixme. - * 2: If the fullpath is root tree instead of subvol tree - */ -int get_subvol_info(const char *fullpath, struct root_info *get_ri) -{ - u64 sv_id; - int ret = 1; - int fd = -1; - int mntfd = -1; - char *mnt = NULL; - const char *svpath = NULL; - DIR *dirstream1 = NULL; - DIR *dirstream2 = NULL; - - ret = test_issubvolume(fullpath); - if (ret < 0) - return ret; - if (!ret) { - error("not a subvolume: %s", fullpath); - return 1; - } - - ret = find_mount_root(fullpath, &mnt); - if (ret < 0) - return ret; - if (ret > 0) { - error("%s doesn't belong to btrfs mount point", fullpath); - return 1; - } - ret = 1; - svpath = subvol_strip_mountpoint(mnt, fullpath); - - fd = btrfs_open_dir(fullpath, &dirstream1, 1); - if (fd < 0) - goto out; - - ret = btrfs_list_get_path_rootid(fd, &sv_id); - if (ret) - goto out; - - mntfd = btrfs_open_dir(mnt, &dirstream2, 1); - if (mntfd < 0) - goto out; - - memset(get_ri, 0, sizeof(*get_ri)); - get_ri->root_id = sv_id; - - if (sv_id == BTRFS_FS_TREE_OBJECTID) - ret = btrfs_get_toplevel_subvol(mntfd, get_ri); - else - ret = btrfs_get_subvol(mntfd, get_ri); - if (ret) - error("can't find '%s': %d", svpath, ret); - -out: - close_file_or_dir(mntfd, dirstream2); - close_file_or_dir(fd, dirstream1); - free(mnt); - - return ret; -} - -int get_subvol_info_by_rootid(const char *mnt, struct root_info *get_ri, u64 r_id) -{ - int fd; - int ret; - DIR *dirstream = NULL; - - fd = btrfs_open_dir(mnt, &dirstream, 1); - if (fd < 0) - return -EINVAL; - - memset(get_ri, 0, sizeof(*get_ri)); - get_ri->root_id = r_id; - - if (r_id == BTRFS_FS_TREE_OBJECTID) - ret = btrfs_get_toplevel_subvol(fd, get_ri); - else - ret = btrfs_get_subvol(fd, get_ri); - - if (ret) - error("can't find rootid '%llu' on '%s': %d", r_id, mnt, ret); - - close_file_or_dir(fd, dirstream); - - return ret; -} - -int get_subvol_info_by_uuid(const char *mnt, struct root_info *get_ri, u8 *uuid_arg) -{ - int fd; - int ret; - DIR *dirstream = NULL; - - fd = btrfs_open_dir(mnt, &dirstream, 1); - if (fd < 0) - return -EINVAL; - - memset(get_ri, 0, sizeof(*get_ri)); - uuid_copy(get_ri->uuid, uuid_arg); - - ret = btrfs_get_subvol(fd, get_ri); - if (ret) { - char uuid_parsed[BTRFS_UUID_UNPARSED_SIZE]; - uuid_unparse(uuid_arg, uuid_parsed); - error("can't find uuid '%s' on '%s': %d", - uuid_parsed, mnt, ret); - } - - close_file_or_dir(fd, dirstream); - - return ret; -} - /* Set the seed manually */ void init_rand_seed(u64 seed) { |