diff --git a/kernel/kernel/Syscall.cpp b/kernel/kernel/Syscall.cpp index 7d3f6c3a..ae52935a 100644 --- a/kernel/kernel/Syscall.cpp +++ b/kernel/kernel/Syscall.cpp @@ -114,12 +114,6 @@ namespace Kernel return ret.value()->pid(); } - long sys_sleep(unsigned int seconds) - { - PIT::sleep(seconds * 1000); - return 0; - } - long sys_exec(const char* pathname, const char* const* argv, const char* const* envp) { auto ret = Process::current().exec(pathname, argv, envp); @@ -128,6 +122,12 @@ namespace Kernel ASSERT_NOT_REACHED(); } + long sys_sleep(unsigned int seconds) + { + PIT::sleep(seconds * 1000); + return 0; + } + long sys_wait(pid_t pid, int* stat_loc, int options) { auto ret = Process::current().wait(pid, stat_loc, options); @@ -219,12 +219,12 @@ namespace Kernel case SYS_FORK: ret = sys_fork_trampoline(); break; - case SYS_SLEEP: - ret = sys_sleep((unsigned int)arg1); - break; case SYS_EXEC: ret = sys_exec((const char*)arg1, (const char* const*)arg2, (const char* const*)arg3); break; + case SYS_SLEEP: + ret = sys_sleep((unsigned int)arg1); + break; case SYS_WAIT: ret = sys_wait((pid_t)arg1, (int*)arg2, (int)arg3); break; diff --git a/libc/unistd.cpp b/libc/unistd.cpp index 95bfd750..b7c879d9 100644 --- a/libc/unistd.cpp +++ b/libc/unistd.cpp @@ -77,12 +77,27 @@ long syscall(long syscall, ...) ret = Kernel::syscall(SYS_OPEN, (uintptr_t)path, oflags); break; } + case SYS_OPENAT: + { + int fd = va_arg(args, int); + const char* path = va_arg(args, const char*); + int oflags = va_arg(args, int); + ret = Kernel::syscall(SYS_OPENAT, fd, (uintptr_t)path, oflags); + break; + } case SYS_ALLOC: { size_t bytes = va_arg(args, size_t); ret = Kernel::syscall(SYS_ALLOC, bytes); break; } + case SYS_REALLOC: + { + void* ptr = va_arg(args, void*); + size_t size = va_arg(args, size_t); + ret = Kernel::syscall(SYS_REALLOC, (uintptr_t)ptr, size); + break; + } case SYS_FREE: { void* ptr = va_arg(args, void*); @@ -120,12 +135,6 @@ long syscall(long syscall, ...) ret = Kernel::syscall(SYS_FORK); break; } - case SYS_SLEEP: - { - unsigned int seconds = va_arg(args, unsigned int); - ret = Kernel::syscall(SYS_SLEEP, seconds); - break; - } case SYS_EXEC: { const char* pathname = va_arg(args, const char*); @@ -134,11 +143,10 @@ long syscall(long syscall, ...) ret = Kernel::syscall(SYS_EXEC, (uintptr_t)pathname, (uintptr_t)argv, (uintptr_t)envp); break; } - case SYS_REALLOC: + case SYS_SLEEP: { - void* ptr = va_arg(args, void*); - size_t size = va_arg(args, size_t); - ret = Kernel::syscall(SYS_REALLOC, (uintptr_t)ptr, size); + unsigned int seconds = va_arg(args, unsigned int); + ret = Kernel::syscall(SYS_SLEEP, seconds); break; } case SYS_WAIT: