changeset 22943:b00d51dbc55d

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.
author Timo Sirainen <timo.sirainen@dovecot.fi>
date Thu, 29 Mar 2018 14:24:11 -0400
parents b91af97dd666
children 666f2182826f
files src/lib-fs/fs-posix.c
diffstat 1 files changed, 2 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/src/lib-fs/fs-posix.c	Thu Apr 26 19:38:55 2018 +0300
+++ b/src/lib-fs/fs-posix.c	Thu Mar 29 14:24:11 2018 -0400
@@ -827,7 +827,8 @@
 		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;