authorgravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2025-04-20 16:43:39 -07:00
committergravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2025-04-20 16:43:39 -07:00
logb731ccd7c458208d6c9b25b2402e26b4c80f3d4b
treee6a7f7c47527f7d9828b76196962f21be0c7e7ff
parent1578e667ed18b96b0335c6b550d0b0a052f70000

add getgid


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

mod.zig+8-1
......@@ -10,6 +10,7 @@ const syscall5 = sys.syscall5;
1010const syscall6 = sys.syscall6;
1111const pid_t = sys.pid_t;
1212const uid_t = sys.uid_t;
13const gid_t = sys.gid_t;
1314
1415fn _errno(rc: usize) enum(c_ushort) { ok, _ } {
1516 const signed: isize = @bitCast(rc);
......@@ -588,7 +589,13 @@ pub const syslog = @compileError("TODO: syslog");
588589// getgid
589590// gid_t getgid(void);
590591// asmlinkage long sys_getgid(void);
591pub const getgid = @compileError("TODO: getgid");
592pub fn getgid() errno.Error!gid_t {
593 const r = syscall0(.getgid);
594 return switch (_errno(r)) {
595 .ok => @intCast(r),
596 _ => |c| errno.errorFromInt(@intFromEnum(c)),
597 };
598}
592599
593600// setuid
594601// int setuid(uid_t uid);
test.zig+1
......@@ -13,4 +13,5 @@ test {
1313 _ = &linux.fork;
1414 _ = &linux.vfork;
1515 _ = &linux.getuid;
16 _ = &linux.getgid;
1617}