From fbe661f56f8f51c8bda7b3ced1ec41af509e61ff Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Tue, 31 Jan 2023 05:16:55 +0100 Subject: Adding upstream version 1.3. Signed-off-by: Daniel Baumann --- src/nvme/util.c | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) (limited to 'src/nvme/util.c') diff --git a/src/nvme/util.c b/src/nvme/util.c index c61dbe9..0354afe 100644 --- a/src/nvme/util.c +++ b/src/nvme/util.c @@ -325,7 +325,7 @@ static const char * const media_status[] = { }; static const char * const path_status[] = { - [NVME_SC_ANA_INTERNAL_PATH_ERROR] = "Internal Path Error: An internal error specific to the controller processing the commmand prevented completion", + [NVME_SC_ANA_INTERNAL_PATH_ERROR] = "Internal Path Error: An internal error specific to the controller processing the command prevented completion", [NVME_SC_ANA_PERSISTENT_LOSS] = "Asymmetric Access Persistent Loss: The controller is in a persistent loss state with the requested namespace", [NVME_SC_ANA_INACCESSIBLE] = "Asymmetric Access Inaccessible: The controller is in an inaccessible state with the requested namespace", [NVME_SC_ANA_TRANSITION] = "Asymmetric Access Transition: The controller is currently transitioning states with the requested namespace", @@ -559,11 +559,12 @@ static const char * const libnvme_status[] = { [ENVME_CONNECT_INVAL_TR] = "invalid transport type", [ENVME_CONNECT_LOOKUP_SUBSYS_NAME] = "failed to lookup subsystem name", [ENVME_CONNECT_LOOKUP_SUBSYS] = "failed to lookup subsystem", - [ENVME_CONNECT_ALREADY] = "already connnected", + [ENVME_CONNECT_ALREADY] = "already connected", [ENVME_CONNECT_INVAL] = "invalid arguments/configuration", [ENVME_CONNECT_ADDRINUSE] = "hostnqn already in use", [ENVME_CONNECT_NODEV] = "invalid interface", [ENVME_CONNECT_OPNOTSUPP] ="not supported", + [ENVME_CONNECT_CONNREFUSED] = "connection refused", }; const char *nvme_errno_to_string(int status) @@ -573,6 +574,7 @@ const char *nvme_errno_to_string(int status) return s; } +#ifdef HAVE_LIBNSS char *hostname2traddr(struct nvme_root *r, const char *traddr) { struct addrinfo *host_info, hints = {.ai_family = AF_UNSPEC}; @@ -617,6 +619,18 @@ free_addrinfo: return ret_traddr; } +#else /* !HAVE_LIBNSS */ + +char *hostname2traddr(struct nvme_root *r, const char *traddr) +{ + nvme_msg(NULL, LOG_ERR, "No support for hostname IP address resolution; " \ + "recompile with libnss support.\n"); + + errno = -ENOTSUP; + return NULL; +} +#endif /* HAVE_LIBNSS */ + char *startswith(const char *s, const char *prefix) { size_t l; @@ -871,13 +885,11 @@ int nvme_uuid_random(unsigned char uuid[NVME_UUID_LEN]) if (f < 0) return -errno; n = read(f, uuid, NVME_UUID_LEN); - if (n < 0) { - close(f); + close(f); + if (n < 0) return -errno; - } else if (n != NVME_UUID_LEN) { - close(f); + else if (n != NVME_UUID_LEN) return -EIO; - } /* * See https://www.rfc-editor.org/rfc/rfc4122#section-4.4 -- cgit v1.2.3