Add sample job file showing how to read backwards
[fio.git] / t / verify-state.c
index 95dcf3a6822e9f8113454be39dc3de46a1c965ce..9a2c3df68cb1db568844ad263a600b3a43285167 100644 (file)
@@ -27,7 +27,9 @@ static void show_s(struct thread_io_list *s, unsigned int no_s)
        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);
@@ -93,22 +95,15 @@ static void show_verify_state(void *buf, size_t 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;
        }
 
@@ -136,3 +131,24 @@ int main(int argc, char *argv[])
        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;
+}