]> www.infradead.org Git - users/sagi/nvme-cli.git/commitdiff
nvme: add error message for mmap_registers
authorSteven Seungcheol Lee <sc108.lee@samsung.com>
Sun, 16 Mar 2025 06:07:14 +0000 (15:07 +0900)
committerDaniel Wagner <wagi@monom.org>
Mon, 17 Mar 2025 08:47:11 +0000 (09:47 +0100)
To indicate that backward compatibility is not supported
since we drop the block device fallback

Signed-off-by: Steven Seungcheol Lee <sc108.lee@samsung.com>
Documentation/nvme-get-reg.txt
Documentation/nvme-set-reg.txt
nvme.c

index 5e9cd950a474afaa20e3455ff4b5ff366f1193b0..74fe324fc80b6e7a1c6afe75180a0fa60666c0c8 100644 (file)
@@ -22,6 +22,9 @@ DESCRIPTION
 -----------
 Read and show the defined NVMe controller register.
 
+The <device> parameter is mandatory and must be the nvme admin character
+device (ex: /dev/nvme0).
+
 OPTIONS
 -------
 -O <offset>::
index 2978c82a7e6adbb36e535607497f454f779f3f88..bd86c3a508ddda7028da1c96deaae9f2da4643e3 100644 (file)
@@ -22,6 +22,9 @@ DESCRIPTION
 -----------
 Writes and shows the defined NVMe controller register.
 
+The <device> parameter is mandatory and must be the nvme admin character
+device (ex: /dev/nvme0).
+
 OPTIONS
 -------
 -O <offset>::
diff --git a/nvme.c b/nvme.c
index 0549bf0b1f35b8db22d7cc3a3274ee17759b9395..bb41284310cf5dae9eb062017274986abc1bddeb 100644 (file)
--- a/nvme.c
+++ b/nvme.c
@@ -1113,7 +1113,10 @@ static int get_effects_log(int argc, char **argv, struct command *cmd, struct pl
 
        if (cfg.csi < 0) {
                __u64 cap;
-
+               if (is_blkdev(dev)) {
+                       nvme_show_error("Block device isn't allowed without csi");
+                       return -EINVAL;
+               }
                bar = mmap_registers(dev, false);
 
                if (bar) {
@@ -5611,6 +5614,11 @@ static int show_registers(int argc, char **argv, struct command *cmd, struct plu
        if (err)
                return err;
 
+       if (is_blkdev(dev)) {
+               nvme_show_error("Only character device is allowed");
+               return -EINVAL;
+       }
+
        err = validate_output_format(nvme_cfg.output_format, &flags);
        if (err < 0) {
                nvme_show_error("Invalid output format");
@@ -5887,6 +5895,11 @@ static int get_register(int argc, char **argv, struct command *cmd, struct plugi
        if (err)
                return err;
 
+       if (is_blkdev(dev)) {
+               nvme_show_error("Only character device is allowed");
+               return -EINVAL;
+       }
+
        err = validate_output_format(nvme_cfg.output_format, &flags);
        if (err < 0) {
                nvme_show_error("Invalid output format");
@@ -6191,6 +6204,11 @@ static int set_register(int argc, char **argv, struct command *cmd, struct plugi
        if (err)
                return err;
 
+       if (is_blkdev(dev)) {
+               nvme_show_error("Only character device is allowed");
+               return -EINVAL;
+       }
+
        bar = mmap_registers(dev, true);
 
        if (argconfig_parse_seen(opts, "offset"))