52244c0958bdf281ca42932b449f644b4decfdc2John Wren Kennedy * This file and its contents are supplied under the terms of the
52244c0958bdf281ca42932b449f644b4decfdc2John Wren Kennedy * Common Development and Distribution License ("CDDL"), version 1.0.
52244c0958bdf281ca42932b449f644b4decfdc2John Wren Kennedy * You may only use this file in accordance with the terms of version
52244c0958bdf281ca42932b449f644b4decfdc2John Wren Kennedy * 1.0 of the CDDL.
52244c0958bdf281ca42932b449f644b4decfdc2John Wren Kennedy * A full copy of the text of the CDDL should have accompanied this
52244c0958bdf281ca42932b449f644b4decfdc2John Wren Kennedy * source. A copy of the CDDL is also available via the Internet at
52244c0958bdf281ca42932b449f644b4decfdc2John Wren Kennedy * Copyright (c) 2014 by Delphix. All rights reserved.
52244c0958bdf281ca42932b449f644b4decfdc2John Wren Kennedy (void) fprintf(stderr, "malloc failed\n");
52244c0958bdf281ca42932b449f644b4decfdc2John Wren Kennedy (void) fprintf(stderr, "mkholes [-d|h offset:length] ... filename\n");
52244c0958bdf281ca42932b449f644b4decfdc2John Wren Kennedy * Fill the buffer from /dev/urandom to counteract the
52244c0958bdf281ca42932b449f644b4decfdc2John Wren Kennedy * effects of compression.
52244c0958bdf281ca42932b449f644b4decfdc2John Wren Kennedy if ((rand_fd = open("/dev/urandom", O_RDONLY)) < 0) {
52244c0958bdf281ca42932b449f644b4decfdc2John Wren Kennedypush_segment(list_t *seg_list, seg_type_t seg_type, char *optarg)
52244c0958bdf281ca42932b449f644b4decfdc2John Wren Kennedy usage("Ranges must ascend and may not overlap.", 1);
52244c0958bdf281ca42932b449f644b4decfdc2John Wren Kennedy seg = umem_alloc(sizeof (seg_t), UMEM_NOFAIL);
52244c0958bdf281ca42932b449f644b4decfdc2John Wren Kennedy list_create(&seg_list, sizeof (seg_t), offsetof(seg_t, seg_node));
52244c0958bdf281ca42932b449f644b4decfdc2John Wren Kennedy while ((c = getopt(argc, argv, "d:h:")) != -1) {
52244c0958bdf281ca42932b449f644b4decfdc2John Wren Kennedy push_segment(&seg_list, SEG_DATA, optarg);
52244c0958bdf281ca42932b449f644b4decfdc2John Wren Kennedy push_segment(&seg_list, SEG_HOLE, optarg);
52244c0958bdf281ca42932b449f644b4decfdc2John Wren Kennedy if ((fd = open(fname, O_LARGEFILE | O_RDWR | O_CREAT | O_SYNC,
52244c0958bdf281ca42932b449f644b4decfdc2John Wren Kennedy 00666)) < 0) {
52244c0958bdf281ca42932b449f644b4decfdc2John Wren Kennedy while ((seg = list_remove_head(&seg_list)) != NULL) {
52244c0958bdf281ca42932b449f644b4decfdc2John Wren Kennedy buf = (char *)umem_alloc(readlen, UMEM_NOFAIL);
52244c0958bdf281ca42932b449f644b4decfdc2John Wren Kennedy vbuf = (char *)umem_zalloc(readlen, UMEM_NOFAIL);
52244c0958bdf281ca42932b449f644b4decfdc2John Wren Kennedy ssize_t bytes = pread(fd, buf, readlen, off);
52244c0958bdf281ca42932b449f644b4decfdc2John Wren Kennedy "didn't match.\n");
52244c0958bdf281ca42932b449f644b4decfdc2John Wren Kennedy vbuf = (char *)umem_alloc(len, UMEM_NOFAIL);
52244c0958bdf281ca42932b449f644b4decfdc2John Wren Kennedy (void) fprintf(stderr, "Read back buf didn't "