git: a233cb6914e6 - main - nvmecontrol: Accept -a {1,2,3,4} for sanitize command for nvme-cli compat
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Fri, 16 Aug 2024 02:30:25 UTC
The branch main has been updated by imp:
URL: https://cgit.FreeBSD.org/src/commit/?id=a233cb6914e68252baf143c5f1d6e01e3956e33e
commit a233cb6914e68252baf143c5f1d6e01e3956e33e
Author: Warner Losh <imp@FreeBSD.org>
AuthorDate: 2024-08-15 21:10:17 +0000
Commit: Warner Losh <imp@FreeBSD.org>
CommitDate: 2024-08-16 02:22:31 +0000
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
---
sbin/nvmecontrol/nvmecontrol.8 | 10 ++++++++++
sbin/nvmecontrol/sanitize.c | 5 ++++-
2 files changed, 14 insertions(+), 1 deletion(-)
diff --git a/sbin/nvmecontrol/nvmecontrol.8 b/sbin/nvmecontrol/nvmecontrol.8
index 713fcf092d64..cb3e8aa9080f 100644
--- a/sbin/nvmecontrol/nvmecontrol.8
+++ b/sbin/nvmecontrol/nvmecontrol.8
@@ -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
diff --git a/sbin/nvmecontrol/sanitize.c b/sbin/nvmecontrol/sanitize.c
index ba89e138db83..e720c6d43497 100644
--- a/sbin/nvmecontrol/sanitize.c
+++ b/sbin/nvmecontrol/sanitize.c
@@ -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);
}
}