diff options
author | Filipe David Borba Manana <fdmanana@gmail.com> | 2013-11-12 13:41:42 +0000 |
---|---|---|
committer | Chris Mason <clm@fb.com> | 2014-01-31 08:22:02 -0800 |
commit | 457b1286dd9976efbfec25bb286ddc8cec410aa1 (patch) | |
tree | 517affec64c49ccdb548beba5e4db3bb03923bbf /utils.c | |
parent | 67d3c3c0d3505377e6468849b086aefc69ae5411 (diff) |
Btrfs-progs: let get_label return the label instead of printing it
get_label prints the label at the moment. Change this so that
the label is returned and printing is done by the caller.
Signed-off-by: Filipe David Borba Manana <fdmanana@gmail.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
Signed-off-by: Chris Mason <clm@fb.com>
Diffstat (limited to 'utils.c')
-rw-r--r-- | utils.c | 15 |
1 files changed, 6 insertions, 9 deletions
@@ -1345,7 +1345,7 @@ static int set_label_mounted(const char *mount_path, const char *label) return 0; } -static int get_label_unmounted(const char *dev) +static int get_label_unmounted(const char *dev, char *label) { struct btrfs_root *root; int ret; @@ -1368,7 +1368,7 @@ static int get_label_unmounted(const char *dev) if(!root) return -1; - fprintf(stdout, "%s\n", root->fs_info->super_copy->label); + memcpy(label, root->fs_info->super_copy->label, BTRFS_LABEL_SIZE); /* Now we close it since we are done. */ close_ctree(root); @@ -1403,18 +1403,15 @@ int get_label_mounted(const char *mount_path, char *labelp) return 0; } -int get_label(const char *btrfs_dev) +int get_label(const char *btrfs_dev, char *label) { int ret; - char label[BTRFS_LABEL_SIZE]; if (is_existing_blk_or_reg_file(btrfs_dev)) - ret = get_label_unmounted(btrfs_dev); - else { + ret = get_label_unmounted(btrfs_dev, label); + else ret = get_label_mounted(btrfs_dev, label); - if (!ret) - fprintf(stdout, "%s\n", label); - } + return ret; } |