authorgravatar for dev@sgregoratto.meStephen Gregoratto <dev@sgregoratto.me> 2023-11-04 17:05:57+11:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2024-01-13 23:52:01-07:00
logcf6751ae5510964f0d349e6ea044d8f618ba6e33
treee137c9b92bca5095b6b2dbbebe217b277c416ebc
parent26db31f6f6a5e034333ff81f2352901201572cba

Add fchmodat2 bits to os/linux.zig


1 files changed, 7 insertions(+), 9 deletions(-)

lib/std/os/linux.zig+7-9
......@@ -796,13 +796,7 @@ pub fn chmod(path: [*:0]const u8, mode: mode_t) usize {
796796 if (@hasField(SYS, "chmod")) {
797797 return syscall2(.chmod, @intFromPtr(path), mode);
798798 } else {
799 return syscall4(
800 .fchmodat,
801 @as(usize, @bitCast(@as(isize, AT.FDCWD))),
802 @intFromPtr(path),
803 mode,
804 0,
805 );
799 return fchmodat(AT.FDCWD, path, mode, 0);
806800 }
807801}
808802
......@@ -814,8 +808,12 @@ pub fn fchown(fd: i32, owner: uid_t, group: gid_t) usize {
814808 }
815809}
816810
817pub fn fchmodat(fd: i32, path: [*:0]const u8, mode: mode_t, flags: u32) usize {
818 return syscall4(.fchmodat, @as(usize, @bitCast(@as(isize, fd))), @intFromPtr(path), mode, flags);
811pub fn fchmodat(fd: i32, path: [*:0]const u8, mode: mode_t, _: u32) usize {
812 return syscall3(.fchmodat, @bitCast(@as(isize, fd)), @intFromPtr(path), mode);
813}
814
815pub fn fchmodat2(fd: i32, path: [*:0]const u8, mode: mode_t, flags: u32) usize {
816 return syscall4(.fchmodat2, @bitCast(@as(isize, fd)), @intFromPtr(path), mode, flags);
819817}
820818
821819/// Can only be called on 32 bit systems. For 64 bit see `lseek`.