From d3c87bf04cfe0e84b3bef943f8920d0198a2553c Mon Sep 17 00:00:00 2001 From: Tokunori Ikegami Date: Tue, 29 Apr 2025 21:43:05 +0900 Subject: [PATCH 1/2] nvme: make --opcode argument mandatory The shorthand -o change for --output from --opcode before. Then the default opcode value zero used incorrectly if the -o used. Signed-off-by: Tokunori Ikegami --- nvme.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/nvme.c b/nvme.c index 5aaa838310..3a37ac122b 100644 --- a/nvme.c +++ b/nvme.c @@ -9123,6 +9123,11 @@ static int passthru(int argc, char **argv, bool admin, return err; } + if (!argconfig_parse_seen(opts, "opcode")) { + nvme_show_error("%s: opcode parameter required", cmd->name); + return -EINVAL; + } + if (cfg.opcode & 0x01) { cfg.write = true; flags = O_RDONLY; @@ -10186,6 +10191,11 @@ static int nvme_mi(int argc, char **argv, __u8 admin_opcode, const char *desc) if (err) return err; + if (!argconfig_parse_seen(opts, "opcode")) { + nvme_show_error("%s: opcode parameter required", *argv); + return -EINVAL; + } + if (admin_opcode == nvme_admin_nvme_mi_send) { flags = O_RDONLY; fd = STDIN_FILENO; From db27cde4e5a6913b820c14af40a349bc75631c53 Mon Sep 17 00:00:00 2001 From: Tokunori Ikegami Date: Thu, 1 May 2025 14:35:33 +0900 Subject: [PATCH 2/2] doc: add opcode description as mandatory The opcode behavior changed as required argument. Signed-off-by: Tokunori Ikegami --- Documentation/nvme-admin-passthru.txt | 1 + Documentation/nvme-io-passthru.txt | 1 + Documentation/nvme-nvme-mi-recv.txt | 1 + Documentation/nvme-nvme-mi-send.txt | 1 + 4 files changed, 4 insertions(+) diff --git a/Documentation/nvme-admin-passthru.txt b/Documentation/nvme-admin-passthru.txt index c930e8c76b..f4a6b06e9c 100644 --- a/Documentation/nvme-admin-passthru.txt +++ b/Documentation/nvme-admin-passthru.txt @@ -47,6 +47,7 @@ OPTIONS -O :: --opcode=:: The NVMe opcode to send to the device in the command + Required argument as this param is mandatory. -f :: --flags=:: diff --git a/Documentation/nvme-io-passthru.txt b/Documentation/nvme-io-passthru.txt index fd76bd5cc0..902bf723bf 100644 --- a/Documentation/nvme-io-passthru.txt +++ b/Documentation/nvme-io-passthru.txt @@ -46,6 +46,7 @@ OPTIONS -O :: --opcode=:: The NVMe opcode to send to the device in the command + Required argument as this param is mandatory. -f :: --flags=:: diff --git a/Documentation/nvme-nvme-mi-recv.txt b/Documentation/nvme-nvme-mi-recv.txt index 152bbe67c0..c2df630289 100644 --- a/Documentation/nvme-nvme-mi-recv.txt +++ b/Documentation/nvme-nvme-mi-recv.txt @@ -30,6 +30,7 @@ OPTIONS -O :: --opcode=:: The NVMe-MI opcode to send to the device in the command + Required argument as this param is mandatory. -n :: --namespace-id=:: diff --git a/Documentation/nvme-nvme-mi-send.txt b/Documentation/nvme-nvme-mi-send.txt index 0e80fe7a02..8e356011e9 100644 --- a/Documentation/nvme-nvme-mi-send.txt +++ b/Documentation/nvme-nvme-mi-send.txt @@ -30,6 +30,7 @@ OPTIONS -O :: --opcode=:: The NVMe-MI opcode to send to the device in the command + Required argument as this param is mandatory. -n :: --namespace-id=::