+/*
+ * Setup a log for storing io patterns.
+ */
+static int init_iolog_write(struct thread_data *td)
+{
+ FILE *f = fopen(td->iolog_file, "w");
+
+ f = fopen(td->iolog_file, "w");
+ if (!f) {
+ perror("fopen write iolog");
+ return 1;
+ }
+
+ /*
+ * That's it for writing, setup a log buffer and we're done.
+ */
+ td->iolog_f = f;
+ td->iolog_buf = malloc(8192);
+ setvbuf(f, td->iolog_buf, _IOFBF, 8192);
+ return 0;
+}
+
+int init_iolog(struct thread_data *td)
+{
+ if (td->read_iolog)
+ return init_iolog_read(td);
+ else if (td->write_iolog)
+ return init_iolog_write(td);
+
+ return 0;
+}
+