libs/libc/pwd: Add getlogin() and getlogin_r().

POSIX specifies getlogin() and getlogin_r(), and NuttX did not have
them.  NuttX has no login sessions, so the login name is the name of
the real user ID in the user database, from getpwuid_r(): "root" when
there is no passwd file.

Assisted-by: Claude Code:claude-opus-5-5
Signed-off-by: Marco Casaroli <marco.casaroli@gmail.com>
This commit is contained in:
Marco Casaroli 2026-10-09 08:41:44 +02:00 • committed by Xiang Xiao
parent 73760338dc
commit 12d5e1c0ba
4 changed files with 121 additions and 2 deletions

View file

@ -399,6 +399,11 @@ int isatty(int fd);
FAR char *ttyname(int fd);
int ttyname_r(int fd, FAR char *buf, size_t buflen);
/* The name of the user */
FAR char *getlogin(void);
int getlogin_r(FAR char *buf, size_t bufsize);
/* Memory management */
#if defined(CONFIG_ARCH_ADDRENV) && defined(CONFIG_MM_PGALLOC) && \