From: Jens Axboe Date: Tue, 27 Mar 2007 17:43:53 +0000 (+0200) Subject: 'opendir' fixes X-Git-Tag: fio-1.15~14 X-Git-Url: https://git.kernel.dk/?a=commitdiff_plain;h=0ddb270c21adffa45cd9d215f29aafd8a9c5b15a;p=fio.git '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 --- 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)