Merge branch 'linux-user-util' into refs/top-bases/linux-zfs-branch

This commit is contained in:
Brian Behlendorf 2010-05-21 10:49:47 -07:00
commit 14152c7b2c
6 changed files with 37 additions and 36 deletions

View File

@ -2394,8 +2394,8 @@ main(int argc, char **argv)
} }
kernel_init(FREAD); kernel_init(FREAD);
g_zfs = libzfs_init(); if ((g_zfs = libzfs_init()) == NULL)
ASSERT(g_zfs != NULL); return (1);
for (c = 0; c < 256; c++) { for (c = 0; c < 256; c++) {
if (dump_all && c != 'l' && c != 'R') if (dump_all && c != 'l' && c != 'R')

View File

@ -4063,17 +4063,6 @@ main(int argc, char **argv)
opterr = 0; opterr = 0;
if ((g_zfs = libzfs_init()) == NULL) {
(void) fprintf(stderr, gettext("internal error: failed to "
"initialize ZFS library\n"));
return (1);
}
zpool_set_history_str("zfs", argc, argv, history_str);
verify(zpool_stage_history(g_zfs, history_str) == 0);
libzfs_print_on_error(g_zfs, B_TRUE);
if ((mnttab_file = fopen(MNTTAB, "r")) == NULL) { if ((mnttab_file = fopen(MNTTAB, "r")) == NULL) {
(void) fprintf(stderr, gettext("internal error: unable to " (void) fprintf(stderr, gettext("internal error: unable to "
"open %s\n"), MNTTAB); "open %s\n"), MNTTAB);
@ -4119,9 +4108,18 @@ main(int argc, char **argv)
/* /*
* Special case '-?' * Special case '-?'
*/ */
if (strcmp(cmdname, "-?") == 0) if ((strcmp(cmdname, "-?") == 0) ||
(strcmp(cmdname, "--help") == 0))
usage(B_TRUE); usage(B_TRUE);
if ((g_zfs = libzfs_init()) == NULL)
return (1);
zpool_set_history_str("zfs", argc, argv, history_str);
verify(zpool_stage_history(g_zfs, history_str) == 0);
libzfs_print_on_error(g_zfs, B_TRUE);
/* /*
* 'volinit' and 'volfini' do not appear in the usage message, * 'volinit' and 'volfini' do not appear in the usage message,
* so we have to special case them here. * so we have to special case them here.

View File

@ -486,19 +486,6 @@ main(int argc, char **argv)
int ret; int ret;
int flags = 0; int flags = 0;
if ((g_zfs = libzfs_init()) == NULL) {
(void) fprintf(stderr, "internal error: failed to "
"initialize ZFS library\n");
return (1);
}
libzfs_print_on_error(g_zfs, B_TRUE);
if ((zfs_fd = open(ZFS_DEV, O_RDWR)) < 0) {
(void) fprintf(stderr, "failed to open ZFS device\n");
return (1);
}
if (argc == 1) { if (argc == 1) {
/* /*
* No arguments. Print the available handlers. If there are no * No arguments. Print the available handlers. If there are no
@ -612,6 +599,16 @@ main(int argc, char **argv)
argc -= optind; argc -= optind;
argv += optind; argv += optind;
if ((g_zfs = libzfs_init()) == NULL)
return (1);
libzfs_print_on_error(g_zfs, B_TRUE);
if ((zfs_fd = open(ZFS_DEV, O_RDWR)) < 0) {
(void) fprintf(stderr, "failed to open ZFS device\n");
return (1);
}
if (cancel != NULL) { if (cancel != NULL) {
/* /*
* '-c' is invalid with any other options. * '-c' is invalid with any other options.

View File

@ -4254,14 +4254,6 @@ main(int argc, char **argv)
(void) setlocale(LC_ALL, ""); (void) setlocale(LC_ALL, "");
(void) textdomain(TEXT_DOMAIN); (void) textdomain(TEXT_DOMAIN);
if ((g_zfs = libzfs_init()) == NULL) {
(void) fprintf(stderr, gettext("internal error: failed to "
"initialize ZFS library\n"));
return (1);
}
libzfs_print_on_error(g_zfs, B_TRUE);
opterr = 0; opterr = 0;
/* /*
@ -4277,9 +4269,15 @@ main(int argc, char **argv)
/* /*
* Special case '-?' * Special case '-?'
*/ */
if (strcmp(cmdname, "-?") == 0) if ((strcmp(cmdname, "-?") == 0) ||
strcmp(cmdname, "--help") == 0)
usage(B_TRUE); usage(B_TRUE);
if ((g_zfs = libzfs_init()) == NULL)
return (1);
libzfs_print_on_error(g_zfs, B_TRUE);
zpool_set_history_str("zpool", argc, argv, history_str); zpool_set_history_str("zpool", argc, argv, history_str);
verify(zpool_stage_history(g_zfs, history_str) == 0); verify(zpool_stage_history(g_zfs, history_str) == 0);

View File

@ -39,6 +39,7 @@
#include <sys/mntent.h> #include <sys/mntent.h>
#include <sys/mnttab.h> #include <sys/mnttab.h>
#include <sys/avl.h> #include <sys/avl.h>
#include <sys/debug.h>
#include <stddef.h> #include <stddef.h>
#include <libzfs.h> #include <libzfs.h>

View File

@ -579,6 +579,13 @@ libzfs_init(void)
} }
if ((hdl->libzfs_fd = open(ZFS_DEV, O_RDWR)) < 0) { if ((hdl->libzfs_fd = open(ZFS_DEV, O_RDWR)) < 0) {
(void) fprintf(stderr, gettext("Unable to open %s: %s.\n"),
ZFS_DEV, strerror(errno));
if (errno == ENOENT)
(void) fprintf(stderr,
gettext("Verify the ZFS module stack is "
"loaded by running '/sbin/modprobe zfs'.\n"));
free(hdl); free(hdl);
return (NULL); return (NULL);
} }