Contents of /trunk/mkinitrd-magellan/klibc/usr/klibc/gethostname.c
Parent Directory | Revision Log
Revision 532 -
(show annotations)
(download)
Sat Sep 1 22:45:15 2007 UTC (16 years, 8 months ago) by niro
File MIME type: text/plain
File size: 320 byte(s)
Sat Sep 1 22:45:15 2007 UTC (16 years, 8 months ago) by niro
File MIME type: text/plain
File size: 320 byte(s)
-import if magellan mkinitrd; it is a fork of redhats mkinitrd-5.0.8 with all magellan patches and features; deprecates magellan-src/mkinitrd
1 | /* |
2 | * gethostname.c |
3 | */ |
4 | |
5 | #include <errno.h> |
6 | #include <unistd.h> |
7 | #include <string.h> |
8 | #include <sys/utsname.h> |
9 | |
10 | int gethostname(char *name, size_t len) |
11 | { |
12 | struct utsname un; |
13 | |
14 | if (!uname(&un)) |
15 | return -1; |
16 | |
17 | if (len < strlen(un.nodename) + 1) { |
18 | errno = EINVAL; |
19 | return -1; |
20 | } |
21 | |
22 | strcpy(name, un.nodename); |
23 | |
24 | return 0; |
25 | } |