diff options
Diffstat (limited to 'src/nvme/fabrics.c')
-rw-r--r-- | src/nvme/fabrics.c | 44 |
1 files changed, 29 insertions, 15 deletions
diff --git a/src/nvme/fabrics.c b/src/nvme/fabrics.c index 4e042d8..6738e9d 100644 --- a/src/nvme/fabrics.c +++ b/src/nvme/fabrics.c @@ -260,6 +260,7 @@ static struct nvme_fabrics_config *merge_config(nvme_ctrl_t c, MERGE_CFG_OPTION(ctrl_cfg, cfg, hdr_digest, false); MERGE_CFG_OPTION(ctrl_cfg, cfg, data_digest, false); MERGE_CFG_OPTION(ctrl_cfg, cfg, tls, false); + MERGE_CFG_OPTION(ctrl_cfg, cfg, concat, false); return ctrl_cfg; } @@ -289,6 +290,7 @@ void nvmf_update_config(nvme_ctrl_t c, const struct nvme_fabrics_config *cfg) UPDATE_CFG_OPTION(ctrl_cfg, cfg, hdr_digest, false); UPDATE_CFG_OPTION(ctrl_cfg, cfg, data_digest, false); UPDATE_CFG_OPTION(ctrl_cfg, cfg, tls, false); + UPDATE_CFG_OPTION(ctrl_cfg, cfg, concat, false); } static int __add_bool_argument(char **argstr, char *tok, bool arg) @@ -637,7 +639,9 @@ static int build_options(nvme_host_t h, nvme_ctrl_t c, char **argstr) (!strcmp(transport, "tcp") && add_bool_argument(r, argstr, data_digest, cfg->data_digest)) || (!strcmp(transport, "tcp") && - add_bool_argument(r, argstr, tls, cfg->tls))) { + add_bool_argument(r, argstr, tls, cfg->tls)) || + (!strcmp(transport, "tcp") && + add_bool_argument(r, argstr, concat, cfg->concat))) { free(*argstr); return -1; } @@ -705,6 +709,7 @@ static int __nvmf_supported_options(nvme_root_t r) nvme_msg(r, LOG_DEBUG, "%s ", v); parse_option(r, v, cntlid); + parse_option(r, v, concat); parse_option(r, v, ctrl_loss_tmo); parse_option(r, v, data_digest); parse_option(r, v, dhchap_ctrl_secret); @@ -740,7 +745,7 @@ static int __nvmf_supported_options(nvme_root_t r) static int __nvmf_add_ctrl(nvme_root_t r, const char *argstr) { - _cleanup_fd_ int fd; + _cleanup_fd_ int fd = -1; int ret, len = strlen(argstr); char buf[0x1000], *options, *p; @@ -1181,14 +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 int uuid_from_device_tree(char *system_uuid) { + _cleanup_fd_ int f = -1; ssize_t len; - _cleanup_fd_ int f; - f = open(PATH_UUID_IBM, O_RDONLY); + f = open(nvme_uuid_ibm_filename(), O_RDONLY); if (f < 0) return -ENXIO; @@ -1200,8 +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" - /* * See System Management BIOS (SMBIOS) Reference Specification * https://www.dmtf.org/sites/default/files/standards/documents/DSP0134_3.2.0.pdf @@ -1229,13 +1230,14 @@ 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; + const char *entries_dir = nvme_dmi_entries_dir(); int f; - _cleanup_dir_ DIR *d; struct dirent *de; char buf[512] = {0}; system_uuid[0] = '\0'; - d = opendir(PATH_DMI_ENTRIES); + d = opendir(entries_dir); if (!d) return -ENXIO; while ((de = readdir(d))) { @@ -1244,7 +1246,7 @@ static int uuid_from_dmi_entries(char *system_uuid) if (de->d_name[0] == '.') continue; - sprintf(filename, "%s/%s/type", PATH_DMI_ENTRIES, de->d_name); + sprintf(filename, "%s/%s/type", entries_dir, de->d_name); f = open(filename, O_RDONLY); if (f < 0) continue; @@ -1256,12 +1258,14 @@ static int uuid_from_dmi_entries(char *system_uuid) continue; if (type != DMI_SYSTEM_INFORMATION) continue; - sprintf(filename, "%s/%s/raw", PATH_DMI_ENTRIES, de->d_name); + sprintf(filename, "%s/%s/raw", entries_dir, de->d_name); f = open(filename, O_RDONLY); if (f < 0) continue; len = read(f, buf, 512); close(f); + if (len <= 0) + continue; if (!is_dmi_uuid_valid(buf, len)) continue; @@ -1294,7 +1298,7 @@ static int uuid_from_dmi_entries(char *system_uuid) */ static int uuid_from_product_uuid(char *system_uuid) { - _cleanup_file_ FILE *stream; + _cleanup_file_ FILE *stream = NULL; ssize_t nread; _cleanup_free_ char *line = NULL; size_t len = 0; @@ -1364,7 +1368,7 @@ char *nvmf_hostnqn_generate() static char *nvmf_read_file(const char *f, int len) { char buf[len]; - _cleanup_fd_ int fd; + _cleanup_fd_ int fd = -1; int ret; fd = open(f, O_RDONLY); @@ -1381,11 +1385,21 @@ static char *nvmf_read_file(const char *f, int len) char *nvmf_hostnqn_from_file() { + char *hostnqn = getenv("LIBNVME_HOSTNQN"); + + if (hostnqn) + return strdup(hostnqn); + return nvmf_read_file(NVMF_HOSTNQN_FILE, NVMF_NQN_SIZE); } char *nvmf_hostid_from_file() { + char *hostid = getenv("LIBNVME_HOSTID"); + + if (hostid) + return strdup(hostid); + return nvmf_read_file(NVMF_HOSTID_FILE, NVMF_HOSTID_SIZE); } @@ -1637,7 +1651,7 @@ static const char *dctype_str[] = { */ static int nvme_fetch_cntrltype_dctype_from_id(nvme_ctrl_t c) { - _cleanup_free_ struct nvme_id_ctrl *id; + _cleanup_free_ struct nvme_id_ctrl *id = NULL; int ret; id = __nvme_alloc(sizeof(*id)); |