2 * Copyright (C) 1991, NeXT Computer, Inc. All Rights Reserverd.
5 * Author: Avadis Tevanian, Jr.
7 * File system exerciser.
9 * Rewritten 8/98 by Conrad Minshall.
11 * Small changes to work under Linux -- davej.
38 #define NUMPRINTCOLUMNS 32 /* # columns of data to print on each line */
41 * A log entry is an operation and a bunch of arguments.
51 struct log_entry oplog[LOGSIZE]; /* the log */
52 int logptr = 0; /* current position in log */
53 int logcount = 0; /* total ops */
62 #define OP_CLOSEOPEN 4
68 #define PAGE_SIZE getpagesize()
70 #define PAGE_MASK (PAGE_SIZE - 1)
72 char *original_buf; /* a pointer to the original data */
73 char *good_buf; /* a pointer to the correct data */
74 char *temp_buf; /* a pointer to the current data */
75 char *fname; /* name of our test file */
76 int fd; /* fd for our test file */
81 unsigned long testcalls = 0; /* calls to function "test" */
83 unsigned long simulatedopcount = 0; /* -b flag */
84 int closeprob = 0; /* -c flag */
85 int debug = 0; /* -d flag */
86 unsigned long debugstart = 0; /* -D flag */
87 int do_fsync = 0; /* -f flag */
88 unsigned long maxfilelen = 256 * 1024; /* -l flag */
89 int sizechecks = 1; /* -n flag disables them */
90 int maxoplen = 64 * 1024; /* -o flag */
91 int quiet = 0; /* -q flag */
92 unsigned long progressinterval = 0; /* -p flag */
93 int readbdy = 1; /* -r flag */
94 int style = 0; /* -s flag */
95 int prealloc = 0; /* -x flag */
96 int truncbdy = 1; /* -t flag */
97 int writebdy = 1; /* -w flag */
98 long monitorstart = -1; /* -m flag */
99 long monitorend = -1; /* -m flag */
100 int lite = 0; /* -L flag */
101 long numops = -1; /* -N flag */
102 int randomoplen = 1; /* -O flag disables it */
103 int seed = 1; /* -S flag */
104 int mapped_writes = 1; /* -W flag disables */
105 int mapped_reads = 1; /* -R flag disables it */
107 int o_direct; /* -Z */
111 int aio_rw(int rw, int fd, char *buf, unsigned len, unsigned offset);
114 #define fsxread(a,b,c,d) aio_rw(READ, a,b,c,d)
115 #define fsxwrite(a,b,c,d) aio_rw(WRITE, a,b,c,d)
117 #define fsxread(a,b,c,d) read(a,b,c)
118 #define fsxwrite(a,b,c,d) write(a,b,c)
121 FILE * fsxlogf = NULL;
125 static void *round_up(void *ptr, unsigned long align, unsigned long offset)
127 unsigned long ret = (unsigned long)ptr;
129 ret = ((ret + align - 1) & ~(align - 1));
135 vwarnc(int code, const char *fmt, va_list ap) {
136 fprintf(stderr, "fsx: ");
138 vfprintf(stderr, fmt, ap);
139 fprintf(stderr, ": ");
141 fprintf(stderr, "%s\n", strerror(code));
145 warn(const char * fmt, ...) {
148 vwarnc(errno, fmt, ap);
158 vfprintf(stdout, fmt, args);
160 vfprintf(fsxlogf, fmt, args);
167 prt("%s%s%s\n", prefix, prefix ? ": " : "", strerror(errno));
172 log4(int operation, int arg0, int arg1, int arg2)
174 struct log_entry *le;
177 le->operation = operation;
179 le->operation = ~ le->operation;
185 if (logptr >= LOGSIZE)
194 struct log_entry *lp;
196 prt("LOG DUMP (%d total operations):\n", logcount);
197 if (logcount < LOGSIZE) {
204 for ( ; count > 0; count--) {
207 opnum = i+1 + (logcount/LOGSIZE)*LOGSIZE;
208 prt("%d(%d mod 256): ", opnum, opnum%256);
210 if ((closeopen = lp->operation < 0))
211 lp->operation = ~ lp->operation;
213 switch (lp->operation) {
215 prt("MAPREAD\t0x%x thru 0x%x\t(0x%x bytes)",
216 lp->args[0], lp->args[0] + lp->args[1] - 1,
218 if (badoff >= lp->args[0] && badoff <
219 lp->args[0] + lp->args[1])
223 prt("MAPWRITE 0x%x thru 0x%x\t(0x%x bytes)",
224 lp->args[0], lp->args[0] + lp->args[1] - 1,
226 if (badoff >= lp->args[0] && badoff <
227 lp->args[0] + lp->args[1])
231 prt("READ\t0x%x thru 0x%x\t(0x%x bytes)",
232 lp->args[0], lp->args[0] + lp->args[1] - 1,
234 if (badoff >= lp->args[0] &&
235 badoff < lp->args[0] + lp->args[1])
239 prt("WRITE\t0x%x thru 0x%x\t(0x%x bytes)",
240 lp->args[0], lp->args[0] + lp->args[1] - 1,
242 if (lp->args[0] > lp->args[2])
244 else if (lp->args[0] + lp->args[1] > lp->args[2])
246 if ((badoff >= lp->args[0] || badoff >=lp->args[2]) &&
247 badoff < lp->args[0] + lp->args[1])
251 down = lp->args[0] < lp->args[1];
252 prt("TRUNCATE %s\tfrom 0x%x to 0x%x",
253 down ? "DOWN" : "UP", lp->args[1], lp->args[0]);
254 if (badoff >= lp->args[!down] &&
255 badoff < lp->args[!!down])
259 prt("SKIPPED (no operation)");
262 prt("BOGUS LOG ENTRY (operation code = %d)!",
266 prt("\n\t\tCLOSE/OPEN");
276 save_buffer(char *buffer, off_t bufferlength, int fd)
279 ssize_t byteswritten;
281 if (fd <= 0 || bufferlength == 0)
284 if (bufferlength > SSIZE_MAX) {
285 prt("fsx flaw: overflow in save_buffer\n");
289 off_t size_by_seek = lseek(fd, (off_t)0, L_XTND);
290 if (size_by_seek == (off_t)-1)
291 prterr("save_buffer: lseek eof");
292 else if (bufferlength > size_by_seek) {
293 warn("save_buffer: .fsxgood file too short... will save 0x%qx bytes instead of 0x%qx\n", (unsigned long long)size_by_seek,
294 (unsigned long long)bufferlength);
295 bufferlength = size_by_seek;
299 ret = lseek(fd, (off_t)0, SEEK_SET);
300 if (ret == (off_t)-1)
301 prterr("save_buffer: lseek 0");
303 byteswritten = write(fd, buffer, (size_t)bufferlength);
304 if (byteswritten != bufferlength) {
305 if (byteswritten == -1)
306 prterr("save_buffer write");
308 warn("save_buffer: short write, 0x%x bytes instead of 0x%qx\n",
309 (unsigned)byteswritten,
310 (unsigned long long)bufferlength);
316 report_failure(int status)
322 save_buffer(good_buf, file_size, fsxgoodfd);
323 prt("Correct content saved for comparison\n");
324 prt("(maybe hexdump \"%s\" vs \"%s.fsxgood\")\n",
333 #define short_at(cp) ((unsigned short)((*((unsigned char *)(cp)) << 8) | \
334 *(((unsigned char *)(cp)) + 1)))
337 check_buffers(unsigned offset, unsigned size)
345 if (bcmp(good_buf + offset, temp_buf, size) != 0) {
346 prt("READ BAD DATA: offset = 0x%x, size = 0x%x, fname = %s\n",
347 offset, size, fname);
348 prt("OFFSET\tGOOD\tBAD\tRANGE\n");
350 c = good_buf[offset];
354 bad = short_at(&temp_buf[i]);
355 prt("0x%5x\t0x%04x\t0x%04x", offset,
356 short_at(&good_buf[offset]), bad);
357 op = temp_buf[offset & 1 ? i+1 : i];
360 prt("operation# (mod 256) for "
361 "the bad data may be %u\n",
362 ((unsigned)op & 0xff));
364 prt("operation# (mod 256) for "
365 "the bad data unknown, check"
366 " HOLE and EXTEND ops\n");
386 if (fstat(fd, &statbuf)) {
387 prterr("check_size: fstat");
388 statbuf.st_size = -1;
390 size_by_seek = lseek(fd, (off_t)0, L_XTND);
391 if (file_size != statbuf.st_size || file_size != size_by_seek) {
392 prt("Size error: expected 0x%qx stat 0x%qx seek 0x%qx\n",
393 (unsigned long long)file_size,
394 (unsigned long long)statbuf.st_size,
395 (unsigned long long)size_by_seek);
402 check_trunc_hack(void)
406 ftruncate(fd, (off_t)0);
407 ftruncate(fd, (off_t)100000);
409 if (statbuf.st_size != (off_t)100000) {
410 prt("no extend on truncate! not posix!\n");
418 doread(unsigned offset, unsigned size)
423 offset -= offset % readbdy;
425 size -= size % readbdy;
427 if (!quiet && testcalls > simulatedopcount && !o_direct)
428 prt("skipping zero size read\n");
429 log4(OP_SKIPPED, OP_READ, offset, size);
432 if (size + offset > file_size) {
433 if (!quiet && testcalls > simulatedopcount)
434 prt("skipping seek/read past end of file\n");
435 log4(OP_SKIPPED, OP_READ, offset, size);
439 log4(OP_READ, offset, size, 0);
441 if (testcalls <= simulatedopcount)
445 ((progressinterval && testcalls % progressinterval == 0) ||
447 (monitorstart == -1 ||
448 (offset + size > monitorstart &&
449 (monitorend == -1 || offset <= monitorend))))))
450 prt("%lu read\t0x%x thru\t0x%x\t(0x%x bytes)\n", testcalls,
451 offset, offset + size - 1, size);
452 ret = lseek(fd, (off_t)offset, SEEK_SET);
453 if (ret == (off_t)-1) {
454 prterr("doread: lseek");
457 iret = fsxread(fd, temp_buf, size, offset);
460 prterr("doread: read");
462 prt("short read: 0x%x bytes instead of 0x%x\n",
466 check_buffers(offset, size);
471 domapread(unsigned offset, unsigned size)
477 offset -= offset % readbdy;
479 if (!quiet && testcalls > simulatedopcount)
480 prt("skipping zero size read\n");
481 log4(OP_SKIPPED, OP_MAPREAD, offset, size);
484 if (size + offset > file_size) {
485 if (!quiet && testcalls > simulatedopcount)
486 prt("skipping seek/read past end of file\n");
487 log4(OP_SKIPPED, OP_MAPREAD, offset, size);
491 log4(OP_MAPREAD, offset, size, 0);
493 if (testcalls <= simulatedopcount)
497 ((progressinterval && testcalls % progressinterval == 0) ||
499 (monitorstart == -1 ||
500 (offset + size > monitorstart &&
501 (monitorend == -1 || offset <= monitorend))))))
502 prt("%lu mapread\t0x%x thru\t0x%x\t(0x%x bytes)\n", testcalls,
503 offset, offset + size - 1, size);
505 pg_offset = offset & PAGE_MASK;
506 map_size = pg_offset + size;
508 if ((p = (char *)mmap(0, map_size, PROT_READ, MAP_SHARED, fd,
509 (off_t)(offset - pg_offset))) == (char *)-1) {
510 prterr("domapread: mmap");
513 memcpy(temp_buf, p + pg_offset, size);
514 if (munmap(p, map_size) != 0) {
515 prterr("domapread: munmap");
519 check_buffers(offset, size);
524 gendata(char *original_buf, char *good_buf, unsigned offset, unsigned size)
527 good_buf[offset] = testcalls % 256;
529 good_buf[offset] += original_buf[offset];
536 dowrite(unsigned offset, unsigned size)
541 offset -= offset % writebdy;
543 size -= size % writebdy;
545 if (!quiet && testcalls > simulatedopcount && !o_direct)
546 prt("skipping zero size write\n");
547 log4(OP_SKIPPED, OP_WRITE, offset, size);
551 log4(OP_WRITE, offset, size, file_size);
553 gendata(original_buf, good_buf, offset, size);
554 if (file_size < offset + size) {
555 if (file_size < offset)
556 bzero(good_buf + file_size, offset - file_size);
557 file_size = offset + size;
559 warn("Lite file size bug in fsx!");
564 if (testcalls <= simulatedopcount)
568 ((progressinterval && testcalls % progressinterval == 0) ||
570 (monitorstart == -1 ||
571 (offset + size > monitorstart &&
572 (monitorend == -1 || offset <= monitorend))))))
573 prt("%lu write\t0x%x thru\t0x%x\t(0x%x bytes)\n", testcalls,
574 offset, offset + size - 1, size);
575 ret = lseek(fd, (off_t)offset, SEEK_SET);
576 if (ret == (off_t)-1) {
577 prterr("dowrite: lseek");
580 iret = fsxwrite(fd, good_buf + offset, size, offset);
583 prterr("dowrite: write");
585 prt("short write: 0x%x bytes instead of 0x%x\n",
591 prt("fsync() failed: %s\n", strerror(errno));
599 domapwrite(unsigned offset, unsigned size)
606 offset -= offset % writebdy;
608 if (!quiet && testcalls > simulatedopcount)
609 prt("skipping zero size write\n");
610 log4(OP_SKIPPED, OP_MAPWRITE, offset, size);
613 cur_filesize = file_size;
615 log4(OP_MAPWRITE, offset, size, 0);
617 gendata(original_buf, good_buf, offset, size);
618 if (file_size < offset + size) {
619 if (file_size < offset)
620 bzero(good_buf + file_size, offset - file_size);
621 file_size = offset + size;
623 warn("Lite file size bug in fsx!");
628 if (testcalls <= simulatedopcount)
632 ((progressinterval && testcalls % progressinterval == 0) ||
634 (monitorstart == -1 ||
635 (offset + size > monitorstart &&
636 (monitorend == -1 || offset <= monitorend))))))
637 prt("%lu mapwrite\t0x%x thru\t0x%x\t(0x%x bytes)\n", testcalls,
638 offset, offset + size - 1, size);
640 if (file_size > cur_filesize) {
641 if (ftruncate(fd, file_size) == -1) {
642 prterr("domapwrite: ftruncate");
646 pg_offset = offset & PAGE_MASK;
647 map_size = pg_offset + size;
649 if ((p = (char *)mmap(0, map_size, PROT_READ | PROT_WRITE,
650 MAP_FILE | MAP_SHARED, fd,
651 (off_t)(offset - pg_offset))) == (char *)-1) {
652 prterr("domapwrite: mmap");
655 memcpy(p + pg_offset, good_buf + offset, size);
656 if (msync(p, map_size, 0) != 0) {
657 prterr("domapwrite: msync");
660 if (munmap(p, map_size) != 0) {
661 prterr("domapwrite: munmap");
668 dotruncate(unsigned size)
670 int oldsize = file_size;
672 size -= size % truncbdy;
673 if (size > biggest) {
675 if (!quiet && testcalls > simulatedopcount)
676 prt("truncating to largest ever: 0x%x\n", size);
679 log4(OP_TRUNCATE, size, (unsigned)file_size, 0);
681 if (size > file_size)
682 bzero(good_buf + file_size, size - file_size);
685 if (testcalls <= simulatedopcount)
688 if ((progressinterval && testcalls % progressinterval == 0) ||
689 (debug && (monitorstart == -1 || monitorend == -1 ||
690 size <= monitorend)))
691 prt("%lu trunc\tfrom 0x%x to 0x%x\n", testcalls, oldsize, size);
692 if (ftruncate(fd, (off_t)size) == -1) {
693 prt("ftruncate1: %x\n", size);
694 prterr("dotruncate: ftruncate");
705 if (lseek(fd, (off_t)0, SEEK_SET) == (off_t)-1) {
706 prterr("writefileimage: lseek");
709 iret = write(fd, good_buf, file_size);
710 if ((off_t)iret != file_size) {
712 prterr("writefileimage: write");
714 prt("short write: 0x%x bytes instead of 0x%qx\n",
715 iret, (unsigned long long)file_size);
718 if (lite ? 0 : ftruncate(fd, file_size) == -1) {
719 prt("ftruncate2: %qx\n", (unsigned long long)file_size);
720 prterr("writefileimage: ftruncate");
729 if (testcalls <= simulatedopcount)
733 prt("%lu close/open\n", testcalls);
735 prterr("docloseopen: close");
738 fd = open(fname, O_RDWR|o_direct, 0);
740 prterr("docloseopen: open");
749 unsigned long offset;
750 unsigned long size = maxoplen;
751 unsigned long rv = random();
752 unsigned long op = rv % (3 + !lite + mapped_writes);
754 /* turn off the map read if necessary */
756 if (op == 2 && !mapped_reads)
759 if (simulatedopcount > 0 && testcalls == simulatedopcount)
765 closeopen = (rv >> 3) < (1 << 28) / closeprob;
767 if (debugstart > 0 && testcalls >= debugstart)
770 if (!quiet && testcalls < simulatedopcount && testcalls % 100000 == 0)
771 prt("%lu...\n", testcalls);
778 * MAPWRITE: op = 3 or 4
780 if (lite ? 0 : op == 3 && (style & 1) == 0) /* vanilla truncate? */
781 dotruncate(random() % maxfilelen);
784 size = random() % (maxoplen+1);
785 if (lite ? 0 : op == 3)
789 if (op == 1 || op == (lite ? 3 : 4)) {
790 offset %= maxfilelen;
791 if (offset + size > maxfilelen)
792 size = maxfilelen - offset;
794 domapwrite(offset, size);
796 dowrite(offset, size);
802 if (offset + size > file_size)
803 size = file_size - offset;
805 domapread(offset, size);
807 doread(offset, size);
811 if (sizechecks && testcalls > simulatedopcount)
823 prt("signal %d\n", sig);
824 prt("testcalls = %lu\n", testcalls);
832 fprintf(stdout, "usage: %s",
833 "fsx [-dnqxALOWZ] [-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\
834 -b opnum: beginning operation number (default 1)\n\
835 -c P: 1 in P chance of file close+open at each op (default infinity)\n\
836 -d: debug output for all operations\n\
837 -l flen: the upper bound on file size (default 262144)\n\
838 -m startop:endop: monitor (print debug output) specified byte range (default 0:infinity)\n\
839 -n: no verifications of file size\n\
840 -o oplen: the upper bound on operation size (default 65536)\n\
841 -p progressinterval: debug output at specified operation interval\n\
842 -q: quieter operation\n\
843 -r readbdy: 4096 would make reads page aligned (default 1)\n\
844 -s style: 1 gives smaller truncates (default 0)\n\
845 -t truncbdy: 4096 would make truncates page aligned (default 1)\n\
846 -w writebdy: 4096 would make writes page aligned (default 1)\n\
847 -x: preallocate file space before starting, XFS only (default 0)\n"
849 "-A: Use the AIO system calls\n"
851 "-D startingop: debug output starting at specified operation\n\
852 -L: fsxLite - no file creations & no file size changes\n\
853 -N numops: total # operations to do (default infinity)\n\
854 -O: use oplen (see -o flag) for every op (default random)\n\
855 -P: save .fsxlog and .fsxgood files in dirpath (default ./)\n\
856 -S seed: for random # generator (default 1) 0 gets timestamp\n\
857 -W: mapped write operations DISabled\n\
858 -R: read() system calls only (mapped reads disabled)\n\
859 -Z: O_DIRECT (use -R, -W, -r and -w too)\n\
860 fname: this filename is REQUIRED (no default)\n");
866 getnum(char *s, char **e)
871 ret = strtol(s, e, 0);
907 ret = io_queue_init(QSZ, &io_ctx);
909 fprintf(stderr, "aio_setup: io_queue_init failed: %s\n",
917 __aio_rw(int rw, int fd, char *buf, unsigned len, unsigned offset)
919 struct io_event event;
920 static struct timespec ts;
921 struct iocb *iocbs[] = { &iocb };
925 io_prep_pread(&iocb, fd, buf, len, offset);
927 io_prep_pwrite(&iocb, fd, buf, len, offset);
932 ret = io_submit(io_ctx, 1, iocbs);
934 fprintf(stderr, "errcode=%d\n", ret);
935 fprintf(stderr, "aio_rw: io_submit failed: %s\n",
940 ret = io_getevents(io_ctx, 1, 1, &event, &ts);
942 fprintf(stderr, "errcode=%d\n", ret);
943 fprintf(stderr, "aio_rw: io_getevents failed: %s\n",
947 if (len != event.res) {
948 fprintf(stderr, "bad read length: %lu instead of %u\n",
954 int aio_rw(int rw, int fd, char *buf, unsigned len, unsigned offset)
959 ret = __aio_rw(rw, fd, buf, len, offset);
962 ret = read(fd, buf, len);
964 ret = write(fd, buf, len);
972 main(int argc, char **argv)
982 setvbuf(stdout, (char *)0, _IOLBF, 0); /* line buffered stdout */
984 while ((ch = getopt(argc, argv, "b:c:dl:m:no:p:qr:s:t:w:xAD:LN:OP:RS:WZ"))
988 simulatedopcount = getnum(optarg, &endp);
990 fprintf(stdout, "Will begin at operation %ld\n",
992 if (simulatedopcount == 0)
994 simulatedopcount -= 1;
997 closeprob = getnum(optarg, &endp);
1000 "Chance of close/open is 1 in %d\n",
1012 maxfilelen = getnum(optarg, &endp);
1013 if (maxfilelen <= 0)
1017 monitorstart = getnum(optarg, &endp);
1018 if (monitorstart < 0)
1020 if (!endp || *endp++ != ':')
1022 monitorend = getnum(endp, &endp);
1025 if (monitorend == 0)
1026 monitorend = -1; /* aka infinity */
1032 maxoplen = getnum(optarg, &endp);
1037 progressinterval = getnum(optarg, &endp);
1038 if (progressinterval == 0)
1045 readbdy = getnum(optarg, &endp);
1050 style = getnum(optarg, &endp);
1051 if (style < 0 || style > 1)
1055 truncbdy = getnum(optarg, &endp);
1060 writebdy = getnum(optarg, &endp);
1071 debugstart = getnum(optarg, &endp);
1079 numops = getnum(optarg, &endp);
1087 strncpy(goodfile, optarg, sizeof(goodfile));
1088 strcat(goodfile, "/");
1089 strncpy(logfile, optarg, sizeof(logfile));
1090 strcat(logfile, "/");
1096 seed = getnum(optarg, &endp);
1098 seed = time(0) % 10000;
1100 fprintf(stdout, "Seed set to %d\n", seed);
1107 fprintf(stdout, "mapped writes DISABLED\n");
1110 o_direct = O_DIRECT;
1122 signal(SIGHUP, cleanup);
1123 signal(SIGINT, cleanup);
1124 signal(SIGPIPE, cleanup);
1125 signal(SIGALRM, cleanup);
1126 signal(SIGTERM, cleanup);
1127 signal(SIGXCPU, cleanup);
1128 signal(SIGXFSZ, cleanup);
1129 signal(SIGVTALRM, cleanup);
1130 signal(SIGUSR1, cleanup);
1131 signal(SIGUSR2, cleanup);
1133 initstate(seed, state, 256);
1136 O_RDWR|(lite ? 0 : O_CREAT|O_TRUNC)|o_direct, 0666);
1143 xfs_flock64_t resv = { 0 };
1144 #ifdef HAVE_XFS_PLATFORM_DEFS_H
1145 if (!platform_test_xfs_fd(fd)) {
1147 fprintf(stderr, "main: cannot prealloc, non XFS\n");
1151 resv.l_len = maxfilelen;
1152 if ((xfsctl(fname, fd, XFS_IOC_RESVSP, &resv)) < 0) {
1158 strncat(goodfile, fname, 256);
1159 strcat (goodfile, ".fsxgood");
1160 fsxgoodfd = open(goodfile, O_RDWR|O_CREAT|O_TRUNC, 0666);
1161 if (fsxgoodfd < 0) {
1165 strncat(logfile, fname, 256);
1166 strcat (logfile, ".fsxlog");
1167 fsxlogf = fopen(logfile, "w");
1168 if (fsxlogf == NULL) {
1180 file_size = maxfilelen = lseek(fd, (off_t)0, L_XTND);
1181 if (file_size == (off_t)-1) {
1183 warn("main: lseek eof");
1186 ret = lseek(fd, (off_t)0, SEEK_SET);
1187 if (ret == (off_t)-1) {
1189 warn("main: lseek 0");
1193 original_buf = (char *) malloc(maxfilelen);
1194 for (i = 0; i < maxfilelen; i++)
1195 original_buf[i] = random() % 256;
1196 good_buf = (char *) malloc(maxfilelen + writebdy);
1197 good_buf = round_up(good_buf, writebdy, 0);
1198 bzero(good_buf, maxfilelen);
1199 temp_buf = (char *) malloc(maxoplen + readbdy);
1200 temp_buf = round_up(temp_buf, readbdy, 0);
1201 bzero(temp_buf, maxoplen);
1202 if (lite) { /* zero entire existing file */
1205 written = write(fd, good_buf, (size_t)maxfilelen);
1206 if (written != maxfilelen) {
1207 if (written == -1) {
1209 warn("main: error on write");
1211 warn("main: short write, 0x%x bytes instead "
1220 while (numops == -1 || numops--)
1227 prt("All operations completed A-OK!\n");