zfs get: add '-t fs' and '-t vol' options

Make `zfs get` accept `fs` for `filesystem` and `vol` for `volume`.

Signed-off-by: Ryan <errornointernet@envs.net>
This commit is contained in:
ErrorNoInternet 2024-04-20 15:24:22 +08:00
parent f4f156157d
commit 5db037029f
No known key found for this signature in database
GPG Key ID: 2486BFB7B1E6A4A3
2 changed files with 26 additions and 7 deletions

View File

@ -2146,15 +2146,25 @@ found2:;
for (char *tok; (tok = strsep(&optarg, ",")); ) { for (char *tok; (tok = strsep(&optarg, ",")); ) {
static const char *const type_opts[] = { static const char *const type_opts[] = {
"filesystem", "volume", "filesystem",
"snapshot", "snap", "fs",
"volume",
"vol",
"snapshot",
"snap",
"bookmark", "bookmark",
"all" }; "all"
};
static const int type_types[] = { static const int type_types[] = {
ZFS_TYPE_FILESYSTEM, ZFS_TYPE_VOLUME, ZFS_TYPE_FILESYSTEM,
ZFS_TYPE_SNAPSHOT, ZFS_TYPE_SNAPSHOT, ZFS_TYPE_FILESYSTEM,
ZFS_TYPE_VOLUME,
ZFS_TYPE_VOLUME,
ZFS_TYPE_SNAPSHOT,
ZFS_TYPE_SNAPSHOT,
ZFS_TYPE_BOOKMARK, ZFS_TYPE_BOOKMARK,
ZFS_TYPE_DATASET | ZFS_TYPE_BOOKMARK }; ZFS_TYPE_DATASET | ZFS_TYPE_BOOKMARK
};
for (i = 0; i < ARRAY_SIZE(type_opts); ++i) for (i = 0; i < ARRAY_SIZE(type_opts); ++i)
if (strcmp(tok, type_opts[i]) == 0) { if (strcmp(tok, type_opts[i]) == 0) {

View File

@ -29,7 +29,7 @@
.\" Copyright 2018 Nexenta Systems, Inc. .\" Copyright 2018 Nexenta Systems, Inc.
.\" Copyright 2019 Joyent, Inc. .\" Copyright 2019 Joyent, Inc.
.\" .\"
.Dd March 16, 2022 .Dd April 20, 2024
.Dt ZFS-SET 8 .Dt ZFS-SET 8
.Os .Os
. .
@ -158,6 +158,15 @@ A comma-separated list of types to display, where
.Ar type .Ar type
is one of is one of
.Sy filesystem , snapshot , volume , bookmark , No or Sy all . .Sy filesystem , snapshot , volume , bookmark , No or Sy all .
.Sy fs ,
.Sy snap ,
or
.Sy vol
can be used as aliases for
.Sy filesystem ,
.Sy snapshot ,
or
.Sy volume .
.El .El
.It Xo .It Xo
.Nm zfs .Nm zfs