diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2023-01-31 04:13:03 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2023-01-31 04:13:03 +0000 |
commit | d2082ee94267e4ca59b187c5e37dac03c1d65187 (patch) | |
tree | cd93a882e0726a7df500fedf2263263984406b36 /plugins/ocp/ocp-utils.c | |
parent | Releasing debian version 2.2.1-4. (diff) | |
download | nvme-cli-d2082ee94267e4ca59b187c5e37dac03c1d65187.tar.xz nvme-cli-d2082ee94267e4ca59b187c5e37dac03c1d65187.zip |
Merging upstream version 2.3.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'plugins/ocp/ocp-utils.c')
-rw-r--r-- | plugins/ocp/ocp-utils.c | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/plugins/ocp/ocp-utils.c b/plugins/ocp/ocp-utils.c new file mode 100644 index 0000000..9294c05 --- /dev/null +++ b/plugins/ocp/ocp-utils.c @@ -0,0 +1,30 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* + * Copyright (c) 2022 Solidigm. + * + * Author: leonardo.da.cunha@solidigm.com + */ + +#include "ocp-utils.h" + +const unsigned char ocp_uuid[NVME_UUID_LEN] = { + 0x6f, 0xbe, 0x56, 0x8f, 0x99, 0x29, 0x1d, 0xa2, 0x94, 0x47, + 0x94, 0xe0, 0x5b, 0xd5, 0x94, 0xc1 }; + +int ocp_get_uuid_index(struct nvme_dev *dev, int *index) +{ + struct nvme_id_uuid_list uuid_list; + int err = nvme_identify_uuid(dev_fd(dev), &uuid_list); + + *index = 0; + if (err) + return err; + + for (int i = 0; i < NVME_ID_UUID_LIST_MAX; i++) { + if (memcmp(ocp_uuid, &uuid_list.entry[i].uuid, NVME_UUID_LEN) == 0) { + *index = i + 1; + break; + } + } + return err; +} |