[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Minios-devel] [UNIKRAFT PATCH 6/6] lib/posix-user: Add more group file related functions
We currently provide only a single group. This can be extended easily, if it will be needed. Signed-off-by: Costin Lupu <costin.lupu@xxxxxxxxx> --- lib/posix-user/user.c | 64 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) diff --git a/lib/posix-user/user.c b/lib/posix-user/user.c index 0d6ca3fb..004eee1b 100644 --- a/lib/posix-user/user.c +++ b/lib/posix-user/user.c @@ -60,6 +60,12 @@ UK_SLIST_HEAD(uk_entry_list, struct passwd_entry); static struct uk_entry_list passwds; +static void init_groups(void); + +/* + * TODO make passwd management consistent with group management + */ + void __constructor init_ukunistd() { static struct passwd_entry p1; @@ -77,6 +83,8 @@ void __constructor init_ukunistd() UK_SLIST_INIT(&passwds); UK_SLIST_INSERT_HEAD(&passwds, &p1, entries); + + init_groups(); } uid_t getuid(void) @@ -328,3 +336,59 @@ int getgrnam_r(const char *name, struct group *grp, return 0; } + +struct group *getgrgid(gid_t gid) +{ + struct group *res; + + if (gid == g__.gr_gid) + res = &g__; + else { + res = NULL; + errno = ENOENT; + } + + return res; +} + +static struct group_entry { + struct group *group; + UK_SLIST_ENTRY(struct group_entry) entries; +} *groups_iter; + +UK_SLIST_HEAD(uk_group_entry_list, struct group_entry); + +static struct uk_group_entry_list groups; + +static void init_groups(void) +{ + static struct group_entry ge; + + ge.group = &g__; + UK_SLIST_INIT(&groups); + UK_SLIST_INSERT_HEAD(&groups, &ge, entries); +} + +void setgrent(void) +{ + groups_iter = UK_SLIST_FIRST(&groups); +} + +void endgrent(void) +{ + setgrent(); +} + +struct group *getgrent(void) +{ + struct group *res; + + if (groups_iter) { + res = groups_iter->group; + groups_iter = UK_SLIST_NEXT(groups_iter, entries); + } else + res = NULL; + + return res; + +} -- 2.20.1 _______________________________________________ Minios-devel mailing list Minios-devel@xxxxxxxxxxxxxxxxxxxx https://lists.xenproject.org/mailman/listinfo/minios-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |