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