From ad0a273593b93f61e72fbdf1910fcf8cdcac738c Mon Sep 17 00:00:00 2001 From: Jens Axboe Date: Fri, 11 Mar 2011 10:16:17 +0100 Subject: [PATCH] Add support for giving multiple --section options Signed-off-by: Jens Axboe --- README | 6 ++++-- init.c | 25 ++++++++++++++++++------- 2 files changed, 22 insertions(+), 9 deletions(-) diff --git a/README b/README index 89a88e96..ca7f73c3 100644 --- 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 e0f58cd5..1cd0cae0 100644 --- 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; -- 2.25.1