Signed-off-by: Chen Hanxiao <chenhanxiao(a)cn.fujitsu.com>
---
daemon/daemon.h | 1 +
daemon/labels.c | 18 +-----------------
daemon/xfs.c | 7 +++++++
3 files changed, 9 insertions(+), 17 deletions(-)
diff --git a/daemon/daemon.h b/daemon/daemon.h
index 7a4b97f..13add6c 100644
--- a/daemon/daemon.h
+++ b/daemon/daemon.h
@@ -268,6 +268,7 @@ extern int copy_xattrs (const char *src, const char *dest);
#define XFS_LABEL_MAX 12
extern int xfs_set_uuid (const char *device, const char *uuid);
extern int xfs_set_uuid_random (const char *device);
+extern int xfs_set_label (const char *device, const char *label);
/*-- debug-bmap.c --*/
extern char *debug_bmap (const char *subcmd, size_t argc, char *const *const argv);
diff --git a/daemon/labels.c b/daemon/labels.c
index d3e3f55..92d339c 100644
--- a/daemon/labels.c
+++ b/daemon/labels.c
@@ -28,7 +28,6 @@
#include "optgroups.h"
GUESTFSD_EXT_CMD(str_dosfslabel, dosfslabel);
-GUESTFSD_EXT_CMD(str_xfs_admin, xfs_admin);
static int
dosfslabel (const char *device, const char *label)
@@ -48,9 +47,6 @@ dosfslabel (const char *device, const char *label)
static int
xfslabel (const char *device, const char *label)
{
- int r;
- CLEANUP_FREE char *err = NULL;
-
/* Don't allow the special value "---". If people want to clear
* the label we'll have to add another call to do that.
*/
@@ -59,19 +55,7 @@ xfslabel (const char *device, const char *label)
return -1;
}
- if (strlen (label) > XFS_LABEL_MAX) {
- reply_with_error ("%s: xfs labels are limited to %d bytes",
- label, XFS_LABEL_MAX);
- return -1;
- }
-
- r = command (NULL, &err, str_xfs_admin, "-L", label, device, NULL);
- if (r == -1) {
- reply_with_error ("%s", err);
- return -1;
- }
-
- return 0;
+ return xfs_set_label (device, label);
}
int
diff --git a/daemon/xfs.c b/daemon/xfs.c
index 2c93311..e5e8b62 100644
--- a/daemon/xfs.c
+++ b/daemon/xfs.c
@@ -470,6 +470,13 @@ xfs_set_uuid_random (const char *device)
}
int
+xfs_set_label (const char *device, const char *label)
+{
+ optargs_bitmask = GUESTFS_XFS_ADMIN_LABEL_BITMASK;
+ return do_xfs_admin (device, 0, 0, 0, 0, 0, label, NULL);
+}
+
+int
do_xfs_admin (const char *device,
int extunwritten, int imgfile, int v2log,
int projid32bit,
--
2.1.0