Add ETA output control and interactivity check
[fio.git] / init.c
diff --git a/init.c b/init.c
index 2a1ee149cc85dc15601a7ad86ec8a01021987d3c..84cb2d261251062a50cf4a1a6c875e4cd87edb97 100644 (file)
--- a/init.c
+++ b/init.c
@@ -24,18 +24,19 @@ static char fio_version_string[] = "fio 1.17.1";
 static char **ini_file;
 static int max_jobs = MAX_JOBS;
 static int dump_cmdline;
-static int read_only;
 
 struct thread_data def_thread;
 struct thread_data *threads = NULL;
 
 int exitall_on_terminate = 0;
 int terse_output = 0;
+int eta_print;
 unsigned long long mlock_size = 0;
 FILE *f_out = NULL;
 FILE *f_err = NULL;
 
 int write_bw_log = 0;
+int read_only = 0;
 
 static int def_timeout = 0;
 static int write_lat_log = 0;
@@ -97,6 +98,11 @@ static struct option long_options[FIO_NR_OPTIONS] = {
                .has_arg        = no_argument,
                .val            = 'r',
        },
+       {
+               .name           = "eta",
+               .has_arg        = required_argument,
+               .val            = 'e',
+       },
        {
                .name           = NULL,
        },
@@ -742,6 +748,8 @@ static void usage(void)
        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");
+       printf("\t--eta=when\tWhen ETA estimate should be printed\n");
+       printf("\t          \tMay be \"always\", \"never\" or \"auto\"\n");
 }
 
 static int parse_cmd_line(int argc, char *argv[])
@@ -785,6 +793,12 @@ static int parse_cmd_line(int argc, char *argv[])
                case 'v':
                        printf("%s\n", fio_version_string);
                        exit(0);
+               case 'e':
+                       if (!strcmp("always", optarg))
+                               eta_print = FIO_ETA_ALWAYS;
+                       else if (!strcmp("never", optarg))
+                               eta_print = FIO_ETA_NEVER;
+                       break;
                case FIO_GETOPT_JOB: {
                        const char *opt = long_options[lidx].name;
                        char *val = optarg;