summaryrefslogtreecommitdiff
path: root/klibc/klibc/getdomainname.c
diff options
context:
space:
mode:
Diffstat (limited to 'klibc/klibc/getdomainname.c')
-rw-r--r--klibc/klibc/getdomainname.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/klibc/klibc/getdomainname.c b/klibc/klibc/getdomainname.c
new file mode 100644
index 0000000000..4cd68a3cb5
--- /dev/null
+++ b/klibc/klibc/getdomainname.c
@@ -0,0 +1,25 @@
+/*
+ * getdomainname.c
+ */
+
+#include <errno.h>
+#include <unistd.h>
+#include <string.h>
+#include <sys/utsname.h>
+
+int getdomainname(char *name, size_t len)
+{
+ struct utsname un;
+
+ if ( !uname(&un) )
+ return -1;
+
+ if ( len < strlen(un.domainname)+1 ) {
+ errno = EINVAL;
+ return -1;
+ }
+
+ strcpy(name, un.domainname);
+
+ return 0;
+}