mirror of
git://sourceware.org/git/newlib-cygwin.git
synced 2025-01-15 11:00:04 +08:00
9a29238544
* 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.
31 lines
474 B
C
31 lines
474 B
C
/* 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;
|
|
}
|
|
|