]> www.infradead.org Git - users/sagi/nvme-cli.git/commitdiff
tree: Move global device info to a single struct
authorJeremy Kerr <jk@codeconstruct.com.au>
Tue, 12 Jul 2022 02:59:20 +0000 (10:59 +0800)
committerDaniel Wagner <dwagner@suse.de>
Fri, 12 Aug 2022 06:50:42 +0000 (08:50 +0200)
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 <jk@codeconstruct.com.au>
14 files changed:
nvme.c
nvme.h
plugins/innogrit/innogrit-nvme.c
plugins/intel/intel-nvme.c
plugins/memblaze/memblaze-nvme.c
plugins/ocp/ocp-nvme.c
plugins/scaleflux/sfx-nvme.c
plugins/seagate/seagate-nvme.c
plugins/shannon/shannon-nvme.c
plugins/solidigm/solidigm-garbage-collection.c
plugins/solidigm/solidigm-smart.c
plugins/toshiba/toshiba-nvme.c
plugins/wdc/wdc-nvme.c
plugins/ymtc/ymtc-nvme.c

diff --git a/nvme.c b/nvme.c
index 12d02820e678488f423dfb66bca431ff0b7f0552..025eb6fd93118778c113e68fc180de223c352083 100644 (file)
--- 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 5afeeceeb5431384f7342ceac59bceb509ea04ea..ca193250c00128bde6a89bf56dcbde6eeed82699 100644 (file)
--- a/nvme.h
+++ b/nvme.h
@@ -21,6 +21,7 @@
 #include <stdint.h>
 #include <endian.h>
 #include <sys/time.h>
+#include <sys/stat.h>
 
 #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);
index 220a5a755d2f597a7f5a67531dfb1ed43ca588ba..fc017b1467cc6bf0a2a4bc071fe8d28c18d85a2b 100644 (file)
@@ -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);
index 1bf662735e643a34a570f9fb16f256c6e45b4c14..7351d6689604ce4390666dcd67663078725e9b87 100644 (file)
@@ -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));
        }
index a6a8ddf4afd8ce01a44f4c0650096446322a1f10..f8eeb078606ecf07938a6694e8ae5d7780056ad1 100644 (file)
@@ -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));
        }
index 52c28a892924bf4d7df8eebb9b06de4dd596abf1..a9f23caedd3dda236be2e805aba8b37c2d56941d 100644 (file)
@@ -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];
index 0740e43a5298e4133855912710b597476d7bfaa3..81aa768a1b34fb2615c46abf1440e352df3aa086 100644 (file)
@@ -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));
        }
index a527c0fe589933df88ca4976381a64f629d386b4..7281c40eefd1b6a3e679a5fee4208d97f3f4960d 100644 (file)
@@ -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);
 
index 220638f02301e52c20fdcec9606dbe8ebef93399..801fdc3b5684f8ef18bdbe6b5966ca0ab6243f72 100644 (file)
@@ -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));
        }
index 415722b5f5f0ee5ec1c35e3e5025b653a9670599..92be7362e9d24909996a5d39fb7adab29d75256c 100644 (file)
@@ -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) {
index 77a22104fbead50795ee96ca48e7537ca3d51fb1..483cc7ae8fd4648214364084c268394b6672332d 100644 (file)
@@ -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);
index cf19352bcc4bdff868e7d6c36b66e01da7f0fbc3..5c121ac8b050acae485693c0fee1ac4d751d933e 100644 (file)
@@ -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);
        }
index 5f90c762f538713a2045bfbb78af3798b845daa1..ab2578d021c70348d1396ad5bc6c08393fd760f6 100644 (file)
@@ -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", 
index cfbf6a614e383ded3adf1d65b05cbff923f55869..0d3002b5e2176df252ac2c6eb710fd29dba8ab5a 100644 (file)
@@ -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));
     }