{
int i;
- printf("Thread %u, %s\n", no_s, s->name);
- printf("Completions: %llu\n", (unsigned long long) s->no_comps);
- printf("Depth: %llu\n", (unsigned long long) s->depth);
- printf("Number IOs: %llu\n", (unsigned long long) s->numberio);
- printf("Index: %llu\n", (unsigned long long) s->index);
+ printf("Thread:\t\t%u\n", no_s);
+ printf("Name:\t\t%s\n", s->name);
+ printf("Completions:\t%llu\n", (unsigned long long) s->no_comps);
+ printf("Depth:\t\t%llu\n", (unsigned long long) s->depth);
+ printf("Number IOs:\t%llu\n", (unsigned long long) s->numberio);
+ printf("Index:\t\t%llu\n", (unsigned long long) s->index);
printf("Completions:\n");
- for (i = 0; i < s->no_comps; i++) {
+ if (!s->no_comps)
+ return;
+ for (i = s->no_comps - 1; i >= 0; i--) {
printf("\t(file=%2llu) %llu\n",
(unsigned long long) s->comps[i].fileno,
(unsigned long long) s->comps[i].offset);
show_s(s, no_s);
no_s++;
size -= __thread_io_list_sz(s->depth, s->nofiles);
- s = (void *) s + __thread_io_list_sz(s->depth, s->nofiles);
+ s = (struct thread_io_list *)((char *) s +
+ __thread_io_list_sz(s->depth, s->nofiles));
} while (size != 0);
}
hdr->size = le64_to_cpu(hdr->size);
hdr->crc = le64_to_cpu(hdr->crc);
- printf("Version: %x, Size %u, crc %x\n", (unsigned int) hdr->version,
- (unsigned int) hdr->size,
- (unsigned int) hdr->crc);
+ printf("Version:\t0x%x\n", (unsigned int) hdr->version);
+ printf("Size:\t\t%u\n", (unsigned int) hdr->size);
+ printf("CRC:\t\t0x%x\n", (unsigned int) hdr->crc);
size -= sizeof(*hdr);
if (hdr->size != size) {
log_err("Unsupported version %d\n", (int) hdr->version);
}
-int main(int argc, char *argv[])
+static int show_file(const char *file)
{
struct stat sb;
void *buf;
int ret, fd;
- debug_init();
-
- if (argc < 2) {
- log_err("Usage: %s <state file>\n", argv[0]);
- return 1;
- }
-
- fd = open(argv[1], O_RDONLY);
+ fd = open(file, O_RDONLY);
if (fd < 0) {
- log_err("open %s: %s\n", argv[1], strerror(errno));
+ log_err("open %s: %s\n", file, strerror(errno));
return 1;
}
if (ret < 0) {
log_err("read: %s\n", strerror(errno));
close(fd);
+ free(buf);
return 1;
} else if (ret != sb.st_size) {
log_err("Short read\n");
close(fd);
+ free(buf);
return 1;
}
free(buf);
return 0;
}
+
+int main(int argc, char *argv[])
+{
+ int i, ret;
+
+ debug_init();
+
+ if (argc < 2) {
+ log_err("Usage: %s <state file>\n", argv[0]);
+ return 1;
+ }
+
+ ret = 0;
+ for (i = 1; i < argc; i++) {
+ ret = show_file(argv[i]);
+ if (ret)
+ break;
+ }
+
+ return ret;
+}