diff options
author | Rich Felker <dalias@aerifal.cx> | 2012-09-09 16:50:20 -0400 |
---|---|---|
committer | Rich Felker <dalias@aerifal.cx> | 2012-09-09 16:50:20 -0400 |
commit | c87584a3e962dabd7b97733bfc3700e003d87d28 (patch) | |
tree | 38a6cde52df84db52a86b686da88f3ecc77c7c9a | |
parent | a660180c6a93681c6efb54fb5826c08d4df60208 (diff) | |
download | musl-c87584a3e962dabd7b97733bfc3700e003d87d28.tar.gz musl-c87584a3e962dabd7b97733bfc3700e003d87d28.tar.xz musl-c87584a3e962dabd7b97733bfc3700e003d87d28.zip |
add setdomainname syscall, fix getdomainname (previously a stub)
-rw-r--r-- | include/unistd.h | 1 | ||||
-rw-r--r-- | src/misc/getdomainname.c | 10 | ||||
-rw-r--r-- | src/misc/setdomainname.c | 8 |
3 files changed, 18 insertions, 1 deletions
diff --git a/include/unistd.h b/include/unistd.h index 4f6953c4..d3bb781a 100644 --- a/include/unistd.h +++ b/include/unistd.h @@ -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); diff --git a/src/misc/getdomainname.c b/src/misc/getdomainname.c index 7eb113d7..59df566d 100644 --- a/src/misc/getdomainname.c +++ b/src/misc/getdomainname.c @@ -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; } diff --git a/src/misc/setdomainname.c b/src/misc/setdomainname.c new file mode 100644 index 00000000..22d3f746 --- /dev/null +++ b/src/misc/setdomainname.c @@ -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); +} |