X-Git-Url: https://git.kernel.dk/?p=fio.git;a=blobdiff_plain;f=fio-ini.c;h=0c874085f466002c5893c994914ead475d412f4a;hp=05afbf142b71af7f75d93d4b183ad3d53cc9cbb8;hb=4e0ba8af8f0bfe0f194122661c8a659c2ac748e6;hpb=59b0f33bbaa635788354ba5de17251facf9590aa diff --git a/fio-ini.c b/fio-ini.c index 05afbf14..0c874085 100644 --- a/fio-ini.c +++ b/fio-ini.c @@ -216,7 +216,7 @@ static int add_job(struct thread_data *td, const char *jobname, int job_add_num) } if (td->filetype == FIO_TYPE_FILE) { - if (td->directory[0] != '\0') + if (td->directory && td->directory[0] != '\0') sprintf(td->file_name, "%s/%s.%d", td->directory, jobname, td->jobnum); else sprintf(td->file_name, "%s.%d", jobname, td->jobnum); @@ -648,7 +648,19 @@ static int str_ioengine_cb(struct thread_data *td, char *str) static int str_iolog_cb(struct thread_data *td, char *file) { - strncpy(td->iolog_file, file, sizeof(td->iolog_file) - 1); + td->iolog_file = strdup(file); + return 0; +} + +static int str_prerun_cb(struct thread_data *td, char *file) +{ + td->exec_prerun = strdup(file); + return 0; +} + +static int str_postrun_cb(struct thread_data *td, char *file) +{ + td->exec_postrun = strdup(file); return 0; } @@ -658,7 +670,7 @@ int parse_jobs_ini(char *file) unsigned long long ull; unsigned long ul1, ul2; struct thread_data *td; - char *string, *name; + char *string, *name, *tmpbuf; fpos_t off; FILE *f; char *p; @@ -671,6 +683,7 @@ int parse_jobs_ini(char *file) string = malloc(4096); name = malloc(256); + tmpbuf = malloc(4096); while ((p = fgets(string, 4096, f)) != NULL) { if (is_empty_or_comment(p)) @@ -853,7 +866,8 @@ int parse_jobs_ini(char *file) fgetpos(f, &off); continue; } - if (!check_strstore(p, "directory", td->directory)) { + if (!check_strstore(p, "directory", tmpbuf)) { + td->directory = strdup(tmpbuf); fgetpos(f, &off); continue; } @@ -905,6 +919,14 @@ int parse_jobs_ini(char *file) fgetpos(f, &off); continue; } + if (!check_str(p, "exec_prerun", str_prerun_cb, td)) { + fgetpos(f, &off); + continue; + } + if (!check_str(p, "exec_postrun", str_postrun_cb, td)) { + fgetpos(f, &off); + continue; + } printf("Client%d: bad option %s\n",td->thread_number,p); return 1; @@ -917,6 +939,7 @@ int parse_jobs_ini(char *file) free(string); free(name); + free(tmpbuf); fclose(f); return 0; }