diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2024-01-14 11:26:25 -0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-01-14 11:26:25 -0800 |
| commit | 4debd4338ce2c27a0dd6127ce5736ca56538214c (patch) | |
| tree | a01612aee6f9f480d029db143f530d58a259377c /lib/std/os/linux.zig | |
| parent | 78549d1e109a922e63b52b3d4a445217ca997c9c (diff) | |
| parent | 09074d7cd7ab76ebf87cb303825ce53834bcc532 (diff) | |
| download | zig-4debd4338ce2c27a0dd6127ce5736ca56538214c.tar.gz zig-4debd4338ce2c27a0dd6127ce5736ca56538214c.zip | |
Merge pull request #18547 from ziglang/gh-fork-dump-fchmod-fixes
Add `fchmodat` fallback on Linux when `flags` is nonzero.
Diffstat (limited to 'lib/std/os/linux.zig')
| -rw-r--r-- | lib/std/os/linux.zig | 16 |
1 files changed, 7 insertions, 9 deletions
diff --git a/lib/std/os/linux.zig b/lib/std/os/linux.zig index 8928e1fdf2..d6e539e98c 100644 --- a/lib/std/os/linux.zig +++ b/lib/std/os/linux.zig @@ -796,13 +796,7 @@ pub fn chmod(path: [*:0]const u8, mode: mode_t) usize { if (@hasField(SYS, "chmod")) { return syscall2(.chmod, @intFromPtr(path), mode); } else { - return syscall4( - .fchmodat, - @as(usize, @bitCast(@as(isize, AT.FDCWD))), - @intFromPtr(path), - mode, - 0, - ); + return fchmodat(AT.FDCWD, path, mode, 0); } } @@ -814,8 +808,12 @@ pub fn fchown(fd: i32, owner: uid_t, group: gid_t) usize { } } -pub fn fchmodat(fd: i32, path: [*:0]const u8, mode: mode_t, flags: u32) usize { - return syscall4(.fchmodat, @as(usize, @bitCast(@as(isize, fd))), @intFromPtr(path), mode, flags); +pub fn fchmodat(fd: i32, path: [*:0]const u8, mode: mode_t, _: u32) usize { + return syscall3(.fchmodat, @bitCast(@as(isize, fd)), @intFromPtr(path), mode); +} + +pub fn fchmodat2(fd: i32, path: [*:0]const u8, mode: mode_t, flags: u32) usize { + return syscall4(.fchmodat2, @bitCast(@as(isize, fd)), @intFromPtr(path), mode, flags); } /// Can only be called on 32 bit systems. For 64 bit see `lseek`. |
