From ea443657ce85860b7a0dd2f39f2572d4a09fc885 Mon Sep 17 00:00:00 2001 From: Jens Axboe Date: Thu, 29 Mar 2007 14:52:13 +0200 Subject: [PATCH 1/1] Unlink a writeable file, if overwrite isn't set Signed-off-by: Jens Axboe --- filesetup.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/filesetup.c b/filesetup.c index aad0720f..e3478f58 100644 --- a/filesetup.c +++ b/filesetup.c @@ -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; -- 2.25.1