From 66748e15aff805c9d8c5016a74fc51d1e7ef6fe1 Mon Sep 17 00:00:00 2001 From: Andre Noll Date: Thu, 1 Sep 2016 17:13:50 +0200 Subject: [PATCH] create: Make the directory scan more robust. The directory traversal of adu calls adu_opendir() of fd.c for every subdirectory. If this call fails with EACCESS, a warning is printed but the operation continues, ignoring the directory which could not be accessed. Other errors are considered fatal, though, and adu aborts in this case. This patch continues to scan in this case. This is achieved by making all errors from adu_opendir non-fatal. In the error case we print a warning and ignore the directory, but no longer abort. Thanks to Steffen Schmidt for pointing out this flaw. --- create.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/create.c b/create.c index af5694c..a3373db 100644 --- a/create.c +++ b/create.c @@ -140,10 +140,9 @@ static int scan_dir(char *dirname, uint64_t *parent_dir_num) check_signals(); DEBUG_LOG("----------------- %llu: %s\n", (long long unsigned)current_dir_num, dirname); ret = adu_opendir(dirname, &dir, &cwd_fd); - if (ret < 0) { - if (ret != -ERRNO_TO_ERROR(EACCES)) - return ret; - WARNING_LOG("permission denied for %s\n", dirname); + if (ret < 0) { /* Non-fatal, continue with next dir */ + WARNING_LOG("skipping dir %s: %s\n", dirname, + adu_strerror(-ret)); return 1; } while ((entry = readdir(dir))) { -- 2.39.5