2 * Copyright (c) 1998-2001 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
6 * The contents of this file constitute Original Code as defined in and
7 * are subject to the Apple Public Source License Version 1.2 (the
8 * "License"). You may not use this file except in compliance with the
9 * License. Please obtain a copy of the License at
10 * http://www.apple.com/publicsource and read it before using this file.
12 * This Original Code and all software distributed under the License are
13 * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
14 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
15 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
17 * License for the specific language governing rights and limitations
20 * @APPLE_LICENSE_HEADER_END@
23 * Author: Avadis Tevanian, Jr.
25 * File system exerciser.
27 * Rewrite and enhancements 1998-2001 Conrad Minshall -- conrad@mac.com
29 * Various features from Joe Sokol, Pat Dirks, and Clark Warner.
31 * Small changes to work under Linux -- davej@suse.de
33 * Sundry porting patches from Guy Harris 12/2001
35 * Checks for mmap last-page zero fill.
37 * $FreeBSD: src/tools/regression/fsx/fsx.c,v 1.2 2003/04/23 23:42:23 jkh Exp $
38 * $DragonFly: src/test/stress/fsx/fsx.c,v 1.2 2005/05/02 19:31:56 dillon Exp $
42 #include <sys/types.h>
45 # include <sys/param.h>
65 #define NUMPRINTCOLUMNS 32 /* # columns of data to print on each line */
68 * A log entry is an operation and a bunch of arguments.
78 struct log_entry oplog[LOGSIZE]; /* the log */
79 int logptr = 0; /* current position in log */
80 int logcount = 0; /* total ops */
91 #define OP_CLOSEOPEN 4
99 char *original_buf; /* a pointer to the original data */
100 char *good_buf; /* a pointer to the correct data */
101 char *temp_buf; /* a pointer to the current data */
102 char *fname; /* name of our test file */
103 int fd; /* fd for our test file */
108 unsigned long testcalls = 0; /* calls to function "test" */
110 unsigned long simulatedopcount = 0; /* -b flag */
111 int closeprob = 0; /* -c flag */
112 int debug = 0; /* -d flag */
113 unsigned long debugstart = 0; /* -D flag */
114 unsigned long maxfilelen = 256 * 1024; /* -l flag */
115 int sizechecks = 1; /* -n flag disables them */
116 int maxoplen = 64 * 1024; /* -o flag */
117 int quiet = 0; /* -q flag */
118 unsigned long progressinterval = 0; /* -p flag */
119 int readbdy = 1; /* -r flag */
120 int style = 0; /* -s flag */
121 int truncbdy = 1; /* -t flag */
122 int writebdy = 1; /* -w flag */
123 long monitorstart = -1; /* -m flag */
124 long monitorend = -1; /* -m flag */
125 int lite = 0; /* -L flag */
126 long numops = -1; /* -N flag */
127 int randomoplen = 1; /* -O flag disables it */
128 int seed = 1; /* -S flag */
129 int mapped_writes = 1; /* -W flag disables */
130 int mapped_reads = 1; /* -R flag disables it */
132 FILE * fsxlogf = NULL;
138 vwarnc(code, fmt, ap)
143 fprintf(stderr, "fsx: ");
145 vfprintf(stderr, fmt, ap);
146 fprintf(stderr, ": ");
148 fprintf(stderr, "%s\n", strerror(code));
153 warn(const char * fmt, ...)
157 vwarnc(errno, fmt, ap);
168 vfprintf(stdout, fmt, args);
170 vfprintf(fsxlogf, fmt, args);
177 prt("%s%s%s\n", prefix, prefix ? ": " : "", strerror(errno));
182 log4(int operation, int arg0, int arg1, int arg2)
184 struct log_entry *le;
187 le->operation = operation;
189 le->operation = ~ le->operation;
195 if (logptr >= LOGSIZE)
204 struct log_entry *lp;
206 prt("LOG DUMP (%d total operations):\n", logcount);
207 if (logcount < LOGSIZE) {
214 for ( ; count > 0; count--) {
217 opnum = i+1 + (logcount/LOGSIZE)*LOGSIZE;
218 prt("%d(%d mod 256): ", opnum, opnum%256);
220 if ((closeopen = lp->operation < 0))
221 lp->operation = ~ lp->operation;
223 switch (lp->operation) {
225 prt("MAPREAD\t0x%x thru 0x%x\t(0x%x bytes)",
226 lp->args[0], lp->args[0] + lp->args[1] - 1,
228 if (badoff >= lp->args[0] && badoff <
229 lp->args[0] + lp->args[1])
233 prt("MAPWRITE 0x%x thru 0x%x\t(0x%x bytes)",
234 lp->args[0], lp->args[0] + lp->args[1] - 1,
236 if (badoff >= lp->args[0] && badoff <
237 lp->args[0] + lp->args[1])
241 prt("READ\t0x%x thru 0x%x\t(0x%x bytes)",
242 lp->args[0], lp->args[0] + lp->args[1] - 1,
244 if (badoff >= lp->args[0] &&
245 badoff < lp->args[0] + lp->args[1])
249 prt("WRITE\t0x%x thru 0x%x\t(0x%x bytes)",
250 lp->args[0], lp->args[0] + lp->args[1] - 1,
252 if (lp->args[0] > lp->args[2])
254 else if (lp->args[0] + lp->args[1] > lp->args[2])
256 if ((badoff >= lp->args[0] || badoff >=lp->args[2]) &&
257 badoff < lp->args[0] + lp->args[1])
261 down = lp->args[0] < lp->args[1];
262 prt("TRUNCATE %s\tfrom 0x%x to 0x%x",
263 down ? "DOWN" : "UP", lp->args[1], lp->args[0]);
264 if (badoff >= lp->args[!down] &&
265 badoff < lp->args[!!down])
269 prt("SKIPPED (no operation)");
272 prt("BOGUS LOG ENTRY (operation code = %d)!",
276 prt("\n\t\tCLOSE/OPEN");
286 save_buffer(char *buffer, off_t bufferlength, int fd)
289 ssize_t byteswritten;
291 if (fd <= 0 || bufferlength == 0)
294 if (bufferlength > SSIZE_MAX) {
295 prt("fsx flaw: overflow in save_buffer\n");
299 off_t size_by_seek = lseek(fd, (off_t)0, SEEK_END);
300 if (size_by_seek == (off_t)-1)
301 prterr("save_buffer: lseek eof");
302 else if (bufferlength > size_by_seek) {
303 warn("save_buffer: .fsxgood file too short... "
304 "will save 0x%jx bytes instead of 0x%llx\n",
305 (intmax_t)size_by_seek,
306 (intmax_t)bufferlength);
307 bufferlength = size_by_seek;
311 ret = lseek(fd, (off_t)0, SEEK_SET);
312 if (ret == (off_t)-1)
313 prterr("save_buffer: lseek 0");
315 byteswritten = write(fd, buffer, (size_t)bufferlength);
316 if (byteswritten != bufferlength) {
317 if (byteswritten == -1)
318 prterr("save_buffer write");
320 warn("save_buffer: short write, "
321 "0x%x bytes instead of 0x%jx\n",
322 (unsigned)byteswritten,
323 (intmax_t)bufferlength);
329 report_failure(int status)
335 save_buffer(good_buf, file_size, fsxgoodfd);
336 prt("Correct content saved for comparison\n");
337 prt("(maybe hexdump \"%s\" vs \"%s.fsxgood\")\n",
346 #define short_at(cp) ((unsigned short)((*((unsigned char *)(cp)) << 8) | \
347 *(((unsigned char *)(cp)) + 1)))
350 check_buffers(unsigned offset, unsigned size)
358 if (memcmp(good_buf + offset, temp_buf, size) != 0) {
359 prt("READ BAD DATA: offset = 0x%x, size = 0x%x\n",
361 prt("OFFSET\tGOOD\tBAD\tRANGE\n");
363 c = good_buf[offset];
367 bad = short_at(&temp_buf[i]);
368 prt("0x%5x\t0x%04x\t0x%04x", offset,
369 short_at(&good_buf[offset]), bad);
370 op = temp_buf[offset & 1 ? i+1 : i];
382 prt("operation# (mod 256) for the bad data may be %u\n", ((unsigned)op & 0xff));
384 prt("operation# (mod 256) for the bad data unknown, check HOLE and EXTEND ops\n");
386 prt("????????????????\n");
398 if (fstat(fd, &statbuf)) {
399 prterr("check_size: fstat");
400 statbuf.st_size = -1;
402 size_by_seek = lseek(fd, (off_t)0, SEEK_END);
403 if (file_size != statbuf.st_size || file_size != size_by_seek) {
404 prt("Size error: expected 0x%llx stat 0x%llx seek 0x%llx\n",
405 (unsigned long long)file_size,
406 (unsigned long long)statbuf.st_size,
407 (unsigned long long)size_by_seek);
414 check_trunc_hack(void)
418 ftruncate(fd, (off_t)0);
419 ftruncate(fd, (off_t)100000);
421 if (statbuf.st_size != (off_t)100000) {
422 prt("no extend on truncate! not posix!\n");
425 ftruncate(fd, (off_t)0);
430 doread(unsigned offset, unsigned size)
435 offset -= offset % readbdy;
437 if (!quiet && testcalls > simulatedopcount)
438 prt("skipping zero size read\n");
439 log4(OP_SKIPPED, OP_READ, offset, size);
442 if (size + offset > file_size) {
443 if (!quiet && testcalls > simulatedopcount)
444 prt("skipping seek/read past end of file\n");
445 log4(OP_SKIPPED, OP_READ, offset, size);
449 log4(OP_READ, offset, size, 0);
451 if (testcalls <= simulatedopcount)
454 if (!quiet && ((progressinterval &&
455 testcalls % progressinterval == 0) ||
457 (monitorstart == -1 ||
458 (offset + size > monitorstart &&
459 (monitorend == -1 || offset <= monitorend))))))
460 prt("%lu read\t0x%x thru\t0x%x\t(0x%x bytes)\n", testcalls,
461 offset, offset + size - 1, size);
462 ret = lseek(fd, (off_t)offset, SEEK_SET);
463 if (ret == (off_t)-1) {
464 prterr("doread: lseek");
467 iret = read(fd, temp_buf, size);
470 prterr("doread: read");
472 prt("short read: 0x%x bytes instead of 0x%x\n",
476 check_buffers(offset, size);
481 check_eofpage(char *s, unsigned offset, char *p, int size)
483 intptr_t last_page, should_be_zero;
485 if (offset + size <= (file_size & ~page_mask))
488 * we landed in the last page of the file
489 * test to make sure the VM system provided 0's
490 * beyond the true end of the file mapping
491 * (as required by mmap def in 1996 posix 1003.1)
493 last_page = ((intptr_t)p + (offset & page_mask) + size) & ~(intptr_t)page_mask;
495 for (should_be_zero = last_page + (file_size & page_mask);
496 should_be_zero < last_page + page_size;
498 if (*(char *)should_be_zero) {
499 prt("Mapped %s: non-zero data past EOF (0x%llx) page offset 0x%x is 0x%04x\n",
500 s, file_size - 1, should_be_zero & page_mask,
501 *(char *)(should_be_zero));
509 domapread(unsigned offset, unsigned size)
515 offset -= offset % readbdy;
517 if (!quiet && testcalls > simulatedopcount)
518 prt("skipping zero size read\n");
519 log4(OP_SKIPPED, OP_MAPREAD, offset, size);
522 if (size + offset > file_size) {
523 if (!quiet && testcalls > simulatedopcount)
524 prt("skipping seek/read past end of file\n");
525 log4(OP_SKIPPED, OP_MAPREAD, offset, size);
529 log4(OP_MAPREAD, offset, size, 0);
531 if (testcalls <= simulatedopcount)
534 if (!quiet && ((progressinterval &&
535 testcalls % progressinterval == 0) ||
537 (monitorstart == -1 ||
538 (offset + size > monitorstart &&
539 (monitorend == -1 || offset <= monitorend))))))
540 prt("%lu mapread\t0x%x thru\t0x%x\t(0x%x bytes)\n", testcalls,
541 offset, offset + size - 1, size);
543 pg_offset = offset & page_mask;
544 map_size = pg_offset + size;
546 if ((p = (char *)mmap(0, map_size, PROT_READ, MAP_FILE | MAP_SHARED, fd,
547 (off_t)(offset - pg_offset))) == (char *)-1) {
548 prterr("domapread: mmap");
551 if (setjmp(jmpbuf) == 0) {
553 memcpy(temp_buf, p + pg_offset, size);
554 check_eofpage("Read", offset, p, size);
557 report_failure(1901);
560 if (munmap(p, map_size) != 0) {
561 prterr("domapread: munmap");
565 check_buffers(offset, size);
570 gendata(char *original_buf, char *good_buf, unsigned offset, unsigned size)
573 good_buf[offset] = testcalls % 256;
575 good_buf[offset] += original_buf[offset];
582 dowrite(unsigned offset, unsigned size)
587 offset -= offset % writebdy;
589 if (!quiet && testcalls > simulatedopcount)
590 prt("skipping zero size write\n");
591 log4(OP_SKIPPED, OP_WRITE, offset, size);
595 log4(OP_WRITE, offset, size, file_size);
597 gendata(original_buf, good_buf, offset, size);
598 if (file_size < offset + size) {
599 if (file_size < offset)
600 memset(good_buf + file_size, '\0', offset - file_size);
601 file_size = offset + size;
603 warn("Lite file size bug in fsx!");
608 if (testcalls <= simulatedopcount)
611 if (!quiet && ((progressinterval &&
612 testcalls % progressinterval == 0) ||
614 (monitorstart == -1 ||
615 (offset + size > monitorstart &&
616 (monitorend == -1 || offset <= monitorend))))))
617 prt("%lu write\t0x%x thru\t0x%x\t(0x%x bytes)\n", testcalls,
618 offset, offset + size - 1, size);
619 ret = lseek(fd, (off_t)offset, SEEK_SET);
620 if (ret == (off_t)-1) {
621 prterr("dowrite: lseek");
624 iret = write(fd, good_buf + offset, size);
627 prterr("dowrite: write");
629 prt("short write: 0x%x bytes instead of 0x%x\n",
637 domapwrite(unsigned offset, unsigned size)
644 offset -= offset % writebdy;
646 if (!quiet && testcalls > simulatedopcount)
647 prt("skipping zero size write\n");
648 log4(OP_SKIPPED, OP_MAPWRITE, offset, size);
651 cur_filesize = file_size;
653 log4(OP_MAPWRITE, offset, size, 0);
655 gendata(original_buf, good_buf, offset, size);
656 if (file_size < offset + size) {
657 if (file_size < offset)
658 memset(good_buf + file_size, '\0', offset - file_size);
659 file_size = offset + size;
661 warn("Lite file size bug in fsx!");
666 if (testcalls <= simulatedopcount)
669 if (!quiet && ((progressinterval &&
670 testcalls % progressinterval == 0) ||
672 (monitorstart == -1 ||
673 (offset + size > monitorstart &&
674 (monitorend == -1 || offset <= monitorend))))))
675 prt("%lu mapwrite\t0x%x thru\t0x%x\t(0x%x bytes)\n", testcalls,
676 offset, offset + size - 1, size);
678 if (file_size > cur_filesize) {
679 if (ftruncate(fd, file_size) == -1) {
680 prterr("domapwrite: ftruncate");
684 pg_offset = offset & page_mask;
685 map_size = pg_offset + size;
687 if ((p = (char *)mmap(0, map_size, PROT_READ | PROT_WRITE,
688 MAP_FILE | MAP_SHARED, fd,
689 (off_t)(offset - pg_offset))) == (char *)-1) {
690 prterr("domapwrite: mmap");
693 if (setjmp(jmpbuf) == 0) {
695 memcpy(p + pg_offset, good_buf + offset, size);
696 if (msync(p, map_size, 0) != 0) {
697 prterr("domapwrite: msync");
700 check_eofpage("Write", offset, p, size);
703 report_failure(2021);
706 if (munmap(p, map_size) != 0) {
707 prterr("domapwrite: munmap");
714 dotruncate(unsigned size)
716 int oldsize = file_size;
718 size -= size % truncbdy;
719 if (size > biggest) {
721 if (!quiet && testcalls > simulatedopcount)
722 prt("truncating to largest ever: 0x%x\n", size);
725 log4(OP_TRUNCATE, size, (unsigned)file_size, 0);
727 if (size > file_size)
728 memset(good_buf + file_size, '\0', size - file_size);
731 if (testcalls <= simulatedopcount)
734 if ((progressinterval && testcalls % progressinterval == 0) ||
735 (debug && (monitorstart == -1 || monitorend == -1 ||
736 size <= monitorend)))
737 prt("%lu trunc\tfrom 0x%x to 0x%x\n", testcalls, oldsize, size);
738 if (ftruncate(fd, (off_t)size) == -1) {
739 prt("ftruncate1: %x\n", size);
740 prterr("dotruncate: ftruncate");
751 if (lseek(fd, (off_t)0, SEEK_SET) == (off_t)-1) {
752 prterr("writefileimage: lseek");
755 iret = write(fd, good_buf, file_size);
756 if ((off_t)iret != file_size) {
758 prterr("writefileimage: write");
760 prt("short write: 0x%x bytes instead of 0x%jx\n",
761 iret, (intmax_t)file_size);
764 if (lite ? 0 : ftruncate(fd, file_size) == -1) {
765 prt("ftruncate2: %jx\n", (intmax_t)file_size);
766 prterr("writefileimage: ftruncate");
775 if (testcalls <= simulatedopcount)
779 prt("%lu close/open\n", testcalls);
781 prterr("docloseopen: close");
784 fd = open(fname, O_RDWR, 0);
786 prterr("docloseopen: open");
795 unsigned long offset;
796 unsigned long size = maxoplen;
797 unsigned long rv = random();
798 unsigned long op = rv % (3 + !lite + mapped_writes);
800 /* turn off the map read if necessary */
802 if (op == 2 && !mapped_reads)
805 if (simulatedopcount > 0 && testcalls == simulatedopcount)
811 closeopen = (rv >> 3) < (1 << 28) / closeprob;
813 if (debugstart > 0 && testcalls >= debugstart)
816 if (!quiet && testcalls < simulatedopcount && testcalls % 100000 == 0)
817 prt("%lu...\n", testcalls);
824 * MAPWRITE: op = 3 or 4
826 if (lite ? 0 : op == 3 && style == 0) /* vanilla truncate? */
827 dotruncate(random() % maxfilelen);
830 size = random() % (maxoplen+1);
831 if (lite ? 0 : op == 3)
835 if (op == 1 || op == (lite ? 3 : 4)) {
836 offset %= maxfilelen;
837 if (offset + size > maxfilelen)
838 size = maxfilelen - offset;
840 domapwrite(offset, size);
842 dowrite(offset, size);
848 if (offset + size > file_size)
849 size = file_size - offset;
851 domapread(offset, size);
853 doread(offset, size);
857 if (sizechecks && testcalls > simulatedopcount)
870 report_failure(9999);
878 prt("signal %d\n", sig);
879 prt("testcalls = %lu\n", testcalls);
887 fprintf(stdout, "usage: %s",
888 "fsx [-dnqLOW] [-b opnum] [-c Prob] [-l flen] [-m start:end] [-o oplen] [-p progressinterval] [-r readbdy] [-s style] [-t truncbdy] [-w writebdy] [-D startingop] [-N numops] [-P dirpath] [-S seed] fname\n\
889 -b opnum: beginning operation number (default 1)\n\
890 -c P: 1 in P chance of file close+open at each op (default infinity)\n\
891 -d: debug output for all operations\n\
892 -l flen: the upper bound on file size (default 262144)\n\
893 -m startop:endop: monitor (print debug output) specified byte range (default 0:infinity)\n\
894 -n: no verifications of file size\n\
895 -o oplen: the upper bound on operation size (default 65536)\n\
896 -p progressinterval: debug output at specified operation interval\n\
897 -q: quieter operation\n\
898 -r readbdy: 4096 would make reads page aligned (default 1)\n\
899 -s style: 1 gives smaller truncates (default 0)\n\
900 -t truncbdy: 4096 would make truncates page aligned (default 1)\n\
901 -w writebdy: 4096 would make writes page aligned (default 1)\n\
902 -D startingop: debug output starting at specified operation\n\
903 -L: fsxLite - no file creations & no file size changes\n\
904 -N numops: total # operations to do (default infinity)\n\
905 -O: use oplen (see -o flag) for every op (default random)\n\
906 -P dirpath: save .fsxlog and .fsxgood files in dirpath (default ./)\n\
907 -S seed: for random # generator (default 1) 0 gets timestamp\n\
908 -W: mapped write operations DISabled\n\
909 -R: mapped read operations DISabled)\n\
910 fname: this filename is REQUIRED (no default)\n");
916 getnum(char *s, char **e)
921 ret = strtol(s, e, 0);
950 main(int argc, char **argv)
960 page_size = getpagesize();
961 page_mask = page_size - 1;
963 setvbuf(stdout, NULL, _IOLBF, 0); /* line buffered stdout */
965 while ((ch = getopt(argc, argv, "b:c:dl:m:no:p:qr:s:t:w:D:LN:OP:RS:W"))
969 simulatedopcount = getnum(optarg, &endp);
971 fprintf(stdout, "Will begin at operation %ld\n",
973 if (simulatedopcount == 0)
975 simulatedopcount -= 1;
978 closeprob = getnum(optarg, &endp);
981 "Chance of close/open is 1 in %d\n",
990 maxfilelen = getnum(optarg, &endp);
995 monitorstart = getnum(optarg, &endp);
996 if (monitorstart < 0)
998 if (!endp || *endp++ != ':')
1000 monitorend = getnum(endp, &endp);
1003 if (monitorend == 0)
1004 monitorend = -1; /* aka infinity */
1010 maxoplen = getnum(optarg, &endp);
1015 progressinterval = getnum(optarg, &endp);
1016 if (progressinterval < 0)
1023 readbdy = getnum(optarg, &endp);
1028 style = getnum(optarg, &endp);
1029 if (style < 0 || style > 1)
1033 truncbdy = getnum(optarg, &endp);
1038 writebdy = getnum(optarg, &endp);
1043 debugstart = getnum(optarg, &endp);
1051 numops = getnum(optarg, &endp);
1059 strncpy(goodfile, optarg, sizeof(goodfile));
1060 strcat(goodfile, "/");
1061 strncpy(logfile, optarg, sizeof(logfile));
1062 strcat(logfile, "/");
1068 seed = getnum(optarg, &endp);
1070 seed = time(0) % 10000;
1072 fprintf(stdout, "Seed set to %d\n", seed);
1079 fprintf(stdout, "mapped writes DISABLED\n");
1092 signal(SIGHUP, cleanup);
1093 signal(SIGINT, cleanup);
1094 signal(SIGPIPE, cleanup);
1095 signal(SIGALRM, cleanup);
1096 signal(SIGTERM, cleanup);
1097 signal(SIGXCPU, cleanup);
1098 signal(SIGXFSZ, cleanup);
1099 signal(SIGVTALRM, cleanup);
1100 signal(SIGUSR1, cleanup);
1101 signal(SIGUSR2, cleanup);
1102 signal(SIGSEGV, segv);
1104 initstate(seed, state, 256);
1106 fd = open(fname, O_RDWR|(lite ? 0 : O_CREAT|O_TRUNC), 0666);
1111 strncat(goodfile, fname, 256);
1112 strcat (goodfile, ".fsxgood");
1113 fsxgoodfd = open(goodfile, O_RDWR|O_CREAT|O_TRUNC, 0666);
1114 if (fsxgoodfd < 0) {
1118 strncat(logfile, fname, 256);
1119 strcat (logfile, ".fsxlog");
1120 fsxlogf = fopen(logfile, "w");
1121 if (fsxlogf == NULL) {
1127 file_size = maxfilelen = lseek(fd, (off_t)0, SEEK_END);
1128 if (file_size == (off_t)-1) {
1130 warn("main: lseek eof");
1133 ret = lseek(fd, (off_t)0, SEEK_SET);
1134 if (ret == (off_t)-1) {
1136 warn("main: lseek 0");
1140 original_buf = (char *) malloc(maxfilelen);
1141 for (i = 0; i < maxfilelen; i++)
1142 original_buf[i] = random() % 256;
1143 good_buf = (char *) malloc(maxfilelen);
1144 memset(good_buf, '\0', maxfilelen);
1145 temp_buf = (char *) malloc(maxoplen);
1146 memset(temp_buf, '\0', maxoplen);
1147 if (lite) { /* zero entire existing file */
1150 written = write(fd, good_buf, (size_t)maxfilelen);
1151 if (written != maxfilelen) {
1152 if (written == -1) {
1154 warn("main: error on write");
1156 warn("main: short write, 0x%x bytes instead of 0x%x\n",
1157 (unsigned)written, maxfilelen);
1163 while (numops == -1 || numops--)
1170 prt("All operations completed A-OK!\n");