From: Jens Axboe Date: Thu, 29 Mar 2007 12:52:13 +0000 (+0200) Subject: Unlink a writeable file, if overwrite isn't set X-Git-Tag: fio-1.15.1~7 X-Git-Url: https://git.kernel.dk/?p=fio.git;a=commitdiff_plain;h=ea443657ce85860b7a0dd2f39f2572d4a09fc885;hp=99cbac76e5b14ea29163f6ea08c3ab807f5e5b19 Unlink a writeable file, if overwrite isn't set Signed-off-by: Jens Axboe --- 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;