summaryrefslogtreecommitdiff
path: root/libc/sysdeps/linux/common/getdnnm.c
diff options
context:
space:
mode:
authorEric Andersen <andersen@codepoet.org>2000-07-05 19:23:36 +0000
committerEric Andersen <andersen@codepoet.org>2000-07-05 19:23:36 +0000
commit9281d180d13057917f618c35ef7433d2e4d4dd86 (patch)
treeb497158acdc1a81b93b938a2f76376c88bc7799b /libc/sysdeps/linux/common/getdnnm.c
parent775622914fa0a2814c705d25b1a3929002c5c785 (diff)
Completely rearchitected the sysdeps directory.
-Erik
Diffstat (limited to 'libc/sysdeps/linux/common/getdnnm.c')
-rw-r--r--libc/sysdeps/linux/common/getdnnm.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/libc/sysdeps/linux/common/getdnnm.c b/libc/sysdeps/linux/common/getdnnm.c
new file mode 100644
index 000000000..fdcbb0f3a
--- /dev/null
+++ b/libc/sysdeps/linux/common/getdnnm.c
@@ -0,0 +1,24 @@
+#include <string.h>
+#include <unistd.h>
+#include <sys/utsname.h>
+#include <errno.h>
+
+int
+getdomainname(char *name, size_t len)
+{
+ struct utsname uts;
+
+ if (name == NULL) {
+ errno = EINVAL;
+ return -1;
+ }
+
+ if (uname(&uts) == -1) return -1;
+
+ if (strlen(uts.domainname)+1 > len) {
+ errno = EINVAL;
+ return -1;
+ }
+ strcpy(name, uts.domainname);
+ return 0;
+}