summaryrefslogtreecommitdiffstats
path: root/plugins/ymtc
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2022-11-05 18:23:26 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2022-11-05 18:23:26 +0000
commitfab3f41b7b3f080c215157a026ee6bc7efbfe968 (patch)
treef0fafb0805c3eb11eb2a278f9f8058376c8f0f2b /plugins/ymtc
parentAdding upstream version 2.1.2. (diff)
downloadnvme-cli-fab3f41b7b3f080c215157a026ee6bc7efbfe968.tar.xz
nvme-cli-fab3f41b7b3f080c215157a026ee6bc7efbfe968.zip
Adding upstream version 2.2.1.upstream/2.2.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r--plugins/ymtc/ymtc-nvme.c24
1 files changed, 13 insertions, 11 deletions
diff --git a/plugins/ymtc/ymtc-nvme.c b/plugins/ymtc/ymtc-nvme.c
index cfbf6a6..d04481c 100644
--- a/plugins/ymtc/ymtc-nvme.c
+++ b/plugins/ymtc/ymtc-nvme.c
@@ -21,8 +21,8 @@ static void get_ymtc_smart_info(struct nvme_ymtc_smart_log *smart, int index, u8
memcpy(raw_val, smart->itemArr[index].rawVal, RAW_SIZE);
}
-static int show_ymtc_smart_log(int fd, __u32 nsid, const char *devname,
- struct nvme_ymtc_smart_log *smart)
+static int show_ymtc_smart_log(struct nvme_dev *dev, __u32 nsid,
+ struct nvme_ymtc_smart_log *smart)
{
struct nvme_id_ctrl ctrl;
char fw_ver[10];
@@ -40,7 +40,7 @@ static int show_ymtc_smart_log(int fd, __u32 nsid, const char *devname,
free(nm);
return -1;
}
- err = nvme_identify_ctrl(fd, &ctrl);
+ err = nvme_identify_ctrl(dev_fd(dev), &ctrl);
if (err) {
free(nm);
free(raw);
@@ -52,7 +52,8 @@ static int show_ymtc_smart_log(int fd, __u32 nsid, const char *devname,
ctrl.fr[4], ctrl.fr[5], ctrl.fr[6]);
/* Table Title */
- printf("Additional Smart Log for NVME device:%s namespace-id:%x\n", devname, nsid);
+ printf("Additional Smart Log for NVME device:%s namespace-id:%x\n",
+ dev->name, nsid);
/* Clumn Name*/
printf("key normalized raw\n");
/* 00 SI_VD_PROGRAM_FAIL */
@@ -119,15 +120,16 @@ static int show_ymtc_smart_log(int fd, __u32 nsid, const char *devname,
static int get_additional_smart_log(int argc, char **argv, struct command *cmd, struct plugin *plugin)
{
struct nvme_ymtc_smart_log smart_log;
- int err, fd;
char *desc = "Get Ymtc vendor specific additional smart log (optionally, "\
"for the specified namespace), and show it.";
const char *namespace = "(optional) desired namespace";
const char *raw = "dump output in binary format";
+ struct nvme_dev *dev;
struct config {
__u32 namespace_id;
bool raw_binary;
};
+ int err;
struct config cfg = {
.namespace_id = NVME_NSID_ALL,
@@ -139,21 +141,21 @@ static int get_additional_smart_log(int argc, char **argv, struct command *cmd,
OPT_END()
};
- fd = parse_and_open(argc, argv, desc, opts);
- if (fd < 0)
- return fd;
+ err = parse_and_open(&dev, argc, argv, desc, opts);
+ if (err)
+ return err;
- err = nvme_get_nsid_log(fd, false, 0xca, cfg.namespace_id,
+ err = nvme_get_nsid_log(dev_fd(dev), false, 0xca, cfg.namespace_id,
sizeof(smart_log), &smart_log);
if (!err) {
if (!cfg.raw_binary)
- err = show_ymtc_smart_log(fd, cfg.namespace_id, devicename, &smart_log);
+ err = show_ymtc_smart_log(dev, cfg.namespace_id, &smart_log);
else
d_raw((unsigned char *)&smart_log, sizeof(smart_log));
}
if (err > 0)
nvme_show_status(err);
- close(fd);
+ dev_close(dev);
return err;
}