userspace/libc: add stub gethostname function

Signed-off-by: EnderIce2 <enderice2@protonmail.com>
This commit is contained in:
2025-02-12 02:53:13 +02:00
parent 97af4d855f
commit 2384791793
2 changed files with 20 additions and 0 deletions

View File

@ -94,6 +94,7 @@ extern "C"
gid_t getgid(void); gid_t getgid(void);
int getgroups(int, gid_t[]); int getgroups(int, gid_t[]);
long gethostid(void); long gethostid(void);
int gethostname(char *name, size_t namelen);
char *getlogin(void); char *getlogin(void);
int getlogin_r(char *, size_t); int getlogin_r(char *, size_t);
int getopt(int, char *const[], const char *); int getopt(int, char *const[], const char *);

View File

@ -179,6 +179,25 @@ export uid_t geteuid(void);
export gid_t getgid(void); export gid_t getgid(void);
export int getgroups(int, gid_t[]); export int getgroups(int, gid_t[]);
export long gethostid(void); export long gethostid(void);
export int gethostname(char *name, size_t namelen)
{
if (namelen == 0)
{
errno = EINVAL;
return -1;
}
strncpy(name, "localhost", namelen);
if (namelen < strlen("localhost") + 1)
{
errno = ENAMETOOLONG;
return -1;
}
return 0;
}
export char *getlogin(void); export char *getlogin(void);
export int getlogin_r(char *, size_t); export int getlogin_r(char *, size_t);
export int getopt(int, char *const[], const char *); export int getopt(int, char *const[], const char *);