Revert "Temporarily disable the reguid test."
[zfs.git] / cmd / zinject / zinject.c
index 60c53ce..d584ead 100644 (file)
@@ -566,26 +566,13 @@ main(int argc, char **argv)
        zinject_record_t record = { 0 };
        char pool[MAXNAMELEN];
        char dataset[MAXNAMELEN];
-       zfs_handle_t *zhp;
+       zfs_handle_t *zhp = NULL;
        int nowrites = 0;
        int dur_txg = 0;
        int dur_secs = 0;
        int ret;
        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) {
                /*
                 * No arguments.  Print the available handlers.  If there are no
@@ -765,6 +752,16 @@ 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 (cancel != NULL) {
                /*
                 * '-c' is invalid with any other options.
@@ -954,7 +951,6 @@ main(int argc, char **argv)
        if (dataset[0] != '\0' && domount) {
                if ((zhp = zfs_open(g_zfs, dataset, ZFS_TYPE_DATASET)) == NULL)
                        return (1);
-
                if (zfs_unmount(zhp, NULL, 0) != 0)
                        return (1);
        }