Skip to content

Commit

Permalink
13690 nvmeadm get-logpage doesn't work after 13672
Browse files Browse the repository at this point in the history
Reviewed by: Andy Fiddaman <andy@omnios.org>
Reviewed by: Patrick Mooney <pmooney@pfmooney.com>
  • Loading branch information
rmustacc committed Mar 31, 2021
1 parent 35d41f2 commit cf988e4
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions usr/src/cmd/nvmeadm/nvmeadm.c
Expand Up @@ -245,6 +245,7 @@ main(int argc, char **argv)
nvme_process_arg_t npa = { 0 };
int help = 0;
char *tmp, *lasts = NULL;
char *ctrl = NULL;

while ((c = getopt(argc, argv, "dhv")) != -1) {
switch (c) {
Expand Down Expand Up @@ -303,7 +304,9 @@ main(int argc, char **argv)
}

/*
* All commands but "list" require a ctl/ns argument.
* All commands but "list" require a ctl/ns argument. However, this
* should not be passed through to the command in its subsequent
* arguments.
*/
if ((npa.npa_argc == 0 || (strncmp(npa.npa_argv[0], "nvme", 4) != 0)) &&
cmd->c_func != do_list) {
Expand All @@ -312,11 +315,19 @@ main(int argc, char **argv)
exit(-1);
}

if (npa.npa_argc > 0) {
ctrl = npa.npa_argv[0];
npa.npa_argv++;
npa.npa_argc--;
} else {
ctrl = NULL;
}

/*
* Make sure we're not running commands on multiple controllers that
* aren't allowed to do that.
*/
if (npa.npa_argv[0] != NULL && strchr(npa.npa_argv[0], ',') != NULL &&
if (ctrl != NULL && strchr(ctrl, ',') != NULL &&
cmd->c_multi == B_FALSE) {
warnx("%s not allowed on multiple controllers",
cmd->c_name);
Expand All @@ -327,7 +338,7 @@ main(int argc, char **argv)
/*
* Get controller/namespace arguments and run command.
*/
npa.npa_name = strtok_r(npa.npa_argv[0], ",", &lasts);
npa.npa_name = strtok_r(ctrl, ",", &lasts);
do {
if (npa.npa_name != NULL) {
tmp = strchr(npa.npa_name, '/');
Expand Down

0 comments on commit cf988e4

Please sign in to comment.