about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorRich Felker <dalias@aerifal.cx>2012-09-09 16:50:20 -0400
committerRich Felker <dalias@aerifal.cx>2012-09-09 16:50:20 -0400
commitc87584a3e962dabd7b97733bfc3700e003d87d28 (patch)
tree38a6cde52df84db52a86b686da88f3ecc77c7c9a /src
parenta660180c6a93681c6efb54fb5826c08d4df60208 (diff)
downloadmusl-c87584a3e962dabd7b97733bfc3700e003d87d28.tar.gz
musl-c87584a3e962dabd7b97733bfc3700e003d87d28.tar.xz
musl-c87584a3e962dabd7b97733bfc3700e003d87d28.zip
add setdomainname syscall, fix getdomainname (previously a stub)
Diffstat (limited to 'src')
-rw-r--r--src/misc/getdomainname.c10
-rw-r--r--src/misc/setdomainname.c8
2 files changed, 17 insertions, 1 deletions
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);
+}