From 08e32bfc8019021a3b16fb5db95f75d1eec6ff31 Mon Sep 17 00:00:00 2001 From: Timo Sirainen Date: Thu, 29 Mar 2018 14:24:11 -0400 Subject: [PATCH] fs-posix: Fix iterating nonexistent symlinks when readdir() returns DT_UNKNOWN This especially broke "doveadm fs delete -R" when the symlink destination was deleted before the symlink. --- src/lib-fs/fs-posix.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/lib-fs/fs-posix.c b/src/lib-fs/fs-posix.c index efd2afe260..08e733dd1c 100644 --- a/src/lib-fs/fs-posix.c +++ b/src/lib-fs/fs-posix.c @@ -829,7 +829,8 @@ static bool fs_posix_iter_want(struct posix_fs_iter *iter, const char *fname) const char *path = t_strdup_printf("%s/%s", iter->path, fname); struct stat st; - if (stat(path, &st) < 0) + if (stat(path, &st) < 0 && + lstat(path, &st) < 0) ret = FALSE; else if (!S_ISDIR(st.st_mode)) ret = (iter->iter.flags & FS_ITER_FLAG_DIRS) == 0; -- 2.47.3