Add Cosmopolitan to uname()

This commit is contained in:
Justine Tunney 2023-09-21 23:51:55 -07:00
parent ed316491ca
commit 3ffc17c50e
No known key found for this signature in database
GPG key ID: BE714B4575D6E328
9 changed files with 56 additions and 14 deletions

View file

@ -25,11 +25,13 @@
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#include "libc/calls/calls.h"
#include "libc/calls/weirdtypes.h"
#include "libc/errno.h"
#include "libc/mem/mem.h"
#include "libc/stdio/stdio.h"
#include "libc/str/str.h"
#include "libc/sysv/consts/limits.h"
#include "libc/thread/thread.h"
#include "third_party/musl/passwd.h"
@ -246,3 +248,10 @@ struct group *getgrnam(const char *name) {
&g_getgrent->mem, &nmem, &res);
return res;
}
int initgroups(const char *user, gid_t gid) {
gid_t groups[NGROUPS_MAX];
int count = NGROUPS_MAX;
if (getgrouplist(user, gid, groups, &count) < 0) return -1;
return setgroups(count, groups);
}