diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2023-01-31 04:16:55 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2023-01-31 04:16:55 +0000 |
commit | fbe661f56f8f51c8bda7b3ced1ec41af509e61ff (patch) | |
tree | ac8ac7d3960922094733bac6d9a5300da7171c56 /src/nvme/util.c | |
parent | Adding upstream version 1.2. (diff) | |
download | libnvme-fbe661f56f8f51c8bda7b3ced1ec41af509e61ff.tar.xz libnvme-fbe661f56f8f51c8bda7b3ced1ec41af509e61ff.zip |
Adding upstream version 1.3.upstream/1.3
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/nvme/util.c')
-rw-r--r-- | src/nvme/util.c | 26 |
1 files changed, 19 insertions, 7 deletions
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 |