Add check for pipe/fifo files
[fio.git] / filesetup.c
index c99d5b36dad8195129d40c048eb966d36caebae0..bb25cd5c20bf43ea46646f3b5fb799637e23f5f2 100644 (file)
@@ -181,7 +181,7 @@ int file_invalidate_cache(struct thread_data *td, struct fio_file *f)
                        log_err("fio: only root may flush block devices. Cache flush bypassed!\n");
                        ret = 0;
                }
-       } else if (f->filetype == FIO_TYPE_CHAR)
+       } else if (f->filetype == FIO_TYPE_CHAR || f->filetype == FIO_TYPE_PIPE)
                ret = 0;
 
        if (ret < 0) {
@@ -283,11 +283,15 @@ static int get_file_sizes(struct thread_data *td)
 
        for_each_file(td, f, i) {
                if (td->io_ops->open_file(td, f)) {
-                       log_err("%s\n", td->verror);
-                       err = 1;
+                       if (td->error != ENOENT) {
+                               log_err("%s\n", td->verror);
+                               err = 1;
+                       }
                        clear_error(td);
-               } else
-                       td->io_ops->close_file(td, f);
+               } else {
+                       if (td->io_ops->close_file)
+                               td->io_ops->close_file(td, f);
+               }
 
                if (f->real_file_size == -1ULL && td->o.size)
                        f->real_file_size = td->o.size / td->o.nr_files;
@@ -481,6 +485,8 @@ static void get_file_type(struct fio_file *f)
                        f->filetype = FIO_TYPE_BD;
                else if (S_ISCHR(sb.st_mode))
                        f->filetype = FIO_TYPE_CHAR;
+               else if (S_ISFIFO(sb.st_mode))
+                       f->filetype = FIO_TYPE_PIPE;
        }
 }
 
@@ -497,6 +503,12 @@ void add_file(struct thread_data *td, const char *fname)
        memset(f, 0, sizeof(*f));
        f->fd = -1;
 
+       /*
+        * init function, io engine may not be loaded yet
+        */
+       if (td->io_ops && (td->io_ops->flags & FIO_DISKLESSIO))
+               f->real_file_size = -1ULL;
+
        if (td->o.directory)
                len = sprintf(file_name, "%s/", td->o.directory);