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

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


  • To: "minios-devel@xxxxxxxxxxxxx" <minios-devel@xxxxxxxxxxxxx>
  • From: Vlad-Andrei BĂDOIU (78692) <vlad_andrei.badoiu@xxxxxxxxxxxxxxx>
  • Date: Mon, 9 Sep 2019 13:18:46 +0000
  • Accept-language: en-US
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=stud.acs.upb.ro; dmarc=pass action=none header.from=stud.acs.upb.ro; dkim=pass header.d=stud.acs.upb.ro; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=+n3Mt67l2a+/C++vdL6x+jWwbY1mzn+elszNnWZpYlo=; b=LRxHnaLWeh8w1IR5Et4xsjRodw3OvpEU8Bs6FGx1ma2nOPdG9L+MxVlCDJknY4T/Xf+SOTD8VlwgPyvvRBXLrr4v5R99Y3Ld3hsIg/BMUJba7uvgW1ua7M2pdNBMz04MT6P/P3TWJayXg6htdYtUabk528As7ooeZcm2mWY/96y2wBt0gk3ewvk8PRa5BKC0yhYZrORHc/rR1bFrPR2jKP8eP+n0z/jaueRagCvpbRnyZeewYhv/wAtkOeWJ9k3AvLbvHv0+GI3O4yzeDA+QKbQuHOWXI2lLDA2W71j5vn09Ox3ufwYGQqFEbceZd+0O9aTw2kro9BLETLmer6L4Mw==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Lb4If34rDG/ss/OJCWewX6HO/zQMu1nTajgQn9CF/WAoH5FxRZcgC/d90+D9JT2mR+FIe0Y1qImtS8H5yhSbHAse8Mj9JfUhlZNXzFkezew+VQ2+LlthUxhXOJbNQjtlLYW6PpYgSfx2H8QM49N9oa8LVeU3T5376q1AG5kMQusANvupF03d/Sqo3YSpS5ust87uqvCABrkLVii/eTB4EGy0LrvVjKFUVuSMT1kfXjyYLWobM1Hf+y/NEk/ralZWcFPfnycV7YDrpXNDCdvU4jvpaOq1Iv2jw/lGfAIfnvu3fxb3v/1UUiz7ktuAew1xj0QfJVVrDpObncyHb47hAw==
  • Authentication-results: spf=none (sender IP is ) smtp.mailfrom=vlad_andrei.badoiu@xxxxxxxxxxxxxxx;
  • Cc: Vlad-Andrei BĂDOIU (78692) <vlad_andrei.badoiu@xxxxxxxxxxxxxxx>, "costin.lupu@xxxxxxxxx" <costin.lupu@xxxxxxxxx>
  • Delivery-date: Mon, 09 Sep 2019 13:18:52 +0000
  • List-id: Mini-os development list <minios-devel.lists.xenproject.org>
  • Thread-index: AQHVZxEch90PQMOpDkeMYYzaj1YmCQ==
  • Thread-topic: [UNIKRAFT PATCH 1/1] Implement sethostname and uname

---
 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;
 }
 
-- 
2.20.1


_______________________________________________
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®.