Provides a way to set a new randomly-generated GUID to disk.
---
daemon/parted.c | 15 +++++++++++++++
generator/actions.ml | 15 +++++++++++++++
src/MAX_PROC_NR | 2 +-
3 files changed, 31 insertions(+), 1 deletion(-)
diff --git a/daemon/parted.c b/daemon/parted.c
index 40f9676..22cd92b 100644
--- a/daemon/parted.c
+++ b/daemon/parted.c
@@ -988,3 +988,18 @@ do_part_set_disk_guid (const char *device, const char *guid)
return 0;
}
+
+int
+do_part_set_disk_guid_random (const char *device)
+{
+ CLEANUP_FREE char *err = NULL;
+ int r = commandf (NULL, &err, COMMAND_FLAG_FOLD_STDOUT_ON_STDERR,
+ str_sgdisk, device, "-U", "R", NULL);
+
+ if (r == -1) {
+ reply_with_error ("%s %s -U R: %s", str_sgdisk, device, err);
+ return -1;
+ }
+
+ return 0;
+}
diff --git a/generator/actions.ml b/generator/actions.ml
index 62c4839..d345175 100644
--- a/generator/actions.ml
+++ b/generator/actions.ml
@@ -12830,6 +12830,21 @@ or if C<guid> is not a valid GUID." };
Return the disk identifier (GUID) of a GPT-partitioned C<device>.
Behaviour is undefined for other partition types." };
+ { defaults with
+ name = "part_set_disk_guid_random"; added = (1, 33, 2);
+ style = RErr, [Device "device"], [];
+ proc_nr = Some 461;
+ optional = Some "gdisk";
+ tests = [
+ InitGPT, Always, TestRun (
+ [["part_set_disk_guid_random"; "/dev/sda"]]), [];
+ ];
+ shortdesc = "set the GUID of a GPT-partitioned disk to random value";
+ longdesc = "\
+Set the disk identifier (GUID) of a GPT-partitioned C<device> to
+a randomly generated value.
+Return an error if the partition table of C<device> isn't GPT." };
+
]
(* Non-API meta-commands available only in guestfish.
diff --git a/src/MAX_PROC_NR b/src/MAX_PROC_NR
index ccbd68f..408b885 100644
--- a/src/MAX_PROC_NR
+++ b/src/MAX_PROC_NR
@@ -1 +1 @@
-460
+461
--
1.8.3.1