authorgravatar for me@gasinfinity.devGasInfinity <me@gasinfinity.dev> 2026-01-24 16:00:16+01:00
committergravatar for me@gasinfinity.devGasInfinity <me@gasinfinity.dev> 2026-01-24 20:41:15+01:00
logb430cd62e40afd30048a4d9992ec62bb34f5e041
tree32d4e85c98e25b141065a3771a9683b16cb11a32
parentd5c3bf25dc7fedfe57b7142828ac83e49dd9f8d0
signaturebadge-check Signed by SSH key SHA256:p3IHbr0lyK2ekfDC1Zi7dOEV/9T6lGghNawhl5sBnM4

feat(std.os.linux): add some missing syscalls


1 files changed, 30 insertions(+), 2 deletions(-)

lib/std/os/linux.zig+30-2
...@@ -1391,6 +1391,10 @@ pub fn faccessat(dirfd: i32, path: [*:0]const u8, mode: u32, flags: u32) usize {...@@ -1391,6 +1391,10 @@ pub fn faccessat(dirfd: i32, path: [*:0]const u8, mode: u32, flags: u32) usize {
1391 return syscall4(.faccessat2, @as(usize, @bitCast(@as(isize, dirfd))), @intFromPtr(path), mode, flags);1391 return syscall4(.faccessat2, @as(usize, @bitCast(@as(isize, dirfd))), @intFromPtr(path), mode, flags);
1392}1392}
13931393
1394pub fn acct(path: [*:0]const u8) usize {
1395 return syscall1(.acct, @intFromPtr(path));
1396}
1397
1394pub fn pipe(fd: *[2]i32) usize {1398pub fn pipe(fd: *[2]i32) usize {
1395 if (comptime (native_arch.isMIPS() or native_arch.isSPARC())) {1399 if (comptime (native_arch.isMIPS() or native_arch.isSPARC())) {
1396 return syscall_pipe(fd);1400 return syscall_pipe(fd);
...@@ -1601,11 +1605,27 @@ pub fn fchown(fd: i32, owner: uid_t, group: gid_t) usize {...@@ -1601,11 +1605,27 @@ pub fn fchown(fd: i32, owner: uid_t, group: gid_t) usize {
1601 }1605 }
1602}1606}
16031607
1608pub fn fchownat(fd: i32, path: [*:0]const u8, owner: uid_t, group: gid_t, flags: u32) usize {
1609 return syscall5(.fchownat, @as(usize, @bitCast(@as(isize, fd))), @intFromPtr(path), owner, group, flags);
1610}
1611
1604pub fn chown(path: [*:0]const u8, owner: uid_t, group: gid_t) usize {1612pub fn chown(path: [*:0]const u8, owner: uid_t, group: gid_t) usize {
1605 if (@hasField(SYS, "chown32")) {1613 if (@hasField(SYS, "chown32")) {
1606 return syscall3(.chown32, @intFromPtr(path), owner, group);1614 return syscall3(.chown32, @intFromPtr(path), owner, group);
1607 } else {1615 } else if (@hasField(SYS, "chown")) {
1608 return syscall3(.chown, @intFromPtr(path), owner, group);1616 return syscall3(.chown, @intFromPtr(path), owner, group);
1617 } else {
1618 return fchownat(AT.FDCWD, path, owner, group, 0);
1619 }
1620}
1621
1622pub fn lchown(path: [*:0]const u8, owner: uid_t, group: gid_t) usize {
1623 if (@hasField(SYS, "lchown32")) {
1624 return syscall3(.lchown32, @intFromPtr(path), owner, group);
1625 } else if (@hasField(SYS, "lchown")) {
1626 return syscall3(.lchown, @intFromPtr(path), owner, group);
1627 } else {
1628 return fchownat(AT.FDCWD, path, owner, group, AT.SYMLINK_NOFOLLOW);
1609 }1629 }
1610}1630}
16111631
...@@ -2064,7 +2084,11 @@ pub fn setpgid(pid: pid_t, pgid: pid_t) usize {...@@ -2064,7 +2084,11 @@ pub fn setpgid(pid: pid_t, pgid: pid_t) usize {
2064 return syscall2(.setpgid, @intCast(pid), @intCast(pgid));2084 return syscall2(.setpgid, @intCast(pid), @intCast(pgid));
2065}2085}
20662086
2067pub fn getgroups(size: usize, list: ?*gid_t) usize {2087pub fn getpgid(pid: pid_t) usize {
2088 return syscall1(.getpgid, @intCast(pid));
2089}
2090
2091pub fn getgroups(size: usize, list: ?[*]gid_t) usize {
2068 if (@hasField(SYS, "getgroups32")) {2092 if (@hasField(SYS, "getgroups32")) {
2069 return syscall2(.getgroups32, size, @intFromPtr(list));2093 return syscall2(.getgroups32, size, @intFromPtr(list));
2070 } else {2094 } else {
...@@ -2084,6 +2108,10 @@ pub fn setsid() usize {...@@ -2084,6 +2108,10 @@ pub fn setsid() usize {
2084 return syscall0(.setsid);2108 return syscall0(.setsid);
2085}2109}
20862110
2111pub fn getsid(pid: pid_t) usize {
2112 return syscall1(.getsid, @intCast(pid));
2113}
2114
2087pub fn getpid() pid_t {2115pub fn getpid() pid_t {
2088 // Casts result to a pid_t, safety-checking >= 0, because getpid() cannot fail2116 // Casts result to a pid_t, safety-checking >= 0, because getpid() cannot fail
2089 return @intCast(@as(u32, @truncate(syscall0(.getpid))));2117 return @intCast(@as(u32, @truncate(syscall0(.getpid))));