zfs -V: Print userland version even if kernel module not loaded

Running zfs -V when the modules are not loaded would currently 
result in the following output:

    zfs_version_kernel() failed: No such file or directory

Note the lack of userland version output.  Reorder the code to
ensure the userland version is printed even when the kmods
are not loaded.

Reviewed-by: George Melikov <mail@gmelikov.ru>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: InsanePrawn <insane.prawny@gmail.com>
Closes #10483
This commit is contained in:
Prawn 2020-06-22 18:56:29 +02:00 committed by GitHub
parent 68301ba20e
commit 2451a55368
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1967,15 +1967,16 @@ zfs_version_print(void)
char zver_userland[128]; char zver_userland[128];
char zver_kernel[128]; char zver_kernel[128];
zfs_version_userland(zver_userland, sizeof (zver_userland));
(void) printf("%s\n", zver_userland);
if (zfs_version_kernel(zver_kernel, sizeof (zver_kernel)) == -1) { if (zfs_version_kernel(zver_kernel, sizeof (zver_kernel)) == -1) {
fprintf(stderr, "zfs_version_kernel() failed: %s\n", fprintf(stderr, "zfs_version_kernel() failed: %s\n",
strerror(errno)); strerror(errno));
return (-1); return (-1);
} }
zfs_version_userland(zver_userland, sizeof (zver_userland));
(void) printf("%s\n", zver_userland);
(void) printf("zfs-kmod-%s\n", zver_kernel); (void) printf("zfs-kmod-%s\n", zver_kernel);
return (0); return (0);