From 0ddb270c21adffa45cd9d215f29aafd8a9c5b15a Mon Sep 17 00:00:00 2001 From: Jens Axboe Date: Tue, 27 Mar 2007 19:43:53 +0200 Subject: [PATCH] 'opendir' fixes - Don't dive into a directory if it isn't a directory - Dump info on how many files added Signed-off-by: Jens Axboe --- filesetup.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/filesetup.c b/filesetup.c index 5ad626a9..b0a40e57 100644 --- a/filesetup.c +++ b/filesetup.c @@ -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) -- 2.25.1