X-Git-Url: https://git.camperquake.de/gitweb.cgi?a=blobdiff_plain;f=cmd%2Fzinject%2Fzinject.c;h=d584eadd82650c63c853bcc07ee0c0a638b0dedd;hb=e8fd45a0f975c6b8ae8cd644714fc21f14fac2bf;hp=ab04e422a9b2b8a460abadd377300957f6ed8838;hpb=428870ff734fdaccc342b33fc53cf94724409a46;p=zfs.git diff --git a/cmd/zinject/zinject.c b/cmd/zinject/zinject.c index ab04e42..d584ead 100644 --- a/cmd/zinject/zinject.c +++ b/cmd/zinject/zinject.c @@ -233,7 +233,7 @@ usage(void) "\t\tInject a fault into a particular device or the device's\n" "\t\tlabel. Label injection can either be 'nvlist', 'uber',\n " "\t\t'pad1', or 'pad2'.\n" - "\t\t'errno' can either be 'nxio' (the default) or 'io'.\n" + "\t\t'errno' can be 'nxio' (the default), 'io', or 'dtl'.\n" "\n" "\tzinject -d device -A pool\n" "\t\tPerform a specific action on a particular device\n" @@ -395,17 +395,25 @@ print_panic_handler(int id, const char *pool, zinject_record_t *record, static int print_all_handlers(void) { - int count = 0; + int count = 0, total = 0; (void) iter_handlers(print_device_handler, &count); - (void) printf("\n"); - count = 0; + if (count > 0) { + total += count; + (void) printf("\n"); + count = 0; + } + (void) iter_handlers(print_data_handler, &count); - (void) printf("\n"); - count = 0; + if (count > 0) { + total += count; + (void) printf("\n"); + count = 0; + } + (void) iter_handlers(print_panic_handler, &count); - return (count); + return (count + total); } /* ARGSUSED */ @@ -558,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 @@ -627,6 +622,8 @@ main(int argc, char **argv) error = ECKSUM; } else if (strcasecmp(optarg, "nxio") == 0) { error = ENXIO; + } else if (strcasecmp(optarg, "dtl") == 0) { + error = ECHILD; } else { (void) fprintf(stderr, "invalid error type " "'%s': must be 'io', 'checksum' or " @@ -755,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. @@ -944,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); }