|
|
61fcf4 |
From db50dbf5692325cfef8fb77e56e1e44af83a022e Mon Sep 17 00:00:00 2001
|
|
|
61fcf4 |
From: Maurizio Lombardi <mlombard@redhat.com>
|
|
|
61fcf4 |
Date: Wed, 29 Jun 2022 16:47:30 +0200
|
|
|
61fcf4 |
Subject: [PATCH 1/7] nvme-cli: nvme gen-hostnqn use partition UUID on IBM
|
|
|
61fcf4 |
POWER
|
|
|
61fcf4 |
|
|
|
61fcf4 |
Signed-off-by: Maurizio Lombardi <mlombard@redhat.com>
|
|
|
61fcf4 |
---
|
|
|
61fcf4 |
nvme.c | 27 +++++++++++++++++++++++++--
|
|
|
61fcf4 |
1 file changed, 25 insertions(+), 2 deletions(-)
|
|
|
61fcf4 |
|
|
|
61fcf4 |
diff --git a/nvme.c b/nvme.c
|
|
|
61fcf4 |
index 5beeac78..0535ed2b 100644
|
|
|
61fcf4 |
--- a/nvme.c
|
|
|
61fcf4 |
+++ b/nvme.c
|
|
|
61fcf4 |
@@ -6516,6 +6516,26 @@ static int admin_passthru(int argc, char **argv, struct command *cmd, struct plu
|
|
|
61fcf4 |
return passthru(argc, argv, NVME_IOCTL_ADMIN_CMD, 1, desc, cmd);
|
|
|
61fcf4 |
}
|
|
|
61fcf4 |
|
|
|
61fcf4 |
+#define PATH_UUID_IBM "/proc/device-tree/ibm,partition-uuid"
|
|
|
61fcf4 |
+
|
|
|
61fcf4 |
+static int uuid_from_device_tree(char *system_uuid)
|
|
|
61fcf4 |
+{
|
|
|
61fcf4 |
+ ssize_t len;
|
|
|
61fcf4 |
+ int f;
|
|
|
61fcf4 |
+
|
|
|
61fcf4 |
+ f = open(PATH_UUID_IBM, O_RDONLY);
|
|
|
61fcf4 |
+ if (f < 0)
|
|
|
61fcf4 |
+ return -ENXIO;
|
|
|
61fcf4 |
+
|
|
|
61fcf4 |
+ memset(system_uuid, 0, 37);
|
|
|
61fcf4 |
+ len = read(f, system_uuid, 37 - 1);
|
|
|
61fcf4 |
+ close(f);
|
|
|
61fcf4 |
+ if (len < 0)
|
|
|
61fcf4 |
+ return -ENXIO;
|
|
|
61fcf4 |
+
|
|
|
61fcf4 |
+ return strlen(system_uuid) ? 0 : -ENXIO;
|
|
|
61fcf4 |
+}
|
|
|
61fcf4 |
+
|
|
|
61fcf4 |
static int gen_hostnqn_cmd(int argc, char **argv, struct command *command, struct plugin *plugin)
|
|
|
61fcf4 |
{
|
|
|
61fcf4 |
int ret;
|
|
|
61fcf4 |
@@ -6525,8 +6545,11 @@ static int gen_hostnqn_cmd(int argc, char **argv, struct command *command, struc
|
|
|
61fcf4 |
#endif
|
|
|
61fcf4 |
|
|
|
61fcf4 |
ret = uuid_from_dmi(uuid_str);
|
|
|
61fcf4 |
- if (ret < 0)
|
|
|
61fcf4 |
- ret = uuid_from_systemd(uuid_str);
|
|
|
61fcf4 |
+ if (ret < 0) {
|
|
|
61fcf4 |
+ ret = uuid_from_device_tree(uuid_str);
|
|
|
61fcf4 |
+ if (ret < 0)
|
|
|
61fcf4 |
+ ret = uuid_from_systemd(uuid_str);
|
|
|
61fcf4 |
+ }
|
|
|
61fcf4 |
#ifdef LIBUUID
|
|
|
61fcf4 |
if (ret < 0) {
|
|
|
61fcf4 |
uuid_generate_random(uuid);
|
|
|
61fcf4 |
--
|
|
|
61fcf4 |
2.31.1
|
|
|
61fcf4 |
|