Extend --readonly
- Never allow open of a data file with writeable bits sets, and that
includes extend as well.
- Skip any writes in replay logs (iolog/iolog2/blktrace)
Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
diff --git a/filesetup.c b/filesetup.c
index ff1385c..47ddacf 100644
--- a/filesetup.c
+++ b/filesetup.c
@@ -18,6 +18,11 @@
unsigned int bs;
char *b;
+ if (read_only) {
+ log_err("fio: refusing extend of file due to read-only\n");
+ return 0;
+ }
+
/*
* check if we need to lay the file out complete again. fio
* does that for operations involving reads, or for writes
@@ -228,6 +233,8 @@
flags |= O_SYNC;
if (td_write(td)) {
+ assert(!read_only);
+
flags |= O_RDWR;
if (f->filetype == FIO_TYPE_FILE)
@@ -238,7 +245,7 @@
else
f->fd = open(f->file_name, flags, 0600);
} else {
- if (f->filetype == FIO_TYPE_CHAR)
+ if (f->filetype == FIO_TYPE_CHAR && !read_only)
flags |= O_RDWR;
else
flags |= O_RDONLY;