Don't check st_size for special files
[fio.git] / filesetup.c
index 1f1259d1ac156bd99666b73e8a6a71ecdd4d28ee..08742247d58c1f345303fbedb968c3594650aa48 100644 (file)
@@ -18,9 +18,15 @@ static int file_ok(struct thread_data *td, struct fio_file *f)
        if (td->filetype != FIO_TYPE_FILE || (td->io_ops->flags & FIO_NULLIO))
                return 0;
 
-       if (stat(f->file_name, &st) == -1)
+       if (lstat(f->file_name, &st) == -1)
                return 1;
-       else if (st.st_size < (off_t) f->file_size)
+
+       /*
+        * if it's a special file, size is always ok for now
+        */
+       if (S_ISCHR(st.st_mode) || S_ISBLK(st.st_mode))
+               return 0;
+       if (st.st_size < (off_t) f->file_size)
                return 1;
 
        return 0;
@@ -154,6 +160,16 @@ static int file_size(struct thread_data *td, struct fio_file *f)
 {
        struct stat st;
 
+       /*
+        * if we are not doing real io, just pretend the file is as large
+        * as the size= given. this works fine with nrfiles > 1 as well,
+        * we only really care about it being at least as big as size=
+        */
+       if (td->io_ops->flags & FIO_NULLIO) {
+               f->real_file_size = f->file_size = td->total_file_size;
+               return 0;
+       }
+
        if (td->overwrite) {
                if (fstat(f->fd, &st) == -1) {
                        td_verror(td, errno);