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;...@@ -10,6 +10,7 @@ const syscall5 = sys.syscall5;
10const syscall6 = sys.syscall6;10const syscall6 = sys.syscall6;
11const pid_t = sys.pid_t;11const pid_t = sys.pid_t;
12const uid_t = sys.uid_t;12const uid_t = sys.uid_t;
13const gid_t = sys.gid_t;
1314
14fn _errno(rc: usize) enum(c_ushort) { ok, _ } {15fn _errno(rc: usize) enum(c_ushort) { ok, _ } {
15 const signed: isize = @bitCast(rc);16 const signed: isize = @bitCast(rc);
...@@ -588,7 +589,13 @@ pub const syslog = @compileError("TODO: syslog");...@@ -588,7 +589,13 @@ pub const syslog = @compileError("TODO: syslog");
588// getgid589// getgid
589// gid_t getgid(void);590// gid_t getgid(void);
590// asmlinkage long sys_getgid(void);591// 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
593// setuid600// setuid
594// int setuid(uid_t uid);601// int setuid(uid_t uid);
test.zig+1
...@@ -13,4 +13,5 @@ test {...@@ -13,4 +13,5 @@ test {
13 _ = &linux.fork;13 _ = &linux.fork;
14 _ = &linux.vfork;14 _ = &linux.vfork;
15 _ = &linux.getuid;15 _ = &linux.getuid;
16 _ = &linux.getgid;
16}17}