int write_bw_log = 0;
int exitall_on_terminate = 0;
unsigned long long mlock_size = 0;
+FILE *f_out = NULL;
+FILE *f_err = NULL;
static struct thread_data *get_new_job(int global, struct thread_data *parent)
{
#ifndef FIO_HAVE_LIBAIO
if (td->io_engine == FIO_LIBAIO) {
- fprintf(stderr, "Linux libaio not available\n");
+ fprintf(f_err, "Linux libaio not available\n");
return 1;
}
#endif
#ifndef FIO_HAVE_POSIXAIO
if (td->io_engine == FIO_POSIXAIO) {
- fprintf(stderr, "posix aio not available\n");
+ fprintf(f_err, "posix aio not available\n");
return 1;
}
#endif
ddir = td->ddir + (!td->sequential << 1) + (td->iomix << 2);
if (!job_add_num)
- printf("%s: (g=%d): rw=%s, odir=%d, bs=%d-%d, rate=%d, ioengine=%s, iodepth=%d\n", td->name, td->groupid, ddir_str[ddir], td->odirect, td->min_bs, td->max_bs, td->rate, td->io_engine_name, td->iodepth);
+ fprintf(f_out, "%s: (g=%d): rw=%s, odir=%d, bs=%d-%d, rate=%d, ioengine=%s, iodepth=%d\n", td->name, td->groupid, ddir_str[ddir], td->odirect, td->min_bs, td->max_bs, td->rate, td->io_engine_name, td->iodepth);
else if (job_add_num == 1)
- printf("...\n");
+ fprintf(f_out, "...\n");
/*
* recurse add identical jobs, clear numjobs and stonewall options
return 0;
}
- fprintf(stderr, "fio: data direction: read, write, randread, randwrite, rw, randrw\n");
+ fprintf(f_err, "fio: data direction: read, write, randread, randwrite, rw, randrw\n");
return 1;
}
return 0;
}
- fprintf(stderr, "fio: verify types: md5, crc32\n");
+ fprintf(f_err, "fio: verify types: md5, crc32\n");
return 1;
}
return 0;
}
- fprintf(stderr, "fio: mem type: malloc, shm, mmap\n");
+ fprintf(f_err, "fio: mem type: malloc, shm, mmap\n");
return 1;
}
return 0;
}
- fprintf(stderr, "fio: ioengine: { linuxaio, aio, libaio }, posixaio, sync, mmap, sgio, splice\n");
+ fprintf(f_err, "fio: ioengine: { linuxaio, aio, libaio }, posixaio, sync, mmap, sgio, splice\n");
return 1;
}
if (!check_int(p, "prio", &prio)) {
#ifndef FIO_HAVE_IOPRIO
- fprintf(stderr, "io priorities not available\n");
+ fprintf(f_err, "io priorities not available\n");
ret = 1;
break;
#endif
}
if (!check_int(p, "prioclass", &prioclass)) {
#ifndef FIO_HAVE_IOPRIO
- fprintf(stderr, "io priorities not available\n");
+ fprintf(f_err, "io priorities not available\n");
ret = 1;
break;
#else
}
if (!check_int(p, "cpumask", &cpu)) {
#ifndef FIO_HAVE_CPU_AFFINITY
- fprintf(stderr, "cpu affinity not available\n");
+ fprintf(f_err, "cpu affinity not available\n");
ret = 1;
break;
#endif
}
if (!check_strstore(p, "iolog", tmpbuf)) {
if (td->write_iolog) {
- fprintf(stderr, "fio: read iolog overrides given write_iolog\n");
+ fprintf(f_err, "fio: read iolog overrides given write_iolog\n");
free(td->iolog_file);
td->write_iolog = 0;
}
td->iolog_file = strdup(tmpbuf);
td->write_iolog = 1;
} else
- fprintf(stderr, "fio: read iolog overrides given write_iolog\n");
+ fprintf(f_err, "fio: read iolog overrides given write_iolog\n");
fgetpos(f, &off);
continue;
}
}
if (!check_strstore(p, "ioscheduler", tmpbuf)) {
#ifndef FIO_HAVE_IOSCHED_SWITCH
- fprintf(stderr, "io scheduler switching not available\n");
+ fprintf(f_err, "io scheduler switching not available\n");
ret = 1;
break;
#else
{
int c;
- while ((c = getopt(argc, argv, "s:b:t:r:R:o:f:lwvh")) != EOF) {
+ while ((c = getopt(argc, argv, "s:b:t:r:R:o:f:lwvhO:")) != EOF) {
switch (c) {
case 's':
def_thread.sequential = !!atoi(optarg);
case 'w':
write_bw_log = 1;
break;
+ case 'O':
+ f_out = fopen(optarg, "w+");
+ if (!f_out) {
+ perror("fopen output");
+ exit(1);
+ }
+ f_err = f_out;
+ break;
case 'h':
usage(argv[0]);
exit(0);
if (!ini_file && argc > 1 && argv[argc - 1][0] != '-')
ini_file = strdup(argv[argc - 1]);
+ if (!f_out) {
+ f_out = stdout;
+ f_err = stderr;
+ }
}
static void free_shm(void)
parse_cmd_line(argc, argv);
if (!ini_file) {
- printf("Need job file\n");
+ fprintf(f_err, "Need job file\n");
usage(argv[0]);
return 1;
}