zfs: get: only accept whole type for -t, not tp[=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
7867f430b4
commit
4695230021
|
@ -1997,7 +1997,7 @@ zfs_do_get(int argc, char **argv)
|
|||
zprop_get_cbdata_t cb = { 0 };
|
||||
int i, c, flags = ZFS_ITER_ARGS_CAN_BE_PATHS;
|
||||
int types = ZFS_TYPE_DATASET | ZFS_TYPE_BOOKMARK;
|
||||
char *value, *fields;
|
||||
char *fields;
|
||||
int ret = 0;
|
||||
int limit = 0;
|
||||
zprop_list_t fake_name = { 0 };
|
||||
|
@ -2115,37 +2115,29 @@ found2:;
|
|||
case 't':
|
||||
types = 0;
|
||||
flags &= ~ZFS_ITER_PROP_LISTSNAPS;
|
||||
while (*optarg != '\0') {
|
||||
static char *type_subopts[] = { "filesystem",
|
||||
"volume", "snapshot", "snap", "bookmark",
|
||||
"all", NULL };
|
||||
|
||||
switch (getsubopt(&optarg, type_subopts,
|
||||
&value)) {
|
||||
case 0:
|
||||
types |= ZFS_TYPE_FILESYSTEM;
|
||||
break;
|
||||
case 1:
|
||||
types |= ZFS_TYPE_VOLUME;
|
||||
break;
|
||||
case 2:
|
||||
case 3:
|
||||
types |= ZFS_TYPE_SNAPSHOT;
|
||||
break;
|
||||
case 4:
|
||||
types |= ZFS_TYPE_BOOKMARK;
|
||||
break;
|
||||
case 5:
|
||||
types = ZFS_TYPE_DATASET |
|
||||
ZFS_TYPE_BOOKMARK;
|
||||
break;
|
||||
for (char *tok; (tok = strsep(&optarg, ",")); ) {
|
||||
static const char *const type_opts[] = {
|
||||
"filesystem", "volume",
|
||||
"snapshot", "snap",
|
||||
"bookmark",
|
||||
"all" };
|
||||
static const int type_types[] = {
|
||||
ZFS_TYPE_FILESYSTEM, ZFS_TYPE_VOLUME,
|
||||
ZFS_TYPE_SNAPSHOT, ZFS_TYPE_SNAPSHOT,
|
||||
ZFS_TYPE_BOOKMARK,
|
||||
ZFS_TYPE_DATASET | ZFS_TYPE_BOOKMARK };
|
||||
|
||||
default:
|
||||
(void) fprintf(stderr,
|
||||
gettext("invalid type '%s'\n"),
|
||||
value);
|
||||
usage(B_FALSE);
|
||||
}
|
||||
for (i = 0; i < ARRAY_SIZE(type_opts); ++i)
|
||||
if (strcmp(tok, type_opts[i]) == 0) {
|
||||
types |= type_types[i];
|
||||
goto found3;
|
||||
}
|
||||
|
||||
(void) fprintf(stderr,
|
||||
gettext("invalid type '%s'\n"), tok);
|
||||
usage(B_FALSE);
|
||||
found3:;
|
||||
}
|
||||
break;
|
||||
|
||||
|
|
Loading…
Reference in New Issue