[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Minios-devel] [UNIKRAFT/NEWLIB PATCH 3/3] Implement gethostname
Signed-off-by: Vlad-Andrei Badoiu <vlad_andrei.badoiu@xxxxxxxxxxxxxxx> --- network.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/network.c b/network.c index 5d7823b..3a57b19 100644 --- a/network.c +++ b/network.c @@ -1,9 +1,22 @@ #include <string.h> #include <unistd.h> #include <netdb.h> +#include <errno.h> +#include <sys/utsname.h> int gethostname(char *name, size_t len) { + struct utsname buf; + size_t node_len; + + if (uname(&buf)) + return -1; + node_len = strlen(buf.nodename) + 1; + memcpy(name, buf.nodename, len < node_len ? len : node_len); + if (node_len > len) { + errno = ENAMETOOLONG; + return -1; + } return 0; } -- 2.21.0 _______________________________________________ Minios-devel mailing list Minios-devel@xxxxxxxxxxxxxxxxxxxx https://lists.xenproject.org/mailman/listinfo/minios-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |