authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2026-01-06 20:44:59-08:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2026-01-07 11:03:37-08:00
log7e8c7e56964f8d9d20be04e314324f84f9db6146
tree6a61f5c6a341a7f35f68f24bd070da1ed1f31119
parentee574f665c4e3d1be4950b307ce3ff8324f13f46

std.Io: fix AT_SYMLINK_FOLLOW flags

hard linking has the backwards default, which uses a different flag

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

lib/std/Io/File.zig+1-1
...@@ -709,7 +709,7 @@ pub fn realPath(file: File, io: Io, out_buffer: []u8) RealPathError!usize {...@@ -709,7 +709,7 @@ pub fn realPath(file: File, io: Io, out_buffer: []u8) RealPathError!usize {
709}709}
710710
711pub const HardLinkOptions = struct {711pub const HardLinkOptions = struct {
712 follow_symlinks: bool = true,712 follow_symlinks: bool = false,
713};713};
714714
715pub const HardLinkError = error{715pub const HardLinkError = error{
lib/std/Io/Threaded.zig+3-3
...@@ -5249,8 +5249,8 @@ fn fileHardLink(...@@ -5249,8 +5249,8 @@ fn fileHardLink(
5249 var new_path_buffer: [posix.PATH_MAX]u8 = undefined;5249 var new_path_buffer: [posix.PATH_MAX]u8 = undefined;
5250 const new_sub_path_posix = try pathToPosix(new_sub_path, &new_path_buffer);5250 const new_sub_path_posix = try pathToPosix(new_sub_path, &new_path_buffer);
52515251
5252 const flags: u32 = if (!options.follow_symlinks)5252 const flags: u32 = if (options.follow_symlinks)
5253 posix.AT.SYMLINK_NOFOLLOW | posix.AT.EMPTY_PATH5253 posix.AT.SYMLINK_FOLLOW | posix.AT.EMPTY_PATH
5254 else5254 else
5255 posix.AT.EMPTY_PATH;5255 posix.AT.EMPTY_PATH;
52565256
...@@ -7829,7 +7829,7 @@ fn dirHardLink(...@@ -7829,7 +7829,7 @@ fn dirHardLink(
7829 const old_sub_path_posix = try pathToPosix(old_sub_path, &old_path_buffer);7829 const old_sub_path_posix = try pathToPosix(old_sub_path, &old_path_buffer);
7830 const new_sub_path_posix = try pathToPosix(new_sub_path, &new_path_buffer);7830 const new_sub_path_posix = try pathToPosix(new_sub_path, &new_path_buffer);
78317831
7832 const flags: u32 = if (!options.follow_symlinks) posix.AT.SYMLINK_NOFOLLOW else 0;7832 const flags: u32 = if (options.follow_symlinks) posix.AT.SYMLINK_FOLLOW else 0;
7833 return linkat(old_dir.handle, old_sub_path_posix, new_dir.handle, new_sub_path_posix, flags);7833 return linkat(old_dir.handle, old_sub_path_posix, new_dir.handle, new_sub_path_posix, flags);
7834}7834}
78357835