Fix zinject list handlers

The zfs_fd must be opened before calling print_all_handlers() or
the ioctl() cannot be used to the zfs control device.  This brings
the zinject code back in sync with the Illumos implementation.

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
This commit is contained in:
Brian Behlendorf 2013-05-01 09:38:49 -07:00
parent cc92e9d0c3
commit 937210a54b
1 changed files with 10 additions and 10 deletions

View File

@ -574,6 +574,16 @@ main(int argc, char **argv)
int ret; int ret;
int flags = 0; int flags = 0;
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 (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
@ -764,16 +774,6 @@ 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 (record.zi_duration != 0) if (record.zi_duration != 0)
record.zi_cmd = ZINJECT_IGNORED_WRITES; record.zi_cmd = ZINJECT_IGNORED_WRITES;