From: Jeremy Kerr Date: Tue, 12 Jul 2022 02:59:20 +0000 (+0800) Subject: tree: Move global device info to a single struct X-Git-Tag: v2.2~64 X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=bd9af05822391753de43f0bf7ce4a45e07367aec;p=users%2Fsagi%2Fnvme-cli.git tree: Move global device info to a single struct Currently, we have a couple of globals that refer to the current NVMe device: the device name, and the stat buffer: static struct stat nvme_stat; const char *devicename; This change moves those two globals into a single global struct: struct nvme_dev { struct stat stat; const char *name; }; extern struct nvme_dev *nvme_dev; This will make it easier to constrain the scope of these globals in a later change. Signed-off-by: Jeremy Kerr --- diff --git a/nvme.c b/nvme.c index 12d02820..025eb6fd 100644 --- a/nvme.c +++ b/nvme.c @@ -79,8 +79,8 @@ struct feat_cfg { bool human_readable; }; -static struct stat nvme_stat; -const char *devicename; +struct nvme_dev _nvme_dev; +struct nvme_dev *nvme_dev = &_nvme_dev; static const char nvme_version_string[] = NVME_VERSION; @@ -210,25 +210,25 @@ static ssize_t getrandom_bytes(void *buf, size_t buflen) static bool is_chardev(void) { - return S_ISCHR(nvme_stat.st_mode); + return S_ISCHR(nvme_dev->stat.st_mode); } static bool is_blkdev(void) { - return S_ISBLK(nvme_stat.st_mode); + return S_ISBLK(nvme_dev->stat.st_mode); } static int open_dev(char *dev, int flags) { int err, fd; - devicename = basename(dev); + nvme_dev->name = basename(dev); err = open(dev, flags); if (err < 0) goto perror; fd = err; - err = fstat(fd, &nvme_stat); + err = fstat(fd, &nvme_dev->stat); if (err < 0) { close(fd); goto perror; @@ -353,8 +353,8 @@ static int get_smart_log(int argc, char **argv, struct command *cmd, struct plug err = nvme_get_log_smart(fd, cfg.namespace_id, false, &smart_log); if (!err) - nvme_show_smart_log(&smart_log, cfg.namespace_id, devicename, - flags); + nvme_show_smart_log(&smart_log, cfg.namespace_id, + nvme_dev->name, flags); else if (err > 0) nvme_show_status(err); else @@ -425,7 +425,7 @@ static int get_ana_log(int argc, char **argv, struct command *cmd, err = nvme_get_log_ana(fd, lsp, true, 0, ana_log_len, ana_log); if (!err) { - nvme_show_ana_log(ana_log, devicename, flags, ana_log_len); + nvme_show_ana_log(ana_log, nvme_dev->name, flags, ana_log_len); } else if (err > 0) nvme_show_status(err); else @@ -576,7 +576,8 @@ static int get_endurance_log(int argc, char **argv, struct command *cmd, struct err = nvme_get_log_endurance_group(fd, cfg.group_id, &endurance_log); if (!err) - nvme_show_endurance_log(&endurance_log, cfg.group_id, devicename, flags); + nvme_show_endurance_log(&endurance_log, cfg.group_id, + nvme_dev->name, flags); else if (err > 0) nvme_show_status(err); else @@ -664,7 +665,7 @@ static int get_effects_log(int argc, char **argv, struct command *cmd, struct pl int nvme_command_set_supported; int other_command_sets_supported; nvme_root = nvme_scan(NULL); - bar = mmap_registers(nvme_root, devicename); + bar = mmap_registers(nvme_root, nvme_dev->name); nvme_free_tree(nvme_root); if (!bar) { @@ -742,7 +743,7 @@ static int get_supported_log_pages(int argc, char **argv, struct command *cmd, err = nvme_get_log_supported_log_pages(fd, false, &supports); if (!err) - nvme_show_supported_log(&supports, devicename, flags); + nvme_show_supported_log(&supports, nvme_dev->name, flags); else if (err > 0) nvme_show_status(err); else @@ -821,7 +822,8 @@ static int get_error_log(int argc, char **argv, struct command *cmd, struct plug err = nvme_get_log_error(fd, cfg.log_entries, false, err_log); if (!err) - nvme_show_error_log(err_log, cfg.log_entries, devicename, flags); + nvme_show_error_log(err_log, cfg.log_entries, + nvme_dev->name, flags); else if (err > 0) nvme_show_status(err); else @@ -870,7 +872,7 @@ static int get_fw_log(int argc, char **argv, struct command *cmd, struct plugin err = nvme_get_log_fw_slot(fd, false, &fw_log); if (!err) - nvme_show_fw_log(&fw_log, devicename, flags); + nvme_show_fw_log(&fw_log, nvme_dev->name, flags); else if (err > 0) nvme_show_status(err); else @@ -919,8 +921,8 @@ static int get_changed_ns_list_log(int argc, char **argv, struct command *cmd, s err = nvme_get_log_changed_ns_list(fd, true, &changed_ns_list_log); if (!err) - nvme_show_changed_ns_list_log(&changed_ns_list_log, devicename, - flags); + nvme_show_changed_ns_list_log(&changed_ns_list_log, + nvme_dev->name, flags); else if (err > 0) nvme_show_status(err); else @@ -976,7 +978,7 @@ static int get_pred_lat_per_nvmset_log(int argc, char **argv, err = nvme_get_log_predictable_lat_nvmset(fd, cfg.nvmset_id, &plpns_log); if (!err) nvme_show_predictable_latency_per_nvmset(&plpns_log, - cfg.nvmset_id, devicename, flags); + cfg.nvmset_id, nvme_dev->name, flags); else if (err > 0) nvme_show_status(err); else @@ -1065,7 +1067,7 @@ static int get_pred_lat_event_agg_log(int argc, char **argv, err = nvme_get_log_predictable_lat_event(fd, cfg.rae, 0, log_size, pea_log); if (!err) nvme_show_predictable_latency_event_agg_log(pea_log, cfg.log_entries, - log_size, devicename, flags); + log_size, nvme_dev->name, flags); else if (err > 0) nvme_show_status(err); else @@ -1192,7 +1194,7 @@ static int get_persistent_event_log(int argc, char **argv, } nvme_show_persistent_event_log(pevent_log_info, cfg.action, - cfg.log_len, devicename, flags); + cfg.log_len, nvme_dev->name, flags); } else if (err > 0) nvme_show_status(err); else @@ -1286,7 +1288,7 @@ static int get_endurance_event_agg_log(int argc, char **argv, err = nvme_get_log_endurance_grp_evt(fd, cfg.rae, 0, log_size, endurance_log); if (!err) nvme_show_endurance_group_event_agg_log(endurance_log, cfg.log_entries, - log_size, devicename, flags); + log_size, nvme_dev->name, flags); else if (err > 0) nvme_show_status(err); else @@ -1354,7 +1356,7 @@ static int get_lba_status_log(int argc, char **argv, err = nvme_get_log_lba_status(fd, cfg.rae, 0, lslplen, lab_status); if (!err) - nvme_show_lba_status_log(lab_status, lslplen, devicename, flags); + nvme_show_lba_status_log(lab_status, lslplen, nvme_dev->name, flags); else if (err > 0) nvme_show_status(err); else @@ -1403,7 +1405,7 @@ static int get_resv_notif_log(int argc, char **argv, err = nvme_get_log_reservation(fd, false, &resv); if (!err) - nvme_show_resv_notif_log(&resv, devicename, flags); + nvme_show_resv_notif_log(&resv, nvme_dev->name, flags); else if (err > 0) nvme_show_status(err); else @@ -1500,7 +1502,8 @@ static int get_boot_part_log(int argc, char **argv, struct command *cmd, struct sizeof(boot) + bpsz, (struct nvme_boot_partition *)bp_log); if (!err) - nvme_show_boot_part_log(&bp_log, devicename, flags, sizeof(boot) + bpsz); + nvme_show_boot_part_log(&bp_log, nvme_dev->name, flags, + sizeof(boot) + bpsz); else if (err > 0) nvme_show_status(err); else @@ -1757,7 +1760,7 @@ static int get_log(int argc, char **argv, struct command *cmd, struct plugin *pl if (!err) { if (!cfg.raw_binary) { printf("Device:%s log-id:%d namespace-id:%#x\n", - devicename, cfg.log_id, + nvme_dev->name, cfg.log_id, cfg.namespace_id); d(log, cfg.log_len, 16, 1); } else @@ -1820,7 +1823,7 @@ static int sanitize_log(int argc, char **argv, struct command *command, struct p err = nvme_get_log_sanitize(fd, cfg.rae, &sanitize_log); if (!err) - nvme_show_sanitize_log(&sanitize_log, devicename, flags); + nvme_show_sanitize_log(&sanitize_log, nvme_dev->name, flags); else if (err > 0) nvme_show_status(err); else @@ -1869,7 +1872,8 @@ static int get_fid_support_effects_log(int argc, char **argv, struct command *cm err = nvme_get_log_fid_supported_effects(fd, false, &fid_support_log); if (!err) - nvme_show_fid_support_effects_log(&fid_support_log, devicename, flags); + nvme_show_fid_support_effects_log(&fid_support_log, + nvme_dev->name, flags); else if (err > 0) nvme_show_status(err); else @@ -1918,7 +1922,8 @@ static int get_mi_cmd_support_effects_log(int argc, char **argv, struct command err = nvme_get_log_mi_cmd_supported_effects(fd, false, &mi_cmd_support_log); if (!err) - nvme_show_mi_cmd_support_effects_log(&mi_cmd_support_log, devicename, flags); + nvme_show_mi_cmd_support_effects_log(&mi_cmd_support_log, + nvme_dev->name, flags); else if (err > 0) nvme_show_status(err); else @@ -2525,6 +2530,7 @@ static int list_subsys(int argc, char **argv, struct command *cmd, const char *desc = "Retrieve information for subsystems"; const char *verbose = "Increase output verbosity"; nvme_scan_filter_t filter = NULL; + char *devname; int err; int nsid = NVME_NSID_ALL; @@ -2548,9 +2554,9 @@ static int list_subsys(int argc, char **argv, struct command *cmd, if (err < 0) goto ret; - devicename = NULL; + devname = NULL; if (optind < argc) - devicename = basename(argv[optind++]); + devname = basename(argv[optind++]); err = flags = validate_output_format(cfg.output_format); if (flags < 0) @@ -2564,29 +2570,28 @@ static int list_subsys(int argc, char **argv, struct command *cmd, r = nvme_create_root(stderr, map_log_level(cfg.verbose, false)); if (!r) { - if (devicename) + if (devname) fprintf(stderr, "Failed to scan nvme subsystem for %s\n", - devicename); + devname); else fprintf(stderr, "Failed to scan nvme subsystem\n"); err = -errno; goto ret; } - if (devicename) { + if (devname) { int subsys_num; - if (sscanf(devicename,"nvme%dn%d", - &subsys_num, &nsid) != 2) { - fprintf(stderr, "Invalid device name %s\n", devicename); + if (sscanf(devname, "nvme%dn%d", &subsys_num, &nsid) != 2) { + fprintf(stderr, "Invalid device name %s\n", devname); err = -EINVAL; goto ret; } filter = nvme_match_device_filter; } - err = nvme_scan_topology(r, filter, (void *)devicename); + err = nvme_scan_topology(r, filter, (void *)devname); if (err) { fprintf(stderr, "Failed to scan topology: %s\n", nvme_strerror(errno)); @@ -3405,7 +3410,7 @@ static int get_ns_id(int argc, char **argv, struct command *cmd, struct plugin * goto close_fd; } err = 0; - printf("%s: namespace-id:%d\n", devicename, nsid); + printf("%s: namespace-id:%d\n", nvme_dev->name, nsid); close_fd: close(fd); @@ -3711,7 +3716,7 @@ static int self_test_log(int argc, char **argv, struct command *cmd, struct plug err = nvme_get_log_device_self_test(fd, &log); if (!err) nvme_show_self_test_log(&log, cfg.dst_entries, 0, - devicename, flags); + nvme_dev->name, flags); else if (err > 0) nvme_show_status(err); else @@ -4383,15 +4388,15 @@ static void *mmap_registers(nvme_root_t r, const char *dev) void *membase; int fd; - c = nvme_scan_ctrl(r, devicename); + c = nvme_scan_ctrl(r, nvme_dev->name); if (c) { snprintf(path, sizeof(path), "%s/device/resource0", nvme_ctrl_get_sysfs_dir(c)); nvme_free_ctrl(c); } else { - n = nvme_scan_namespace(devicename); + n = nvme_scan_namespace(nvme_dev->name); if (!n) { - fprintf(stderr, "Unable to find %s\n", devicename); + fprintf(stderr, "Unable to find %s\n", nvme_dev->name); return NULL; } snprintf(path, sizeof(path), "%s/device/device/resource0", @@ -4402,13 +4407,13 @@ static void *mmap_registers(nvme_root_t r, const char *dev) fd = open(path, O_RDONLY); if (fd < 0) { fprintf(stderr, "%s did not find a pci resource, open failed %s\n", - devicename, strerror(errno)); + nvme_dev->name, strerror(errno)); return NULL; } membase = mmap(NULL, getpagesize(), PROT_READ, MAP_SHARED, fd, 0); if (membase == MAP_FAILED) { - fprintf(stderr, "%s failed to map. ", devicename); + fprintf(stderr, "%s failed to map. ", nvme_dev->name); fprintf(stderr, "Did your kernel enable CONFIG_IO_STRICT_DEVMEM?\n"); membase = NULL; } @@ -4459,7 +4464,7 @@ static int show_registers(int argc, char **argv, struct command *cmd, struct plu err = nvme_get_properties(fd, &bar); if (err) { - bar = mmap_registers(r, devicename); + bar = mmap_registers(r, nvme_dev->name); fabrics = false; if (bar) err = 0; @@ -4794,9 +4799,9 @@ static int format(int argc, char **argv, struct command *cmd, struct plugin *plu if (!cfg.force) { fprintf(stderr, "You are about to format %s, namespace %#x%s.\n", - devicename, cfg.namespace_id, + nvme_dev->name, cfg.namespace_id, cfg.namespace_id == NVME_NSID_ALL ? "(ALL namespaces)" : ""); - nvme_show_relatives(devicename); + nvme_show_relatives(nvme_dev->name); fprintf(stderr, "WARNING: Format may irrevocably delete this device's data.\n" "You have 10 seconds to press Ctrl-C to cancel this operation.\n\n" "Use the force [--force] option to suppress this warning.\n"); diff --git a/nvme.h b/nvme.h index 5afeecee..ca193250 100644 --- a/nvme.h +++ b/nvme.h @@ -21,6 +21,7 @@ #include #include #include +#include #include "plugin.h" #include "util/json.h" @@ -40,7 +41,12 @@ void register_extension(struct plugin *plugin); int parse_and_open(int argc, char **argv, const char *desc, const struct argconfig_commandline_options *clo); -extern const char *devicename; +struct nvme_dev { + struct stat stat; + const char *name; +}; + +extern struct nvme_dev *nvme_dev; extern const char *output_format; enum nvme_print_flags validate_output_format(const char *format); diff --git a/plugins/innogrit/innogrit-nvme.c b/plugins/innogrit/innogrit-nvme.c index 220a5a75..fc017b14 100644 --- a/plugins/innogrit/innogrit-nvme.c +++ b/plugins/innogrit/innogrit-nvme.c @@ -43,7 +43,8 @@ static int innogrit_smart_log_additional(int argc, char **argv, return fd; nvme_get_log_smart(fd, cfg.namespace_id, false, &smart_log); - nvme_show_smart_log(&smart_log, cfg.namespace_id, devicename, NORMAL); + nvme_show_smart_log(&smart_log, cfg.namespace_id, + nvme_dev->name, NORMAL); printf("DW0[0-1] Defect Cnt : %u\n", pvsc_smart->defect_cnt); printf("DW0[2-3] Slc Spb Cnt : %u\n", pvsc_smart->slc_spb_cnt); diff --git a/plugins/intel/intel-nvme.c b/plugins/intel/intel-nvme.c index 1bf66273..7351d668 100644 --- a/plugins/intel/intel-nvme.c +++ b/plugins/intel/intel-nvme.c @@ -370,9 +370,11 @@ static int get_additional_smart_log(int argc, char **argv, struct command *cmd, err = nvme_get_log_simple(fd, 0xca, sizeof(smart_log), &smart_log); if (!err) { if (cfg.json) - show_intel_smart_log_jsn(&smart_log, cfg.namespace_id, devicename); + show_intel_smart_log_jsn(&smart_log, cfg.namespace_id, + nvme_dev->name); else if (!cfg.raw_binary) - show_intel_smart_log(&smart_log, cfg.namespace_id, devicename); + show_intel_smart_log(&smart_log, cfg.namespace_id, + nvme_dev->name); else d_raw((unsigned char *)&smart_log, sizeof(smart_log)); } diff --git a/plugins/memblaze/memblaze-nvme.c b/plugins/memblaze/memblaze-nvme.c index a6a8ddf4..f8eeb078 100644 --- a/plugins/memblaze/memblaze-nvme.c +++ b/plugins/memblaze/memblaze-nvme.c @@ -481,7 +481,9 @@ static int mb_get_additional_smart_log(int argc, char **argv, struct command *cm sizeof(smart_log), &smart_log); if (!err) { if (!cfg.raw_binary) - err = show_memblaze_smart_log(fd, cfg.namespace_id, devicename, &smart_log); + err = show_memblaze_smart_log(fd, cfg.namespace_id, + nvme_dev->name, + &smart_log); else d_raw((unsigned char *)&smart_log, sizeof(smart_log)); } diff --git a/plugins/ocp/ocp-nvme.c b/plugins/ocp/ocp-nvme.c index 52c28a89..a9f23cae 100644 --- a/plugins/ocp/ocp-nvme.c +++ b/plugins/ocp/ocp-nvme.c @@ -432,7 +432,7 @@ static int ocp_smart_add_log(int argc, char **argv, struct command *cmd, static int ocp_print_C3_log_normal(struct ssd_latency_monitor_log *log_data) { printf("-Latency Monitor/C3 Log Page Data- \n"); - printf(" Controller : %s\n", devicename); + printf(" Controller : %s\n", nvme_dev->name); int i, j; int pos = 0; char ts_buf[128]; diff --git a/plugins/scaleflux/sfx-nvme.c b/plugins/scaleflux/sfx-nvme.c index 0740e43a..81aa768a 100644 --- a/plugins/scaleflux/sfx-nvme.c +++ b/plugins/scaleflux/sfx-nvme.c @@ -431,9 +431,11 @@ static int get_additional_smart_log(int argc, char **argv, struct command *cmd, sizeof(smart_log), (void *)&smart_log); if (!err) { if (cfg.json) - show_sfx_smart_log_jsn(&smart_log, cfg.namespace_id, devicename); + show_sfx_smart_log_jsn(&smart_log, cfg.namespace_id, + nvme_dev->name); else if (!cfg.raw_binary) - show_sfx_smart_log(&smart_log, cfg.namespace_id, devicename); + show_sfx_smart_log(&smart_log, cfg.namespace_id, + nvme_dev->name); else d_raw((unsigned char *)&smart_log, sizeof(smart_log)); } diff --git a/plugins/seagate/seagate-nvme.c b/plugins/seagate/seagate-nvme.c index a527c0fe..7281c40e 100644 --- a/plugins/seagate/seagate-nvme.c +++ b/plugins/seagate/seagate-nvme.c @@ -1119,7 +1119,7 @@ static int get_host_tele(int argc, char **argv, struct command *cmd, struct plug if (!cfg.raw_binary) { printf("Device:%s log-id:%d namespace-id:%#x\n", - devicename, cfg.log_id, + nvme_dev->name, cfg.log_id, cfg.namespace_id); printf("Data Block 1 Last Block:%d Data Block 2 Last Block:%d Data Block 3 Last Block:%d\n", tele_log.tele_data_area1, tele_log.tele_data_area2, tele_log.tele_data_area3); @@ -1239,7 +1239,7 @@ static int get_ctrl_tele(int argc, char **argv, struct command *cmd, struct plug if (!cfg.raw_binary) { printf("Device:%s namespace-id:%#x\n", - devicename, cfg.namespace_id); + nvme_dev->name, cfg.namespace_id); printf("Data Block 1 Last Block:%d Data Block 2 Last Block:%d Data Block 3 Last Block:%d\n", tele_log.tele_data_area1, tele_log.tele_data_area2, tele_log.tele_data_area3); diff --git a/plugins/shannon/shannon-nvme.c b/plugins/shannon/shannon-nvme.c index 220638f0..801fdc3b 100644 --- a/plugins/shannon/shannon-nvme.c +++ b/plugins/shannon/shannon-nvme.c @@ -144,7 +144,8 @@ static int get_additional_smart_log(int argc, char **argv, struct command *cmd, sizeof(smart_log), &smart_log); if (!err) { if (!cfg.raw_binary) - show_shannon_smart_log(&smart_log, cfg.namespace_id, devicename); + show_shannon_smart_log(&smart_log, cfg.namespace_id, + nvme_dev->name); else d_raw((unsigned char *)&smart_log, sizeof(smart_log)); } diff --git a/plugins/solidigm/solidigm-garbage-collection.c b/plugins/solidigm/solidigm-garbage-collection.c index 415722b5..92be7362 100644 --- a/plugins/solidigm/solidigm-garbage-collection.c +++ b/plugins/solidigm/solidigm-garbage-collection.c @@ -97,9 +97,9 @@ int solidigm_get_garbage_collection_log(int argc, char **argv, struct command *c if (flags & BINARY) { d_raw((unsigned char *)&gc_log, sizeof(gc_log)); } else if (flags & JSON) { - vu_gc_log_show_json(&gc_log, devicename); + vu_gc_log_show_json(&gc_log, nvme_dev->name); } else { - vu_gc_log_show(&gc_log, devicename); + vu_gc_log_show(&gc_log, nvme_dev->name); } } else if (err > 0) { diff --git a/plugins/solidigm/solidigm-smart.c b/plugins/solidigm/solidigm-smart.c index 77a22104..483cc7ae 100644 --- a/plugins/solidigm/solidigm-smart.c +++ b/plugins/solidigm/solidigm-smart.c @@ -234,11 +234,14 @@ int solidigm_get_additional_smart_log(int argc, char **argv, struct command *cmd err = nvme_get_log_simple(fd, solidigm_vu_smart_log_id, sizeof(smart_log_payload), &smart_log_payload); if (!err) { if (flags & JSON) { - vu_smart_log_show_json(&smart_log_payload, cfg.namespace_id, devicename); + vu_smart_log_show_json(&smart_log_payload, + cfg.namespace_id, + nvme_dev->name); } else if (flags & BINARY) { d_raw((unsigned char *)&smart_log_payload, sizeof(smart_log_payload)); } else { - vu_smart_log_show(&smart_log_payload, cfg.namespace_id, devicename); + vu_smart_log_show(&smart_log_payload, cfg.namespace_id, + nvme_dev->name); } } else if (err > 0) { nvme_show_status(err); diff --git a/plugins/toshiba/toshiba-nvme.c b/plugins/toshiba/toshiba-nvme.c index cf19352b..5c121ac8 100644 --- a/plugins/toshiba/toshiba-nvme.c +++ b/plugins/toshiba/toshiba-nvme.c @@ -419,8 +419,9 @@ static int nvme_get_vendor_log(int fd, __u32 namespace_id, int log_page, } } else { if (log_page == 0xc0) - default_show_vendor_log_c0(fd, namespace_id, devicename, - (struct nvme_xdn_smart_log_c0 *)log); + default_show_vendor_log_c0(fd, namespace_id, + nvme_dev->name, + (struct nvme_xdn_smart_log_c0 *)log); else d(log, log_len,16,1); } diff --git a/plugins/wdc/wdc-nvme.c b/plugins/wdc/wdc-nvme.c index 5f90c762..ab2578d0 100644 --- a/plugins/wdc/wdc-nvme.c +++ b/plugins/wdc/wdc-nvme.c @@ -1297,7 +1297,7 @@ static int wdc_get_pci_ids(nvme_root_t r, uint32_t *device_id, nvme_ns_t n = NULL; int fd, ret; - c = nvme_scan_ctrl(r, devicename); + c = nvme_scan_ctrl(r, nvme_dev->name); if (c) { snprintf(vid, sizeof(vid), "%s/device/vendor", nvme_ctrl_get_sysfs_dir(c)); @@ -1305,9 +1305,9 @@ static int wdc_get_pci_ids(nvme_root_t r, uint32_t *device_id, nvme_ctrl_get_sysfs_dir(c)); nvme_free_ctrl(c); } else { - n = nvme_scan_namespace(devicename); + n = nvme_scan_namespace(nvme_dev->name); if (!n) { - fprintf(stderr, "Unable to find %s\n", devicename); + fprintf(stderr, "Unable to find %s\n", nvme_dev->name); return -1; } @@ -4012,7 +4012,7 @@ static int wdc_convert_ts(time_t time, char *ts_buf) static int wdc_print_latency_monitor_log_normal(int fd, struct wdc_ssd_latency_monitor_log *log_data) { printf("Latency Monitor/C3 Log Page Data \n"); - printf(" Controller : %s\n", devicename); + printf(" Controller : %s\n", nvme_dev->name); int err = -1, i, j; struct nvme_id_ctrl ctrl; char ts_buf[128]; @@ -4453,7 +4453,7 @@ static void wdc_print_bd_ca_log_normal(void *data) if (bd_data->field_id == 0x00) { raw = (__u64*)&bd_data->raw_value[0]; printf("Additional Smart Log for NVME device:%s namespace-id:%x\n", - devicename, WDC_DE_GLOBAL_NSID); + nvme_dev->name, WDC_DE_GLOBAL_NSID); printf("key normalized raw\n"); printf("program_fail_count : %3"PRIu8"%% %"PRIu64"\n", bd_data->normalized_value, le64_to_cpu(*raw & 0x00FFFFFFFFFFFFFF)); @@ -10446,7 +10446,7 @@ static int wdc_vs_temperature_stats(int argc, char **argv, if (fmt == NORMAL) { /* print the temperature stats */ printf("Temperature Stats for NVME device:%s namespace-id:%x\n", - devicename, WDC_DE_GLOBAL_NSID); + nvme_dev->name, WDC_DE_GLOBAL_NSID); printf("Current Composite Temperature : %d °C\n", temperature); printf("WCTEMP : %"PRIu16" °C\n", id_ctrl.wctemp - 273); @@ -10520,7 +10520,7 @@ static int wdc_capabilities(int argc, char **argv, capabilities = wdc_get_drive_capabilities(r, fd); /* print command and supported status */ - printf("WDC Plugin Capabilities for NVME device:%s\n", devicename); + printf("WDC Plugin Capabilities for NVME device:%s\n", nvme_dev->name); printf("cap-diag : %s\n", capabilities & WDC_DRIVE_CAP_CAP_DIAG ? "Supported" : "Not Supported"); printf("drive-log : %s\n", diff --git a/plugins/ymtc/ymtc-nvme.c b/plugins/ymtc/ymtc-nvme.c index cfbf6a61..0d3002b5 100644 --- a/plugins/ymtc/ymtc-nvme.c +++ b/plugins/ymtc/ymtc-nvme.c @@ -147,7 +147,7 @@ static int get_additional_smart_log(int argc, char **argv, struct command *cmd, 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(fd, cfg.namespace_id, nvme_dev->name, &smart_log); else d_raw((unsigned char *)&smart_log, sizeof(smart_log)); }