diff --git a/include/sys/amd64/sys_sys.h b/include/sys/amd64/sys_sys.h index 5722fe9..d08cd00 100644 --- a/include/sys/amd64/sys_sys.h +++ b/include/sys/amd64/sys_sys.h @@ -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); diff --git a/include/sys/syscall.h b/include/sys/syscall.h index 0978835..2158ad5 100644 --- a/include/sys/syscall.h +++ b/include/sys/syscall.h @@ -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 diff --git a/include/sys/utsname.h b/include/sys/utsname.h new file mode 100644 index 0000000..6db2c69 --- /dev/null +++ b/include/sys/utsname.h @@ -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 diff --git a/install-headers.sh b/install-headers.sh index 3f5a6c0..6d0524e 100755 --- a/install-headers.sh +++ b/install-headers.sh @@ -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') diff --git a/sys/amd64/sys_sys.c b/sys/amd64/sys_sys.c index 28f5292..02bb3c7 100644 --- a/sys/amd64/sys_sys.c +++ b/sys/amd64/sys_sys.c @@ -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; +} diff --git a/sys/amd64/syscall.c b/sys/amd64/syscall.c index 0f29c43..38531ff 100644 --- a/sys/amd64/syscall.c +++ b/sys/amd64/syscall.c @@ -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,