Signed-off-by: Chen Hanxiao <chenhanxiao(a)cn.fujitsu.com>
---
daemon/btrfs.c | 21 +++++++++++++++++++++
daemon/daemon.h | 1 +
2 files changed, 22 insertions(+)
diff --git a/daemon/btrfs.c b/daemon/btrfs.c
index a69c512..a3f3590 100644
--- a/daemon/btrfs.c
+++ b/daemon/btrfs.c
@@ -867,6 +867,27 @@ btrfs_set_uuid (const char *device, const char *uuid)
return 0;
}
+int
+btrfs_set_uuid_random (const char *device)
+{
+ CLEANUP_FREE char *err = NULL;
+ int r;
+ int has_uuid_opts = test_btrfstune_uuid_opt();
+
+ if (has_uuid_opts <= 0) {
+ reply_with_error_errno (ENOTSUP, "btrfs filesystems' UUID cannot be
changed");
+ return -1;
+ }
+
+ r = commandr (NULL, &err, str_btrfstune, "-f", "-u", device,
NULL);
+ if (r == -1) {
+ reply_with_error ("%s: %s", device, err);
+ return -1;
+ }
+
+ return 0;
+}
+
/* Takes optional arguments, consult optargs_bitmask. */
int
do_btrfs_fsck (const char *device, int64_t superblock, int repair)
diff --git a/daemon/daemon.h b/daemon/daemon.h
index d4c8c11..5087327 100644
--- a/daemon/daemon.h
+++ b/daemon/daemon.h
@@ -270,6 +270,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_uuid (const char *device, const char *uuid);
+extern int btrfs_set_uuid_random (const char *device);
/*-- in ntfs.c --*/
extern char *ntfs_get_label (const char *device);
--
2.1.0