Add support for giving multiple --section options

Signed-off-by: Jens Axboe <jaxboe@fusionio.com>
diff --git a/README b/README
index 89a88e9..ca7f73c 100644
--- a/README
+++ b/README
@@ -137,10 +137,12 @@
 	--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 e0f58cd..1cd0cae 100644
--- a/init.c
+++ b/init.c
@@ -39,7 +39,8 @@
 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 @@
 
 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 @@
 			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 @@
 				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;