diff options
Diffstat (limited to 'src/nvme/tree.h')
-rw-r--r-- | src/nvme/tree.h | 47 |
1 files changed, 45 insertions, 2 deletions
diff --git a/src/nvme/tree.h b/src/nvme/tree.h index 5e82579..1b583cd 100644 --- a/src/nvme/tree.h +++ b/src/nvme/tree.h @@ -63,6 +63,14 @@ void nvme_root_set_application(nvme_root_t r, const char *a); const char *nvme_root_get_application(nvme_root_t r); /** + * nvme_root_skip_namespaces - Skip namespace scanning + * @r: &nvme_root_t object + * + * Sets a flag to skip namespaces during scanning. + */ +void nvme_root_skip_namespaces(nvme_root_t r); + +/** * nvme_root_release_fds - Close all opened file descriptors in the tree * @r: &nvme_root_t object * @@ -161,14 +169,49 @@ bool nvme_host_is_pdc_enabled(nvme_host_t h, bool fallback); * nvme_default_host() - Initializes the default host * @r: &nvme_root_t object * - * Initializes the default host object based on the values in - * /etc/nvme/hostnqn and /etc/nvme/hostid and attaches it to @r. + * Initializes the default host object based on the hostnqn/hostid + * values returned by nvme_host_get_ids() and attaches it to @r. * * Return: &nvme_host_t object */ nvme_host_t nvme_default_host(nvme_root_t r); /** + * nvme_host_get_ids - Retrieve host ids from various sources + * + * @r: &nvme_root_t object + * @hostnqn_arg: Input hostnqn (command line) argument + * @hostid_arg: Input hostid (command line) argument + * @hostnqn: Output hostnqn + * @hostid: Output hostid + * + * nvme_host_get_ids figures out which hostnqn/hostid is to be used. + * There are several sources where this information can be retrieved. + * + * The order is: + * + * - Start with informartion from DMI or device-tree + * - Override hostnqn and hostid from /etc/nvme files + * - Override hostnqn or hostid with values from JSON + * configuration file. The first host entry in the file is + * considered the default host. + * - Override hostnqn or hostid with values from the command line + * (@hostnqn_arg, @hostid_arg). + * + * If the IDs are still NULL after the lookup algorithm, the function + * will generate random IDs. + * + * The function also verifies that hostnqn and hostid matches. The Linux + * NVMe implementation expects a 1:1 matching between the IDs. + * + * Return: 0 on success (@hostnqn and @hostid contain valid strings + * which the caller needs to free), -1 otherwise and errno is set. + */ +int nvme_host_get_ids(nvme_root_t r, + char *hostnqn_arg, char *hostid_arg, + char **hostnqn, char **hostid); + +/** * nvme_first_subsystem() - Start subsystem iterator * @h: &nvme_host_t object * |