summaryrefslogtreecommitdiff
path: root/lib/libc/grp/getgrgid.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/libc/grp/getgrgid.c')
-rw-r--r--lib/libc/grp/getgrgid.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/lib/libc/grp/getgrgid.c b/lib/libc/grp/getgrgid.c
new file mode 100644
index 00000000..66ccaff1
--- /dev/null
+++ b/lib/libc/grp/getgrgid.c
@@ -0,0 +1,15 @@
+#include <grp.h>
+#include <stddef.h>
+#include <limits.h>
+
+struct group *getgrgid(gid_t gid)
+{
+ static struct group grp;
+ static char buf[LINE_MAX * 2];
+ struct group *res;
+
+ if (getgrgid_r(gid, &grp, buf, sizeof(buf), &res) != 0)
+ return NULL;
+
+ return res;
+}