mirror of
https://git.proxmox.com/git/mirror_zfs.git
synced 2024-12-26 11:19:32 +03:00
zpool: wait: only accept whole columns for -t, not col[=whatever]
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Signed-off-by: Ahelenia Ziemiańska <nabijaczleweli@nabijaczleweli.xyz> Closes #12996
This commit is contained in:
parent
c21819026f
commit
675508f608
@ -50,7 +50,6 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <strings.h>
|
||||
#include <time.h>
|
||||
#include <unistd.h>
|
||||
#include <pwd.h>
|
||||
@ -10672,9 +10671,7 @@ int
|
||||
zpool_do_wait(int argc, char **argv)
|
||||
{
|
||||
boolean_t verbose = B_FALSE;
|
||||
int c;
|
||||
char *value;
|
||||
int i;
|
||||
int c, i;
|
||||
unsigned long count;
|
||||
pthread_t status_thr;
|
||||
int error = 0;
|
||||
@ -10708,28 +10705,26 @@ zpool_do_wait(int argc, char **argv)
|
||||
get_timestamp_arg(*optarg);
|
||||
break;
|
||||
case 't':
|
||||
{
|
||||
static char *col_subopts[] = { "discard", "free",
|
||||
"initialize", "replace", "remove", "resilver",
|
||||
"scrub", "trim", NULL };
|
||||
|
||||
/* Reset activities array */
|
||||
memset(&wd.wd_enabled, 0, sizeof (wd.wd_enabled));
|
||||
while (*optarg != '\0') {
|
||||
int activity = getsubopt(&optarg, col_subopts,
|
||||
&value);
|
||||
|
||||
if (activity < 0) {
|
||||
(void) fprintf(stderr,
|
||||
gettext("invalid activity '%s'\n"),
|
||||
value);
|
||||
usage(B_FALSE);
|
||||
for (char *tok; (tok = strsep(&optarg, ",")); ) {
|
||||
static const char *const col_opts[] = {
|
||||
"discard", "free", "initialize", "replace",
|
||||
"remove", "resilver", "scrub", "trim" };
|
||||
|
||||
for (i = 0; i < ARRAY_SIZE(col_opts); ++i)
|
||||
if (strcmp(tok, col_opts[i]) == 0) {
|
||||
wd.wd_enabled[i] = B_TRUE;
|
||||
goto found;
|
||||
}
|
||||
|
||||
wd.wd_enabled[activity] = B_TRUE;
|
||||
(void) fprintf(stderr,
|
||||
gettext("invalid activity '%s'\n"), tok);
|
||||
usage(B_FALSE);
|
||||
found:;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case '?':
|
||||
(void) fprintf(stderr, gettext("invalid option '%c'\n"),
|
||||
optopt);
|
||||
|
Loading…
Reference in New Issue
Block a user