From 4901f97b7df3c192cf397cade82e5fa96df55e95 Mon Sep 17 00:00:00 2001 From: Daniel Wagner Date: Thu, 13 Oct 2022 17:52:10 +0200 Subject: [PATCH] build: Drop dependency on libuuid libnvme provide the uuid functions we actually need, so just use those and drop the libuuid dependency. Signed-off-by: Daniel Wagner --- meson.build | 7 +------ nvme-print.c | 19 +++++++++---------- plugins/netapp/netapp-nvme.c | 5 ++--- tests/meson.build | 2 +- util/types.c | 7 +++---- util/types.h | 4 +++- 6 files changed, 19 insertions(+), 25 deletions(-) diff --git a/meson.build b/meson.build index aca98f89..eb7c6af6 100644 --- a/meson.build +++ b/meson.build @@ -49,11 +49,6 @@ libnvme_dep = dependency('libnvme', version: '>=1.1', required: true, libnvme_mi_dep = dependency('libnvme-mi', required: true, fallback : ['libnvme', 'libnvme_mi_dep']) -# Check for libuuid availability -libuuid_dep = dependency('uuid', required: true, - fallback : ['uuid', 'uuid_dep']) -conf.set('CONFIG_LIBUUID', libuuid_dep.found(), description: 'Is libuuid available?') - # Check for libjson-c availability json_c_dep = dependency('json-c', required: true, version: '>=0.13', fallback : ['json-c', 'json_c_dep']) @@ -261,7 +256,7 @@ subdir('Documentation') executable( 'nvme', sources, - dependencies: [ libnvme_dep, libnvme_mi_dep, libuuid_dep, json_c_dep, libz_dep, + dependencies: [ libnvme_dep, libnvme_mi_dep, json_c_dep, libz_dep, libhugetlbfs_dep ], link_args: '-ldl', include_directories: incdir, diff --git a/nvme-print.c b/nvme-print.c index a50d6363..b16bccf7 100644 --- a/nvme-print.c +++ b/nvme-print.c @@ -6,7 +6,6 @@ #include #include #include -#include #include "nvme.h" #include "libnvme.h" @@ -4326,7 +4325,7 @@ static void json_nvme_id_ns_descs(void *data) union { __u8 eui64[NVME_NIDT_EUI64_LEN]; __u8 nguid[NVME_NIDT_NGUID_LEN]; - uuid_t uuid; + __u8 uuid[NVME_UUID_LEN]; __u8 csi; } desc; @@ -4367,7 +4366,7 @@ static void json_nvme_id_ns_descs(void *data) case NVME_NIDT_UUID: memcpy(desc.uuid, data + off, sizeof(desc.uuid)); - uuid_unparse_lower(desc.uuid, json_str); + nvme_uuid_to_string(desc.uuid, json_str); len = sizeof(desc.uuid); nidt_name = "uuid"; break; @@ -4417,8 +4416,8 @@ void nvme_show_id_ns_descs(void *data, unsigned nsid, enum nvme_print_flags flag { int pos, len = 0; int i; - uuid_t uuid; - char uuid_str[37]; + __u8 uuid[NVME_UUID_LEN]; + char uuid_str[NVME_UUID_LEN_STRING]; __u8 eui64[8]; __u8 nguid[16]; __u8 csi; @@ -4454,7 +4453,7 @@ void nvme_show_id_ns_descs(void *data, unsigned nsid, enum nvme_print_flags flag break; case NVME_NIDT_UUID: memcpy(uuid, data + pos + sizeof(*cur), 16); - uuid_unparse_lower(uuid, uuid_str); + nvme_uuid_to_string(uuid, uuid_str); printf("uuid : %s\n", uuid_str); len = sizeof(uuid); break; @@ -5607,7 +5606,7 @@ static void json_nvme_id_uuid_list(const struct nvme_id_uuid_list *uuid_list) entries = json_create_array(); /* The 0th entry is reserved */ for (i = 1; i < NVME_ID_UUID_LIST_MAX; i++) { - uuid_t uuid; + __u8 uuid[NVME_UUID_LEN]; struct json_object *entry = json_create_object(); /* The list is terminated by a zero UUID value */ @@ -5639,13 +5638,13 @@ void nvme_show_id_uuid_list(const struct nvme_id_uuid_list *uuid_list, /* The 0th entry is reserved */ printf("NVME Identify UUID:\n"); for (i = 0; i < NVME_ID_UUID_LIST_MAX; i++) { - uuid_t uuid; + __u8 uuid[NVME_UUID_LEN]; char *association = ""; uint8_t identifier_association = uuid_list->entry[i].header & 0x3; /* The list is terminated by a zero UUID value */ - if (memcmp(uuid_list->entry[i].uuid, zero_uuid, sizeof(zero_uuid)) == 0) + if (memcmp(uuid_list->entry[i].uuid, zero_uuid, NVME_UUID_LEN) == 0) break; - memcpy(&uuid, uuid_list->entry[i].uuid, sizeof(uuid)); + memcpy(&uuid, uuid_list->entry[i].uuid, NVME_UUID_LEN); if (human) { switch (identifier_association) { case 0x0: diff --git a/plugins/netapp/netapp-nvme.c b/plugins/netapp/netapp-nvme.c index b6bd3f68..f5cb0733 100644 --- a/plugins/netapp/netapp-nvme.c +++ b/plugins/netapp/netapp-nvme.c @@ -22,7 +22,6 @@ #include #include #include -#include #include "common.h" #include "nvme.h" @@ -68,7 +67,7 @@ struct ontapdevice_info { unsigned nsid; struct nvme_id_ctrl ctrl; struct nvme_id_ns ns; - uuid_t uuid; + unsigned char uuid[NVME_UUID_LEN]; unsigned char log_data[ONTAP_C2_LOG_SIZE]; char dev[265]; }; @@ -334,7 +333,7 @@ static void netapp_ontapdevices_print(struct ontapdevice_info *devices, for (i = 0; i < count; i++) { netapp_get_ns_size(size, &lba, &devices[i].ns); - uuid_unparse_lower(devices[i].uuid, uuid_str); + nvme_uuid_to_string(devices[i].uuid, uuid_str); netapp_get_ontap_labels(vsname, nspath, devices[i].log_data); if (format == NJSON) { diff --git a/tests/meson.build b/tests/meson.build index c148c736..6f171373 100644 --- a/tests/meson.build +++ b/tests/meson.build @@ -59,7 +59,7 @@ test_uint128 = executable( 'test-uint128', ['test-uint128.c', '../util/types.c'], include_directories: [incdir, '..'], - dependencies: [libuuid_dep], + dependencies: [libnvme_dep], ) test('uint128', test_uint128) diff --git a/util/types.c b/util/types.c index f063ad5b..06bb8d4e 100644 --- a/util/types.c +++ b/util/types.c @@ -78,12 +78,11 @@ char *uint128_t_to_string(nvme_uint128_t val) return str + idx; } -const char *util_uuid_to_string(uuid_t uuid) +const char *util_uuid_to_string(unsigned char uuid[NVME_UUID_LEN]) { - /* large enough to hold uuid str (37) + null-termination byte */ - static char uuid_str[40]; + static char uuid_str[NVME_UUID_LEN_STRING]; - uuid_unparse_lower(uuid, uuid_str); + nvme_uuid_to_string(uuid, uuid_str); return uuid_str; } diff --git a/util/types.h b/util/types.h index d48dda18..45fbbb6a 100644 --- a/util/types.h +++ b/util/types.h @@ -8,6 +8,8 @@ #include #include +#include + #define ABSOLUTE_ZERO_CELSIUS -273 static inline long kelvin_to_celsius(long t) @@ -28,7 +30,7 @@ long double int128_to_double(__u8 *data); uint64_t int48_to_long(__u8 *data); char *uint128_t_to_string(nvme_uint128_t val); -const char *util_uuid_to_string(uuid_t uuid); +const char *util_uuid_to_string(unsigned char uuid[NVME_UUID_LEN]); const char *util_fw_to_string(char *c); #endif /* _MISC_H */ -- 2.50.1