Unlink a writeable file, if overwrite isn't set
authorJens Axboe <jens.axboe@oracle.com>
Thu, 29 Mar 2007 12:52:13 +0000 (14:52 +0200)
committerJens Axboe <jens.axboe@oracle.com>
Thu, 29 Mar 2007 12:52:13 +0000 (14:52 +0200)
Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
filesetup.c

index aad0720f97e9429248f31fd439e2a6e5d1098170..e3478f582ac2c81405457546f6b8a15634521baa 100644 (file)
@@ -12,7 +12,7 @@
 
 static int extend_file(struct thread_data *td, struct fio_file *f)
 {
-       int r, new_layout = 0, flags;
+       int r, new_layout = 0, unlink_file = 0, flags;
        unsigned long long left;
        unsigned int bs;
        char *b;
@@ -24,8 +24,10 @@ static int extend_file(struct thread_data *td, struct fio_file *f)
         */
        if (td_read(td) || (td_write(td) && td->o.overwrite))
                new_layout = 1;
+       if (td_write(td) && !td->o.overwrite)
+               unlink_file = 1;
 
-       if (new_layout && (f->flags & FIO_FILE_EXISTS)) {
+       if ((unlink_file || new_layout) && (f->flags & FIO_FILE_EXISTS)) {
                if (unlink(f->file_name) < 0) {
                        td_verror(td, errno, "unlink");
                        return 1;