diff options
author | Thomas Fitzsimmons <fitzsim@redhat.com> | 2002-05-24 18:50:29 +0000 |
---|---|---|
committer | Thomas Fitzsimmons <fitzsim@redhat.com> | 2002-05-24 18:50:29 +0000 |
commit | 9a292385440df3da10f7eaeff6678ce5d4d49c60 (patch) | |
tree | 20059302cd52797389849582e786a547343b0ee0 /newlib/libc/sys/linux/gethostname.c | |
parent | 908f9b653b602b5161152d97a7213c6024b1ffb7 (diff) | |
download | cygnal-9a292385440df3da10f7eaeff6678ce5d4d49c60.tar.gz cygnal-9a292385440df3da10f7eaeff6678ce5d4d49c60.tar.bz2 cygnal-9a292385440df3da10f7eaeff6678ce5d4d49c60.zip |
* libc/sys/linux/sys/cdefs.h: Add __weak_reference macros.
* libc/sys/linux/sys/time.h: Add conversion macros.
* libc/sys/linux/sys/types.h: Add FD_ macros. Include <bits/types.h>.
* libc/sys/linux/ids.c: Add setresuid and syslog syscalls.
* libc/sys/linux/gethostname.c: New file.
* libc/sys/linux/seteuid.c: New file.
* libc/sys/linux/sysctl.c: New file.
Diffstat (limited to 'newlib/libc/sys/linux/gethostname.c')
-rw-r--r-- | newlib/libc/sys/linux/gethostname.c | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/newlib/libc/sys/linux/gethostname.c b/newlib/libc/sys/linux/gethostname.c new file mode 100644 index 000000000..d5ebe58a2 --- /dev/null +++ b/newlib/libc/sys/linux/gethostname.c @@ -0,0 +1,30 @@ +/* Copyright 2002, Red Hat Inc. */ + +#include <errno.h> +#include <string.h> +#include <unistd.h> +#include <sys/utsname.h> + +int +gethostname (char *name, size_t len) +{ + struct utsname nodebuf; + size_t nodelen; + + if (uname (&nodebuf)) + return -1; + + nodelen = strlen (nodebuf.nodename) + 1; + if (len < nodelen) + memcpy (name, nodebuf.nodename, len); + else + memcpy (name, nodebuf.nodename, nodelen); + + if (nodelen > len) + { + errno = ENAMETOOLONG; + return -1; + } + return 0; +} + |