Make fill_device detect bdev sizes too
[fio.git] / filesetup.c
index ec5d781ed0dea0e8c98c5a05289340969123e4c5..8aa9fc7461397513fca56b1f58b280a49b210782 100644 (file)
@@ -3,6 +3,7 @@
 #include <string.h>
 #include <assert.h>
 #include <dirent.h>
 #include <string.h>
 #include <assert.h>
 #include <dirent.h>
+#include <libgen.h>
 #include <sys/stat.h>
 #include <sys/mman.h>
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <sys/mman.h>
 #include <sys/types.h>
@@ -516,7 +517,7 @@ struct fio_mount {
 static unsigned long long get_fs_free_counts(struct thread_data *td)
 {
        struct flist_head *n, *tmp;
 static unsigned long long get_fs_free_counts(struct thread_data *td)
 {
        struct flist_head *n, *tmp;
-       unsigned long long ret;
+       unsigned long long ret = 0;
        struct fio_mount *fm;
        FLIST_HEAD(list);
        struct fio_file *f;
        struct fio_mount *fm;
        FLIST_HEAD(list);
        struct fio_file *f;
@@ -526,6 +527,12 @@ static unsigned long long get_fs_free_counts(struct thread_data *td)
                struct stat sb;
                char buf[256];
 
                struct stat sb;
                char buf[256];
 
+               if (f->filetype == FIO_TYPE_BD) {
+                       ret += f->real_file_size;
+                       continue;
+               } else if (f->filetype != FIO_TYPE_FILE)
+                       continue;
+
                strcpy(buf, f->file_name);
 
                if (stat(buf, &sb) < 0) {
                strcpy(buf, f->file_name);
 
                if (stat(buf, &sb) < 0) {
@@ -555,7 +562,6 @@ static unsigned long long get_fs_free_counts(struct thread_data *td)
                flist_add(&fm->list, &list);
        }
 
                flist_add(&fm->list, &list);
        }
 
-       ret = 0;
        flist_for_each_safe(n, tmp, &list) {
                unsigned long long sz;
 
        flist_for_each_safe(n, tmp, &list) {
                unsigned long long sz;