Make sure the ->files array is job private

Otherwise we introduce differences between threads and processes,
we don't want to do that.

Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
diff --git a/filesetup.c b/filesetup.c
index 137afac..d8b7401 100644
--- a/filesetup.c
+++ b/filesetup.c
@@ -539,6 +539,7 @@
 	}
 
 	td->o.filename = NULL;
+	free(td->files);
 	td->files = NULL;
 	td->o.nr_files = 0;
 }
@@ -661,3 +662,22 @@
 {
 	return recurse_dir(td, path);
 }
+
+void dup_files(struct thread_data *td, struct thread_data *org)
+{
+	struct fio_file *f;
+	unsigned int i;
+	size_t bytes;
+
+	if (!org->files)
+		return;
+
+	bytes = org->files_index * sizeof(*f);
+	td->files = malloc(bytes);
+	memcpy(td->files, org->files, bytes);
+
+	for_each_file(td, f, i) {
+		if (f->file_name)
+			f->file_name = strdup(f->file_name);
+	}
+}