diff options
Diffstat (limited to 'src/nvme/fabrics.c')
-rw-r--r-- | src/nvme/fabrics.c | 39 |
1 files changed, 4 insertions, 35 deletions
diff --git a/src/nvme/fabrics.c b/src/nvme/fabrics.c index 1f50229..6738e9d 100644 --- a/src/nvme/fabrics.c +++ b/src/nvme/fabrics.c @@ -1186,29 +1186,12 @@ struct nvmf_discovery_log *nvmf_get_discovery_wargs(struct nvme_get_discovery_ar return log; } -#define PATH_UUID_IBM "/proc/device-tree/ibm,partition-uuid" - -static char *uuid_ibm_filename(void) -{ - char *basepath = getenv("LIBNVME_SYSFS_PATH"); - char *str; - - if (!basepath) - return strdup(PATH_UUID_IBM); - - if (!asprintf(&str, "%s" PATH_UUID_IBM, basepath)) - return NULL; - - return str; -} - static int uuid_from_device_tree(char *system_uuid) { - _cleanup_free_ char *filename = uuid_ibm_filename(); _cleanup_fd_ int f = -1; ssize_t len; - f = open(filename, O_RDONLY); + f = open(nvme_uuid_ibm_filename(), O_RDONLY); if (f < 0) return -ENXIO; @@ -1220,22 +1203,6 @@ static int uuid_from_device_tree(char *system_uuid) return strlen(system_uuid) ? 0 : -ENXIO; } -#define PATH_DMI_ENTRIES "/sys/firmware/dmi/entries" - -static char *dmi_entries_dir(void) -{ - char *basepath = getenv("LIBNVME_SYSFS_PATH"); - char *str; - - if (!basepath) - return strdup(PATH_DMI_ENTRIES); - - if (!asprintf(&str, "%s" PATH_DMI_ENTRIES, basepath)) - return NULL; - - return str; -} - /* * See System Management BIOS (SMBIOS) Reference Specification * https://www.dmtf.org/sites/default/files/standards/documents/DSP0134_3.2.0.pdf @@ -1264,7 +1231,7 @@ static bool is_dmi_uuid_valid(const char *buf, size_t len) static int uuid_from_dmi_entries(char *system_uuid) { _cleanup_dir_ DIR *d = NULL; - _cleanup_free_ char *entries_dir = dmi_entries_dir(); + const char *entries_dir = nvme_dmi_entries_dir(); int f; struct dirent *de; char buf[512] = {0}; @@ -1297,6 +1264,8 @@ static int uuid_from_dmi_entries(char *system_uuid) continue; len = read(f, buf, 512); close(f); + if (len <= 0) + continue; if (!is_dmi_uuid_valid(buf, len)) continue; |