libguestfs/SOURCES/0043-New-API-luks_uuid.patch

88 lines
2.3 KiB
Diff

From c31eaba4d6b36d90cfd835a4750e50f6a5256b73 Mon Sep 17 00:00:00 2001
From: Pino Toscano <ptoscano@redhat.com>
Date: Fri, 29 Nov 2019 11:48:59 +0100
Subject: [PATCH] New API: luks_uuid
Return the UUID of a LUKS device.
(cherry picked from commit 206ce8bbf1bc3332dc019e553d17d6a36f74b725)
---
daemon/luks.c | 25 +++++++++++++++++++++++++
generator/actions_core.ml | 8 ++++++++
generator/proc_nr.ml | 1 +
lib/MAX_PROC_NR | 2 +-
4 files changed, 35 insertions(+), 1 deletion(-)
diff --git a/daemon/luks.c b/daemon/luks.c
index 5c48a91eb..d631cb100 100644
--- a/daemon/luks.c
+++ b/daemon/luks.c
@@ -292,3 +292,28 @@ do_luks_kill_slot (const char *device, const char *key, int keyslot)
return 0;
}
+
+char *
+do_luks_uuid (const char *device)
+{
+ const char *argv[MAX_ARGS];
+ size_t i = 0;
+
+ ADD_ARG (argv, i, "cryptsetup");
+ ADD_ARG (argv, i, "luksUUID");
+ ADD_ARG (argv, i, device);
+ ADD_ARG (argv, i, NULL);
+
+ char *out = NULL;
+ CLEANUP_FREE char *err = NULL;
+ int r = commandv (&out, &err, (const char * const *) argv);
+
+ if (r == -1) {
+ reply_with_error ("%s", err);
+ return NULL;
+ }
+
+ trim (out);
+
+ return out;
+}
diff --git a/generator/actions_core.ml b/generator/actions_core.ml
index 7b6568b90..deda483a9 100644
--- a/generator/actions_core.ml
+++ b/generator/actions_core.ml
@@ -9728,4 +9728,12 @@ it is useful when you have added a new device or deleted an
existing device (such as when the C<guestfs_luks_open> API
is used)." };
+ { defaults with
+ name = "luks_uuid"; added = (1, 41, 9);
+ style = RString (RPlainString, "uuid"), [String (Device, "device")], [];
+ optional = Some "luks";
+ shortdesc = "get the UUID of a LUKS device";
+ longdesc = "\
+This returns the UUID of the LUKS device C<device>." };
+
]
diff --git a/generator/proc_nr.ml b/generator/proc_nr.ml
index efa8c5d21..11a557076 100644
--- a/generator/proc_nr.ml
+++ b/generator/proc_nr.ml
@@ -514,6 +514,7 @@ let proc_nr = [
504, "part_get_gpt_attributes";
505, "f2fs_expand";
506, "lvm_scan";
+507, "luks_uuid";
]
(* End of list. If adding a new entry, add it at the end of the list
diff --git a/lib/MAX_PROC_NR b/lib/MAX_PROC_NR
index 80e3e6eab..055b6671a 100644
--- a/lib/MAX_PROC_NR
+++ b/lib/MAX_PROC_NR
@@ -1 +1 @@
-506
+507
--
2.18.4