mrc0mmand / rpms / libguestfs

Forked from rpms/libguestfs 3 years ago
Clone

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

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