Skip to content

Commit 0a0ca8d

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 62fb6db commit 0a0ca8d

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
@@ -1339,12 +1339,12 @@ fn dirStatPathPosix(
13391339
var path_buffer: [posix.PATH_MAX]u8 = undefined;
13401340
const sub_path_posix = try pathToPosix(sub_path, &path_buffer);
13411341

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

13441344
while (true) {
13451345
try t.checkCancel();
13461346
var stat = std.mem.zeroes(posix.Stat);
1347-
switch (posix.errno(fstatat_sym(dir.handle, sub_path_posix, &stat, flags))) {
1347+
switch (posix.errno(fstatat_sym(dir.handle, sub_path_posix, &stat, @bitCast(flags)))) {
13481348
.SUCCESS => return statFromPosix(&stat),
13491349
.INTR => continue,
13501350
.CANCELED => return error.Canceled,
@@ -1568,7 +1568,7 @@ fn dirAccessPosix(
15681568
var path_buffer: [posix.PATH_MAX]u8 = undefined;
15691569
const sub_path_posix = try pathToPosix(sub_path, &path_buffer);
15701570

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

15731573
const mode: u32 =
15741574
@as(u32, if (options.read) posix.R_OK else 0) |
@@ -1577,7 +1577,7 @@ fn dirAccessPosix(
15771577

15781578
while (true) {
15791579
try t.checkCancel();
1580-
switch (posix.errno(posix.system.faccessat(dir.handle, sub_path_posix, mode, flags))) {
1580+
switch (posix.errno(posix.system.faccessat(dir.handle, sub_path_posix, mode, @bitCast(flags)))) {
15811581
.SUCCESS => return,
15821582
.INTR => continue,
15831583
.CANCELED => return error.Canceled,
@@ -2837,7 +2837,7 @@ fn fileSeekTo(userdata: ?*anyopaque, file: Io.File, offset: u64) Io.File.SeekErr
28372837
fn openSelfExe(userdata: ?*anyopaque, flags: Io.File.OpenFlags) Io.File.OpenSelfExeError!Io.File {
28382838
const t: *Threaded = @ptrCast(@alignCast(userdata));
28392839
switch (native_os) {
2840-
.linux, .serenity => return dirOpenFilePosix(t, .{ .handle = posix.AT.FDCWD }, "/proc/self/exe", flags),
2840+
.linux, .serenity => return dirOpenFilePosix(t, .{ .handle = posix.At.fdcwd }, "/proc/self/exe", flags),
28412841
.windows => {
28422842
// If ImagePathName is a symlink, then it will contain the path of the symlink,
28432843
// not the path that the symlink points to. However, because we are opening

0 commit comments

Comments
 (0)