mirror of
https://github.com/Mathewnd/Astral.git
synced 2026-11-01 06:58:22 +00:00
handle /etc/hostname, sethostname(2), gethostname(2) and uname(2)
This commit is contained in:
@@ -192,10 +192,10 @@ index 0000000..e5b087a
|
||||
+
|
||||
diff --git mlibc-workdir/sysdeps/astral/generic/generic.cpp mlibc-workdir/sysdeps/astral/generic/generic.cpp
|
||||
new file mode 100644
|
||||
index 0000000..8ebf840
|
||||
index 0000000..c409d89
|
||||
--- /dev/null
|
||||
+++ mlibc-workdir/sysdeps/astral/generic/generic.cpp
|
||||
@@ -0,0 +1,694 @@
|
||||
@@ -0,0 +1,690 @@
|
||||
+#include <bits/ensure.h>
|
||||
+#include <mlibc/debug.hpp>
|
||||
+#include <mlibc/all-sysdeps.hpp>
|
||||
@@ -300,23 +300,19 @@ index 0000000..8ebf840
|
||||
+ return 0;
|
||||
+ }
|
||||
+
|
||||
+ #define ASTRALHOSTNAME "astral"
|
||||
+
|
||||
+ int sys_gethostname(char *buffer, size_t bufsize) {
|
||||
+ // TODO unstub
|
||||
+ memcpy(buffer, ASTRALHOSTNAME, strlen(ASTRALHOSTNAME));
|
||||
+ return 0;
|
||||
+ long ret;
|
||||
+ return syscall(SYSCALL_HOSTNAME, &ret, NULL, 0, (uint64_t)buffer, bufsize);
|
||||
+ }
|
||||
+
|
||||
+ int sys_sethostname(const char *buffer, size_t bufsize) {
|
||||
+ long ret;
|
||||
+ return syscall(SYSCALL_HOSTNAME, &ret, (uint64_t)buffer, bufsize, NULL, 0), NULL, 0;
|
||||
+ }
|
||||
+
|
||||
+ int sys_uname(struct utsname *buf) {
|
||||
+ // TODO unstub
|
||||
+ memcpy(buf->sysname, "Astral", 7);
|
||||
+ memcpy(buf->nodename, ASTRALHOSTNAME, strlen(ASTRALHOSTNAME)+1);
|
||||
+ memcpy(buf->version, "rw-0.0.1", 9);
|
||||
+ memcpy(buf->release, "Astral", 13);
|
||||
+ memcpy(buf->machine, "x86_64", 7);
|
||||
+ memcpy(buf->domainname, ASTRALHOSTNAME, strlen(ASTRALHOSTNAME)+1);
|
||||
+ return 0;
|
||||
+ long ret;
|
||||
+ return syscall(SYSCALL_UNAME, &ret, (uint64_t)buf);
|
||||
+ }
|
||||
+
|
||||
+ int sys_fsync(int fd) {
|
||||
@@ -909,10 +905,10 @@ index 0000000..990eca0
|
||||
+#endif
|
||||
diff --git mlibc-workdir/sysdeps/astral/include/astral/syscall.h mlibc-workdir/sysdeps/astral/include/astral/syscall.h
|
||||
new file mode 100644
|
||||
index 0000000..14f3c2b
|
||||
index 0000000..3a130be
|
||||
--- /dev/null
|
||||
+++ mlibc-workdir/sysdeps/astral/include/astral/syscall.h
|
||||
@@ -0,0 +1,86 @@
|
||||
@@ -0,0 +1,88 @@
|
||||
+#ifndef _SYSCALL_H_INCLUDE
|
||||
+#define _SYSCALL_H_INCLUDE
|
||||
+
|
||||
@@ -979,6 +975,8 @@ index 0000000..14f3c2b
|
||||
+#define SYSCALL_SIGPROCMASK 60
|
||||
+#define SYSCALL_KILL 61
|
||||
+#define SYSCALL_SIGRETURN 62
|
||||
+#define SYSCALL_UNAME 63
|
||||
+#define SYSCALL_HOSTNAME 64
|
||||
+
|
||||
+#include <stddef.h>
|
||||
+#include <stdint.h>
|
||||
|
||||
Reference in New Issue
Block a user