options: check for conflict between trims and readonly option
[fio.git] / options.c
index 445f3d453e88baa1c9a9c4737b16b34fd1aaef38..a174e2cd165316494211a256428c758632da7d86 100644 (file)
--- a/options.c
+++ b/options.c
@@ -1046,8 +1046,6 @@ static int parse_zoned_distribution(struct thread_data *td, const char *input,
        }
 
        if (parse_dryrun()) {
-               int i;
-
                for (i = 0; i < DDIR_RWDIR_CNT; i++) {
                        free(td->o.zone_split[i]);
                        td->o.zone_split[i] = NULL;
@@ -1557,9 +1555,9 @@ static int rw_verify(const struct fio_option *o, void *data)
 {
        struct thread_data *td = cb_data_to_td(data);
 
-       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);
+       if (read_only && (td_write(td) || td_trim(td))) {
+               log_err("fio: job <%s> has write or trim bit set, but"
+                       " fio is in read-only mode\n", td->o.name);
                return 1;
        }
 
@@ -4792,7 +4790,7 @@ static char *bc_calc(char *str)
  * substitution always occurs, even if VARNAME is empty or the corresponding
  * environment variable undefined.
  */
-static char *option_dup_subs(const char *opt)
+char *fio_option_dup_subs(const char *opt)
 {
        char out[OPT_LEN_MAX+1];
        char in[OPT_LEN_MAX+1];
@@ -4897,7 +4895,7 @@ static char **dup_and_sub_options(char **opts, int num_opts)
        int i;
        char **opts_copy = malloc(num_opts * sizeof(*opts));
        for (i = 0; i < num_opts; i++) {
-               opts_copy[i] = option_dup_subs(opts[i]);
+               opts_copy[i] = fio_option_dup_subs(opts[i]);
                if (!opts_copy[i])
                        continue;
                opts_copy[i] = fio_keyword_replace(opts_copy[i]);