mirror of
https://git.proxmox.com/git/mirror_zfs.git
synced 2026-05-22 18:40:43 +03:00
Add option [-V|--version] to emit version string
Add the 'zfs version' and 'zpool version' subcommands to display the version of the user space utilities and loaded zfs kernel module. For example: $ zfs version zfs-0.8.0-rc3_169_g67e0366b88 zfs-kmod-0.8.0-rc3_169_g67e0366b88 The '-V' and '--version' aliases were added to support the common convention of using 'zfs --version` to obtain the version information. Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Reviewed-by: Matthew Ahrens <mahrens@delphix.com> Reviewed-by: Richard Laager <rlaager@wiktel.com> Signed-off-by: TerraTech <1118433+TerraTech@users.noreply.github.com> Closes #2501 Closes #8567
This commit is contained in:
committed by
Brian Behlendorf
parent
8750edf1f7
commit
50478c6dad
@@ -117,6 +117,7 @@ static int zfs_do_load_key(int argc, char **argv);
|
||||
static int zfs_do_unload_key(int argc, char **argv);
|
||||
static int zfs_do_change_key(int argc, char **argv);
|
||||
static int zfs_do_project(int argc, char **argv);
|
||||
static int zfs_do_version(int argc, char **argv);
|
||||
|
||||
/*
|
||||
* Enable a reasonable set of defaults for libumem debugging on DEBUG builds.
|
||||
@@ -171,6 +172,7 @@ typedef enum {
|
||||
HELP_LOAD_KEY,
|
||||
HELP_UNLOAD_KEY,
|
||||
HELP_CHANGE_KEY,
|
||||
HELP_VERSION
|
||||
} zfs_help_t;
|
||||
|
||||
typedef struct zfs_command {
|
||||
@@ -189,6 +191,8 @@ typedef struct zfs_command {
|
||||
* the generic usage message.
|
||||
*/
|
||||
static zfs_command_t command_table[] = {
|
||||
{ "version", zfs_do_version, HELP_VERSION },
|
||||
{ NULL },
|
||||
{ "create", zfs_do_create, HELP_CREATE },
|
||||
{ "destroy", zfs_do_destroy, HELP_DESTROY },
|
||||
{ NULL },
|
||||
@@ -379,6 +383,8 @@ get_usage(zfs_help_t idx)
|
||||
"\t [-o keylocation=<value>] [-o pbkfd2iters=<value>]\n"
|
||||
"\t <filesystem|volume>\n"
|
||||
"\tchange-key -i [-l] <filesystem|volume>\n"));
|
||||
case HELP_VERSION:
|
||||
return (gettext("\tversion\n"));
|
||||
}
|
||||
|
||||
abort();
|
||||
@@ -8059,6 +8065,18 @@ zfs_do_project(int argc, char **argv)
|
||||
return (ret);
|
||||
}
|
||||
|
||||
/*
|
||||
* Display version message
|
||||
*/
|
||||
static int
|
||||
zfs_do_version(int argc, char **argv)
|
||||
{
|
||||
if (zfs_version_print() == -1)
|
||||
return (1);
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
int
|
||||
main(int argc, char **argv)
|
||||
{
|
||||
@@ -8114,6 +8132,12 @@ main(int argc, char **argv)
|
||||
(strcmp(cmdname, "--help") == 0))
|
||||
usage(B_TRUE);
|
||||
|
||||
/*
|
||||
* Special case '-V|--version'
|
||||
*/
|
||||
if ((strcmp(cmdname, "-V") == 0) || (strcmp(cmdname, "--version") == 0))
|
||||
return (zfs_do_version(argc, argv));
|
||||
|
||||
if ((g_zfs = libzfs_init()) == NULL) {
|
||||
(void) fprintf(stderr, "%s", libzfs_error_init(errno));
|
||||
return (1);
|
||||
|
||||
+26
-1
@@ -115,6 +115,8 @@ static int zpool_do_set(int, char **);
|
||||
|
||||
static int zpool_do_sync(int, char **);
|
||||
|
||||
static int zpool_do_version(int, char **);
|
||||
|
||||
/*
|
||||
* These libumem hooks provide a reasonable set of defaults for the allocator's
|
||||
* debugging facilities.
|
||||
@@ -164,7 +166,8 @@ typedef enum {
|
||||
HELP_SPLIT,
|
||||
HELP_SYNC,
|
||||
HELP_REGUID,
|
||||
HELP_REOPEN
|
||||
HELP_REOPEN,
|
||||
HELP_VERSION
|
||||
} zpool_help_t;
|
||||
|
||||
|
||||
@@ -263,6 +266,8 @@ typedef struct zpool_command {
|
||||
* the generic usage message.
|
||||
*/
|
||||
static zpool_command_t command_table[] = {
|
||||
{ "version", zpool_do_version, HELP_VERSION },
|
||||
{ NULL },
|
||||
{ "create", zpool_do_create, HELP_CREATE },
|
||||
{ "destroy", zpool_do_destroy, HELP_DESTROY },
|
||||
{ NULL },
|
||||
@@ -404,6 +409,8 @@ get_usage(zpool_help_t idx)
|
||||
return (gettext("\treguid <pool>\n"));
|
||||
case HELP_SYNC:
|
||||
return (gettext("\tsync [pool] ...\n"));
|
||||
case HELP_VERSION:
|
||||
return (gettext("\tversion\n"));
|
||||
}
|
||||
|
||||
abort();
|
||||
@@ -9222,6 +9229,18 @@ find_command_idx(char *command, int *idx)
|
||||
return (1);
|
||||
}
|
||||
|
||||
/*
|
||||
* Display version message
|
||||
*/
|
||||
static int
|
||||
zpool_do_version(int argc, char **argv)
|
||||
{
|
||||
if (zfs_version_print() == -1)
|
||||
return (1);
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
int
|
||||
main(int argc, char **argv)
|
||||
{
|
||||
@@ -9252,6 +9271,12 @@ main(int argc, char **argv)
|
||||
if ((strcmp(cmdname, "-?") == 0) || strcmp(cmdname, "--help") == 0)
|
||||
usage(B_TRUE);
|
||||
|
||||
/*
|
||||
* Special case '-V|--version'
|
||||
*/
|
||||
if ((strcmp(cmdname, "-V") == 0) || (strcmp(cmdname, "--version") == 0))
|
||||
return (zpool_do_version(argc, argv));
|
||||
|
||||
if ((g_zfs = libzfs_init()) == NULL) {
|
||||
(void) fprintf(stderr, "%s", libzfs_error_init(errno));
|
||||
return (1);
|
||||
|
||||
Reference in New Issue
Block a user