Skip to content

Commit

Permalink
uuid: use newly introduced xfs_set_uuid of xfs
Browse files Browse the repository at this point in the history
Signed-off-by: Chen Hanxiao <chenhanxiao@cn.fujitsu.com>
  • Loading branch information
chenhanxiao authored and ptoscano committed Jun 30, 2015
1 parent ad21fb8 commit 5166388
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 11 deletions.
1 change: 1 addition & 0 deletions daemon/daemon.h
Expand Up @@ -262,6 +262,7 @@ extern int copy_xattrs (const char *src, const char *dest);
/*-- in xfs.c --*/
/* Documented in xfs_admin(8). */
#define XFS_LABEL_MAX 12
extern int xfs_set_uuid (const char *device, const char *uuid);

/*-- debug-bmap.c --*/
extern char *debug_bmap (const char *subcmd, size_t argc, char *const *const argv);
Expand Down
12 changes: 1 addition & 11 deletions daemon/uuids.c
Expand Up @@ -27,7 +27,6 @@
#include "actions.h"
#include "optgroups.h"

GUESTFSD_EXT_CMD(str_xfs_admin, xfs_admin);
GUESTFSD_EXT_CMD(str_swaplabel, swaplabel);

static int
Expand All @@ -48,22 +47,13 @@ e2uuid (const char *device, const char *uuid)
static int
xfsuuid (const char *device, const char *uuid)
{
int r;
CLEANUP_FREE char *err = NULL;

/* Don't allow special values. */
if (STREQ (uuid, "nil") || STREQ (uuid, "generate")) {
reply_with_error ("xfs: invalid new UUID");
return -1;
}

r = command (NULL, &err, str_xfs_admin, "-U", uuid, device, NULL);
if (r == -1) {
reply_with_error ("%s", err);
return -1;
}

return 0;
return xfs_set_uuid (device, uuid);
}

static int
Expand Down
7 changes: 7 additions & 0 deletions daemon/xfs.c
Expand Up @@ -455,6 +455,13 @@ do_xfs_growfs (const char *path,
return 0;
}

int
xfs_set_uuid (const char *device, const char *uuid)
{
optargs_bitmask = GUESTFS_XFS_ADMIN_UUID_BITMASK;
return do_xfs_admin (device, 0, 0, 0, 0, 0, NULL, uuid);
}

int
do_xfs_admin (const char *device,
int extunwritten, int imgfile, int v2log,
Expand Down

0 comments on commit 5166388

Please sign in to comment.