Skip to content

Commit 6ff20a2

Browse files
jeff-lien-sndkigaw
authored andcommitted
linux: Add nvme_get_uuid_list function
The nvme_get_uuid_list function will check for uuid list support and return the list if supported. Signed-off-by: Jeff Lien <[email protected]> Reviewed-by: Brandon Paupore <[email protected]>
1 parent 7f2243c commit 6ff20a2

3 files changed

Lines changed: 30 additions & 0 deletions

File tree

src/libnvme.map

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# SPDX-License-Identifier: LGPL-2.1-or-later
22
LIBNVME_UNRELEASED {
33
global:
4+
nvme_get_uuid_list;
45
nvme_set_etdas;
56
nvme_clear_etdas;
67
nvme_insert_tls_key_compat;

src/nvme/linux.c

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,24 @@ int nvme_clear_etdas(int fd, bool *changed)
168168
return 0;
169169
}
170170

171+
int nvme_get_uuid_list(int fd, struct nvme_id_uuid_list *uuid_list)
172+
{
173+
int err;
174+
struct nvme_id_ctrl ctrl;
175+
176+
memset(&ctrl, 0, sizeof(struct nvme_id_ctrl));
177+
err = nvme_identify_ctrl(fd, &ctrl);
178+
if (err) {
179+
fprintf(stderr, "ERROR: nvme_identify_ctrl() failed 0x%x\n", err);
180+
return err;
181+
}
182+
183+
if ((ctrl.ctratt & NVME_CTRL_CTRATT_UUID_LIST) == NVME_CTRL_CTRATT_UUID_LIST)
184+
err = nvme_identify_uuid(fd, uuid_list);
185+
186+
return err;
187+
}
188+
171189
int nvme_get_telemetry_max(int fd, enum nvme_telemetry_da *da, size_t *data_tx)
172190
{
173191
_cleanup_free_ struct nvme_id_ctrl *id_ctrl = NULL;

src/nvme/linux.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,17 @@ int nvme_set_etdas(int fd, bool *changed);
5656
*/
5757
int nvme_clear_etdas(int fd, bool *changed);
5858

59+
/**
60+
* nvme_get_uuid_list - Returns the uuid list (if supported)
61+
* @fd: File descriptor of nvme device
62+
* @uuid_list: UUID list returned by identify UUID
63+
*
64+
* Return: The nvme command status if a response was received (see
65+
* &enum nvme_status_field) or -1 with errno set otherwise.
66+
*/
67+
int nvme_get_uuid_list(int fd,
68+
struct nvme_id_uuid_list *uuid_list);
69+
5970
/**
6071
* nvme_get_telemetry_max() - Get telemetry limits
6172
* @fd: File descriptor of nvme device

0 commit comments

Comments
 (0)