[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Minios-devel] [UNIKRAFT PATCH v2 1/1] lib/uksysinfo: Add gethostname implementation



Thanks, Vlad!

Reviewed-by: Costin Lupu <costin.lupu@xxxxxxxxx>

On 6/25/19 6:49 PM, Vlad-Andrei BĂDOIU (78692) wrote:
> Signed-off-by: Vlad-Andrei Badoiu <vlad_andrei.badoiu@xxxxxxxxxxxxxxx>
> ---
>  lib/uksysinfo/exportsyms.uk |  1 +
>  lib/uksysinfo/sysinfo.c     | 23 +++++++++++++++++++++++
>  2 files changed, 24 insertions(+)
> 
> diff --git a/lib/uksysinfo/exportsyms.uk b/lib/uksysinfo/exportsyms.uk
> index d205e602..2e35b6fa 100644
> --- a/lib/uksysinfo/exportsyms.uk
> +++ b/lib/uksysinfo/exportsyms.uk
> @@ -4,3 +4,4 @@ confstr
>  pathconf
>  getpagesize
>  uname
> +gethostname
> diff --git a/lib/uksysinfo/sysinfo.c b/lib/uksysinfo/sysinfo.c
> index 3bff4e6f..15e097c4 100644
> --- a/lib/uksysinfo/sysinfo.c
> +++ b/lib/uksysinfo/sysinfo.c
> @@ -35,6 +35,8 @@
>  #include <stddef.h>
>  #include <limits.h>
>  #include <unistd.h>
> +#include <errno.h>
> +#include <string.h>
>  #include <sys/utsname.h>
>  #include <uk/essentials.h>
>  
> @@ -70,3 +72,24 @@ int uname(struct utsname *buf __unused)
>  {
>       return 0;
>  }
> +
> +int gethostname(char *name, size_t len)
> +{
> +     struct utsname buf;
> +     size_t node_len;
> +     int rc;
> +
> +     rc = uname(&buf);
> +     if (rc)
> +             return -1;
> +
> +     node_len = strlen(buf.nodename) + 1;
> +     if (node_len > len) {
> +             errno = ENAMETOOLONG;
> +             return -1;
> +     }
> +
> +     strncpy(name, buf.nodename, node_len);
> +
> +     return 0;
> +}
> 

_______________________________________________
Minios-devel mailing list
Minios-devel@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/mailman/listinfo/minios-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.