int args[3];
};
-#define LOGSIZE 1000
+#define LOGSIZE 100000
struct log_entry oplog[LOGSIZE]; /* the log */
int logptr = 0; /* current position in log */
prterr("save_buffer: lseek eof");
else if (bufferlength > size_by_seek) {
warn("save_buffer: .fsxgood file too short... will"
- "save 0x%llx bytes instead of 0x%llx\n",
+ "save 0x%llx bytes instead of 0x%llx\n",
(unsigned long long)size_by_seek,
(unsigned long long)bufferlength);
bufferlength = size_by_seek;
if (c != t) {
if (n == 0) {
bad = short_at(&temp_buf[i]);
- prt("0x%5x\t0x%04x\t0x%04x", offset,
+ prt("%#07x\t%#06x\t%#06x", offset,
short_at(&good_buf[offset]), bad);
op = temp_buf[offset & 1 ? i+1 : i];
}
size--;
}
if (n) {
- prt("\t0x%5x\n", n);
+ prt("\t%#7x\n", n);
if (bad)
prt("operation# (mod 256) for the bad data"
"may be %u\n", ((unsigned)op & 0xff));
int fd_policy = FD_RANDOM;
int fd_last = 0;
-struct test_file *
+struct test_file *
get_tf(void)
{
unsigned index = 0;
}
}
-int
+int
get_fd(void)
{
struct test_file *tf = get_tf();
return tf->fd;
}
-static const char *basename(const char *path)
+static const char *my_basename(const char *path)
{
char *c = strrchr(path, '/');
return c ? c++ : path;
}
-void
+void
open_test_files(char **argv, int argc)
{
struct test_file *tf;
for (i = 0, tf = test_files; i < num_test_files; i++, tf++) {
tf->path = argv[i];
- tf->fd = open(tf->path, O_RDWR|(lite ? 0 : O_CREAT|O_TRUNC),
+ tf->fd = open(tf->path, O_RDWR|(lite ? 0 : O_CREAT|O_TRUNC),
0666);
if (tf->fd < 0) {
prterr(tf->path);
struct stat statbuf;
int fd = get_fd();
- ftruncate(fd, (off_t)0);
- ftruncate(fd, (off_t)100000);
- fstat(fd, &statbuf);
+ /* should not ignore ftruncate(2)'s return value */
+ if (ftruncate(fd, (off_t)0) < 0) {
+ prterr("trunc_hack: ftruncate(0)");
+ exit(1);
+ }
+ if (ftruncate(fd, (off_t)100000) < 0) {
+ prterr("trunc_hack: ftruncate(100000)");
+ exit(1);
+ }
+ if (fstat(fd, &statbuf)) {
+ prterr("trunc_hack: fstat");
+ statbuf.st_size = -1;
+ }
if (statbuf.st_size != (off_t)100000) {
prt("no extend on truncate! not posix!\n");
exit(130);
}
- ftruncate(fd, 0);
+ if (ftruncate(fd, 0) < 0) {
+ prterr("trunc_hack: ftruncate(0) (2nd call)");
+ exit(1);
+ }
}
static char *tf_buf = NULL;
}
}
-char *
+char *
fill_tf_buf(struct test_file *tf)
{
if (tf_buf == NULL)
}
void
-output_line(struct test_file *tf, int op, unsigned offset,
+output_line(struct test_file *tf, int op, unsigned offset,
unsigned size, struct timeval *tv)
{
char *tf_num = "";
prt("%06lu %lu.%06lu %.*s%-10s %#08x %s %#08x\t(0x%x bytes)\n",
testcalls, tv->tv_sec, tv->tv_usec, max_tf_len,
- tf_num, ops[op],
+ tf_num, ops[op],
offset, op == OP_TRUNCATE ? " to " : "thru",
offset + size - 1, size);
}
prterr("writefileimage: write");
else
prt("short write: 0x%lx bytes instead of 0x%llx\n",
- (unsigned long)iret,
+ (unsigned long)iret,
(unsigned long long)file_size);
report_failure(172);
}
setvbuf(stdout, (char *)0, _IOLBF, 0); /* line buffered stdout */
- while ((ch = getopt(argc, argv,
+ while ((ch = getopt(argc, argv,
"b:c:dl:m:no:p:qr:s:t:w:D:I:LN:OP:RS:W"))
!= EOF)
switch (ch) {
open_test_files(argv, argc);
- strncat(goodfile, dirpath ? basename(fname) : fname, 256);
+ strncat(goodfile, dirpath ? my_basename(fname) : fname, 256);
strcat (goodfile, ".fsxgood");
fsxgoodfd = open(goodfile, O_RDWR|O_CREAT|O_TRUNC, 0666);
if (fsxgoodfd < 0) {
prterr(goodfile);
exit(92);
}
- strncat(logfile, dirpath ? basename(fname) : fname, 256);
+ strncat(logfile, dirpath ? my_basename(fname) : fname, 256);
strcat (logfile, ".fsxlog");
fsxlogf = fopen(logfile, "w");
if (fsxlogf == NULL) {