diff options
author | Brian Behlendorf <[email protected]> | 2015-05-20 14:39:52 -0700 |
---|---|---|
committer | Brian Behlendorf <[email protected]> | 2015-05-22 13:34:58 -0700 |
commit | 65037d9b25c2bfa98d0aa5c9e34678127c03b345 (patch) | |
tree | f952dd40e26497af55a6a61cf9c42ea6baa7d6dc /cmd | |
parent | 87abfcba2283bfeb6636caf9aa2a72186d7708c4 (diff) |
Add libzfs_error_init() function
All fprintf() error messages are moved out of the libzfs_init()
library function where they never belonged in the first place. A
libzfs_error_init() function is added to provide useful error
messages for the most common causes of failure.
Additionally, in libzfs_run_process() the 'rc' variable was renamed
to 'error' for consistency with the rest of the code base.
Signed-off-by: Brian Behlendorf <[email protected]>
Signed-off-by: Chris Dunlap <[email protected]>
Signed-off-by: Richard Yao <[email protected]>
Diffstat (limited to 'cmd')
-rw-r--r-- | cmd/mount_zfs/mount_zfs.c | 4 | ||||
-rw-r--r-- | cmd/zdb/zdb.c | 4 | ||||
-rw-r--r-- | cmd/zfs/zfs_main.c | 4 | ||||
-rw-r--r-- | cmd/zinject/zinject.c | 4 | ||||
-rw-r--r-- | cmd/zpool/zpool_main.c | 4 |
5 files changed, 15 insertions, 5 deletions
diff --git a/cmd/mount_zfs/mount_zfs.c b/cmd/mount_zfs/mount_zfs.c index 6cdb668f5..0f4995943 100644 --- a/cmd/mount_zfs/mount_zfs.c +++ b/cmd/mount_zfs/mount_zfs.c @@ -473,8 +473,10 @@ main(int argc, char **argv) if (zfsflags & ZS_ZFSUTIL) zfsutil = 1; - if ((g_zfs = libzfs_init()) == NULL) + if ((g_zfs = libzfs_init()) == NULL) { + (void) fprintf(stderr, "%s", libzfs_error_init(errno)); return (MOUNT_SYSERR); + } /* try to open the dataset to access the mount point */ if ((zhp = zfs_open(g_zfs, dataset, diff --git a/cmd/zdb/zdb.c b/cmd/zdb/zdb.c index fc6e3fff0..6e75d0c21 100644 --- a/cmd/zdb/zdb.c +++ b/cmd/zdb/zdb.c @@ -3699,8 +3699,10 @@ main(int argc, char **argv) zfs_vdev_async_read_max_active = 10; kernel_init(FREAD); - if ((g_zfs = libzfs_init()) == NULL) + if ((g_zfs = libzfs_init()) == NULL) { + (void) fprintf(stderr, "%s", libzfs_error_init(errno)); return (1); + } if (dump_all) verbose = MAX(verbose, 1); diff --git a/cmd/zfs/zfs_main.c b/cmd/zfs/zfs_main.c index 32b9239b7..cd3bab9e1 100644 --- a/cmd/zfs/zfs_main.c +++ b/cmd/zfs/zfs_main.c @@ -6708,8 +6708,10 @@ main(int argc, char **argv) (strcmp(cmdname, "--help") == 0)) usage(B_TRUE); - if ((g_zfs = libzfs_init()) == NULL) + if ((g_zfs = libzfs_init()) == NULL) { + (void) fprintf(stderr, "%s", libzfs_error_init(errno)); return (1); + } mnttab_file = g_zfs->libzfs_mnttab; diff --git a/cmd/zinject/zinject.c b/cmd/zinject/zinject.c index f6c89159e..f64e50462 100644 --- a/cmd/zinject/zinject.c +++ b/cmd/zinject/zinject.c @@ -572,8 +572,10 @@ main(int argc, char **argv) int ret; int flags = 0; - if ((g_zfs = libzfs_init()) == NULL) + if ((g_zfs = libzfs_init()) == NULL) { + (void) fprintf(stderr, "%s", libzfs_error_init(errno)); return (1); + } libzfs_print_on_error(g_zfs, B_TRUE); diff --git a/cmd/zpool/zpool_main.c b/cmd/zpool/zpool_main.c index bf323ee08..5c28e8bb1 100644 --- a/cmd/zpool/zpool_main.c +++ b/cmd/zpool/zpool_main.c @@ -5919,8 +5919,10 @@ main(int argc, char **argv) if ((strcmp(cmdname, "-?") == 0) || strcmp(cmdname, "--help") == 0) usage(B_TRUE); - if ((g_zfs = libzfs_init()) == NULL) + if ((g_zfs = libzfs_init()) == NULL) { + (void) fprintf(stderr, "%s", libzfs_error_init(errno)); return (1); + } libzfs_print_on_error(g_zfs, B_TRUE); |