shithub: 9pro

Download patch

ref: 99cc37a021706ce117745d6e8fe950f9f40c24d8
parent: 00f366402fbdfb5800697dad6ee083b893dafac4
author: Sigrid Haflínudóttir <ftrvxmtrx@gmail.com>
date: Fri Dec 27 06:32:01 EST 2019

in case of a broken symlink call fstatat on the link itself, not the reference

--- a/9pex.c
+++ b/9pex.c
@@ -689,7 +689,8 @@
 
 		if (fstatat(f->fd, e->d_name, &st, 0) != 0) {
 			*err = strerror(errno);
-			return -1;
+			if (fstatat(f->fd, e->d_name, &st, AT_SYMLINK_NOFOLLOW) != 0) /* broken symlink, try to stat the link itself */
+				return -1;
 		}
 		if (stat2c9stat(e->d_name, &st, &c9st[i], err) != 0)
 			return -1;