nvmecontrol: Accept -a {1,2,3,4} for sanitize command for nvme-cli compat

Linux's `nvme sanititze -a` takes a number, not a string. Accept 1-4 for
compatibility so vendor's recepies are easier to implmement.

Sponsored by: Netflix
This commit is contained in:
Warner Losh 2024-08-15 15:10:17 -06:00
parent d5507f9e43
commit a233cb6914
2 changed files with 14 additions and 1 deletions

View File

@ -572,6 +572,16 @@ A failed sanitize operation can only be exited if it was
run in the unrestricted completion mode, as provided by the
.Fl U
argument.
.It 1, 2, 3, 4
nvme-cli compatible
.Fl a
values for
.Dq exitfailure ,
.Dq block ,
.Dq overwrite ,
and
.Dq crypto
respectively.
.El
.It Fl c Ar passes
The number of passes when performing an

View File

@ -130,8 +130,11 @@ sanitize(const struct cmd *f, int argc, char *argv[])
sanact = 3;
else if (strcmp(opt.sanact, "crypto") == 0)
sanact = 4;
else if ((sanact = (int)strtol(opt.sanact, NULL, 10) != 0)
&& (sanact >= 1 && sanact <= 4))
; /* compat with nvme sanitize -a number */
else {
fprintf(stderr, "Incorrect Sanitize Action value\n");
fprintf(stderr, "Incorrect Sanitize Action value: %s\n", opt.sanact);
arg_help(argc, argv, f);
}
}