Add --readonly option

Suggested by Valerie Henson. It can be used as an extra safety guard
against accidentically turning on a write setting. See README.

Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
diff --git a/init.c b/init.c
index f3cb9ad..2a1ee14 100644
--- a/init.c
+++ b/init.c
@@ -24,6 +24,7 @@
 static char **ini_file;
 static int max_jobs = MAX_JOBS;
 static int dump_cmdline;
+static int read_only;
 
 struct thread_data def_thread;
 struct thread_data *threads = NULL;
@@ -89,7 +90,12 @@
 	{
 		.name		= "showcmd",
 		.has_arg	= no_argument,
-		.val		= 's'
+		.val		= 's',
+	},
+	{
+		.name		= "readonly",
+		.has_arg	= no_argument,
+		.val		= 'r',
 	},
 	{
 		.name		= NULL,
@@ -180,6 +186,11 @@
 {
 	struct thread_options *o = &td->o;
 
+	if (read_only && td_write(td)) {
+		log_err("fio: job <%s> has write bit set, but fio is in read-only mode\n", td->o.name);
+		return 1;
+	}
+	
 	if (o->rwmix[DDIR_READ] + o->rwmix[DDIR_WRITE] > 100)
 		o->rwmix[DDIR_WRITE] = 100 - o->rwmix[DDIR_READ];
 
@@ -768,6 +779,9 @@
 		case 's':
 			dump_cmdline = 1;
 			break;
+		case 'r':
+			read_only = 1;
+			break;
 		case 'v':
 			printf("%s\n", fio_version_string);
 			exit(0);