From cca73aa73328c3cb4d78adf1e54345701eff29fd Mon Sep 17 00:00:00 2001 From: Jens Axboe Date: Wed, 4 Apr 2007 11:09:19 +0200 Subject: [PATCH] Add a '--showcmd' option for dumping a job file It effectively shows what the equivelant command line string would be. Signed-off-by: Jens Axboe --- README | 1 + init.c | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 33 insertions(+) diff --git a/README b/README index 8b55f314..6b23d7c5 100644 --- a/README +++ b/README @@ -65,6 +65,7 @@ $ fio --version Print version info and exit --help Print this page --cmdhelp=cmd Print command help, "all" for all of them + --showcmd Turn a job file into command line options Any parameters following the options will be assumed to be job files, unless they match a job file parameter. You can add as many as you want, diff --git a/init.c b/init.c index 50c47601..0151c9bd 100644 --- a/init.c +++ b/init.c @@ -23,6 +23,7 @@ static char fio_version_string[] = "fio 1.15.1"; static char **ini_file; static int max_jobs = MAX_JOBS; +static int dump_cmdline; struct thread_data def_thread; struct thread_data *threads = NULL; @@ -85,6 +86,11 @@ static struct option long_options[FIO_NR_OPTIONS] = { .has_arg = optional_argument, .val = 'c', }, + { + .name = "showcmd", + .has_arg = no_argument, + .val = 's' + }, { .name = NULL, }, @@ -381,6 +387,14 @@ static int add_job(struct thread_data *td, const char *jobname, int job_add_num) if (td == &def_thread) return 0; + /* + * if we are just dumping the output command line, don't add the job + */ + if (dump_cmdline) { + put_job(td); + return 0; + } + engine = get_engine_name(td->o.ioengine); td->io_ops = load_ioengine(td, engine); if (!td->io_ops) { @@ -560,6 +574,12 @@ static int parse_jobs_ini(char *file, int stonewall_flag) name[strlen(name) - 1] = '\0'; + if (dump_cmdline) { + log_info("fio "); + if (!global) + log_info("--name=%s ", name); + } + td = get_new_job(global, &def_thread); if (!td) { ret = 1; @@ -594,6 +614,8 @@ static int parse_jobs_ini(char *file, int stonewall_flag) * easier on the user. */ ret |= fio_option_parse(td, p); + if (!ret && dump_cmdline) + log_info("--%s ", p); } if (!ret) { @@ -605,6 +627,9 @@ static int parse_jobs_ini(char *file, int stonewall_flag) } } while (!ret); + if (dump_cmdline) + log_info("\n"); + free(string); free(name); fclose(f); @@ -696,6 +721,7 @@ static void usage(void) printf("\t--version\tPrint version info and exit\n"); printf("\t--help\t\tPrint this page\n"); printf("\t--cmdhelp=cmd\tPrint command help, \"all\" for all of them\n"); + printf("\t--showcmd\tTurn a job file into command line options\n"); } static int parse_cmd_line(int argc, char *argv[]) @@ -730,6 +756,9 @@ static int parse_cmd_line(int argc, char *argv[]) exit(0); case 'c': exit(fio_show_option_help(optarg)); + case 's': + dump_cmdline = 1; + break; case 'v': printf("%s\n", fio_version_string); exit(0); @@ -812,6 +841,9 @@ int parse_options(int argc, char *argv[]) options_mem_free(&def_thread); if (!thread_number) { + if (dump_cmdline) + return 0; + log_err("No jobs defined(s)\n"); return 1; } -- 2.25.1