diff --git a/daemon/btrfs.c b/daemon/btrfs.c index 8fcfd819d..ee3464dda 100644 --- a/daemon/btrfs.c +++ b/daemon/btrfs.c @@ -70,6 +70,22 @@ btrfs_get_label (const char *device) return out; } +int +btrfs_set_label (const char *device, const char *label) +{ + int r; + CLEANUP_FREE char *err = NULL; + + r = command (NULL, &err, str_btrfs, "filesystem", "label", + device, label, NULL); + if (r == -1) { + reply_with_error ("%s", err); + return -1; + } + + return 0; +} + /* Takes optional arguments, consult optargs_bitmask. */ int do_btrfs_filesystem_resize (const char *filesystem, int64_t size) diff --git a/daemon/daemon.h b/daemon/daemon.h index a4a436183..783d7397d 100644 --- a/daemon/daemon.h +++ b/daemon/daemon.h @@ -275,6 +275,7 @@ extern char *debug_bmap_device (const char *subcmd, size_t argc, char *const *co /*-- in btrfs.c --*/ extern char *btrfs_get_label (const char *device); +extern int btrfs_set_label (const char *device, const char *label); extern int btrfs_set_uuid (const char *device, const char *uuid); extern int btrfs_set_uuid_random (const char *device); diff --git a/daemon/labels.c b/daemon/labels.c index cfcb4df91..eec5b9686 100644 --- a/daemon/labels.c +++ b/daemon/labels.c @@ -27,28 +27,11 @@ #include "actions.h" #include "optgroups.h" -GUESTFSD_EXT_CMD(str_btrfs, btrfs); GUESTFSD_EXT_CMD(str_dosfslabel, dosfslabel); GUESTFSD_EXT_CMD(str_e2label, e2label); GUESTFSD_EXT_CMD(str_ntfslabel, ntfslabel); GUESTFSD_EXT_CMD(str_xfs_admin, xfs_admin); -static int -btrfslabel (const char *device, const char *label) -{ - int r; - CLEANUP_FREE char *err = NULL; - - r = command (NULL, &err, str_btrfs, "filesystem", "label", - device, label, NULL); - if (r == -1) { - reply_with_error ("%s", err); - return -1; - } - - return 0; -} - static int dosfslabel (const char *device, const char *label) { @@ -144,7 +127,7 @@ do_set_label (const mountable_t *mountable, const char *label) return -1; if (STREQ (vfs_type, "btrfs")) - r = btrfslabel (mountable->device, label); + r = btrfs_set_label (mountable->device, label); else if (STREQ (vfs_type, "msdos") || STREQ (vfs_type, "fat") ||