Merge branch 'add-libpmem-engine' of https://github.com/tishizaki/fio into libpmem
[fio.git] / filesetup.c
index 1efffa8febb19d1a7f19ccc3110212f05686b6dd..4d29b70a32e14ffaca9b85b09e8ccc62aa13e960 100644 (file)
@@ -59,8 +59,6 @@ static int native_fallocate(struct thread_data *td, struct fio_file *f)
 
 static void fallocate_file(struct thread_data *td, struct fio_file *f)
 {
-       int r;
-
        if (td->o.fill_device)
                return;
 
@@ -71,7 +69,9 @@ static void fallocate_file(struct thread_data *td, struct fio_file *f)
        case FIO_FALLOCATE_NONE:
                break;
 #ifdef CONFIG_POSIX_FALLOCATE
-       case FIO_FALLOCATE_POSIX:
+       case FIO_FALLOCATE_POSIX: {
+               int r;
+
                dprint(FD_FILE, "posix_fallocate file %s size %llu\n",
                                 f->file_name,
                                 (unsigned long long) f->real_file_size);
@@ -80,9 +80,12 @@ static void fallocate_file(struct thread_data *td, struct fio_file *f)
                if (r > 0)
                        log_err("fio: posix_fallocate fails: %s\n", strerror(r));
                break;
+               }
 #endif /* CONFIG_POSIX_FALLOCATE */
 #ifdef CONFIG_LINUX_FALLOCATE
-       case FIO_FALLOCATE_KEEP_SIZE:
+       case FIO_FALLOCATE_KEEP_SIZE: {
+               int r;
+
                dprint(FD_FILE, "fallocate(FALLOC_FL_KEEP_SIZE) "
                                "file %s size %llu\n", f->file_name,
                                (unsigned long long) f->real_file_size);
@@ -92,6 +95,7 @@ static void fallocate_file(struct thread_data *td, struct fio_file *f)
                        td_verror(td, errno, "fallocate");
 
                break;
+               }
 #endif /* CONFIG_LINUX_FALLOCATE */
        default:
                log_err("fio: unknown fallocate mode: %d\n", td->o.fallocate_mode);
@@ -1516,7 +1520,7 @@ bool exists_and_not_regfile(const char *filename)
        return true;
 }
 
-static int create_work_dirs(struct thread_data *td, const char *fname)
+static bool create_work_dirs(struct thread_data *td, const char *fname)
 {
        char path[PATH_MAX];
        char *start, *end;
@@ -1543,13 +1547,13 @@ static int create_work_dirs(struct thread_data *td, const char *fname)
 #endif
                        log_err("fio: failed to create dir (%s): %d\n",
                                start, errno);
-                       return 1;
+                       return false;
                }
                *end = FIO_OS_PATH_SEPARATOR;
                end++;
        }
        td->flags |= TD_F_DIRS_CREATED;
-       return 0;
+       return true;
 }
 
 int add_file(struct thread_data *td, const char *fname, int numjob, int inc)
@@ -1569,7 +1573,7 @@ int add_file(struct thread_data *td, const char *fname, int numjob, int inc)
 
        if (strchr(fname, FIO_OS_PATH_SEPARATOR) &&
            !(td->flags & TD_F_DIRS_CREATED) &&
-           create_work_dirs(td, fname))
+           !create_work_dirs(td, fname))
                return 1;
 
        /* clean cloned siblings using existing files */
@@ -1737,10 +1741,10 @@ void unlock_file_all(struct thread_data *td, struct fio_file *f)
                unlock_file(td, f);
 }
 
-static int recurse_dir(struct thread_data *td, const char *dirname)
+static bool recurse_dir(struct thread_data *td, const char *dirname)
 {
        struct dirent *dir;
-       int ret = 0;
+       bool ret = false;
        DIR *D;
 
        D = opendir(dirname);
@@ -1749,7 +1753,7 @@ static int recurse_dir(struct thread_data *td, const char *dirname)
 
                snprintf(buf, FIO_VERROR_SIZE, "opendir(%s)", dirname);
                td_verror(td, errno, buf);
-               return 1;
+               return true;
        }
 
        while ((dir = readdir(D)) != NULL) {
@@ -1764,7 +1768,7 @@ static int recurse_dir(struct thread_data *td, const char *dirname)
                if (lstat(full_path, &sb) == -1) {
                        if (errno != ENOENT) {
                                td_verror(td, errno, "stat");
-                               ret = 1;
+                               ret = true;
                                break;
                        }
                }