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... will save 0x%llx bytes instead of 0x%llx\n", (unsigned long long)size_by_seek,
304 (unsigned long long)bufferlength);
305 bufferlength = size_by_seek;
309 ret = lseek(fd, (off_t)0, SEEK_SET);
310 if (ret == (off_t)-1)
311 prterr("save_buffer: lseek 0");
313 byteswritten = write(fd, buffer, (size_t)bufferlength);
314 if (byteswritten != bufferlength) {
315 if (byteswritten == -1)
316 prterr("save_buffer write");
318 warn("save_buffer: short write, 0x%x bytes instead of 0x%llx\n",
319 (unsigned)byteswritten,
320 (unsigned long long)bufferlength);
326 report_failure(int status)
332 save_buffer(good_buf, file_size, fsxgoodfd);
333 prt("Correct content saved for comparison\n");
334 prt("(maybe hexdump \"%s\" vs \"%s.fsxgood\")\n",
343 #define short_at(cp) ((unsigned short)((*((unsigned char *)(cp)) << 8) | \
344 *(((unsigned char *)(cp)) + 1)))
347 check_buffers(unsigned offset, unsigned size)
355 if (memcmp(good_buf + offset, temp_buf, size) != 0) {
356 prt("READ BAD DATA: offset = 0x%x, size = 0x%x\n",
358 prt("OFFSET\tGOOD\tBAD\tRANGE\n");
360 c = good_buf[offset];
364 bad = short_at(&temp_buf[i]);
365 prt("0x%5x\t0x%04x\t0x%04x", offset,
366 short_at(&good_buf[offset]), bad);
367 op = temp_buf[offset & 1 ? i+1 : i];
379 prt("operation# (mod 256) for the bad data may be %u\n", ((unsigned)op & 0xff));
381 prt("operation# (mod 256) for the bad data unknown, check HOLE and EXTEND ops\n");
383 prt("????????????????\n");
395 if (fstat(fd, &statbuf)) {
396 prterr("check_size: fstat");
397 statbuf.st_size = -1;
399 size_by_seek = lseek(fd, (off_t)0, SEEK_END);
400 if (file_size != statbuf.st_size || file_size != size_by_seek) {
401 prt("Size error: expected 0x%llx stat 0x%llx seek 0x%llx\n",
402 (unsigned long long)file_size,
403 (unsigned long long)statbuf.st_size,
404 (unsigned long long)size_by_seek);
411 check_trunc_hack(void)
415 ftruncate(fd, (off_t)0);
416 ftruncate(fd, (off_t)100000);
418 if (statbuf.st_size != (off_t)100000) {
419 prt("no extend on truncate! not posix!\n");
422 ftruncate(fd, (off_t)0);
427 doread(unsigned offset, unsigned size)
432 offset -= offset % readbdy;
434 if (!quiet && testcalls > simulatedopcount)
435 prt("skipping zero size read\n");
436 log4(OP_SKIPPED, OP_READ, offset, size);
439 if (size + offset > file_size) {
440 if (!quiet && testcalls > simulatedopcount)
441 prt("skipping seek/read past end of file\n");
442 log4(OP_SKIPPED, OP_READ, offset, size);
446 log4(OP_READ, offset, size, 0);
448 if (testcalls <= simulatedopcount)
451 if (!quiet && ((progressinterval &&
452 testcalls % progressinterval == 0) ||
454 (monitorstart == -1 ||
455 (offset + size > monitorstart &&
456 (monitorend == -1 || offset <= monitorend))))))
457 prt("%lu read\t0x%x thru\t0x%x\t(0x%x bytes)\n", testcalls,
458 offset, offset + size - 1, size);
459 ret = lseek(fd, (off_t)offset, SEEK_SET);
460 if (ret == (off_t)-1) {
461 prterr("doread: lseek");
464 iret = read(fd, temp_buf, size);
467 prterr("doread: read");
469 prt("short read: 0x%x bytes instead of 0x%x\n",
473 check_buffers(offset, size);
478 check_eofpage(char *s, unsigned offset, char *p, int size)
480 unsigned last_page, should_be_zero;
482 if (offset + size <= (file_size & ~page_mask))
485 * we landed in the last page of the file
486 * test to make sure the VM system provided 0's
487 * beyond the true end of the file mapping
488 * (as required by mmap def in 1996 posix 1003.1)
490 last_page = ((int)p + (offset & page_mask) + size) & ~page_mask;
492 for (should_be_zero = last_page + (file_size & page_mask);
493 should_be_zero < last_page + page_size;
495 if (*(char *)should_be_zero) {
496 prt("Mapped %s: non-zero data past EOF (0x%llx) page offset 0x%x is 0x%04x\n",
497 s, file_size - 1, should_be_zero & page_mask,
498 short_at(should_be_zero));
505 domapread(unsigned offset, unsigned size)
511 offset -= offset % readbdy;
513 if (!quiet && testcalls > simulatedopcount)
514 prt("skipping zero size read\n");
515 log4(OP_SKIPPED, OP_MAPREAD, offset, size);
518 if (size + offset > file_size) {
519 if (!quiet && testcalls > simulatedopcount)
520 prt("skipping seek/read past end of file\n");
521 log4(OP_SKIPPED, OP_MAPREAD, offset, size);
525 log4(OP_MAPREAD, offset, size, 0);
527 if (testcalls <= simulatedopcount)
530 if (!quiet && ((progressinterval &&
531 testcalls % progressinterval == 0) ||
533 (monitorstart == -1 ||
534 (offset + size > monitorstart &&
535 (monitorend == -1 || offset <= monitorend))))))
536 prt("%lu mapread\t0x%x thru\t0x%x\t(0x%x bytes)\n", testcalls,
537 offset, offset + size - 1, size);
539 pg_offset = offset & page_mask;
540 map_size = pg_offset + size;
542 if ((p = (char *)mmap(0, map_size, PROT_READ, MAP_FILE | MAP_SHARED, fd,
543 (off_t)(offset - pg_offset))) == (char *)-1) {
544 prterr("domapread: mmap");
547 if (setjmp(jmpbuf) == 0) {
549 memcpy(temp_buf, p + pg_offset, size);
550 check_eofpage("Read", offset, p, size);
553 report_failure(1901);
556 if (munmap(p, map_size) != 0) {
557 prterr("domapread: munmap");
561 check_buffers(offset, size);
566 gendata(char *original_buf, char *good_buf, unsigned offset, unsigned size)
569 good_buf[offset] = testcalls % 256;
571 good_buf[offset] += original_buf[offset];
578 dowrite(unsigned offset, unsigned size)
583 offset -= offset % writebdy;
585 if (!quiet && testcalls > simulatedopcount)
586 prt("skipping zero size write\n");
587 log4(OP_SKIPPED, OP_WRITE, offset, size);
591 log4(OP_WRITE, offset, size, file_size);
593 gendata(original_buf, good_buf, offset, size);
594 if (file_size < offset + size) {
595 if (file_size < offset)
596 memset(good_buf + file_size, '\0', offset - file_size);
597 file_size = offset + size;
599 warn("Lite file size bug in fsx!");
604 if (testcalls <= simulatedopcount)
607 if (!quiet && ((progressinterval &&
608 testcalls % progressinterval == 0) ||
610 (monitorstart == -1 ||
611 (offset + size > monitorstart &&
612 (monitorend == -1 || offset <= monitorend))))))
613 prt("%lu write\t0x%x thru\t0x%x\t(0x%x bytes)\n", testcalls,
614 offset, offset + size - 1, size);
615 ret = lseek(fd, (off_t)offset, SEEK_SET);
616 if (ret == (off_t)-1) {
617 prterr("dowrite: lseek");
620 iret = write(fd, good_buf + offset, size);
623 prterr("dowrite: write");
625 prt("short write: 0x%x bytes instead of 0x%x\n",
633 domapwrite(unsigned offset, unsigned size)
640 offset -= offset % writebdy;
642 if (!quiet && testcalls > simulatedopcount)
643 prt("skipping zero size write\n");
644 log4(OP_SKIPPED, OP_MAPWRITE, offset, size);
647 cur_filesize = file_size;
649 log4(OP_MAPWRITE, offset, size, 0);
651 gendata(original_buf, good_buf, offset, size);
652 if (file_size < offset + size) {
653 if (file_size < offset)
654 memset(good_buf + file_size, '\0', offset - file_size);
655 file_size = offset + size;
657 warn("Lite file size bug in fsx!");
662 if (testcalls <= simulatedopcount)
665 if (!quiet && ((progressinterval &&
666 testcalls % progressinterval == 0) ||
668 (monitorstart == -1 ||
669 (offset + size > monitorstart &&
670 (monitorend == -1 || offset <= monitorend))))))
671 prt("%lu mapwrite\t0x%x thru\t0x%x\t(0x%x bytes)\n", testcalls,
672 offset, offset + size - 1, size);
674 if (file_size > cur_filesize) {
675 if (ftruncate(fd, file_size) == -1) {
676 prterr("domapwrite: ftruncate");
680 pg_offset = offset & page_mask;
681 map_size = pg_offset + size;
683 if ((p = (char *)mmap(0, map_size, PROT_READ | PROT_WRITE,
684 MAP_FILE | MAP_SHARED, fd,
685 (off_t)(offset - pg_offset))) == (char *)-1) {
686 prterr("domapwrite: mmap");
689 if (setjmp(jmpbuf) == 0) {
691 memcpy(p + pg_offset, good_buf + offset, size);
692 if (msync(p, map_size, 0) != 0) {
693 prterr("domapwrite: msync");
696 check_eofpage("Write", offset, p, size);
699 report_failure(2021);
702 if (munmap(p, map_size) != 0) {
703 prterr("domapwrite: munmap");
710 dotruncate(unsigned size)
712 int oldsize = file_size;
714 size -= size % truncbdy;
715 if (size > biggest) {
717 if (!quiet && testcalls > simulatedopcount)
718 prt("truncating to largest ever: 0x%x\n", size);
721 log4(OP_TRUNCATE, size, (unsigned)file_size, 0);
723 if (size > file_size)
724 memset(good_buf + file_size, '\0', size - file_size);
727 if (testcalls <= simulatedopcount)
730 if ((progressinterval && testcalls % progressinterval == 0) ||
731 (debug && (monitorstart == -1 || monitorend == -1 ||
732 size <= monitorend)))
733 prt("%lu trunc\tfrom 0x%x to 0x%x\n", testcalls, oldsize, size);
734 if (ftruncate(fd, (off_t)size) == -1) {
735 prt("ftruncate1: %x\n", size);
736 prterr("dotruncate: ftruncate");
747 if (lseek(fd, (off_t)0, SEEK_SET) == (off_t)-1) {
748 prterr("writefileimage: lseek");
751 iret = write(fd, good_buf, file_size);
752 if ((off_t)iret != file_size) {
754 prterr("writefileimage: write");
756 prt("short write: 0x%x bytes instead of 0x%llx\n",
757 iret, (unsigned long long)file_size);
760 if (lite ? 0 : ftruncate(fd, file_size) == -1) {
761 prt("ftruncate2: %llx\n", (unsigned long long)file_size);
762 prterr("writefileimage: ftruncate");
771 if (testcalls <= simulatedopcount)
775 prt("%lu close/open\n", testcalls);
777 prterr("docloseopen: close");
780 fd = open(fname, O_RDWR, 0);
782 prterr("docloseopen: open");
791 unsigned long offset;
792 unsigned long size = maxoplen;
793 unsigned long rv = random();
794 unsigned long op = rv % (3 + !lite + mapped_writes);
796 /* turn off the map read if necessary */
798 if (op == 2 && !mapped_reads)
801 if (simulatedopcount > 0 && testcalls == simulatedopcount)
807 closeopen = (rv >> 3) < (1 << 28) / closeprob;
809 if (debugstart > 0 && testcalls >= debugstart)
812 if (!quiet && testcalls < simulatedopcount && testcalls % 100000 == 0)
813 prt("%lu...\n", testcalls);
820 * MAPWRITE: op = 3 or 4
822 if (lite ? 0 : op == 3 && style == 0) /* vanilla truncate? */
823 dotruncate(random() % maxfilelen);
826 size = random() % (maxoplen+1);
827 if (lite ? 0 : op == 3)
831 if (op == 1 || op == (lite ? 3 : 4)) {
832 offset %= maxfilelen;
833 if (offset + size > maxfilelen)
834 size = maxfilelen - offset;
836 domapwrite(offset, size);
838 dowrite(offset, size);
844 if (offset + size > file_size)
845 size = file_size - offset;
847 domapread(offset, size);
849 doread(offset, size);
853 if (sizechecks && testcalls > simulatedopcount)
866 report_failure(9999);
874 prt("signal %d\n", sig);
875 prt("testcalls = %lu\n", testcalls);
883 fprintf(stdout, "usage: %s",
884 "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\
885 -b opnum: beginning operation number (default 1)\n\
886 -c P: 1 in P chance of file close+open at each op (default infinity)\n\
887 -d: debug output for all operations\n\
888 -l flen: the upper bound on file size (default 262144)\n\
889 -m startop:endop: monitor (print debug output) specified byte range (default 0:infinity)\n\
890 -n: no verifications of file size\n\
891 -o oplen: the upper bound on operation size (default 65536)\n\
892 -p progressinterval: debug output at specified operation interval\n\
893 -q: quieter operation\n\
894 -r readbdy: 4096 would make reads page aligned (default 1)\n\
895 -s style: 1 gives smaller truncates (default 0)\n\
896 -t truncbdy: 4096 would make truncates page aligned (default 1)\n\
897 -w writebdy: 4096 would make writes page aligned (default 1)\n\
898 -D startingop: debug output starting at specified operation\n\
899 -L: fsxLite - no file creations & no file size changes\n\
900 -N numops: total # operations to do (default infinity)\n\
901 -O: use oplen (see -o flag) for every op (default random)\n\
902 -P dirpath: save .fsxlog and .fsxgood files in dirpath (default ./)\n\
903 -S seed: for random # generator (default 1) 0 gets timestamp\n\
904 -W: mapped write operations DISabled\n\
905 -R: mapped read operations DISabled)\n\
906 fname: this filename is REQUIRED (no default)\n");
912 getnum(char *s, char **e)
917 ret = strtol(s, e, 0);
946 main(int argc, char **argv)
956 page_size = getpagesize();
957 page_mask = page_size - 1;
959 setvbuf(stdout, (char *)0, _IOLBF, 0); /* line buffered stdout */
961 while ((ch = getopt(argc, argv, "b:c:dl:m:no:p:qr:s:t:w:D:LN:OP:RS:W"))
965 simulatedopcount = getnum(optarg, &endp);
967 fprintf(stdout, "Will begin at operation %ld\n",
969 if (simulatedopcount == 0)
971 simulatedopcount -= 1;
974 closeprob = getnum(optarg, &endp);
977 "Chance of close/open is 1 in %d\n",
986 maxfilelen = getnum(optarg, &endp);
991 monitorstart = getnum(optarg, &endp);
992 if (monitorstart < 0)
994 if (!endp || *endp++ != ':')
996 monitorend = getnum(endp, &endp);
1000 monitorend = -1; /* aka infinity */
1006 maxoplen = getnum(optarg, &endp);
1011 progressinterval = getnum(optarg, &endp);
1012 if (progressinterval < 0)
1019 readbdy = getnum(optarg, &endp);
1024 style = getnum(optarg, &endp);
1025 if (style < 0 || style > 1)
1029 truncbdy = getnum(optarg, &endp);
1034 writebdy = getnum(optarg, &endp);
1039 debugstart = getnum(optarg, &endp);
1047 numops = getnum(optarg, &endp);
1055 strncpy(goodfile, optarg, sizeof(goodfile));
1056 strcat(goodfile, "/");
1057 strncpy(logfile, optarg, sizeof(logfile));
1058 strcat(logfile, "/");
1064 seed = getnum(optarg, &endp);
1066 seed = time(0) % 10000;
1068 fprintf(stdout, "Seed set to %d\n", seed);
1075 fprintf(stdout, "mapped writes DISABLED\n");
1088 signal(SIGHUP, cleanup);
1089 signal(SIGINT, cleanup);
1090 signal(SIGPIPE, cleanup);
1091 signal(SIGALRM, cleanup);
1092 signal(SIGTERM, cleanup);
1093 signal(SIGXCPU, cleanup);
1094 signal(SIGXFSZ, cleanup);
1095 signal(SIGVTALRM, cleanup);
1096 signal(SIGUSR1, cleanup);
1097 signal(SIGUSR2, cleanup);
1098 signal(SIGSEGV, segv);
1100 initstate(seed, state, 256);
1102 fd = open(fname, O_RDWR|(lite ? 0 : O_CREAT|O_TRUNC), 0666);
1107 strncat(goodfile, fname, 256);
1108 strcat (goodfile, ".fsxgood");
1109 fsxgoodfd = open(goodfile, O_RDWR|O_CREAT|O_TRUNC, 0666);
1110 if (fsxgoodfd < 0) {
1114 strncat(logfile, fname, 256);
1115 strcat (logfile, ".fsxlog");
1116 fsxlogf = fopen(logfile, "w");
1117 if (fsxlogf == NULL) {
1123 file_size = maxfilelen = lseek(fd, (off_t)0, SEEK_END);
1124 if (file_size == (off_t)-1) {
1126 warn("main: lseek eof");
1129 ret = lseek(fd, (off_t)0, SEEK_SET);
1130 if (ret == (off_t)-1) {
1132 warn("main: lseek 0");
1136 original_buf = (char *) malloc(maxfilelen);
1137 for (i = 0; i < maxfilelen; i++)
1138 original_buf[i] = random() % 256;
1139 good_buf = (char *) malloc(maxfilelen);
1140 memset(good_buf, '\0', maxfilelen);
1141 temp_buf = (char *) malloc(maxoplen);
1142 memset(temp_buf, '\0', maxoplen);
1143 if (lite) { /* zero entire existing file */
1146 written = write(fd, good_buf, (size_t)maxfilelen);
1147 if (written != maxfilelen) {
1148 if (written == -1) {
1150 warn("main: error on write");
1152 warn("main: short write, 0x%x bytes instead of 0x%x\n",
1153 (unsigned)written, maxfilelen);
1159 while (numops == -1 || numops--)
1166 prt("All operations completed A-OK!\n");