]> www.infradead.org Git - users/sagi/nvme-cli.git/commitdiff
nvme: Fix --force flag inversion
authorDaniel Wagner <dwagner@suse.de>
Tue, 8 Feb 2022 11:13:34 +0000 (12:13 +0100)
committerDaniel Wagner <dwagner@suse.de>
Tue, 8 Feb 2022 11:13:34 +0000 (12:13 +0100)
argparse sets the default_value member when the argument has been
provided by the user. But in parse_and_open we set O_EXCL when --force
is not used.

It also introduced a regression in the 'id-ns' where the --force flag
is used to determine which function is used to identify the
namespace (nvme_identify_allocated_ns() vs nvme_identify_ns()).

Fixes: 2100609 ("nvme: open namespace exclusive by default")
Signed-off-by: Daniel Wagner <dwagner@suse.de>
nvme.c

diff --git a/nvme.c b/nvme.c
index 40bd4c94662428f9e66f765c7b103a12c6b865d5..73052a12b0e4186df9421168705331eeb98b5a9f 100644 (file)
--- a/nvme.c
+++ b/nvme.c
@@ -277,7 +277,7 @@ int parse_and_open(int argc, char **argv, const char *desc,
 
        for (s = opts; s && s->option; s++) {
                if (!strcmp(s->option, "force")) {
-                       if (*(int *)s->default_value)
+                       if (*(int *)s->default_value)
                                flags |= O_EXCL;
                        break;
                }