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

Re: [Minios-devel] [UNIKRAFT PATCH 1/1] Implement sethostname and uname



Thanks for the patch, Vlad! Don't forget your Signed-off-by next time.

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

On 9/9/19 4:18 PM, Vlad-Andrei BĂDOIU (78692) wrote:
> ---
>  lib/uksysinfo/exportsyms.uk |  1 +
>  lib/uksysinfo/sysinfo.c     | 39 +++++++++++++++++++++++++++++++++++++
>  2 files changed, 40 insertions(+)
> 
> diff --git a/lib/uksysinfo/exportsyms.uk b/lib/uksysinfo/exportsyms.uk
> index 2e35b6fa..73e1fe99 100644
> --- a/lib/uksysinfo/exportsyms.uk
> +++ b/lib/uksysinfo/exportsyms.uk
> @@ -5,3 +5,4 @@ pathconf
>  getpagesize
>  uname
>  gethostname
> +sethostname
> diff --git a/lib/uksysinfo/sysinfo.c b/lib/uksysinfo/sysinfo.c
> index 15e097c4..b41b2f7b 100644
> --- a/lib/uksysinfo/sysinfo.c
> +++ b/lib/uksysinfo/sysinfo.c
> @@ -39,6 +39,21 @@
>  #include <string.h>
>  #include <sys/utsname.h>
>  #include <uk/essentials.h>
> +#include <uk/config.h>
> +
> +static struct utsname utsname = {
> +     .sysname        = "Unikraft",
> +     .nodename       = "unikraft",
> +     .release        = STRINGIFY(UK_CODENAME),
> +     .version        = STRINGIFY(UK_FULLVERSION),
> +#ifdef ARCH_X86_64
> +     .machine        = "x86_64"
> +#elif ARCH_ARM_64
> +     .machine        = "arm64"
> +#elif ARCH_ARM_32
> +     .machine        = "arm32"
> +#endif
> +};
>  
>  long fpathconf(int fd __unused, int name __unused)
>  {
> @@ -70,6 +85,30 @@ int getpagesize(void)
>  
>  int uname(struct utsname *buf __unused)
>  {
> +     if (buf == NULL) {
> +             errno = EFAULT;
> +             return -1;
> +     }
> +
> +     memcpy(buf, &utsname, sizeof(struct utsname));
> +     return 0;
> +}
> +
> +int sethostname(const char *name, size_t len)
> +{
> +     if (name == NULL) {
> +             errno = EFAULT;
> +             return -1;
> +     }
> +
> +     if (len < 0 || len > sizeof(utsname.nodename)) {
> +             errno = EINVAL;
> +             return -1;
> +     }
> +
> +     strncpy(utsname.nodename, name, len);
> +     if (len < sizeof(utsname.nodename))
> +             utsname.nodename[len] = 0;
>       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®.