From 9281d180d13057917f618c35ef7433d2e4d4dd86 Mon Sep 17 00:00:00 2001 From: Eric Andersen Date: Wed, 5 Jul 2000 19:23:36 +0000 Subject: Completely rearchitected the sysdeps directory. -Erik --- libc/sysdeps/linux/common/gethstnm.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 libc/sysdeps/linux/common/gethstnm.c (limited to 'libc/sysdeps/linux/common/gethstnm.c') diff --git a/libc/sysdeps/linux/common/gethstnm.c b/libc/sysdeps/linux/common/gethstnm.c new file mode 100644 index 000000000..0728f65a4 --- /dev/null +++ b/libc/sysdeps/linux/common/gethstnm.c @@ -0,0 +1,24 @@ +#include +#include +#include +#include + +int +gethostname(char *name, size_t len) +{ + struct utsname uts; + + if (name == NULL) { + errno = EINVAL; + return -1; + } + + if (uname(&uts) == -1) return -1; + + if (strlen(uts.nodename)+1 > len) { + errno = EINVAL; + return -1; + } + strcpy(name, uts.nodename); + return 0; +} -- cgit v1.2.3