Skip to content

Commit cc474ab

Browse files
committed
Fix At flags for real
The fix got reverted in the merge conflict but now properly fix `At` Update posix `At` to use packed struct (I was holding back from touching `posix` and `c` but I might as well just get this done instead of using the deprecated constants since the diff is already big and At is worth while) Signed-off-by: Bernard Assan <mega.alpha100@gmail.com>
1 parent 23a4561 commit cc474ab

8 files changed

Lines changed: 263 additions & 122 deletions

File tree

lib/std/Io/Dir.zig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ pub fn cwd() Dir {
2424
return switch (native_os) {
2525
.windows => .{ .handle = std.os.windows.peb().ProcessParameters.CurrentDirectory.Handle },
2626
.wasi => .{ .handle = std.options.wasiCwd() },
27-
else => .{ .handle = std.posix.AT.FDCWD },
27+
else => .{ .handle = std.posix.At.fdcwd },
2828
};
2929
}
3030

lib/std/Io/Threaded.zig

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1403,12 +1403,12 @@ fn dirStatPathPosix(
14031403
var path_buffer: [posix.PATH_MAX]u8 = undefined;
14041404
const sub_path_posix = try pathToPosix(sub_path, &path_buffer);
14051405

1406-
const flags: u32 = if (!options.follow_symlinks) posix.AT.SYMLINK_NOFOLLOW else 0;
1406+
const flags: posix.At = .{ .symlink_nofollow = if (!options.follow_symlinks) true else false };
14071407

14081408
while (true) {
14091409
try t.checkCancel();
14101410
var stat = std.mem.zeroes(posix.Stat);
1411-
switch (posix.errno(fstatat_sym(dir.handle, sub_path_posix, &stat, flags))) {
1411+
switch (posix.errno(fstatat_sym(dir.handle, sub_path_posix, &stat, @bitCast(flags)))) {
14121412
.SUCCESS => return statFromPosix(&stat),
14131413
.INTR => continue,
14141414
.CANCELED => return error.Canceled,
@@ -1632,7 +1632,7 @@ fn dirAccessPosix(
16321632
var path_buffer: [posix.PATH_MAX]u8 = undefined;
16331633
const sub_path_posix = try pathToPosix(sub_path, &path_buffer);
16341634

1635-
const flags: u32 = @as(u32, if (!options.follow_symlinks) posix.AT.SYMLINK_NOFOLLOW else 0);
1635+
const flags: posix.At = .{ .symlink_nofollow = if (!options.follow_symlinks) true else false };
16361636

16371637
const mode: u32 =
16381638
@as(u32, if (options.read) posix.R_OK else 0) |
@@ -1641,7 +1641,7 @@ fn dirAccessPosix(
16411641

16421642
while (true) {
16431643
try t.checkCancel();
1644-
switch (posix.errno(posix.system.faccessat(dir.handle, sub_path_posix, mode, flags))) {
1644+
switch (posix.errno(posix.system.faccessat(dir.handle, sub_path_posix, mode, @bitCast(flags)))) {
16451645
.SUCCESS => return,
16461646
.INTR => continue,
16471647
.CANCELED => return error.Canceled,
@@ -2901,7 +2901,7 @@ fn fileSeekTo(userdata: ?*anyopaque, file: Io.File, offset: u64) Io.File.SeekErr
29012901
fn openSelfExe(userdata: ?*anyopaque, flags: Io.File.OpenFlags) Io.File.OpenSelfExeError!Io.File {
29022902
const t: *Threaded = @ptrCast(@alignCast(userdata));
29032903
switch (native_os) {
2904-
.linux, .serenity => return dirOpenFilePosix(t, .{ .handle = posix.AT.FDCWD }, "/proc/self/exe", flags),
2904+
.linux, .serenity => return dirOpenFilePosix(t, .{ .handle = posix.At.fdcwd }, "/proc/self/exe", flags),
29052905
.windows => {
29062906
// If ImagePathName is a symlink, then it will contain the path of the symlink,
29072907
// not the path that the symlink points to. However, because we are opening

0 commit comments

Comments
 (0)