diff --git a/libnvme/src/accessors.ld b/libnvme/src/accessors.ld index 28401c804e..3cd26f8f7d 100644 --- a/libnvme/src/accessors.ld +++ b/libnvme/src/accessors.ld @@ -37,27 +37,17 @@ LIBNVME_ACCESSORS_3 { nvme_ns_get_lba_util; nvme_ns_set_lba_util; nvme_ctrl_get_name; - nvme_ctrl_set_name; nvme_ctrl_get_sysfs_dir; - nvme_ctrl_set_sysfs_dir; nvme_ctrl_get_firmware; - nvme_ctrl_set_firmware; nvme_ctrl_get_model; - nvme_ctrl_set_model; nvme_ctrl_get_numa_node; - nvme_ctrl_set_numa_node; nvme_ctrl_get_queue_count; - nvme_ctrl_set_queue_count; nvme_ctrl_get_serial; - nvme_ctrl_set_serial; nvme_ctrl_get_sqsize; - nvme_ctrl_set_sqsize; nvme_ctrl_get_transport; - nvme_ctrl_set_transport; + nvme_ctrl_get_subsysnqn; nvme_ctrl_get_traddr; - nvme_ctrl_set_traddr; nvme_ctrl_get_trsvcid; - nvme_ctrl_set_trsvcid; nvme_ctrl_get_dhchap_host_key; nvme_ctrl_set_dhchap_host_key; nvme_ctrl_get_dhchap_ctrl_key; @@ -69,15 +59,10 @@ LIBNVME_ACCESSORS_3 { nvme_ctrl_get_tls_key; nvme_ctrl_set_tls_key; nvme_ctrl_get_cntrltype; - nvme_ctrl_set_cntrltype; nvme_ctrl_get_cntlid; - nvme_ctrl_set_cntlid; nvme_ctrl_get_dctype; - nvme_ctrl_set_dctype; nvme_ctrl_get_host_traddr; - nvme_ctrl_set_host_traddr; nvme_ctrl_get_host_iface; - nvme_ctrl_set_host_iface; nvme_ctrl_get_discovery_ctrl; nvme_ctrl_set_discovery_ctrl; nvme_ctrl_get_unique_discovery_ctrl; @@ -86,28 +71,20 @@ LIBNVME_ACCESSORS_3 { nvme_ctrl_set_discovered; nvme_ctrl_get_persistent; nvme_ctrl_set_persistent; + nvme_ctrl_get_phy_slot; nvme_subsystem_get_name; - nvme_subsystem_set_name; nvme_subsystem_get_sysfs_dir; - nvme_subsystem_set_sysfs_dir; nvme_subsystem_get_subsysnqn; - nvme_subsystem_set_subsysnqn; nvme_subsystem_get_model; - nvme_subsystem_set_model; nvme_subsystem_get_serial; - nvme_subsystem_set_serial; nvme_subsystem_get_firmware; - nvme_subsystem_set_firmware; nvme_subsystem_get_subsystype; - nvme_subsystem_set_subsystype; nvme_subsystem_get_application; nvme_subsystem_set_application; nvme_subsystem_get_iopolicy; nvme_subsystem_set_iopolicy; nvme_host_get_hostnqn; - nvme_host_set_hostnqn; nvme_host_get_hostid; - nvme_host_set_hostid; nvme_host_get_dhchap_host_key; nvme_host_set_dhchap_host_key; nvme_host_get_hostsymname; diff --git a/libnvme/src/nvme/accessors.c b/libnvme/src/nvme/accessors.c index ca22a4ce3a..7f529b3206 100644 --- a/libnvme/src/nvme/accessors.c +++ b/libnvme/src/nvme/accessors.c @@ -171,109 +171,54 @@ uint64_t nvme_ns_get_lba_util(const struct nvme_ns *p) * Accessors for: struct nvme_ctrl ****************************************************************************/ -void nvme_ctrl_set_name(struct nvme_ctrl *p, const char *name) -{ - free(p->name); - p->name = name ? strdup(name) : NULL; -} - const char *nvme_ctrl_get_name(const struct nvme_ctrl *p) { return p->name; } -void nvme_ctrl_set_sysfs_dir(struct nvme_ctrl *p, const char *sysfs_dir) -{ - free(p->sysfs_dir); - p->sysfs_dir = sysfs_dir ? strdup(sysfs_dir) : NULL; -} - const char *nvme_ctrl_get_sysfs_dir(const struct nvme_ctrl *p) { return p->sysfs_dir; } -void nvme_ctrl_set_firmware(struct nvme_ctrl *p, const char *firmware) -{ - free(p->firmware); - p->firmware = firmware ? strdup(firmware) : NULL; -} - const char *nvme_ctrl_get_firmware(const struct nvme_ctrl *p) { return p->firmware; } -void nvme_ctrl_set_model(struct nvme_ctrl *p, const char *model) -{ - free(p->model); - p->model = model ? strdup(model) : NULL; -} - const char *nvme_ctrl_get_model(const struct nvme_ctrl *p) { return p->model; } -void nvme_ctrl_set_numa_node(struct nvme_ctrl *p, const char *numa_node) -{ - free(p->numa_node); - p->numa_node = numa_node ? strdup(numa_node) : NULL; -} - const char *nvme_ctrl_get_numa_node(const struct nvme_ctrl *p) { return p->numa_node; } -void nvme_ctrl_set_queue_count(struct nvme_ctrl *p, const char *queue_count) -{ - free(p->queue_count); - p->queue_count = queue_count ? strdup(queue_count) : NULL; -} - const char *nvme_ctrl_get_queue_count(const struct nvme_ctrl *p) { return p->queue_count; } -void nvme_ctrl_set_serial(struct nvme_ctrl *p, const char *serial) -{ - free(p->serial); - p->serial = serial ? strdup(serial) : NULL; -} - const char *nvme_ctrl_get_serial(const struct nvme_ctrl *p) { return p->serial; } -void nvme_ctrl_set_sqsize(struct nvme_ctrl *p, const char *sqsize) -{ - free(p->sqsize); - p->sqsize = sqsize ? strdup(sqsize) : NULL; -} - const char *nvme_ctrl_get_sqsize(const struct nvme_ctrl *p) { return p->sqsize; } -void nvme_ctrl_set_transport(struct nvme_ctrl *p, const char *transport) -{ - free(p->transport); - p->transport = transport ? strdup(transport) : NULL; -} - const char *nvme_ctrl_get_transport(const struct nvme_ctrl *p) { return p->transport; } -void nvme_ctrl_set_traddr(struct nvme_ctrl *p, const char *traddr) +const char *nvme_ctrl_get_subsysnqn(const struct nvme_ctrl *p) { - free(p->traddr); - p->traddr = traddr ? strdup(traddr) : NULL; + return p->subsysnqn; } const char *nvme_ctrl_get_traddr(const struct nvme_ctrl *p) @@ -281,12 +226,6 @@ const char *nvme_ctrl_get_traddr(const struct nvme_ctrl *p) return p->traddr; } -void nvme_ctrl_set_trsvcid(struct nvme_ctrl *p, const char *trsvcid) -{ - free(p->trsvcid); - p->trsvcid = trsvcid ? strdup(trsvcid) : NULL; -} - const char *nvme_ctrl_get_trsvcid(const struct nvme_ctrl *p) { return p->trsvcid; @@ -354,43 +293,24 @@ const char *nvme_ctrl_get_tls_key(const struct nvme_ctrl *p) return p->tls_key; } -void nvme_ctrl_set_cntrltype(struct nvme_ctrl *p, const char *cntrltype) -{ - free(p->cntrltype); - p->cntrltype = cntrltype ? strdup(cntrltype) : NULL; -} - const char *nvme_ctrl_get_cntrltype(const struct nvme_ctrl *p) { return p->cntrltype; } -void nvme_ctrl_set_cntlid(struct nvme_ctrl *p, const char *cntlid) -{ - free(p->cntlid); - p->cntlid = cntlid ? strdup(cntlid) : NULL; -} - const char *nvme_ctrl_get_cntlid(const struct nvme_ctrl *p) { return p->cntlid; } -void nvme_ctrl_set_dctype(struct nvme_ctrl *p, const char *dctype) -{ - free(p->dctype); - p->dctype = dctype ? strdup(dctype) : NULL; -} - const char *nvme_ctrl_get_dctype(const struct nvme_ctrl *p) { return p->dctype; } -void nvme_ctrl_set_host_traddr(struct nvme_ctrl *p, const char *host_traddr) +const char *nvme_ctrl_get_phy_slot(const struct nvme_ctrl *p) { - free(p->host_traddr); - p->host_traddr = host_traddr ? strdup(host_traddr) : NULL; + return p->phy_slot; } const char *nvme_ctrl_get_host_traddr(const struct nvme_ctrl *p) @@ -398,12 +318,6 @@ const char *nvme_ctrl_get_host_traddr(const struct nvme_ctrl *p) return p->host_traddr; } -void nvme_ctrl_set_host_iface(struct nvme_ctrl *p, const char *host_iface) -{ - free(p->host_iface); - p->host_iface = host_iface ? strdup(host_iface) : NULL; -} - const char *nvme_ctrl_get_host_iface(const struct nvme_ctrl *p) { return p->host_iface; @@ -455,84 +369,36 @@ bool nvme_ctrl_get_persistent(const struct nvme_ctrl *p) * Accessors for: struct nvme_subsystem ****************************************************************************/ -void nvme_subsystem_set_name(struct nvme_subsystem *p, const char *name) -{ - free(p->name); - p->name = name ? strdup(name) : NULL; -} - const char *nvme_subsystem_get_name(const struct nvme_subsystem *p) { return p->name; } -void nvme_subsystem_set_sysfs_dir( - struct nvme_subsystem *p, - const char *sysfs_dir) -{ - free(p->sysfs_dir); - p->sysfs_dir = sysfs_dir ? strdup(sysfs_dir) : NULL; -} - const char *nvme_subsystem_get_sysfs_dir(const struct nvme_subsystem *p) { return p->sysfs_dir; } -void nvme_subsystem_set_subsysnqn( - struct nvme_subsystem *p, - const char *subsysnqn) -{ - free(p->subsysnqn); - p->subsysnqn = subsysnqn ? strdup(subsysnqn) : NULL; -} - const char *nvme_subsystem_get_subsysnqn(const struct nvme_subsystem *p) { return p->subsysnqn; } -void nvme_subsystem_set_model(struct nvme_subsystem *p, const char *model) -{ - free(p->model); - p->model = model ? strdup(model) : NULL; -} - const char *nvme_subsystem_get_model(const struct nvme_subsystem *p) { return p->model; } -void nvme_subsystem_set_serial(struct nvme_subsystem *p, const char *serial) -{ - free(p->serial); - p->serial = serial ? strdup(serial) : NULL; -} - const char *nvme_subsystem_get_serial(const struct nvme_subsystem *p) { return p->serial; } -void nvme_subsystem_set_firmware(struct nvme_subsystem *p, const char *firmware) -{ - free(p->firmware); - p->firmware = firmware ? strdup(firmware) : NULL; -} - const char *nvme_subsystem_get_firmware(const struct nvme_subsystem *p) { return p->firmware; } -void nvme_subsystem_set_subsystype( - struct nvme_subsystem *p, - const char *subsystype) -{ - free(p->subsystype); - p->subsystype = subsystype ? strdup(subsystype) : NULL; -} - const char *nvme_subsystem_get_subsystype(const struct nvme_subsystem *p) { return p->subsystype; @@ -566,23 +432,11 @@ const char *nvme_subsystem_get_iopolicy(const struct nvme_subsystem *p) * Accessors for: struct nvme_host ****************************************************************************/ -void nvme_host_set_hostnqn(struct nvme_host *p, const char *hostnqn) -{ - free(p->hostnqn); - p->hostnqn = hostnqn ? strdup(hostnqn) : NULL; -} - const char *nvme_host_get_hostnqn(const struct nvme_host *p) { return p->hostnqn; } -void nvme_host_set_hostid(struct nvme_host *p, const char *hostid) -{ - free(p->hostid); - p->hostid = hostid ? strdup(hostid) : NULL; -} - const char *nvme_host_get_hostid(const struct nvme_host *p) { return p->hostid; diff --git a/libnvme/src/nvme/accessors.h b/libnvme/src/nvme/accessors.h index 9611dada55..5c594dd127 100644 --- a/libnvme/src/nvme/accessors.h +++ b/libnvme/src/nvme/accessors.h @@ -241,13 +241,6 @@ uint64_t nvme_ns_get_lba_util(const struct nvme_ns *p); * Accessors for: struct nvme_ctrl ****************************************************************************/ -/** - * nvme_ctrl_set_name() - Set name. - * @p: The &struct nvme_ctrl instance to update. - * @name: New string; a copy is stored. Pass NULL to clear. - */ -void nvme_ctrl_set_name(struct nvme_ctrl *p, const char *name); - /** * nvme_ctrl_get_name() - Get name. * @p: The &struct nvme_ctrl instance to query. @@ -256,13 +249,6 @@ void nvme_ctrl_set_name(struct nvme_ctrl *p, const char *name); */ const char *nvme_ctrl_get_name(const struct nvme_ctrl *p); -/** - * nvme_ctrl_set_sysfs_dir() - Set sysfs_dir. - * @p: The &struct nvme_ctrl instance to update. - * @sysfs_dir: New string; a copy is stored. Pass NULL to clear. - */ -void nvme_ctrl_set_sysfs_dir(struct nvme_ctrl *p, const char *sysfs_dir); - /** * nvme_ctrl_get_sysfs_dir() - Get sysfs_dir. * @p: The &struct nvme_ctrl instance to query. @@ -271,13 +257,6 @@ void nvme_ctrl_set_sysfs_dir(struct nvme_ctrl *p, const char *sysfs_dir); */ const char *nvme_ctrl_get_sysfs_dir(const struct nvme_ctrl *p); -/** - * nvme_ctrl_set_firmware() - Set firmware. - * @p: The &struct nvme_ctrl instance to update. - * @firmware: New string; a copy is stored. Pass NULL to clear. - */ -void nvme_ctrl_set_firmware(struct nvme_ctrl *p, const char *firmware); - /** * nvme_ctrl_get_firmware() - Get firmware. * @p: The &struct nvme_ctrl instance to query. @@ -286,13 +265,6 @@ void nvme_ctrl_set_firmware(struct nvme_ctrl *p, const char *firmware); */ const char *nvme_ctrl_get_firmware(const struct nvme_ctrl *p); -/** - * nvme_ctrl_set_model() - Set model. - * @p: The &struct nvme_ctrl instance to update. - * @model: New string; a copy is stored. Pass NULL to clear. - */ -void nvme_ctrl_set_model(struct nvme_ctrl *p, const char *model); - /** * nvme_ctrl_get_model() - Get model. * @p: The &struct nvme_ctrl instance to query. @@ -301,13 +273,6 @@ void nvme_ctrl_set_model(struct nvme_ctrl *p, const char *model); */ const char *nvme_ctrl_get_model(const struct nvme_ctrl *p); -/** - * nvme_ctrl_set_numa_node() - Set numa_node. - * @p: The &struct nvme_ctrl instance to update. - * @numa_node: New string; a copy is stored. Pass NULL to clear. - */ -void nvme_ctrl_set_numa_node(struct nvme_ctrl *p, const char *numa_node); - /** * nvme_ctrl_get_numa_node() - Get numa_node. * @p: The &struct nvme_ctrl instance to query. @@ -316,13 +281,6 @@ void nvme_ctrl_set_numa_node(struct nvme_ctrl *p, const char *numa_node); */ const char *nvme_ctrl_get_numa_node(const struct nvme_ctrl *p); -/** - * nvme_ctrl_set_queue_count() - Set queue_count. - * @p: The &struct nvme_ctrl instance to update. - * @queue_count: New string; a copy is stored. Pass NULL to clear. - */ -void nvme_ctrl_set_queue_count(struct nvme_ctrl *p, const char *queue_count); - /** * nvme_ctrl_get_queue_count() - Get queue_count. * @p: The &struct nvme_ctrl instance to query. @@ -331,13 +289,6 @@ void nvme_ctrl_set_queue_count(struct nvme_ctrl *p, const char *queue_count); */ const char *nvme_ctrl_get_queue_count(const struct nvme_ctrl *p); -/** - * nvme_ctrl_set_serial() - Set serial. - * @p: The &struct nvme_ctrl instance to update. - * @serial: New string; a copy is stored. Pass NULL to clear. - */ -void nvme_ctrl_set_serial(struct nvme_ctrl *p, const char *serial); - /** * nvme_ctrl_get_serial() - Get serial. * @p: The &struct nvme_ctrl instance to query. @@ -346,13 +297,6 @@ void nvme_ctrl_set_serial(struct nvme_ctrl *p, const char *serial); */ const char *nvme_ctrl_get_serial(const struct nvme_ctrl *p); -/** - * nvme_ctrl_set_sqsize() - Set sqsize. - * @p: The &struct nvme_ctrl instance to update. - * @sqsize: New string; a copy is stored. Pass NULL to clear. - */ -void nvme_ctrl_set_sqsize(struct nvme_ctrl *p, const char *sqsize); - /** * nvme_ctrl_get_sqsize() - Get sqsize. * @p: The &struct nvme_ctrl instance to query. @@ -361,13 +305,6 @@ void nvme_ctrl_set_sqsize(struct nvme_ctrl *p, const char *sqsize); */ const char *nvme_ctrl_get_sqsize(const struct nvme_ctrl *p); -/** - * nvme_ctrl_set_transport() - Set transport. - * @p: The &struct nvme_ctrl instance to update. - * @transport: New string; a copy is stored. Pass NULL to clear. - */ -void nvme_ctrl_set_transport(struct nvme_ctrl *p, const char *transport); - /** * nvme_ctrl_get_transport() - Get transport. * @p: The &struct nvme_ctrl instance to query. @@ -377,11 +314,12 @@ void nvme_ctrl_set_transport(struct nvme_ctrl *p, const char *transport); const char *nvme_ctrl_get_transport(const struct nvme_ctrl *p); /** - * nvme_ctrl_set_traddr() - Set traddr. - * @p: The &struct nvme_ctrl instance to update. - * @traddr: New string; a copy is stored. Pass NULL to clear. + * nvme_ctrl_get_subsysnqn() - Get subsysnqn. + * @p: The &struct nvme_ctrl instance to query. + * + * Return: The value of the subsysnqn field, or NULL if not set. */ -void nvme_ctrl_set_traddr(struct nvme_ctrl *p, const char *traddr); +const char *nvme_ctrl_get_subsysnqn(const struct nvme_ctrl *p); /** * nvme_ctrl_get_traddr() - Get traddr. @@ -391,13 +329,6 @@ void nvme_ctrl_set_traddr(struct nvme_ctrl *p, const char *traddr); */ const char *nvme_ctrl_get_traddr(const struct nvme_ctrl *p); -/** - * nvme_ctrl_set_trsvcid() - Set trsvcid. - * @p: The &struct nvme_ctrl instance to update. - * @trsvcid: New string; a copy is stored. Pass NULL to clear. - */ -void nvme_ctrl_set_trsvcid(struct nvme_ctrl *p, const char *trsvcid); - /** * nvme_ctrl_get_trsvcid() - Get trsvcid. * @p: The &struct nvme_ctrl instance to query. @@ -487,13 +418,6 @@ void nvme_ctrl_set_tls_key(struct nvme_ctrl *p, const char *tls_key); */ const char *nvme_ctrl_get_tls_key(const struct nvme_ctrl *p); -/** - * nvme_ctrl_set_cntrltype() - Set cntrltype. - * @p: The &struct nvme_ctrl instance to update. - * @cntrltype: New string; a copy is stored. Pass NULL to clear. - */ -void nvme_ctrl_set_cntrltype(struct nvme_ctrl *p, const char *cntrltype); - /** * nvme_ctrl_get_cntrltype() - Get cntrltype. * @p: The &struct nvme_ctrl instance to query. @@ -502,13 +426,6 @@ void nvme_ctrl_set_cntrltype(struct nvme_ctrl *p, const char *cntrltype); */ const char *nvme_ctrl_get_cntrltype(const struct nvme_ctrl *p); -/** - * nvme_ctrl_set_cntlid() - Set cntlid. - * @p: The &struct nvme_ctrl instance to update. - * @cntlid: New string; a copy is stored. Pass NULL to clear. - */ -void nvme_ctrl_set_cntlid(struct nvme_ctrl *p, const char *cntlid); - /** * nvme_ctrl_get_cntlid() - Get cntlid. * @p: The &struct nvme_ctrl instance to query. @@ -517,13 +434,6 @@ void nvme_ctrl_set_cntlid(struct nvme_ctrl *p, const char *cntlid); */ const char *nvme_ctrl_get_cntlid(const struct nvme_ctrl *p); -/** - * nvme_ctrl_set_dctype() - Set dctype. - * @p: The &struct nvme_ctrl instance to update. - * @dctype: New string; a copy is stored. Pass NULL to clear. - */ -void nvme_ctrl_set_dctype(struct nvme_ctrl *p, const char *dctype); - /** * nvme_ctrl_get_dctype() - Get dctype. * @p: The &struct nvme_ctrl instance to query. @@ -533,11 +443,12 @@ void nvme_ctrl_set_dctype(struct nvme_ctrl *p, const char *dctype); const char *nvme_ctrl_get_dctype(const struct nvme_ctrl *p); /** - * nvme_ctrl_set_host_traddr() - Set host_traddr. - * @p: The &struct nvme_ctrl instance to update. - * @host_traddr: New string; a copy is stored. Pass NULL to clear. + * nvme_ctrl_get_phy_slot() - Get phy_slot. + * @p: The &struct nvme_ctrl instance to query. + * + * Return: The value of the phy_slot field, or NULL if not set. */ -void nvme_ctrl_set_host_traddr(struct nvme_ctrl *p, const char *host_traddr); +const char *nvme_ctrl_get_phy_slot(const struct nvme_ctrl *p); /** * nvme_ctrl_get_host_traddr() - Get host_traddr. @@ -547,13 +458,6 @@ void nvme_ctrl_set_host_traddr(struct nvme_ctrl *p, const char *host_traddr); */ const char *nvme_ctrl_get_host_traddr(const struct nvme_ctrl *p); -/** - * nvme_ctrl_set_host_iface() - Set host_iface. - * @p: The &struct nvme_ctrl instance to update. - * @host_iface: New string; a copy is stored. Pass NULL to clear. - */ -void nvme_ctrl_set_host_iface(struct nvme_ctrl *p, const char *host_iface); - /** * nvme_ctrl_get_host_iface() - Get host_iface. * @p: The &struct nvme_ctrl instance to query. @@ -628,13 +532,6 @@ bool nvme_ctrl_get_persistent(const struct nvme_ctrl *p); * Accessors for: struct nvme_subsystem ****************************************************************************/ -/** - * nvme_subsystem_set_name() - Set name. - * @p: The &struct nvme_subsystem instance to update. - * @name: New string; a copy is stored. Pass NULL to clear. - */ -void nvme_subsystem_set_name(struct nvme_subsystem *p, const char *name); - /** * nvme_subsystem_get_name() - Get name. * @p: The &struct nvme_subsystem instance to query. @@ -643,15 +540,6 @@ void nvme_subsystem_set_name(struct nvme_subsystem *p, const char *name); */ const char *nvme_subsystem_get_name(const struct nvme_subsystem *p); -/** - * nvme_subsystem_set_sysfs_dir() - Set sysfs_dir. - * @p: The &struct nvme_subsystem instance to update. - * @sysfs_dir: New string; a copy is stored. Pass NULL to clear. - */ -void nvme_subsystem_set_sysfs_dir( - struct nvme_subsystem *p, - const char *sysfs_dir); - /** * nvme_subsystem_get_sysfs_dir() - Get sysfs_dir. * @p: The &struct nvme_subsystem instance to query. @@ -660,15 +548,6 @@ void nvme_subsystem_set_sysfs_dir( */ const char *nvme_subsystem_get_sysfs_dir(const struct nvme_subsystem *p); -/** - * nvme_subsystem_set_subsysnqn() - Set subsysnqn. - * @p: The &struct nvme_subsystem instance to update. - * @subsysnqn: New string; a copy is stored. Pass NULL to clear. - */ -void nvme_subsystem_set_subsysnqn( - struct nvme_subsystem *p, - const char *subsysnqn); - /** * nvme_subsystem_get_subsysnqn() - Get subsysnqn. * @p: The &struct nvme_subsystem instance to query. @@ -677,13 +556,6 @@ void nvme_subsystem_set_subsysnqn( */ const char *nvme_subsystem_get_subsysnqn(const struct nvme_subsystem *p); -/** - * nvme_subsystem_set_model() - Set model. - * @p: The &struct nvme_subsystem instance to update. - * @model: New string; a copy is stored. Pass NULL to clear. - */ -void nvme_subsystem_set_model(struct nvme_subsystem *p, const char *model); - /** * nvme_subsystem_get_model() - Get model. * @p: The &struct nvme_subsystem instance to query. @@ -692,13 +564,6 @@ void nvme_subsystem_set_model(struct nvme_subsystem *p, const char *model); */ const char *nvme_subsystem_get_model(const struct nvme_subsystem *p); -/** - * nvme_subsystem_set_serial() - Set serial. - * @p: The &struct nvme_subsystem instance to update. - * @serial: New string; a copy is stored. Pass NULL to clear. - */ -void nvme_subsystem_set_serial(struct nvme_subsystem *p, const char *serial); - /** * nvme_subsystem_get_serial() - Get serial. * @p: The &struct nvme_subsystem instance to query. @@ -707,15 +572,6 @@ void nvme_subsystem_set_serial(struct nvme_subsystem *p, const char *serial); */ const char *nvme_subsystem_get_serial(const struct nvme_subsystem *p); -/** - * nvme_subsystem_set_firmware() - Set firmware. - * @p: The &struct nvme_subsystem instance to update. - * @firmware: New string; a copy is stored. Pass NULL to clear. - */ -void nvme_subsystem_set_firmware( - struct nvme_subsystem *p, - const char *firmware); - /** * nvme_subsystem_get_firmware() - Get firmware. * @p: The &struct nvme_subsystem instance to query. @@ -724,15 +580,6 @@ void nvme_subsystem_set_firmware( */ const char *nvme_subsystem_get_firmware(const struct nvme_subsystem *p); -/** - * nvme_subsystem_set_subsystype() - Set subsystype. - * @p: The &struct nvme_subsystem instance to update. - * @subsystype: New string; a copy is stored. Pass NULL to clear. - */ -void nvme_subsystem_set_subsystype( - struct nvme_subsystem *p, - const char *subsystype); - /** * nvme_subsystem_get_subsystype() - Get subsystype. * @p: The &struct nvme_subsystem instance to query. @@ -779,13 +626,6 @@ const char *nvme_subsystem_get_iopolicy(const struct nvme_subsystem *p); * Accessors for: struct nvme_host ****************************************************************************/ -/** - * nvme_host_set_hostnqn() - Set hostnqn. - * @p: The &struct nvme_host instance to update. - * @hostnqn: New string; a copy is stored. Pass NULL to clear. - */ -void nvme_host_set_hostnqn(struct nvme_host *p, const char *hostnqn); - /** * nvme_host_get_hostnqn() - Get hostnqn. * @p: The &struct nvme_host instance to query. @@ -794,13 +634,6 @@ void nvme_host_set_hostnqn(struct nvme_host *p, const char *hostnqn); */ const char *nvme_host_get_hostnqn(const struct nvme_host *p); -/** - * nvme_host_set_hostid() - Set hostid. - * @p: The &struct nvme_host instance to update. - * @hostid: New string; a copy is stored. Pass NULL to clear. - */ -void nvme_host_set_hostid(struct nvme_host *p, const char *hostid); - /** * nvme_host_get_hostid() - Get hostid. * @p: The &struct nvme_host instance to query. diff --git a/libnvme/src/nvme/private.h b/libnvme/src/nvme/private.h index 749c6c616b..78bbc42a63 100644 --- a/libnvme/src/nvme/private.h +++ b/libnvme/src/nvme/private.h @@ -184,31 +184,31 @@ struct nvme_ctrl { /*!generate-accessors*/ struct nvme_global_ctx *ctx; struct nvme_transport_handle *hdl; - char *name; - char *sysfs_dir; + char *name; //!accessors:readonly + char *sysfs_dir; //!accessors:readonly char *address; //!accessors:none - char *firmware; - char *model; + char *firmware; //!accessors:readonly + char *model; //!accessors:readonly char *state; //!accessors:none - char *numa_node; - char *queue_count; - char *serial; - char *sqsize; - char *transport; - char *subsysnqn; //!accessors:none - char *traddr; - char *trsvcid; + char *numa_node; //!accessors:readonly + char *queue_count; //!accessors:readonly + char *serial; //!accessors:readonly + char *sqsize; //!accessors:readonly + char *transport; //!accessors:readonly + char *subsysnqn; //!accessors:readonly + char *traddr; //!accessors:readonly + char *trsvcid; //!accessors:readonly char *dhchap_host_key; char *dhchap_ctrl_key; char *keyring; char *tls_key_identity; char *tls_key; - char *cntrltype; - char *cntlid; - char *dctype; - char *phy_slot; //!accessors:none - char *host_traddr; - char *host_iface; + char *cntrltype; //!accessors:readonly + char *cntlid; //!accessors:readonly + char *dctype; //!accessors:readonly + char *phy_slot; //!accessors:readonly + char *host_traddr; //!accessors:readonly + char *host_iface; //!accessors:readonly bool discovery_ctrl; bool unique_discovery_ctrl; bool discovered; @@ -222,13 +222,13 @@ struct nvme_subsystem { /*!generate-accessors*/ struct list_head namespaces; struct nvme_host *h; - char *name; - char *sysfs_dir; - char *subsysnqn; - char *model; - char *serial; - char *firmware; - char *subsystype; + char *name; /*!accessors:readonly*/ + char *sysfs_dir; /*!accessors:readonly*/ + char *subsysnqn; /*!accessors:readonly*/ + char *model; /*!accessors:readonly*/ + char *serial; /*!accessors:readonly*/ + char *firmware; /*!accessors:readonly*/ + char *subsystype; /*!accessors:readonly*/ char *application; char *iopolicy; }; @@ -238,8 +238,8 @@ struct nvme_host { /*!generate-accessors*/ struct list_head subsystems; struct nvme_global_ctx *ctx; - char *hostnqn; - char *hostid; + char *hostnqn; /*!accessors:readonly*/ + char *hostid; /*!accessors:readonly*/ char *dhchap_host_key; char *hostsymname; bool pdc_enabled; //!accessors:none diff --git a/libnvme/src/nvme/tree.c b/libnvme/src/nvme/tree.c index dcc18f9b8d..d2f6728dff 100644 --- a/libnvme/src/nvme/tree.c +++ b/libnvme/src/nvme/tree.c @@ -890,11 +890,6 @@ nvme_subsystem_t nvme_ctrl_get_subsystem(nvme_ctrl_t c) } -const char *nvme_ctrl_get_subsysnqn(nvme_ctrl_t c) -{ - return c->s ? c->s->subsysnqn : c->subsysnqn; -} - char *nvme_ctrl_get_src_addr(nvme_ctrl_t c, char *src_addr, size_t src_addr_len) { size_t l; @@ -921,11 +916,6 @@ char *nvme_ctrl_get_src_addr(nvme_ctrl_t c, char *src_addr, size_t src_addr_len) return src_addr; } -const char *nvme_ctrl_get_phy_slot(nvme_ctrl_t c) -{ - return c->phy_slot ? c->phy_slot : ""; -} - const char *nvme_ctrl_get_state(nvme_ctrl_t c) { char *state = c->state; @@ -1603,8 +1593,7 @@ static int nvme_ctrl_lookup_subsystem_name(struct nvme_global_ctx *ctx, } static int nvme_ctrl_lookup_phy_slot(struct nvme_global_ctx *ctx, - const char *address, - char **slotp) + nvme_ctrl_t c) { const char *slots_sysfs_dir = nvme_slots_sysfs_dir(); _cleanup_free_ char *target_addr = NULL; @@ -1613,7 +1602,7 @@ static int nvme_ctrl_lookup_phy_slot(struct nvme_global_ctx *ctx, char *slot; int ret; - if (!address) + if (!c->address) return -EINVAL; slots_dir = opendir(slots_sysfs_dir); @@ -1623,7 +1612,7 @@ static int nvme_ctrl_lookup_phy_slot(struct nvme_global_ctx *ctx, return -errno; } - target_addr = strndup(address, 10); + target_addr = strndup(c->address, 10); while ((entry = readdir(slots_dir))) { if (entry->d_type == DT_DIR && strncmp(entry->d_name, ".", 1) != 0 && @@ -1647,7 +1636,7 @@ static int nvme_ctrl_lookup_phy_slot(struct nvme_global_ctx *ctx, if (!slot) return -ENOMEM; - *slotp = slot; + c->phy_slot = slot; return 0; } } @@ -1760,7 +1749,7 @@ static int nvme_reconfigure_ctrl(struct nvme_global_ctx *ctx, nvme_ctrl_t c, con c->cntrltype = nvme_get_ctrl_attr(c, "cntrltype"); c->cntlid = nvme_get_ctrl_attr(c, "cntlid"); c->dctype = nvme_get_ctrl_attr(c, "dctype"); - nvme_ctrl_lookup_phy_slot(ctx, c->address, &c->phy_slot); + nvme_ctrl_lookup_phy_slot(ctx, c); nvme_read_sysfs_dhchap(ctx, c); nvme_read_sysfs_tls(ctx, c); diff --git a/libnvme/src/nvme/tree.h b/libnvme/src/nvme/tree.h index fde0fe11bd..07b75677cd 100644 --- a/libnvme/src/nvme/tree.h +++ b/libnvme/src/nvme/tree.h @@ -726,15 +726,6 @@ void nvme_ctrl_release_transport_handle(nvme_ctrl_t c); */ char *nvme_ctrl_get_src_addr(nvme_ctrl_t c, char *src_addr, size_t src_addr_len); -/** - * nvme_ctrl_get_phy_slot() - PCI physical slot number of a controller - * @c: Controller instance - * - * Return: PCI physical slot number of @c or empty string if slot - * number is not present. - */ -const char *nvme_ctrl_get_phy_slot(nvme_ctrl_t c); - /** * nvme_ctrl_get_state() - Running state of a controller * @c: Controller instance @@ -743,14 +734,6 @@ const char *nvme_ctrl_get_phy_slot(nvme_ctrl_t c); */ const char *nvme_ctrl_get_state(nvme_ctrl_t c); -/** - * nvme_ctrl_get_subsysnqn() - Subsystem NQN of a controller - * @c: Controller instance - * - * Return: Subsystem NQN of @c - */ -const char *nvme_ctrl_get_subsysnqn(nvme_ctrl_t c); - /** * nvme_ctrl_get_subsystem() - Parent subsystem of a controller * @c: Controller instance