From: Andrey Kuzmin Date: Sat, 13 Feb 2016 19:31:00 +0000 (-0700) Subject: Allow for the include file specification to be relative. X-Git-Tag: fio-2.7~19 X-Git-Url: https://git.kernel.dk/?p=fio.git;a=commitdiff_plain;h=c0821a08db2fd3e37e16db73c3c4c9c7ff601e88;ds=inline Allow for the include file specification to be relative. Simplifies include file grouping, with same directory file included via file name. Checked only if the lookup by the file name specified fails. Signed-off-by: Jens Axboe --- diff --git a/init.c b/init.c index 5ee40823..c7ce2cc0 100644 --- a/init.c +++ b/init.c @@ -1773,15 +1773,48 @@ int __parse_jobs_ini(struct thread_data *td, strip_blank_end(p); if (!strncmp(p, "include", strlen("include"))) { - char *filename = p + strlen("include") + 1; + char *filename = p + strlen("include") + 1, + *ts, *full_fn = NULL; - if ((ret = __parse_jobs_ini(td, filename, - is_buf, stonewall_flag, type, 1, - name, &opts, &alloc_opts, &num_opts))) { - log_err("Error %d while parsing include file %s\n", + /* + * Allow for the include filename + * specification to be relative. + */ + if (access(filename, F_OK) && + (ts = strrchr(file, '/'))) { + int len = ts - file + + strlen(filename) + 2; + + if (!(full_fn = calloc(1, len))) { + ret = ENOMEM; + break; + } + + strncpy(full_fn, + file, (ts - file) + 1); + strncpy(full_fn + (ts - file) + 1, + filename, strlen(filename)); + full_fn[len - 1] = 0; + filename = full_fn; + } + + ret = __parse_jobs_ini(td, filename, is_buf, + stonewall_flag, type, 1, + name, &opts, + &alloc_opts, &num_opts); + + if (ret) { + log_err("Error %d while parsing " + "include file %s\n", ret, filename); - break; } + + if (full_fn) + free(full_fn); + + if (ret) + break; + continue; }