From 685f911431564975a10efb8ae7977a17fbad7737 Mon Sep 17 00:00:00 2001 From: Marvin Friedrich Date: Tue, 6 Oct 2026 00:20:35 +0200 Subject: [PATCH] change errno to error to avoid confusion --- arch/x86_64/archctl.c | 6 +++--- include/zinnia/syscall.h | 2 +- include/zinnia/syscall_list.inc | 2 +- syscalls/dispatch.c | 3 ++- syscalls/exit.c | 2 +- syscalls/uname.c | 8 ++++---- 6 files changed, 12 insertions(+), 11 deletions(-) diff --git a/arch/x86_64/archctl.c b/arch/x86_64/archctl.c index d8d863d..a0f462c 100644 --- a/arch/x86_64/archctl.c +++ b/arch/x86_64/archctl.c @@ -12,21 +12,21 @@ struct syscall_ret arch_archctl(uintptr_t op, uintptr_t arg) { switch (op) { case __ARCHCTL_SET_FSBASE: if (!arch_mem_addr_is_user(arg)) { - ret.errno = EINVAL; + ret.error = EINVAL; return ret; } asm_wrmsr(MSR_FS_BASE, arg); return ret; case __ARCHCTL_SET_GSBASE: if (!arch_mem_addr_is_user(arg)) { - ret.errno = EINVAL; + ret.error = EINVAL; return ret; } // Update the inactive GSBASE MSR, not ours. asm_wrmsr(MSR_KERNEL_GS_BASE, arg); return ret; default: - ret.errno = EINVAL; + ret.error = EINVAL; return ret; } } diff --git a/include/zinnia/syscall.h b/include/zinnia/syscall.h index afff80d..58ab7e2 100644 --- a/include/zinnia/syscall.h +++ b/include/zinnia/syscall.h @@ -4,7 +4,7 @@ struct syscall_ret { uintptr_t value; - int errno; + int error; }; struct syscall { diff --git a/include/zinnia/syscall_list.inc b/include/zinnia/syscall_list.inc index ed02b54..e8595df 100644 --- a/include/zinnia/syscall_list.inc +++ b/include/zinnia/syscall_list.inc @@ -1,5 +1,5 @@ #ifndef SYSCALL_DECLARE -#define SYSCALL_DECLARE(number, name, num_args) extern void sys_##name(...); +#define SYSCALL_DECLARE(number, name, num_args) #endif SYSCALL_DECLARE(0, exit, 1) diff --git a/syscalls/dispatch.c b/syscalls/dispatch.c index 12f419d..e5b2fa5 100644 --- a/syscalls/dispatch.c +++ b/syscalls/dispatch.c @@ -8,6 +8,7 @@ #include // Declare all syscalls. +#define SYSCALL_DECLARE(number, name, num_args) extern void sys_##name(...); #include #undef SYSCALL_DECLARE @@ -43,5 +44,5 @@ void syscall_dispatch(struct arch_context* ctx) { } ctx->ARCH_CTX_RET0 = ret.value; - ctx->ARCH_CTX_RET1 = ret.errno; + ctx->ARCH_CTX_RET1 = ret.error; } diff --git a/syscalls/exit.c b/syscalls/exit.c index 1b21b6c..868120e 100644 --- a/syscalls/exit.c +++ b/syscalls/exit.c @@ -4,7 +4,7 @@ struct syscall_ret sys_exit(int err) { struct syscall_ret ret = {}; - ret.errno = ENOSYS; + ret.error = ENOSYS; panic("sys::exit() not implemented!\n"); diff --git a/syscalls/uname.c b/syscalls/uname.c index 1807082..f33bbb6 100644 --- a/syscalls/uname.c +++ b/syscalls/uname.c @@ -20,7 +20,7 @@ struct syscall_ret sys_setuname(const __user struct __utsname* ptr) { struct syscall_ret ret = {}; if (!ptr) { - ret.errno = EINVAL; + ret.error = EINVAL; return ret; } @@ -28,7 +28,7 @@ struct syscall_ret sys_setuname(const __user struct __utsname* ptr) { struct __utsname read_buf; if (!usercopy_read(&read_buf, ptr, sizeof(read_buf))) { - ret.errno = EFAULT; + ret.error = EFAULT; return ret; } @@ -50,7 +50,7 @@ struct syscall_ret sys_getuname(__user struct __utsname* ptr) { struct syscall_ret ret = {}; if (!ptr) { - ret.errno = EINVAL; + ret.error = EINVAL; return ret; } @@ -59,7 +59,7 @@ struct syscall_ret sys_getuname(__user struct __utsname* ptr) { spin_unlock(&uname_lock); if (!usercopy_write(ptr, &write_buf, sizeof(write_buf))) - ret.errno = EFAULT; + ret.error = EFAULT; return ret; }