mirror of
https://git.proxmox.com/git/mirror_zfs.git
synced 2026-05-24 03:08:51 +03:00
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 <behlendorf1@llnl.gov> Signed-off-by: Chris Dunlap <cdunlap@llnl.gov> Signed-off-by: Richard Yao <ryao@gentoo.org>
This commit is contained in:
@@ -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,
|
||||
|
||||
+3
-1
@@ -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);
|
||||
|
||||
+3
-1
@@ -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;
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user