summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrian Behlendorf <[email protected]>2013-05-01 09:38:49 -0700
committerBrian Behlendorf <[email protected]>2013-05-01 17:05:58 -0700
commit937210a54b9c2d3dddc7221e31d5695e9720a055 (patch)
treeb65da5a5832c1d54f7e568e8af1f76f2bad59b6c
parentcc92e9d0c3e67a7e66c844466f85696a087bf60a (diff)
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 <[email protected]>
-rw-r--r--cmd/zinject/zinject.c20
1 files changed, 10 insertions, 10 deletions
diff --git a/cmd/zinject/zinject.c b/cmd/zinject/zinject.c
index 9ae3f9ddc..13d067dc5 100644
--- a/cmd/zinject/zinject.c
+++ b/cmd/zinject/zinject.c
@@ -574,6 +574,16 @@ main(int argc, char **argv)
int ret;
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) {
/*
* No arguments. Print the available handlers. If there are no
@@ -764,16 +774,6 @@ main(int argc, char **argv)
argc -= 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)
record.zi_cmd = ZINJECT_IGNORED_WRITES;