authorgravatar for squeek502@hotmail.comRyan Liptak <squeek502@hotmail.com> 2020-06-26 17:12:02-07:00
committergravatar for squeek502@hotmail.comRyan Liptak <squeek502@hotmail.com> 2020-06-26 17:12:02-07:00
log12aca758c6ee923065d1d64a62e44c8a8fd6cd99
tree3ed4ac673b1872bc19d7a96ed99682fa7a7cc350
parent505bc9817a2b78c97819f481b3cd98102c7ff964

Dir.deleteFile: Fix symlink behavior when translating EPERM to EISDIR


1 files changed, 2 insertions(+), 1 deletions(-)

lib/std/fs.zig+2-1
...@@ -1134,7 +1134,8 @@ pub const Dir = struct {...@@ -1134,7 +1134,8 @@ pub const Dir = struct {
1134 // non-Linux POSIX systems return EPERM when trying to delete a directory, so1134 // non-Linux POSIX systems return EPERM when trying to delete a directory, so
1135 // we need to handle that case specifically and translate the error1135 // we need to handle that case specifically and translate the error
1136 .macosx, .ios, .freebsd, .netbsd, .dragonfly => {1136 .macosx, .ios, .freebsd, .netbsd, .dragonfly => {
1137 const fstat = os.fstatatZ(self.fd, sub_path_c, 0) catch return e;1137 // Don't follow symlinks to match unlinkat (which acts on symlinks rather than follows them)
1138 const fstat = os.fstatatZ(self.fd, sub_path_c, os.AT_SYMLINK_NOFOLLOW) catch return e;
1138 const is_dir = fstat.mode & os.S_IFMT == os.S_IFDIR;1139 const is_dir = fstat.mode & os.S_IFMT == os.S_IFDIR;
1139 return if (is_dir) error.IsDir else e;1140 return if (is_dir) error.IsDir else e;
1140 },1141 },