For ns identify/delete allow nsid of 0xffffffff.

The first should report common parameters, the second should delete
all namespaces.

MFC after:	1 week
This commit is contained in:
Alexander Motin 2021-07-14 14:56:34 -04:00
parent 325ff93274
commit dbf1dce8d6

View File

@ -198,7 +198,7 @@ static struct delete_options {
uint32_t nsid; uint32_t nsid;
const char *dev; const char *dev;
} delete_opt = { } delete_opt = {
.nsid = NONE, .nsid = NONE - 1,
.dev = NULL, .dev = NULL,
}; };
@ -331,7 +331,7 @@ static struct identify_options {
.hex = false, .hex = false,
.verbose = false, .verbose = false,
.dev = NULL, .dev = NULL,
.nsid = NONE, .nsid = NONE - 1,
}; };
static const struct opts identify_opts[] = { static const struct opts identify_opts[] = {
@ -639,12 +639,12 @@ nsdelete(const struct cmd *f, int argc, char *argv[])
if (nsid != 0) { if (nsid != 0) {
close(fd); close(fd);
open_dev(path, &fd, 1, 1); open_dev(path, &fd, 1, 1);
} else if (delete_opt.nsid == NONE) { } else if (delete_opt.nsid == NONE - 1) {
close(fd); close(fd);
fprintf(stderr, "No NSID specified"); fprintf(stderr, "No NSID specified");
arg_help(argc, argv, f); arg_help(argc, argv, f);
} }
if (delete_opt.nsid != NONE) if (delete_opt.nsid != NONE - 1)
nsid = delete_opt.nsid; nsid = delete_opt.nsid;
free(path); free(path);
if (read_controller_data(fd, &cd)) if (read_controller_data(fd, &cd))
@ -912,12 +912,12 @@ nsidentify(const struct cmd *f, int argc, char *argv[])
if (nsid != 0) { if (nsid != 0) {
close(fd); close(fd);
open_dev(path, &fd, 1, 1); open_dev(path, &fd, 1, 1);
} else if (identify_opt.nsid == NONE) { } else if (identify_opt.nsid == NONE - 1) {
close(fd); close(fd);
fprintf(stderr, "No NSID specified"); fprintf(stderr, "No NSID specified");
arg_help(argc, argv, f); arg_help(argc, argv, f);
} }
if (identify_opt.nsid != NONE) if (identify_opt.nsid != NONE - 1)
nsid = identify_opt.nsid; nsid = identify_opt.nsid;
if (read_controller_data(fd, &cd)) if (read_controller_data(fd, &cd))
errx(EX_IOERR, "Identify request failed"); errx(EX_IOERR, "Identify request failed");