Kill -arch from OSX Makefile
[fio.git] / filesetup.c
index b90d12ae8f17aefb4aeb11c1dac3a45b697c9546..ae893c7b178ecf4ab3080afd70095a3af2c97e2e 100644 (file)
@@ -71,9 +71,9 @@ static int extend_file(struct thread_data *td, struct fio_file *f)
                                                        f->real_file_size);
 
                r = posix_fallocate(f->fd, 0, f->real_file_size);
-               if (r < 0) {
+               if (r > 0) {
                        log_err("fio: posix_fallocate fails: %s\n",
-                                       strerror(-r));
+                                       strerror(r));
                }
        }
 #endif
@@ -244,6 +244,7 @@ static int bdev_size(struct thread_data *td, struct fio_file *f)
        r = blockdev_size(f->fd, &bytes);
        if (r) {
                td_verror(td, r, "blockdev_size");
+               printf("fd is %d\n", f->fd);
                goto err;
        }
 
@@ -909,6 +910,7 @@ int add_file(struct thread_data *td, const char *fname)
        }
 
        f->fd = -1;
+       fio_file_reset(f);
 
        if (td->files_size <= td->files_index) {
                int new_size = td->o.nr_files + 1;
@@ -962,6 +964,19 @@ int add_file(struct thread_data *td, const char *fname)
        return cur_files;
 }
 
+int add_file_exclusive(struct thread_data *td, const char *fname)
+{
+       struct fio_file *f;
+       unsigned int i;
+
+       for_each_file(td, f, i) {
+               if (!strcmp(f->file_name, fname))
+                       return i;
+       }
+
+       return add_file(td, fname);
+}
+
 void get_file(struct fio_file *f)
 {
        dprint(FD_FILE, "get file %s, ref=%d\n", f->file_name, f->references);
@@ -1136,6 +1151,7 @@ void dup_files(struct thread_data *td, struct thread_data *org)
                        assert(0);
                }
                __f->fd = -1;
+               fio_file_reset(__f);
 
                if (f->file_name) {
                        __f->file_name = smalloc_strdup(f->file_name);