get_file_type() should use stat(), not lstat()
[fio.git] / filesetup.c
index 70589aa513eaa95d6108664df88d43270d8ba475..c188981356a2cb022e9037d84c8f6f01d9c33a6c 100644 (file)
@@ -64,6 +64,19 @@ static int extend_file(struct thread_data *td, struct fio_file *f)
                return 1;
        }
 
+#ifdef FIO_HAVE_FALLOCATE
+       if (td->o.fallocate && !td->o.fill_device) {
+               dprint(FD_FILE, "fallocate file %s size %llu\n", f->file_name,
+                                                       f->real_file_size);
+
+               r = posix_fallocate(f->fd, 0, f->real_file_size);
+               if (r < 0) {
+                       log_err("fio: posix_fallocate fails: %s\n",
+                                       strerror(-r));
+               }
+       }
+#endif
+       
        if (!new_layout)
                goto done;
 
@@ -78,16 +91,6 @@ static int extend_file(struct thread_data *td, struct fio_file *f)
                        td_verror(td, errno, "ftruncate");
                        goto err;
                }
-
-#ifdef FIO_HAVE_FALLOCATE
-               dprint(FD_FILE, "fallocate file %s, size %llu\n", f->file_name,
-                                                       f->real_file_size);
-               r = posix_fallocate(f->fd, 0, f->real_file_size);
-               if (r < 0) {
-                       log_err("fio: posix_fallocate fails: %s\n",
-                                       strerror(-r));
-               }
-#endif
        }
 
        b = malloc(td->o.max_bs[DDIR_WRITE]);
@@ -767,7 +770,7 @@ static void get_file_type(struct fio_file *f)
        else
                f->filetype = FIO_TYPE_FILE;
 
-       if (!lstat(f->file_name, &sb)) {
+       if (!stat(f->file_name, &sb)) {
                if (S_ISBLK(sb.st_mode))
                        f->filetype = FIO_TYPE_BD;
                else if (S_ISCHR(sb.st_mode))