Add support for giving multiple --section options
authorJens Axboe <jaxboe@fusionio.com>
Fri, 11 Mar 2011 09:16:17 +0000 (10:16 +0100)
committerJens Axboe <jaxboe@fusionio.com>
Fri, 11 Mar 2011 09:16:17 +0000 (10:16 +0100)
Signed-off-by: Jens Axboe <jaxboe@fusionio.com>
README
init.c

diff --git a/README b/README
index 89a88e9615cbc2dea6ef7a0f00b0859ecb92d9f8..ca7f73c33d4f19b299536edd95a59aef2c8fd697 100644 (file)
--- a/README
+++ b/README
@@ -137,10 +137,12 @@ $ fio
        --help                  Print this page
        --cmdhelp=cmd   Print command help, "all" for all of them
        --showcmd               Turn a job file into command line options
-       --readonly              Turn on safety read-only checks, preventing writes
+       --readonly              Turn on safety read-only checks, preventing
+                                       writes
        --eta=when              When ETA estimate should be printed
                                        May be "always", "never" or "auto"
-       --section=name  Only run specified section in job file
+       --section=name  Only run specified section in job file. Multiple
+                               sections can be specified.
        --alloc-size=kb Set smalloc pool to this size in kb (def 1024)
        --warnings-fatal Fio parser warnings are fatal
 
diff --git a/init.c b/init.c
index e0f58cd54817369f3dfb57e9ab5b5d3de2b4dea9..1cd0cae05e99109ae224c1e079563c0950e642d6 100644 (file)
--- a/init.c
+++ b/init.c
@@ -39,7 +39,8 @@ int eta_print;
 unsigned long long mlock_size = 0;
 FILE *f_out = NULL;
 FILE *f_err = NULL;
-char *job_section = NULL;
+char **job_sections = NULL;
+int nr_job_sections = 0;
 char *exec_profile = NULL;
 int warnings_fatal = 0;
 
@@ -724,12 +725,18 @@ void add_job_opts(const char **o)
 
 static int skip_this_section(const char *name)
 {
-       if (!job_section)
+       int i;
+
+       if (!nr_job_sections)
                return 0;
        if (!strncmp(name, "global", 6))
                return 0;
 
-       return strcmp(job_section, name);
+       for (i = 0; i < nr_job_sections; i++)
+               if (!strcmp(job_sections[i], name))
+                       return 0;
+
+       return 1;
 }
 
 static int is_empty_or_comment(char *line)
@@ -1167,7 +1174,9 @@ static int parse_cmd_line(int argc, char *argv[])
                        if (set_debug(optarg))
                                do_exit++;
                        break;
-               case 'x':
+               case 'x': {
+                       size_t new_size;
+
                        if (!strcmp(optarg, "global")) {
                                log_err("fio: can't use global as only "
                                        "section\n");
@@ -1175,10 +1184,12 @@ static int parse_cmd_line(int argc, char *argv[])
                                exit_val = 1;
                                break;
                        }
-                       if (job_section)
-                               free(job_section);
-                       job_section = strdup(optarg);
+                       new_size = (nr_job_sections + 1) * sizeof(char *);
+                       job_sections = realloc(job_sections, new_size);
+                       job_sections[nr_job_sections] = strdup(optarg);
+                       nr_job_sections++;
                        break;
+                       }
                case 'p':
                        exec_profile = strdup(optarg);
                        break;