From 87e352de758203414fcb96e30200b59d6e5623c6 Mon Sep 17 00:00:00 2001 From: Daniel Wagner Date: Mon, 16 Mar 2026 09:12:37 +0000 Subject: [PATCH 1/3] libnvme: API review Add a table which documents the renaming proposal. Signed-off-by: Daniel Wagner --- libnvme/doc/function-index.md | 242 ++++++++++++++++++++++++++++++++++ 1 file changed, 242 insertions(+) create mode 100644 libnvme/doc/function-index.md diff --git a/libnvme/doc/function-index.md b/libnvme/doc/function-index.md new file mode 100644 index 0000000000..4ef699923e --- /dev/null +++ b/libnvme/doc/function-index.md @@ -0,0 +1,242 @@ + + +# libnvme API review + +This document lists the currently exported function names. The goal is to make +the naming more consistent. Functions are grouped by common prefixes. Generic +top-level functions use the nvme_ prefix, while functions operating on specific +objects use the object type as a prefix (e.g., nvme_ns_). The prefix is +typically followed by a verb, such as nvme_create_ctrl. + +--- + +## tree.h — libnvme tree object interface + +| Function | Suggested Name | +|--------------------------------------|--------------------------| +| `nvme_create_ctrl` | | +| `nvme_ctrl_config_match` | `nvme_ctrl_match_config` | +| `nvme_ctrl_first_ns` | | +| `nvme_ctrl_first_path` | | +| `nvme_ctrl_for_each_ns_safe` | | +| `nvme_ctrl_for_each_ns` | | +| `nvme_ctrl_for_each_path_safe` | | +| `nvme_ctrl_for_each_path` | | +| `nvme_ctrl_get_address` | | +| `nvme_ctrl_get_config` | | +| `nvme_ctrl_get_dhchap_host_key` | | +| `nvme_ctrl_get_phy_slot` | | +| `nvme_ctrl_get_src_addr` | | +| `nvme_ctrl_get_state` | | +| `nvme_ctrl_get_subsysnqn` | | +| `nvme_ctrl_get_subsystem` | | +| `nvme_ctrl_get_transport_handle` | | +| `nvme_ctrl_identify` | `nvme_identify_ctrl` | +| `nvme_ctrl_is_discovered` | | +| `nvme_ctrl_is_discovery_ctrl` | | +| `nvme_ctrl_is_persistent` | | +| `nvme_ctrl_is_unique_discovery_ctrl` | | +| `nvme_ctrl_next_ns` | | +| `nvme_ctrl_next_path` | | +| `nvme_ctrl_release_transport_handle` | | +| `nvme_ctrl_set_dhchap_host_key` | | +| `nvme_disconnect_ctrl` | | +| `nvme_dump_config` | | +| `nvme_dump_tree` | | +| `nvme_first_host` | | +| `nvme_first_subsystem` | | +| `nvme_for_each_host_safe` | | +| `nvme_for_each_host` | | +| `nvme_for_each_subsystem_safe` | | +| `nvme_for_each_subsystem` | | +| `nvme_free_ctrl` | | +| `nvme_free_host` | | +| `nvme_free_ns` | | +| `nvme_free_subsystem` | | +| `nvme_get_application` | | +| `nvme_get_attr` | | +| `nvme_get_ctrl_attr` | | +| `nvme_get_ns_attr` | | +| `nvme_get_path_attr` | | +| `nvme_get_subsys_attr` | | +| `nvme_host_get_global_ctx` | | +| `nvme_host_get_ids` | | +| `nvme_host_get` | `nvme_get_host` | +| `nvme_host_is_pdc_enabled` | | +| `nvme_host_release_fds` | | +| `nvme_host_set_pdc_enabled` | | +| `nvme_init_ctrl` | | +| `nvme_namespace_first_path` | | +| `nvme_namespace_for_each_path_safe` | | +| `nvme_namespace_for_each_path` | | +| `nvme_namespace_next_path` | | +| `nvme_next_host` | | +| `nvme_next_subsystem` | | +| `nvme_ns_compare` | | +| `nvme_ns_flush` | | +| `nvme_ns_get_csi` | | +| `nvme_ns_get_ctrl` | | +| `nvme_ns_get_eui64` | | +| `nvme_ns_get_firmware` | | +| `nvme_ns_get_generic_name` | | +| `nvme_ns_get_model` | | +| `nvme_ns_get_nguid` | | +| `nvme_ns_get_serial` | | +| `nvme_ns_get_subsystem` | | +| `nvme_ns_get_uuid` | | +| `nvme_ns_head_get_sysfs_dir` | | +| `nvme_ns_identify_descs` | | +| `nvme_ns_identify` | | +| `nvme_ns_read` | | +| `nvme_ns_verify` | | +| `nvme_ns_write_uncorrectable` | | +| `nvme_ns_write_zeros` | | +| `nvme_ns_write` | | +| `nvme_path_get_ctrl` | | +| `nvme_path_get_ns` | | +| `nvme_path_get_queue_depth` | | +| `nvme_read_config` | | +| `nvme_refresh_topology` | | +| `nvme_release_fds` | | +| `nvme_rescan_ctrl` | | +| `nvme_scan_ctrl` | | +| `nvme_scan_namespace` | | +| `nvme_scan_topology` | | +| `nvme_set_application` | | +| `nvme_skip_namespaces` | | +| `nvme_subsystem_first_ctrl` | | +| `nvme_subsystem_first_ns` | | +| `nvme_subsystem_for_each_ctrl_safe` | | +| `nvme_subsystem_for_each_ctrl` | | +| `nvme_subsystem_for_each_ns_safe` | +| `nvme_subsystem_for_each_ns` | | +| `nvme_subsystem_get_fw_rev` | | +| `nvme_subsystem_get_host` | | +| `nvme_subsystem_get_nqn` | | +| `nvme_subsystem_get_type` | | +| `nvme_subsystem_get` | `nvme_get_subsystem` | +| `nvme_subsystem_lookup_namespace` | | +| `nvme_subsystem_next_ctrl` | | +| `nvme_subsystem_next_ns` | | +| `nvme_subsystem_release_fds` | | +| `nvme_unlink_ctrl` | | +--- + +## linux.h — Linux-specific key and identity utilities + +| Function | Suggested Name | +|-----------------------------------------|-------------------------------------| +| `nvme_describe_key_serial` | | +| `nvme_export_tls_key_versioned` | | +| `nvme_export_tls_key` | | +| `nvme_gen_dhchap_key` | | +| `nvme_generate_tls_key_identity_compat` | | +| `nvme_generate_tls_key_identity` | | +| `nvme_hostid_from_file` | `nvme_read_hostid` | +| `nvme_hostid_generate` | `nvme_generate_hostid` | +| `nvme_hostnqn_from_file` | `nvme_read_hostnqn` | +| `nvme_hostnqn_generate_from_hostid` | `nvme_generate_hostnqn_from_hostid` | +| `nvme_hostnqn_generate` | `nvme_generate_hostnqn` | +| `nvme_import_tls_key_versioned` | | +| `nvme_import_tls_key` | | +| `nvme_insert_tls_key_compat` | | +| `nvme_insert_tls_key_versioned` | | +| `nvme_insert_tls_key` | | +| `nvme_lookup_key` | | +| `nvme_lookup_keyring` | | +| `nvme_read_key` | | +| `nvme_revoke_tls_key` | | +| `nvme_scan_tls_keys` | | +| `nvme_set_keyring` | | +| `nvme_update_key` | | + +--- + +## lib.h — libnvme library context and device management + +| Function | Suggested Name | +|------------------------------------------|----------------| +| `nvme_close` | | +| `nvme_create_global_ctx` | | +| `nvme_free_global_ctx` | | +| `nvme_get_logging_level` | | +| `nvme_open` | | +| `nvme_set_dry_run` | | +| `nvme_set_ioctl_probing` | | +| `nvme_set_logging_level` | | +| `nvme_set_probe_enabled` | | +| `nvme_transport_handle_get_fd` | | +| `nvme_transport_handle_get_name` | | +| `nvme_transport_handle_is_blkdev` | | +| `nvme_transport_handle_is_chardev` | | +| `nvme_transport_handle_is_direct` | | +| `nvme_transport_handle_is_mi` | | +| `nvme_transport_handle_set_decide_retry` | | +| `nvme_transport_handle_set_submit_entry` | | +| `nvme_transport_handle_set_submit_exit` | | + +--- + +## ioctl.h — NVMe IOCTL passthrough interface + +| Function | Suggested Name | +|------------------------------|------------------------| +| `nvme_ctrl_reset` | `nvme_reset_ctrl` | +| `nvme_get_nsid` | | +| `nvme_ns_rescan` | `nvme_rescan_ns` | +| `nvme_submit_admin_passthru` | | +| `nvme_submit_io_passthru` | | +| `nvme_subsystem_reset` | `nvme_reset_subsystem` | + +--- + +## filters.h — libnvme directory filter + +| Function | Suggested Name | +|----------------------------------|-------------------------| +| `nvme_ctrls_filter` | `nvme_filter_ctrls` | +| `nvme_namespace_filter` | `nvme_filter_namespace` | +| `nvme_paths_filter` | `nvme_filter_paths` | +| `nvme_scan_ctrl_namespace_paths` | | +| `nvme_scan_ctrl_namespaces` | | +| `nvme_scan_ctrls` | | +| `nvme_scan_ns_head_paths` | | +| `nvme_scan_subsystem_namespaces` | | +| `nvme_scan_subsystems` | | +| `nvme_subsys_filter` | `nvme_filter_subsys` | + +--- + +## fabrics.h — NVMe-oF fabrics helper functions + +| Function | Suggested Name | +|------------------|----------------| +| `nvme_parse_uri` | | + +--- + +## nbft.h — NVM Express Boot Firmware Table (NBFT) parser + +| Function | Suggested Name | +|------------------|------------------| +| `nvme_nbft_free` | `nvme_free_nbft` | +| `nvme_nbft_read` | `nvme_read_nbft` | + +--- + +## util.h — libnvme utility functions + +| Function | Suggested Name | +|-------------------------------------|--------------------| +| `nvme_basename` | | +| `nvme_errno_to_string` | | +| `nvme_get_version` | | +| `nvme_opcode_status_to_string` | | +| `nvme_sanitize_ns_status_to_string` | | +| `nvme_status_to_errno` | | +| `nvme_status_to_string` | | +| `nvme_strerror` | | +| `nvme_uuid_find` | `nvme_find_uuid` | +| `nvme_uuid_from_string` | | +| `nvme_uuid_random` | `nvme_random_uuid` | +| `nvme_uuid_to_string` | | From bce7f318e7f8380341c7530110fca9e857a4614d Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 16 Mar 2026 13:43:29 +0000 Subject: [PATCH 2/3] Initial plan From 022690b8cbeda1443af71e30691d167842cbc653 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 16 Mar 2026 13:52:06 +0000 Subject: [PATCH 3/3] Rename functions as described in libnvme/doc/function-index.md Co-authored-by: igaw <1050803+igaw@users.noreply.github.com> --- libnvme/examples/discover-loop.c | 2 +- libnvme/libnvme/nvme.i | 12 +++++----- libnvme/src/libnvme.ld | 38 ++++++++++++++++---------------- libnvme/src/nvme/fabrics.c | 10 ++++----- libnvme/src/nvme/filters.c | 20 ++++++++--------- libnvme/src/nvme/filters.h | 16 +++++++------- libnvme/src/nvme/ioctl.c | 6 ++--- libnvme/src/nvme/ioctl.h | 12 +++++----- libnvme/src/nvme/linux.c | 16 +++++++------- libnvme/src/nvme/linux.h | 20 ++++++++--------- libnvme/src/nvme/nbft.c | 6 ++--- libnvme/src/nvme/nbft.h | 10 ++++----- libnvme/src/nvme/tree.c | 18 +++++++-------- libnvme/src/nvme/tree.h | 12 +++++----- libnvme/src/nvme/util.c | 4 ++-- libnvme/src/nvme/util.h | 8 +++---- libnvme/test/nbft/nbft-dump.c | 4 ++-- libnvme/test/tree.c | 20 ++++++++--------- libnvme/test/uuid.c | 4 ++-- nvme.c | 22 +++++++++--------- plugins/huawei/huawei-nvme.c | 2 +- plugins/ocp/ocp-utils.c | 2 +- plugins/sandisk/sandisk-utils.c | 12 +++++----- plugins/scaleflux/sfx-nvme.c | 2 +- plugins/solidigm/solidigm-util.c | 2 +- plugins/wdc/wdc-nvme.c | 24 ++++++++++---------- 26 files changed, 152 insertions(+), 152 deletions(-) diff --git a/libnvme/examples/discover-loop.c b/libnvme/examples/discover-loop.c index a41df92b43..f1369e8a0d 100644 --- a/libnvme/examples/discover-loop.c +++ b/libnvme/examples/discover-loop.c @@ -69,7 +69,7 @@ int main() nvme_free_global_ctx(ctx); return 1; } - ret = nvme_host_get(ctx, NULL, NULL, &h); + ret = nvme_get_host(ctx, NULL, NULL, &h); if (ret) { fprintf(stderr, "Failed to allocated memory\n"); return 1; diff --git a/libnvme/libnvme/nvme.i b/libnvme/libnvme/nvme.i index 460500e06b..577bab8e63 100644 --- a/libnvme/libnvme/nvme.i +++ b/libnvme/libnvme/nvme.i @@ -39,13 +39,13 @@ Py_XDECREF(val); /* .. therefore decrement ref. count. */ } PyObject *hostnqn_from_file() { - char * val = nvme_hostnqn_from_file(); + char * val = nvme_read_hostnqn(); PyObject * obj = PyUnicode_FromString(val); free(val); return obj; } PyObject *hostid_from_file() { - char * val = nvme_hostid_from_file(); + char * val = nvme_read_hostid(); PyObject * obj = PyUnicode_FromString(val); free(val); return obj; @@ -557,7 +557,7 @@ struct nvme_ns { const char *hostkey = NULL, const char *hostsymname = NULL) { nvme_host_t h; - if (nvme_host_get(ctx, hostnqn, hostid, &h)) + if (nvme_get_host(ctx, hostnqn, hostid, &h)) return NULL; if (hostsymname) nvme_host_set_hostsymname(h, hostsymname); @@ -613,7 +613,7 @@ struct nvme_ns { const char *name = NULL) { struct nvme_subsystem *s; - if (nvme_subsystem_get(ctx, host, name, subsysnqn, &s)) + if (nvme_get_subsystem(ctx, host, name, subsysnqn, &s)) return NULL; return s; @@ -1245,13 +1245,13 @@ struct nvme_ns { PyObject *output; int ret; - ret = nvme_nbft_read(ctx, &nbft, filename); + ret = nvme_read_nbft(ctx, &nbft, filename); if (ret) { Py_RETURN_NONE; } output = nbft_to_pydict(nbft); - nvme_nbft_free(ctx, nbft); + nvme_free_nbft(ctx, nbft); return output; } %}; diff --git a/libnvme/src/libnvme.ld b/libnvme/src/libnvme.ld index 6fd9afad14..b9cc9e2d49 100644 --- a/libnvme/src/libnvme.ld +++ b/libnvme/src/libnvme.ld @@ -6,7 +6,7 @@ LIBNVME_3 { nvme_close; nvme_create_ctrl; nvme_create_global_ctx; - nvme_ctrl_config_match; + nvme_ctrl_match_config; nvme_ctrl_first_ns; nvme_ctrl_first_path; nvme_ctrl_get_address; @@ -25,9 +25,9 @@ LIBNVME_3 { nvme_ctrl_next_ns; nvme_ctrl_next_path; nvme_ctrl_release_transport_handle; - nvme_ctrl_reset; + nvme_reset_ctrl; nvme_ctrl_set_dhchap_host_key; - nvme_ctrls_filter; + nvme_filter_ctrls; nvme_describe_key_serial; nvme_disconnect_ctrl; nvme_dump_config; @@ -69,17 +69,17 @@ LIBNVME_3 { nvme_get_telemetry_max; nvme_get_uuid_list; nvme_get_version; - nvme_host_get; + nvme_get_host; nvme_host_get_global_ctx; nvme_host_get_ids; nvme_host_is_pdc_enabled; nvme_host_release_fds; nvme_host_set_pdc_enabled; - nvme_hostid_from_file; - nvme_hostid_generate; - nvme_hostnqn_from_file; - nvme_hostnqn_generate; - nvme_hostnqn_generate_from_hostid; + nvme_read_hostid; + nvme_generate_hostid; + nvme_read_hostnqn; + nvme_generate_hostnqn; + nvme_generate_hostnqn_from_hostid; nvme_import_tls_key; nvme_import_tls_key_versioned; nvme_init_copy_range; @@ -130,11 +130,11 @@ LIBNVME_3 { nvme_mi_submit_exit; nvme_namespace_attach_ctrls; nvme_namespace_detach_ctrls; - nvme_namespace_filter; + nvme_filter_namespace; nvme_namespace_first_path; nvme_namespace_next_path; - nvme_nbft_free; - nvme_nbft_read; + nvme_free_nbft; + nvme_read_nbft; nvme_next_host; nvme_next_subsystem; nvme_ns_attach; @@ -152,7 +152,7 @@ LIBNVME_3 { nvme_ns_get_uuid; nvme_ns_identify; nvme_ns_read; - nvme_ns_rescan; + nvme_rescan_ns; nvme_ns_verify; nvme_ns_write; nvme_ns_write_uncorrectable; @@ -162,7 +162,7 @@ LIBNVME_3 { nvme_path_get_ctrl; nvme_path_get_ns; nvme_path_get_queue_depth; - nvme_paths_filter; + nvme_filter_paths; nvme_read_config; nvme_read_key; nvme_refresh_topology; @@ -193,10 +193,10 @@ LIBNVME_3 { nvme_strerror; nvme_submit_admin_passthru; nvme_submit_io_passthru; - nvme_subsys_filter; + nvme_filter_subsys; nvme_subsystem_first_ctrl; nvme_subsystem_first_ns; - nvme_subsystem_get; + nvme_get_subsystem; nvme_subsystem_get_fw_rev; nvme_subsystem_get_host; nvme_subsystem_get_nqn; @@ -205,7 +205,7 @@ LIBNVME_3 { nvme_subsystem_next_ctrl; nvme_subsystem_next_ns; nvme_subsystem_release_fds; - nvme_subsystem_reset; + nvme_reset_subsystem; nvme_transport_handle_get_fd; nvme_transport_handle_get_name; nvme_transport_handle_is_blkdev; @@ -217,9 +217,9 @@ LIBNVME_3 { nvme_transport_handle_set_submit_exit; nvme_unlink_ctrl; nvme_update_key; - nvme_uuid_find; + nvme_find_uuid; nvme_uuid_from_string; - nvme_uuid_random; + nvme_random_uuid; nvme_uuid_to_string; local: *; diff --git a/libnvme/src/nvme/fabrics.c b/libnvme/src/nvme/fabrics.c index fe0fb064ca..83431b23af 100644 --- a/libnvme/src/nvme/fabrics.c +++ b/libnvme/src/nvme/fabrics.c @@ -2425,9 +2425,9 @@ int nvmf_config_modify(struct nvme_global_ctx *ctx, struct nvme_ctrl *c; if (!fctx->hostnqn) - fctx->hostnqn = hnqn = nvme_hostnqn_from_file(); + fctx->hostnqn = hnqn = nvme_read_hostnqn(); if (!fctx->hostid && hnqn) - fctx->hostid = hid = nvme_hostid_from_file(); + fctx->hostid = hid = nvme_read_hostid(); h = nvme_lookup_host(ctx, fctx->hostnqn, fctx->hostid); if (!h) { @@ -2489,7 +2489,7 @@ int nvmf_nbft_read_files(struct nvme_global_ctx *ctx, char *path, snprintf(filename, sizeof(filename), "%s/%s", path, dent[i]->d_name); - ret = nvme_nbft_read(ctx, &nbft, filename); + ret = nvme_read_nbft(ctx, &nbft, filename); if (!ret) { struct nbft_file_entry *new; @@ -2516,7 +2516,7 @@ void nvmf_nbft_free(struct nvme_global_ctx *ctx, struct nbft_file_entry *head) while (head) { struct nbft_file_entry *next = head->next; - nvme_nbft_free(ctx, head->nbft); + nvme_free_nbft(ctx, head->nbft); free(head); head = next; @@ -3041,7 +3041,7 @@ int nvmf_discovery(struct nvme_global_ctx *ctx, struct nvmf_context *fctx, ret = nvme_scan_ctrl(ctx, fctx->device, &c); if (!ret) { /* Check if device matches command-line options */ - if (!nvme_ctrl_config_match(c, fctx->transport, + if (!nvme_ctrl_match_config(c, fctx->transport, fctx->traddr, fctx->trsvcid, fctx->subsysnqn, fctx->host_traddr, fctx->host_iface)) { diff --git a/libnvme/src/nvme/filters.c b/libnvme/src/nvme/filters.c index de6915ed86..a3fb4cbfc6 100644 --- a/libnvme/src/nvme/filters.c +++ b/libnvme/src/nvme/filters.c @@ -14,7 +14,7 @@ #include "private.h" -int nvme_namespace_filter(const struct dirent *d) +int nvme_filter_namespace(const struct dirent *d) { int i, n; @@ -28,7 +28,7 @@ int nvme_namespace_filter(const struct dirent *d) return 0; } -int nvme_paths_filter(const struct dirent *d) +int nvme_filter_paths(const struct dirent *d) { int i, c, n; @@ -42,7 +42,7 @@ int nvme_paths_filter(const struct dirent *d) return 0; } -int nvme_ctrls_filter(const struct dirent *d) +int nvme_filter_ctrls(const struct dirent *d) { int i, c, n; @@ -61,7 +61,7 @@ int nvme_ctrls_filter(const struct dirent *d) return 0; } -int nvme_subsys_filter(const struct dirent *d) +int nvme_filter_subsys(const struct dirent *d) { int i; @@ -80,7 +80,7 @@ int nvme_scan_subsystems(struct dirent ***subsys) const char *dir = nvme_subsys_sysfs_dir(); int ret; - ret = scandir(dir, subsys, nvme_subsys_filter, alphasort); + ret = scandir(dir, subsys, nvme_filter_subsys, alphasort); if (ret < 0) return -errno; @@ -92,7 +92,7 @@ int nvme_scan_subsystem_namespaces(nvme_subsystem_t s, struct dirent ***ns) int ret; ret = scandir(nvme_subsystem_get_sysfs_dir(s), ns, - nvme_namespace_filter, alphasort); + nvme_filter_namespace, alphasort); if (ret < 0) return -errno; @@ -104,7 +104,7 @@ int nvme_scan_ctrls(struct dirent ***ctrls) const char *dir = nvme_ctrl_sysfs_dir(); int ret; - ret = scandir(dir, ctrls, nvme_ctrls_filter, alphasort); + ret = scandir(dir, ctrls, nvme_filter_ctrls, alphasort); if (ret < 0) return -errno; @@ -116,7 +116,7 @@ int nvme_scan_ctrl_namespace_paths(nvme_ctrl_t c, struct dirent ***paths) int ret; ret = scandir(nvme_ctrl_get_sysfs_dir(c), paths, - nvme_paths_filter, alphasort); + nvme_filter_paths, alphasort); if (ret < 0) return -errno; @@ -128,7 +128,7 @@ int nvme_scan_ctrl_namespaces(nvme_ctrl_t c, struct dirent ***ns) int ret; ret = scandir(nvme_ctrl_get_sysfs_dir(c), ns, - nvme_namespace_filter, alphasort); + nvme_filter_namespace, alphasort); if (ret < 0) return -errno; @@ -140,7 +140,7 @@ int nvme_scan_ns_head_paths(nvme_ns_head_t head, struct dirent ***paths) int ret; ret = scandir(nvme_ns_head_get_sysfs_dir(head), paths, - nvme_paths_filter, alphasort); + nvme_filter_paths, alphasort); if (ret < 0) return -errno; diff --git a/libnvme/src/nvme/filters.h b/libnvme/src/nvme/filters.h index 44f26ab2b3..05fd02a6f6 100644 --- a/libnvme/src/nvme/filters.h +++ b/libnvme/src/nvme/filters.h @@ -20,36 +20,36 @@ */ /** - * nvme_namespace_filter() - Filter for namespaces + * nvme_filter_namespace() - Filter for namespaces * @d: dirent to check * * Return: 1 if @d matches, 0 otherwise */ -int nvme_namespace_filter(const struct dirent *d); +int nvme_filter_namespace(const struct dirent *d); /** - * nvme_paths_filter() - Filter for paths + * nvme_filter_paths() - Filter for paths * @d: dirent to check * * Return: 1 if @d matches, 0 otherwise */ -int nvme_paths_filter(const struct dirent *d); +int nvme_filter_paths(const struct dirent *d); /** - * nvme_ctrls_filter() - Filter for controllers + * nvme_filter_ctrls() - Filter for controllers * @d: dirent to check * * Return: 1 if @d matches, 0 otherwise */ -int nvme_ctrls_filter(const struct dirent *d); +int nvme_filter_ctrls(const struct dirent *d); /** - * nvme_subsys_filter() - Filter for subsystems + * nvme_filter_subsys() - Filter for subsystems * @d: dirent to check * * Return: 1 if @d matches, 0 otherwise */ -int nvme_subsys_filter(const struct dirent *d); +int nvme_filter_subsys(const struct dirent *d); /** * nvme_scan_subsystems() - Scan for subsystems diff --git a/libnvme/src/nvme/ioctl.c b/libnvme/src/nvme/ioctl.c index 324bf7c569..9df1efa219 100644 --- a/libnvme/src/nvme/ioctl.c +++ b/libnvme/src/nvme/ioctl.c @@ -41,7 +41,7 @@ static int nvme_verify_chr(struct nvme_transport_handle *hdl) return 0; } -int nvme_subsystem_reset(struct nvme_transport_handle *hdl) +int nvme_reset_subsystem(struct nvme_transport_handle *hdl) { int ret; @@ -55,7 +55,7 @@ int nvme_subsystem_reset(struct nvme_transport_handle *hdl) return ret; } -int nvme_ctrl_reset(struct nvme_transport_handle *hdl) +int nvme_reset_ctrl(struct nvme_transport_handle *hdl) { int ret; @@ -69,7 +69,7 @@ int nvme_ctrl_reset(struct nvme_transport_handle *hdl) return ret; } -int nvme_ns_rescan(struct nvme_transport_handle *hdl) +int nvme_rescan_ns(struct nvme_transport_handle *hdl) { int ret; diff --git a/libnvme/src/nvme/ioctl.h b/libnvme/src/nvme/ioctl.h index 7c002d1852..c3aa3ca104 100644 --- a/libnvme/src/nvme/ioctl.h +++ b/libnvme/src/nvme/ioctl.h @@ -58,7 +58,7 @@ int nvme_submit_io_passthru(struct nvme_transport_handle *hdl, struct nvme_passthru_cmd *cmd); /** - * nvme_subsystem_reset() - Initiate a subsystem reset + * nvme_reset_subsystem() - Initiate a subsystem reset * @hdl: Transport handle * * This should only be sent to controller handles, not to namespaces. @@ -66,27 +66,27 @@ int nvme_submit_io_passthru(struct nvme_transport_handle *hdl, * Return: Zero if a subsystem reset was initiated or -1 with errno set * otherwise. */ -int nvme_subsystem_reset(struct nvme_transport_handle *hdl); +int nvme_reset_subsystem(struct nvme_transport_handle *hdl); /** - * nvme_ctrl_reset() - Initiate a controller reset + * nvme_reset_ctrl() - Initiate a controller reset * @hdl: Transport handle * * This should only be sent to controller handles, not to namespaces. * * Return: 0 if a reset was initiated or -1 with errno set otherwise. */ -int nvme_ctrl_reset(struct nvme_transport_handle *hdl); +int nvme_reset_ctrl(struct nvme_transport_handle *hdl); /** - * nvme_ns_rescan() - Initiate a controller rescan + * nvme_rescan_ns() - Initiate a controller rescan * @hdl: Transport handle * * This should only be sent to controller handles, not to namespaces. * * Return: 0 if a rescan was initiated or -1 with errno set otherwise. */ -int nvme_ns_rescan(struct nvme_transport_handle *hdl); +int nvme_rescan_ns(struct nvme_transport_handle *hdl); /** * nvme_get_nsid() - Retrieve the NSID from a namespace file descriptor diff --git a/libnvme/src/nvme/linux.c b/libnvme/src/nvme/linux.c index 80ce135ca1..2ca91cf0ab 100644 --- a/libnvme/src/nvme/linux.c +++ b/libnvme/src/nvme/linux.c @@ -1723,7 +1723,7 @@ static int uuid_from_dmi(char *system_uuid) return ret; } -char *nvme_hostid_generate() +char *nvme_generate_hostid() { int ret; char uuid_str[NVME_UUID_LEN_STRING]; @@ -1733,7 +1733,7 @@ char *nvme_hostid_generate() if (ret < 0) ret = uuid_from_device_tree(uuid_str); if (ret < 0) { - if (nvme_uuid_random(uuid) < 0) + if (nvme_random_uuid(uuid) < 0) memset(uuid, 0, NVME_UUID_LEN); nvme_uuid_to_string(uuid, uuid_str); } @@ -1741,14 +1741,14 @@ char *nvme_hostid_generate() return strdup(uuid_str); } -char *nvme_hostnqn_generate_from_hostid(char *hostid) +char *nvme_generate_hostnqn_from_hostid(char *hostid) { char *hid = NULL; char *hostnqn; int ret; if (!hostid) - hostid = hid = nvme_hostid_generate(); + hostid = hid = nvme_generate_hostid(); ret = asprintf(&hostnqn, "nqn.2014-08.org.nvmexpress:uuid:%s", hostid); free(hid); @@ -1756,9 +1756,9 @@ char *nvme_hostnqn_generate_from_hostid(char *hostid) return (ret < 0) ? NULL : hostnqn; } -char *nvme_hostnqn_generate() +char *nvme_generate_hostnqn() { - return nvme_hostnqn_generate_from_hostid(NULL); + return nvme_generate_hostnqn_from_hostid(NULL); } static char *nvmf_read_file(const char *f, int len) @@ -1779,7 +1779,7 @@ static char *nvmf_read_file(const char *f, int len) return strndup(buf, strcspn(buf, "\n")); } -char *nvme_hostnqn_from_file() +char *nvme_read_hostnqn() { char *hostnqn = getenv("LIBNVME_HOSTNQN"); @@ -1792,7 +1792,7 @@ char *nvme_hostnqn_from_file() return nvmf_read_file(NVMF_HOSTNQN_FILE, NVMF_NQN_SIZE); } -char *nvme_hostid_from_file() +char *nvme_read_hostid() { char *hostid = getenv("LIBNVME_HOSTID"); diff --git a/libnvme/src/nvme/linux.h b/libnvme/src/nvme/linux.h index 6b9da6ae17..7beccbee68 100644 --- a/libnvme/src/nvme/linux.h +++ b/libnvme/src/nvme/linux.h @@ -395,14 +395,14 @@ int nvme_import_tls_key_versioned(struct nvme_global_ctx *ctx, unsigned char *hmac, size_t *key_len, unsigned char **key); /** - * nvme_hostnqn_generate() - Generate a machine specific host nqn + * nvme_generate_hostnqn() - Generate a machine specific host nqn * Returns: An nvm namespace qualified name string based on the machine * identifier, or NULL if not successful. */ -char *nvme_hostnqn_generate(); +char *nvme_generate_hostnqn(); /** - * nvme_hostnqn_generate_from_hostid() - Generate a host nqn from + * nvme_generate_hostnqn_from_hostid() - Generate a host nqn from * host identifier * @hostid: Host identifier * @@ -412,18 +412,18 @@ char *nvme_hostnqn_generate(); * Return: On success, an NVMe Qualified Name for host identification. This * name is based on the given host identifier. On failure, NULL. */ -char *nvme_hostnqn_generate_from_hostid(char *hostid); +char *nvme_generate_hostnqn_from_hostid(char *hostid); /** - * nvme_hostid_generate() - Generate a machine specific host identifier + * nvme_generate_hostid() - Generate a machine specific host identifier * * Return: On success, an identifier string based on the machine identifier to * be used as NVMe Host Identifier, or NULL on failure. */ -char *nvme_hostid_generate(); +char *nvme_generate_hostid(); /** - * nvme_hostnqn_from_file() - Reads the host nvm qualified name from the config + * nvme_read_hostnqn() - Reads the host nvm qualified name from the config * default location * * Retrieve the qualified name from the config file located in $SYSCONFDIR/nvme. @@ -432,10 +432,10 @@ char *nvme_hostid_generate(); * Return: The host nqn, or NULL if unsuccessful. If found, the caller * is responsible to free the string. */ -char *nvme_hostnqn_from_file(); +char *nvme_read_hostnqn(); /** - * nvme_hostid_from_file() - Reads the host identifier from the config default + * nvme_read_hostid() - Reads the host identifier from the config default * location * * Retrieve the host idenditifer from the config file located in @@ -444,4 +444,4 @@ char *nvme_hostnqn_from_file(); * Return: The host identifier, or NULL if unsuccessful. If found, the caller * is responsible to free the string. */ -char *nvme_hostid_from_file(); +char *nvme_read_hostid(); diff --git a/libnvme/src/nvme/nbft.c b/libnvme/src/nvme/nbft.c index 9dd0fb676b..2baa4d4e52 100644 --- a/libnvme/src/nvme/nbft.c +++ b/libnvme/src/nvme/nbft.c @@ -711,7 +711,7 @@ static int parse_raw_nbft(struct nvme_global_ctx *ctx, struct nbft_info *nbft) return 0; } -void nvme_nbft_free(struct nvme_global_ctx *ctx, struct nbft_info *nbft) +void nvme_free_nbft(struct nvme_global_ctx *ctx, struct nbft_info *nbft) { struct nbft_info_hfi **hfi; struct nbft_info_security **sec; @@ -737,7 +737,7 @@ void nvme_nbft_free(struct nvme_global_ctx *ctx, struct nbft_info *nbft) free(nbft); } -int nvme_nbft_read(struct nvme_global_ctx *ctx, struct nbft_info **nbft, +int nvme_read_nbft(struct nvme_global_ctx *ctx, struct nbft_info **nbft, const char *filename) { __u8 *raw_nbft = NULL; @@ -801,7 +801,7 @@ int nvme_nbft_read(struct nvme_global_ctx *ctx, struct nbft_info **nbft, if (parse_raw_nbft(ctx, *nbft)) { nvme_msg(ctx, LOG_ERR, "Failed to parse %s\n", filename); - nvme_nbft_free(ctx, *nbft); + nvme_free_nbft(ctx, *nbft); return -EINVAL; } return 0; diff --git a/libnvme/src/nvme/nbft.h b/libnvme/src/nvme/nbft.h index 16d1606c7a..48d60ffb1b 100644 --- a/libnvme/src/nvme/nbft.h +++ b/libnvme/src/nvme/nbft.h @@ -1234,26 +1234,26 @@ struct nbft_info { }; /** - * nvme_nbft_read() - Read and parse contents of an ACPI NBFT table + * nvme_read_nbft() - Read and parse contents of an ACPI NBFT table * * @ctx: struct nvme_global_ctx object * @nbft: Parsed NBFT table data. * @filename: Filename of the raw NBFT table to read. * * Read and parse the specified NBFT file into a struct nbft_info. - * Free with nvme_nbft_free(). + * Free with nvme_free_nbft(). * * Return: 0 on success, errno otherwise. */ -int nvme_nbft_read(struct nvme_global_ctx *ctx, struct nbft_info **nbft, +int nvme_read_nbft(struct nvme_global_ctx *ctx, struct nbft_info **nbft, const char *filename); /** - * nvme_nbft_free() - Free the struct nbft_info and its contents + * nvme_free_nbft() - Free the struct nbft_info and its contents * @ctx: struct nvme_global_ctx object * @nbft: Parsed NBFT table data. */ -void nvme_nbft_free(struct nvme_global_ctx *ctx, struct nbft_info *nbft); +void nvme_free_nbft(struct nvme_global_ctx *ctx, struct nbft_info *nbft); /** * struct nbft_file_entry - Linked list entry for NBFT files diff --git a/libnvme/src/nvme/tree.c b/libnvme/src/nvme/tree.c index fc207aea5c..3967ce1913 100644 --- a/libnvme/src/nvme/tree.c +++ b/libnvme/src/nvme/tree.c @@ -144,9 +144,9 @@ int nvme_host_get_ids(struct nvme_global_ctx *ctx, /* /etc/nvme/hostid and/or /etc/nvme/hostnqn */ if (!hid) - hid = nvme_hostid_from_file(); + hid = nvme_read_hostid(); if (!hnqn) - hnqn = nvme_hostnqn_from_file(); + hnqn = nvme_read_hostnqn(); /* incomplete configuration, thus derive hostid from hostnqn */ if (!hid && hnqn) @@ -157,7 +157,7 @@ int nvme_host_get_ids(struct nvme_global_ctx *ctx, * fails generate one */ if (!hid) { - hid = nvme_hostid_generate(); + hid = nvme_generate_hostid(); if (!hid) return -ENOMEM; @@ -167,7 +167,7 @@ int nvme_host_get_ids(struct nvme_global_ctx *ctx, /* incomplete configuration, thus derive hostnqn from hostid */ if (!hnqn) { - hnqn = nvme_hostnqn_generate_from_hostid(hid); + hnqn = nvme_generate_hostnqn_from_hostid(hid); if (!hnqn) return -ENOMEM; } @@ -188,7 +188,7 @@ int nvme_host_get_ids(struct nvme_global_ctx *ctx, return 0; } -int nvme_host_get(struct nvme_global_ctx *ctx, const char *hostnqn, +int nvme_get_host(struct nvme_global_ctx *ctx, const char *hostnqn, const char *hostid, nvme_host_t *host) { _cleanup_free_ char *hnqn = NULL; @@ -592,7 +592,7 @@ struct nvme_subsystem *nvme_lookup_subsystem(struct nvme_host *h, return nvme_alloc_subsystem(h, name, subsysnqn); } -int nvme_subsystem_get(struct nvme_global_ctx *ctx, +int nvme_get_subsystem(struct nvme_global_ctx *ctx, struct nvme_host *h, const char *name, const char *subsysnqn, struct nvme_subsystem **subsys) { @@ -779,7 +779,7 @@ static int nvme_scan_subsystem(struct nvme_global_ctx *ctx, const char *name) */ nvme_msg(ctx, LOG_DEBUG, "creating detached subsystem '%s'\n", name); - ret = nvme_host_get(ctx, NULL, NULL, &h); + ret = nvme_get_host(ctx, NULL, NULL, &h); if (ret) return ret; s = nvme_alloc_subsystem(h, name, subsysnqn); @@ -1525,7 +1525,7 @@ nvme_ctrl_t __nvme_lookup_ctrl(nvme_subsystem_t s, const char *transport, return matching_c; } -bool nvme_ctrl_config_match(struct nvme_ctrl *c, const char *transport, +bool nvme_ctrl_match_config(struct nvme_ctrl *c, const char *transport, const char *traddr, const char *trsvcid, const char *subsysnqn, const char *host_traddr, const char *host_iface) @@ -1981,7 +1981,7 @@ int nvme_scan_ctrl(struct nvme_global_ctx *ctx, const char *name, hostnqn = nvme_get_attr(path, "hostnqn"); hostid = nvme_get_attr(path, "hostid"); - ret = nvme_host_get(ctx, hostnqn, hostid, &h); + ret = nvme_get_host(ctx, hostnqn, hostid, &h); if (ret) return ret; diff --git a/libnvme/src/nvme/tree.h b/libnvme/src/nvme/tree.h index 3ced214d1d..d553e97c97 100644 --- a/libnvme/src/nvme/tree.h +++ b/libnvme/src/nvme/tree.h @@ -114,7 +114,7 @@ void nvme_host_set_pdc_enabled(nvme_host_t h, bool enabled); bool nvme_host_is_pdc_enabled(nvme_host_t h, bool fallback); /** - * nvme_host_get() - Returns a host object + * nvme_get_host() - Returns a host object * @ctx: struct nvme_global_ctx object * @hostnqn: Host NQN (optional) * @hostid: Host ID (optional) @@ -125,7 +125,7 @@ bool nvme_host_is_pdc_enabled(nvme_host_t h, bool fallback); * * Return: 0 on success or negative error code otherwise */ -int nvme_host_get(struct nvme_global_ctx *ctx, const char *hostnqn, +int nvme_get_host(struct nvme_global_ctx *ctx, const char *hostnqn, const char *hostid, nvme_host_t *h); /** @@ -181,7 +181,7 @@ nvme_subsystem_t nvme_first_subsystem(nvme_host_t h); nvme_subsystem_t nvme_next_subsystem(nvme_host_t h, nvme_subsystem_t s); /** - * nvme_subsystem_get() - Returns nvme_subsystem_t object + * nvme_get_subsystem() - Returns nvme_subsystem_t object * @ctx: struct nvme_global_ctx object * @h: &nvme_host_t object * @name: Name of the subsystem (may be NULL) @@ -192,7 +192,7 @@ nvme_subsystem_t nvme_next_subsystem(nvme_host_t h, nvme_subsystem_t s); * and @subsysnqn or create one if not found. * */ -int nvme_subsystem_get(struct nvme_global_ctx *ctx, +int nvme_get_subsystem(struct nvme_global_ctx *ctx, struct nvme_host *h, const char *name, const char *subsysnqn, struct nvme_subsystem **s); @@ -281,7 +281,7 @@ nvme_path_t nvme_namespace_first_path(nvme_ns_t ns); nvme_path_t nvme_namespace_next_path(nvme_ns_t ns, nvme_path_t p); /** - * nvme_ctrl_config_match() - Check if ctrl @c matches config params + * nvme_ctrl_match_config() - Check if ctrl @c matches config params * @c: An existing controller instance * @transport: Transport name * @traddr: Transport address @@ -296,7 +296,7 @@ nvme_path_t nvme_namespace_next_path(nvme_ns_t ns, nvme_path_t p); * * Return: true if there's a match, false otherwise. */ -bool nvme_ctrl_config_match(struct nvme_ctrl *c, const char *transport, +bool nvme_ctrl_match_config(struct nvme_ctrl *c, const char *transport, const char *traddr, const char *trsvcid, const char *subsysnqn, const char *host_traddr, const char *host_iface); diff --git a/libnvme/src/nvme/util.c b/libnvme/src/nvme/util.c index d60667d337..113e782e07 100644 --- a/libnvme/src/nvme/util.c +++ b/libnvme/src/nvme/util.c @@ -749,7 +749,7 @@ int nvme_uuid_from_string(const char *str, unsigned char uuid[NVME_UUID_LEN]) } -int nvme_uuid_random(unsigned char uuid[NVME_UUID_LEN]) +int nvme_random_uuid(unsigned char uuid[NVME_UUID_LEN]) { _cleanup_fd_ int f = -1; ssize_t n; @@ -774,7 +774,7 @@ int nvme_uuid_random(unsigned char uuid[NVME_UUID_LEN]) return 0; } -int nvme_uuid_find(struct nvme_id_uuid_list *uuid_list, const unsigned char uuid[NVME_UUID_LEN]) +int nvme_find_uuid(struct nvme_id_uuid_list *uuid_list, const unsigned char uuid[NVME_UUID_LEN]) { const unsigned char uuid_end[NVME_UUID_LEN] = {0}; diff --git a/libnvme/src/nvme/util.h b/libnvme/src/nvme/util.h index 0a9e2625e2..021b1bd218 100644 --- a/libnvme/src/nvme/util.h +++ b/libnvme/src/nvme/util.h @@ -199,7 +199,7 @@ int nvme_uuid_to_string(unsigned char uuid[NVME_UUID_LEN], char *str); int nvme_uuid_from_string(const char *str, unsigned char uuid[NVME_UUID_LEN]); /** - * nvme_uuid_random - Generate random UUID + * nvme_random_uuid - Generate random UUID * @uuid: Generated random UUID * * Generate random number according @@ -207,16 +207,16 @@ int nvme_uuid_from_string(const char *str, unsigned char uuid[NVME_UUID_LEN]); * * Return: Returns error code if generating of random number fails. */ -int nvme_uuid_random(unsigned char uuid[NVME_UUID_LEN]); +int nvme_random_uuid(unsigned char uuid[NVME_UUID_LEN]); /** - * nvme_uuid_find - Find UUID position on UUID list + * nvme_find_uuid - Find UUID position on UUID list * @uuid_list: UUID list returned by identify UUID * @uuid: Binary encoded input UUID * * Return: The array position where given UUID is present, or -1 on failure with errno set. */ -int nvme_uuid_find(struct nvme_id_uuid_list *uuid_list, const unsigned char uuid[NVME_UUID_LEN]); +int nvme_find_uuid(struct nvme_id_uuid_list *uuid_list, const unsigned char uuid[NVME_UUID_LEN]); /** * nvme_basename - Return the final path component (the one after the last '/') diff --git a/libnvme/test/nbft/nbft-dump.c b/libnvme/test/nbft/nbft-dump.c index d170cf1ec9..2b14bf5869 100644 --- a/libnvme/test/nbft/nbft-dump.c +++ b/libnvme/test/nbft/nbft-dump.c @@ -118,7 +118,7 @@ int main(int argc, char **argv) return 1; } - if (nvme_nbft_read(ctx, &table, argv[1]) != 0) { + if (nvme_read_nbft(ctx, &table, argv[1]) != 0) { fprintf(stderr, "Error parsing the NBFT table %s: %m\n", argv[1]); nvme_free_global_ctx(ctx); @@ -127,7 +127,7 @@ int main(int argc, char **argv) print_nbft(table); - nvme_nbft_free(ctx, table); + nvme_free_nbft(ctx, table); nvme_free_global_ctx(ctx); return 0; } diff --git a/libnvme/test/tree.c b/libnvme/test/tree.c index db10f2af0f..eff77a85b8 100644 --- a/libnvme/test/tree.c +++ b/libnvme/test/tree.c @@ -131,14 +131,14 @@ static struct nvme_global_ctx *create_tree() ctx = nvme_create_global_ctx(stdout, LOG_DEBUG); assert(ctx); - nvme_host_get(ctx, DEFAULT_HOSTNQN, DEFAULT_HOSTID, &h); + nvme_get_host(ctx, DEFAULT_HOSTNQN, DEFAULT_HOSTID, &h); assert(h); printf(" ctrls created:\n"); for (int i = 0; i < ARRAY_SIZE(test_data); i++) { struct test_data *d = &test_data[i]; - assert(!nvme_subsystem_get(ctx, h, d->subsysname, + assert(!nvme_get_subsystem(ctx, h, d->subsysname, d->subsysnqn, &d->s)); assert(d->s); d->c = nvme_lookup_ctrl(d->s, d->transport, d->traddr, @@ -236,7 +236,7 @@ static bool ctrl_lookups(struct nvme_global_ctx *ctx) bool pass = true; h = nvme_first_host(ctx); - nvme_subsystem_get(ctx, h, DEFAULT_SUBSYSNAME, DEFAULT_SUBSYSNQN, &s); + nvme_get_subsystem(ctx, h, DEFAULT_SUBSYSNAME, DEFAULT_SUBSYSNQN, &s); printf(" lookup controller:\n"); for (int i = 0; i < ARRAY_SIZE(test_data); i++) { @@ -288,10 +288,10 @@ static bool test_src_addr() ctx = nvme_create_global_ctx(stdout, LOG_DEBUG); assert(ctx); - nvme_host_get(ctx, DEFAULT_HOSTNQN, DEFAULT_HOSTID, &h); + nvme_get_host(ctx, DEFAULT_HOSTNQN, DEFAULT_HOSTID, &h); assert(h); - nvme_subsystem_get(ctx, h, DEFAULT_SUBSYSNAME, DEFAULT_SUBSYSNQN, &s); + nvme_get_subsystem(ctx, h, DEFAULT_SUBSYSNAME, DEFAULT_SUBSYSNQN, &s); assert(s); c = nvme_lookup_ctrl(s, "tcp", "192.168.56.1", NULL, NULL, "8009", NULL); @@ -464,10 +464,10 @@ static bool ctrl_match(const char *tag, ctx = nvme_create_global_ctx(stdout, LOG_INFO); assert(ctx); - nvme_host_get(ctx, DEFAULT_HOSTNQN, DEFAULT_HOSTID, &h); + nvme_get_host(ctx, DEFAULT_HOSTNQN, DEFAULT_HOSTID, &h); assert(h); - assert(!nvme_subsystem_get(ctx, h, DEFAULT_SUBSYSNAME, + assert(!nvme_get_subsystem(ctx, h, DEFAULT_SUBSYSNAME, reference->subsysnqn ? reference->subsysnqn : DEFAULT_SUBSYSNQN, &s)); @@ -1080,10 +1080,10 @@ static bool ctrl_config_match(const char *tag, ctx = nvme_create_global_ctx(stdout, LOG_INFO); assert(ctx); - nvme_host_get(ctx, DEFAULT_HOSTNQN, DEFAULT_HOSTID, &h); + nvme_get_host(ctx, DEFAULT_HOSTNQN, DEFAULT_HOSTID, &h); assert(h); - assert(!nvme_subsystem_get(ctx, h, DEFAULT_SUBSYSNAME, + assert(!nvme_get_subsystem(ctx, h, DEFAULT_SUBSYSNAME, reference->subsysnqn ? reference->subsysnqn : DEFAULT_SUBSYSNQN, &s)); @@ -1098,7 +1098,7 @@ static bool ctrl_config_match(const char *tag, reference_ctrl->address = (char *)reference->address; } - match = nvme_ctrl_config_match(reference_ctrl, candidate->transport, candidate->traddr, + match = nvme_ctrl_match_config(reference_ctrl, candidate->transport, candidate->traddr, candidate->trsvcid, candidate->subsysnqn, candidate->host_traddr, candidate->host_iface); diff --git a/libnvme/test/uuid.c b/libnvme/test/uuid.c index 9a2bbc659c..3b557969c4 100644 --- a/libnvme/test/uuid.c +++ b/libnvme/test/uuid.c @@ -85,9 +85,9 @@ static void random_uuid_test(void) unsigned char uuid1[NVME_UUID_LEN], uuid2[NVME_UUID_LEN]; char str1[NVME_UUID_LEN_STRING], str2[NVME_UUID_LEN_STRING]; - if (nvme_uuid_random(uuid1) || nvme_uuid_random(uuid2)) { + if (nvme_random_uuid(uuid1) || nvme_random_uuid(uuid2)) { test_rc = 1; - printf("ERROR: nvme_uuid_random() failed\n"); + printf("ERROR: nvme_random_uuid() failed\n"); return; } diff --git a/nvme.c b/nvme.c index 7539e937a7..05364d5387 100644 --- a/nvme.c +++ b/nvme.c @@ -5466,7 +5466,7 @@ static int subsystem_reset(int argc, char **argv, struct command *acmd, struct p return -EINVAL; } - err = nvme_subsystem_reset(hdl); + err = nvme_reset_subsystem(hdl); if (err < 0) { if (errno == ENOTTY) nvme_show_error("Subsystem-reset: NVM Subsystem Reset not supported."); @@ -5497,7 +5497,7 @@ static int reset(int argc, char **argv, struct command *acmd, struct plugin *plu return -EINVAL; } - err = nvme_ctrl_reset(hdl); + err = nvme_reset_ctrl(hdl); if (err < 0) nvme_show_error("Reset: %s", nvme_strerror(-err)); else if (argconfig_parse_seen(opts, "verbose")) @@ -5532,7 +5532,7 @@ static int ns_rescan(int argc, char **argv, struct command *acmd, struct plugin return err; } - err = nvme_ns_rescan(hdl); + err = nvme_rescan_ns(hdl); if (err < 0) nvme_show_error("Namespace Rescan: %s\n", nvme_strerror(-err)); else if (argconfig_parse_seen(opts, "verbose")) @@ -6823,7 +6823,7 @@ static int format_cmd(int argc, char **argv, struct command *acmd, struct plugin printf("Success formatting namespace:%x\n", cfg.namespace_id); if (nvme_transport_handle_is_direct(hdl) && cfg.lbaf != prev_lbaf) { if (nvme_transport_handle_is_chardev(hdl)) { - if (nvme_ns_rescan(hdl) < 0) { + if (nvme_rescan_ns(hdl) < 0) { nvme_show_error("failed to rescan namespaces"); return -errno; } @@ -6855,7 +6855,7 @@ static int format_cmd(int argc, char **argv, struct command *acmd, struct plugin } if (nvme_transport_handle_is_direct(hdl) && cfg.reset && nvme_transport_handle_is_chardev(hdl)) - nvme_ctrl_reset(hdl); + nvme_reset_ctrl(hdl); return err; } @@ -9522,7 +9522,7 @@ static int gen_hostnqn_cmd(int argc, char **argv, struct command *acmd, struct p { char *hostnqn; - hostnqn = nvme_hostnqn_generate(); + hostnqn = nvme_generate_hostnqn(); if (!hostnqn) { nvme_show_error("\"%s\" not supported. Install lib uuid and rebuild.", acmd->name); @@ -9537,9 +9537,9 @@ static int show_hostnqn_cmd(int argc, char **argv, struct command *acmd, struct { char *hostnqn; - hostnqn = nvme_hostnqn_from_file(); + hostnqn = nvme_read_hostnqn(); if (!hostnqn) - hostnqn = nvme_hostnqn_generate(); + hostnqn = nvme_generate_hostnqn(); if (!hostnqn) { nvme_show_error("hostnqn is not available -- use nvme gen-hostnqn"); @@ -9667,7 +9667,7 @@ static int gen_dhchap_key(int argc, char **argv, struct command *acmd, struct pl } if (!cfg.nqn) { - cfg.nqn = hnqn = nvme_hostnqn_from_file(); + cfg.nqn = hnqn = nvme_read_hostnqn(); if (!cfg.nqn) { nvme_show_error("Could not read host NQN"); return -ENOENT; @@ -9931,7 +9931,7 @@ static int gen_tls_key(int argc, char **argv, struct command *acmd, struct plugi return -EINVAL; } if (!cfg.hostnqn) { - cfg.hostnqn = hnqn = nvme_hostnqn_from_file(); + cfg.hostnqn = hnqn = nvme_read_hostnqn(); if (!cfg.hostnqn) { nvme_show_error("Failed to read host NQN"); return -EINVAL; @@ -10093,7 +10093,7 @@ static int check_tls_key(int argc, char **argv, struct command *acmd, struct plu if (cfg.subsysnqn) { if (!cfg.hostnqn) { - cfg.hostnqn = hnqn = nvme_hostnqn_from_file(); + cfg.hostnqn = hnqn = nvme_read_hostnqn(); if (!cfg.hostnqn) { nvme_show_error("Failed to read host NQN"); return -EINVAL; diff --git a/plugins/huawei/huawei-nvme.c b/plugins/huawei/huawei-nvme.c index 65f3fc73c6..a814a9d3fe 100644 --- a/plugins/huawei/huawei-nvme.c +++ b/plugins/huawei/huawei-nvme.c @@ -318,7 +318,7 @@ static int huawei_list(int argc, char **argv, struct command *acmd, if (ret < 0 || (fmt != JSON && fmt != NORMAL)) return ret; - n = scandir("/dev", &devices, nvme_namespace_filter, alphasort); + n = scandir("/dev", &devices, nvme_filter_namespace, alphasort); if (n <= 0) return n; diff --git a/plugins/ocp/ocp-utils.c b/plugins/ocp/ocp-utils.c index 08401bb73e..7238067cf1 100644 --- a/plugins/ocp/ocp-utils.c +++ b/plugins/ocp/ocp-utils.c @@ -21,7 +21,7 @@ const unsigned char ocp_uuid[NVME_UUID_LEN] = { int ocp_find_uuid_index(struct nvme_id_uuid_list *uuid_list, __u8 *index) { - int i = nvme_uuid_find(uuid_list, ocp_uuid); + int i = nvme_find_uuid(uuid_list, ocp_uuid); *index = 0; if (i > 0) diff --git a/plugins/sandisk/sandisk-utils.c b/plugins/sandisk/sandisk-utils.c index 04f00fc0ab..be415dfe79 100644 --- a/plugins/sandisk/sandisk-utils.c +++ b/plugins/sandisk/sandisk-utils.c @@ -335,16 +335,16 @@ bool sndk_get_dev_mgment_data(struct nvme_global_ctx *ctx, struct nvme_transport memset(&uuid_list, 0, sizeof(struct nvme_id_uuid_list)); if (!nvme_get_uuid_list(hdl, &uuid_list)) { /* check for the Sandisk UUID first */ - uuid_index = nvme_uuid_find(&uuid_list, SNDK_UUID); + uuid_index = nvme_find_uuid(&uuid_list, SNDK_UUID); if (uuid_index < 0) { /* The Sandisk UUID is not found; * check for the WDC UUID second. */ - uuid_index = nvme_uuid_find(&uuid_list, WDC_UUID); + uuid_index = nvme_find_uuid(&uuid_list, WDC_UUID); if (uuid_index < 0) /* Check for the UUID used on SN640 and SN655 drives */ - uuid_index = nvme_uuid_find(&uuid_list, WDC_UUID_SN640_3); + uuid_index = nvme_find_uuid(&uuid_list, WDC_UUID_SN640_3); } if (uuid_index >= 0) @@ -682,16 +682,16 @@ __u64 sndk_get_enc_drive_capabilities(struct nvme_global_ctx *ctx, memset(&uuid_list, 0, sizeof(struct nvme_id_uuid_list)); if (!nvme_get_uuid_list(hdl, &uuid_list)) { /* check for the Sandisk UUID first */ - uuid_index = nvme_uuid_find(&uuid_list, SNDK_UUID); + uuid_index = nvme_find_uuid(&uuid_list, SNDK_UUID); if (uuid_index < 0) { /* The Sandisk UUID is not found; * check for the WDC UUID second. */ - uuid_index = nvme_uuid_find(&uuid_list, WDC_UUID); + uuid_index = nvme_find_uuid(&uuid_list, WDC_UUID); if (uuid_index < 0) /* Check for the UUID used on SN640 and SN655 drives */ - uuid_index = nvme_uuid_find(&uuid_list, WDC_UUID_SN640_3); + uuid_index = nvme_find_uuid(&uuid_list, WDC_UUID_SN640_3); } } else { /* UUID Lists not supported, Use default uuid index - 0 */ diff --git a/plugins/scaleflux/sfx-nvme.c b/plugins/scaleflux/sfx-nvme.c index e4b35150c4..ceb8bf451f 100644 --- a/plugins/scaleflux/sfx-nvme.c +++ b/plugins/scaleflux/sfx-nvme.c @@ -1422,7 +1422,7 @@ static int nvme_expand_cap(struct nvme_transport_handle *hdl, __u32 namespace_id else strcpy(dev_name, nvme_transport_handle_get_name(hdl)); - num = scandir("/dev", &devices, nvme_namespace_filter, alphasort); + num = scandir("/dev", &devices, nvme_filter_namespace, alphasort); if (num <= 0) { err = num; goto ret; diff --git a/plugins/solidigm/solidigm-util.c b/plugins/solidigm/solidigm-util.c index 11b3ba1647..c54d576705 100644 --- a/plugins/solidigm/solidigm-util.c +++ b/plugins/solidigm/solidigm-util.c @@ -15,7 +15,7 @@ const unsigned char solidigm_uuid[NVME_UUID_LEN] = { int sldgm_find_uuid_index(struct nvme_id_uuid_list *uuid_list, __u8 *index) { - int i = nvme_uuid_find(uuid_list, solidigm_uuid); + int i = nvme_find_uuid(uuid_list, solidigm_uuid); *index = 0; if (i > 0) diff --git a/plugins/wdc/wdc-nvme.c b/plugins/wdc/wdc-nvme.c index 0662e16e4b..a39080865a 100644 --- a/plugins/wdc/wdc-nvme.c +++ b/plugins/wdc/wdc-nvme.c @@ -2121,13 +2121,13 @@ static __u64 wdc_get_enc_drive_capabilities(struct nvme_global_ctx *ctx, memset(&uuid_list, 0, sizeof(struct nvme_id_uuid_list)); if (wdc_CheckUuidListSupport(hdl, &uuid_list)) { /* check for the Sandisk UUID first */ - uuid_index = nvme_uuid_find(&uuid_list, SNDK_UUID); + uuid_index = nvme_find_uuid(&uuid_list, SNDK_UUID); if (uuid_index < 0) /* The Sandisk UUID is not found; * check for the WDC UUID second. */ - uuid_index = nvme_uuid_find(&uuid_list, WDC_UUID); + uuid_index = nvme_find_uuid(&uuid_list, WDC_UUID); } /* WD UUID not found, use default uuid index - 0 */ @@ -2734,15 +2734,15 @@ static bool get_dev_mgment_data(struct nvme_global_ctx *ctx, struct nvme_transpo memset(&uuid_list, 0, sizeof(struct nvme_id_uuid_list)); if (wdc_CheckUuidListSupport(hdl, &uuid_list)) { /* check for the Sandisk UUID first */ - uuid_index = nvme_uuid_find(&uuid_list, SNDK_UUID); + uuid_index = nvme_find_uuid(&uuid_list, SNDK_UUID); if (uuid_index < 0) { /* The Sandisk UUID is not found; * check for the WDC UUID second. */ - uuid_index = nvme_uuid_find(&uuid_list, WDC_UUID); + uuid_index = nvme_find_uuid(&uuid_list, WDC_UUID); if (uuid_index < 0) - uuid_index = nvme_uuid_find(&uuid_list, WDC_UUID_SN640_3); + uuid_index = nvme_find_uuid(&uuid_list, WDC_UUID_SN640_3); } if (uuid_index >= 0) @@ -2803,15 +2803,15 @@ static bool get_dev_mgment_cbs_data(struct nvme_global_ctx *ctx, struct nvme_tra memset(&uuid_list, 0, sizeof(struct nvme_id_uuid_list)); if (wdc_CheckUuidListSupport(hdl, &uuid_list)) { /* check for the Sandisk UUID first */ - uuid_index = nvme_uuid_find(&uuid_list, SNDK_UUID); + uuid_index = nvme_find_uuid(&uuid_list, SNDK_UUID); if (uuid_index < 0) { /* The Sandisk UUID is not found; * check for the WDC UUID second. */ - uuid_index = nvme_uuid_find(&uuid_list, WDC_UUID); + uuid_index = nvme_find_uuid(&uuid_list, WDC_UUID); if (uuid_index < 0) - uuid_index = nvme_uuid_find(&uuid_list, WDC_UUID_SN640_3); + uuid_index = nvme_find_uuid(&uuid_list, WDC_UUID_SN640_3); } if (uuid_index >= 0) @@ -9096,13 +9096,13 @@ static int wdc_drive_status(int argc, char **argv, struct command *acmd, memset(&uuid_list, 0, sizeof(struct nvme_id_uuid_list)); if (wdc_CheckUuidListSupport(hdl, &uuid_list)) { /* check for the Sandisk UUID first */ - uuid_index = nvme_uuid_find(&uuid_list, SNDK_UUID); + uuid_index = nvme_find_uuid(&uuid_list, SNDK_UUID); if (uuid_index < 0) /* The Sandisk UUID is not found; * check for the WDC UUID second. */ - uuid_index = nvme_uuid_find(&uuid_list, WDC_UUID); + uuid_index = nvme_find_uuid(&uuid_list, WDC_UUID); } /* WD UUID not found, use default uuid index - 0 */ @@ -10871,13 +10871,13 @@ static int wdc_log_page_directory(int argc, char **argv, struct command *acmd, if (!wdc_is_sn861(device_id)) { if (uuid_supported) { /* check for the Sandisk UUID first */ - uuid_index = nvme_uuid_find(&uuid_list, SNDK_UUID); + uuid_index = nvme_find_uuid(&uuid_list, SNDK_UUID); if (uuid_index < 0) /* The Sandisk UUID is not found; * check for the WDC UUID second. */ - uuid_index = nvme_uuid_find(&uuid_list, WDC_UUID); + uuid_index = nvme_find_uuid(&uuid_list, WDC_UUID); } /* WD UUID not found, use default uuid index - 0 */