diff --git a/src/libnvme.map b/src/libnvme.map index af722218a..e708e5821 100644 --- a/src/libnvme.map +++ b/src/libnvme.map @@ -1,6 +1,7 @@ # SPDX-License-Identifier: LGPL-2.1-or-later LIBNVME_UNRELEASED { global: + nvme_get_uuid_list; nvme_set_etdas; nvme_clear_etdas; nvme_insert_tls_key_compat; diff --git a/src/nvme/linux.c b/src/nvme/linux.c index a6a1f4d2d..f2243db88 100644 --- a/src/nvme/linux.c +++ b/src/nvme/linux.c @@ -168,6 +168,24 @@ int nvme_clear_etdas(int fd, bool *changed) return 0; } +int nvme_get_uuid_list(int fd, struct nvme_id_uuid_list *uuid_list) +{ + int err; + struct nvme_id_ctrl ctrl; + + memset(&ctrl, 0, sizeof(struct nvme_id_ctrl)); + err = nvme_identify_ctrl(fd, &ctrl); + if (err) { + fprintf(stderr, "ERROR: nvme_identify_ctrl() failed 0x%x\n", err); + return err; + } + + if ((ctrl.ctratt & NVME_CTRL_CTRATT_UUID_LIST) == NVME_CTRL_CTRATT_UUID_LIST) + err = nvme_identify_uuid(fd, uuid_list); + + return err; +} + int nvme_get_telemetry_max(int fd, enum nvme_telemetry_da *da, size_t *data_tx) { _cleanup_free_ struct nvme_id_ctrl *id_ctrl = NULL; diff --git a/src/nvme/linux.h b/src/nvme/linux.h index 3b438720d..38bea3cec 100644 --- a/src/nvme/linux.h +++ b/src/nvme/linux.h @@ -56,6 +56,17 @@ int nvme_set_etdas(int fd, bool *changed); */ int nvme_clear_etdas(int fd, bool *changed); +/** + * nvme_get_uuid_list - Returns the uuid list (if supported) + * @fd: File descriptor of nvme device + * @uuid_list: UUID list returned by identify UUID + * + * Return: The nvme command status if a response was received (see + * &enum nvme_status_field) or -1 with errno set otherwise. + */ +int nvme_get_uuid_list(int fd, + struct nvme_id_uuid_list *uuid_list); + /** * nvme_get_telemetry_max() - Get telemetry limits * @fd: File descriptor of nvme device