mirror of
git://git.musl-libc.org/musl
synced 2025-01-21 22:23:13 +00:00
add setdomainname syscall, fix getdomainname (previously a stub)
This commit is contained in:
parent
a660180c6a
commit
c87584a3e9
@ -165,6 +165,7 @@ int getpagesize(void);
|
||||
int getdtablesize(void);
|
||||
int sethostname(const char *, size_t);
|
||||
int getdomainname(char *, size_t);
|
||||
int setdomainname(const char *, size_t);
|
||||
int setgroups(size_t, const gid_t []);
|
||||
char *getpass(const char *);
|
||||
int daemon(int, int);
|
||||
|
@ -1,9 +1,17 @@
|
||||
#define _GNU_SOURCE
|
||||
#include <unistd.h>
|
||||
#include <sys/utsname.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
|
||||
int getdomainname(char *name, size_t len)
|
||||
{
|
||||
*name = 0;
|
||||
struct utsname temp;
|
||||
uname(&temp);
|
||||
if (!len || strlen(temp.domainname) >= len) {
|
||||
errno = EINVAL;
|
||||
return -1;
|
||||
}
|
||||
strcpy(name, temp.domainname);
|
||||
return 0;
|
||||
}
|
||||
|
8
src/misc/setdomainname.c
Normal file
8
src/misc/setdomainname.c
Normal file
@ -0,0 +1,8 @@
|
||||
#define _GNU_SOURCE
|
||||
#include <unistd.h>
|
||||
#include "syscall.h"
|
||||
|
||||
int setdomainname(const char *name, size_t len)
|
||||
{
|
||||
return syscall(SYS_setdomainname, name, len);
|
||||
}
|
Loading…
Reference in New Issue
Block a user