Last change
on this file was
444,
checked in by satin@…, 6 years ago
|
add newlib,libalmos-mkh, restructure shared_syscalls.h and mini-libc
|
File size:
545 bytes
|
Line | |
---|
1 | /* Copyright 2002, Red Hat Inc. */ |
---|
2 | |
---|
3 | #include <errno.h> |
---|
4 | #include <string.h> |
---|
5 | #include <unistd.h> |
---|
6 | #include <sys/utsname.h> |
---|
7 | #include <machine/weakalias.h> |
---|
8 | |
---|
9 | int |
---|
10 | __gethostname (char *name, size_t len) |
---|
11 | { |
---|
12 | struct utsname nodebuf; |
---|
13 | size_t nodelen; |
---|
14 | |
---|
15 | if (uname (&nodebuf)) |
---|
16 | return -1; |
---|
17 | |
---|
18 | nodelen = strlen (nodebuf.nodename) + 1; |
---|
19 | if (len < nodelen) |
---|
20 | memcpy (name, nodebuf.nodename, len); |
---|
21 | else |
---|
22 | memcpy (name, nodebuf.nodename, nodelen); |
---|
23 | |
---|
24 | if (nodelen > len) |
---|
25 | { |
---|
26 | errno = ENAMETOOLONG; |
---|
27 | return -1; |
---|
28 | } |
---|
29 | return 0; |
---|
30 | } |
---|
31 | weak_alias(__gethostname, gethostname) |
---|
Note: See
TracBrowser
for help on using the repository browser.