- }
-
- return err;
-}
-
-static int setup_file(struct thread_data *td, struct fio_file *f)
-{
- int flags = 0;
-
- if (td->io_ops->flags & FIO_NETIO)
- return 0;
-
- /*
- * we need a valid file descriptor, but don't create a real file.
- * lets just dup stdout, seems like a sensible approach.
- */
- if (td->io_ops->flags & FIO_NULLIO)
- f->fd = dup(STDOUT_FILENO);
- else {
- if (td->odirect)
- flags |= OS_O_DIRECT;
- if (td->sync_io)
- flags |= O_SYNC;
-
- if (td_write(td) || td_rw(td)) {
- flags |= O_RDWR;
-
- if (td->filetype == FIO_TYPE_FILE) {
- if (!td->overwrite)
- flags |= O_TRUNC;
-
- flags |= O_CREAT;
- }
-
- f->fd = open(f->file_name, flags, 0600);
- } else {
- if (td->filetype == FIO_TYPE_CHAR)
- flags |= O_RDWR;
- else
- flags |= O_RDONLY;
-
- f->fd = open(f->file_name, flags);
- }
- }
-
- if (f->fd == -1) {
- int __e = errno;
-
- td_verror(td, __e, "open");
- if (__e == EINVAL && td->odirect)
- log_err("fio: destination does not support O_DIRECT\n");
- return 1;
- }
-
- if (get_file_size(td, f))
- return 1;
-
- return 0;
-}
-
-int open_files(struct thread_data *td)
-{
- struct fio_file *f;
- int i, err = 0;