Signed-off-by: Chen Hanxiao <chenhanx...@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 ade385e..508691a 100644 --- a/daemon/daemon.h +++ b/daemon/daemon.h @@ -267,6 +267,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 5985d3a..57c6e93 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 _______________________________________________ Libguestfs mailing list Libguestfs@redhat.com https://www.redhat.com/mailman/listinfo/libguestfs