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

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