[PATCH] Unlink write file if !overwrite and it exists
[fio.git] / filesetup.c
index 75288706cdd2e09a8aa138a67d2d671668557e08..2af6c2fc560b99237b6ca24344f4a8c55426289c 100644 (file)
@@ -103,9 +103,18 @@ static int create_files(struct thread_data *td)
                return 0;
 
        need_create = 0;
-       if (td->filetype == FIO_TYPE_FILE)
-               for_each_file(td, f, i)
-                       need_create += file_ok(td, f);
+       if (td->filetype == FIO_TYPE_FILE) {
+               for_each_file(td, f, i) {
+                       int file_there = !file_ok(td, f);
+
+                       if (file_there && td->ddir == WRITE && !td->overwrite) {
+                               unlink(f->file_name);
+                               file_there = 0;
+                       }
+
+                       need_create += !file_there;
+               }
+       }
 
        if (!need_create)
                return 0;