labels: move btrfslabel to btrfs.c

Signed-off-by: Chen Hanxiao <chenhanxiao@cn.fujitsu.com>
This commit is contained in:
Chen Hanxiao
2015-07-08 11:07:47 +08:00
committed by Pino Toscano
parent de93c690a1
commit 16232ffd58
3 changed files with 18 additions and 18 deletions

View File

@@ -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)

View File

@@ -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);

View File

@@ -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") ||