'opendir' fixes
authorJens Axboe <jens.axboe@oracle.com>
Tue, 27 Mar 2007 17:43:53 +0000 (19:43 +0200)
committerJens Axboe <jens.axboe@oracle.com>
Tue, 27 Mar 2007 17:43:53 +0000 (19:43 +0200)
- Don't dive into a directory if it isn't a directory
- Dump info on how many files added

Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
filesetup.c

index 5ad626a9df38a9b77bf6360eeabc4cebd42f760a..b0a40e572b23996ba6f53996a75eb447d2c6ecde 100644 (file)
@@ -521,7 +521,10 @@ static int recurse_dir(struct thread_data *td, const char *dirname)
 
        D = opendir(dirname);
        if (!D) {
-               td_verror(td, errno, "opendir");
+               char buf[FIO_VERROR_SIZE];
+
+               snprintf(buf, FIO_VERROR_SIZE - 1, "opendir(%s)", dirname);
+               td_verror(td, errno, buf);
                return 1;
        }
 
@@ -546,6 +549,8 @@ static int recurse_dir(struct thread_data *td, const char *dirname)
                        td->o.nr_files++;
                        continue;
                }
+               if (!S_ISDIR(sb.st_mode))
+                       continue;
 
                if ((ret = recurse_dir(td, full_path)) != 0)
                        break;
@@ -557,7 +562,12 @@ static int recurse_dir(struct thread_data *td, const char *dirname)
 
 int add_dir_files(struct thread_data *td, const char *path)
 {
-       return recurse_dir(td, path);
+       int ret = recurse_dir(td, path);
+
+       if (!ret)
+               log_info("fio: opendir added %d files\n", td->o.nr_files);
+
+       return ret;
 }
 
 void dup_files(struct thread_data *td, struct thread_data *org)