Add "uname" system call

This commit is contained in:
Mark
2020-01-15 17:16:03 +02:00
parent 86cd5446cd
commit 05e10db0e2
6 changed files with 38 additions and 1 deletions
+2
View File
@@ -1,7 +1,9 @@
#pragma once
#include "sys/utsname.h"
#include "sys/types.h"
#include "sys/time.h"
int sys_uname(struct utsname *name);
int sys_gettimeofday(struct timeval *tv, struct timezone *tz);
int sys_nanosleep(const struct timespec *req, struct timespec *rem);
int sys_reboot(int magic1, int magic2, unsigned int cmd, void *arg);
+1
View File
@@ -31,6 +31,7 @@
#define SYSCALL_NR_SETUID 105
#define SYSCALL_NR_SETGID 106
#define SYSCALL_NR_UNAME 63
#define SYSCALL_NR_MOUNT 165
#define SYSCALL_NR_REBOOT 169
+14
View File
@@ -0,0 +1,14 @@
#pragma once
struct utsname {
char sysname[16];
char nodename[8];
char release[16];
char version[32];
char machine[16];
char domainname[64];
};
#if !defined(__KERNEL__)
int uname(struct utsname *buf);
#endif
+2 -1
View File
@@ -13,7 +13,8 @@ KERNEL_HEADERS="include/sys/fcntl.h \
include/sys/types.h \
include/sys/time.h \
include/sys/errno.h \
include/sys/signum.h"
include/sys/signum.h \
include/sys/utsname.h"
for src_file in $KERNEL_HEADERS; do
dst_file=$INSTALL_HDR$(echo $src_file | sed -e 's/^include//g')
+18
View File
@@ -2,6 +2,7 @@
#include "sys/amd64/hw/rtc.h"
#include "sys/amd64/cpu.h"
#include "sys/reboot.h"
#include "sys/string.h"
#include "sys/assert.h"
#include "sys/errno.h"
#include "sys/sched.h"
@@ -86,3 +87,20 @@ int sys_reboot(int magic1, int magic2, unsigned int cmd, void *arg) {
}
}
int sys_uname(struct utsname *name) {
if (!name) {
return -EFAULT;
}
strcpy(name->sysname, "yggdrasil");
// XXX: Hostname is not present in the kernel yet
strcpy(name->nodename, "nyan");
// XXX: No release numbers yet, only git version
strcpy(name->release, "X.Y");
strcpy(name->version, KERNEL_VERSION_STR);
// It's the only platform I'm developing the kernel for
strcpy(name->machine, "x86_64");
strcpy(name->domainname, "localhost");
return 0;
}
+1
View File
@@ -44,6 +44,7 @@ const void *amd64_syscall_jmp_table[256] = {
[SYSCALL_NR_GETGID] = sys_getgid,
// System
[SYSCALL_NR_UNAME] = sys_uname,
[SYSCALL_NR_MOUNT] = sys_mount,
[SYSCALL_NR_REBOOT] = sys_reboot,
[SYSCALL_NR_NANOSLEEP] = sys_nanosleep,