]> www.infradead.org Git - users/hch/nvme-cli.git/commitdiff
controller list argument is required in attach-ns/detach-ns commands
authorKLZ-0 <adrian@kalazi.com>
Fri, 1 May 2020 19:22:40 +0000 (21:22 +0200)
committerKeith Busch <kbusch@kernel.org>
Wed, 6 May 2020 16:40:47 +0000 (10:40 -0600)
Empty controller-id list in the ioctl call for attach/detach of namespace results effectively in no operation, yet the nvme cli reports falsely success. The controller id list must be specified with at least 1 controller in the list.

nvme.c

diff --git a/nvme.c b/nvme.c
index f4218a3198c8f3110109d9a7241f09c9f1bf3c4e..e2e2abf15b67c661f531cb29a90e173df7fdde72 100644 (file)
--- a/nvme.c
+++ b/nvme.c
@@ -1058,7 +1058,7 @@ static int nvme_attach_ns(int argc, char **argv, int attach, const char *desc, s
        __u16 ctrlist[2048];
 
        const char *namespace_id = "namespace to attach";
-       const char *cont = "optional comma-sep controller id list";
+       const char *cont = "comma-sep controller id list";
 
        struct config {
                char  *cntlist;
@@ -1088,7 +1088,7 @@ static int nvme_attach_ns(int argc, char **argv, int attach, const char *desc, s
        }
 
        num = argconfig_parse_comma_sep_array(cfg.cntlist, list, 2047);
-       if (num == -1) {
+       if (num 1) {
                fprintf(stderr, "%s: controller id list is required\n",
                                                cmd->name);
                err = -EINVAL;