mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 04:07:44 +00:00
Kernel: Make all syscall functions return KResultOr<T>
This makes it a lot easier to return errors since we no longer have to worry about negating EFOO errors and can just return them flat.
This commit is contained in:
parent
9af1e1a3bf
commit
ac71775de5
70 changed files with 747 additions and 742 deletions
|
@ -28,36 +28,36 @@
|
|||
|
||||
namespace Kernel {
|
||||
|
||||
int Process::sys$yield()
|
||||
KResultOr<int> Process::sys$yield()
|
||||
{
|
||||
REQUIRE_PROMISE(stdio);
|
||||
Thread::current()->yield_without_holding_big_lock();
|
||||
return 0;
|
||||
}
|
||||
|
||||
int Process::sys$donate(pid_t tid)
|
||||
KResultOr<int> Process::sys$donate(pid_t tid)
|
||||
{
|
||||
REQUIRE_PROMISE(stdio);
|
||||
if (tid < 0)
|
||||
return -EINVAL;
|
||||
return EINVAL;
|
||||
|
||||
ScopedCritical critical;
|
||||
auto thread = Thread::from_tid(tid);
|
||||
if (!thread || thread->pid() != pid())
|
||||
return -ESRCH;
|
||||
return ESRCH;
|
||||
Thread::current()->donate_without_holding_big_lock(thread, "sys$donate");
|
||||
return 0;
|
||||
}
|
||||
|
||||
int Process::sys$sched_setparam(int pid, Userspace<const struct sched_param*> user_param)
|
||||
KResultOr<int> Process::sys$sched_setparam(int pid, Userspace<const struct sched_param*> user_param)
|
||||
{
|
||||
REQUIRE_PROMISE(proc);
|
||||
struct sched_param desired_param;
|
||||
if (!copy_from_user(&desired_param, user_param))
|
||||
return -EFAULT;
|
||||
return EFAULT;
|
||||
|
||||
if (desired_param.sched_priority < THREAD_PRIORITY_MIN || desired_param.sched_priority > THREAD_PRIORITY_MAX)
|
||||
return -EINVAL;
|
||||
return EINVAL;
|
||||
|
||||
auto* peer = Thread::current();
|
||||
ScopedSpinLock lock(g_scheduler_lock);
|
||||
|
@ -65,16 +65,16 @@ int Process::sys$sched_setparam(int pid, Userspace<const struct sched_param*> us
|
|||
peer = Thread::from_tid(pid);
|
||||
|
||||
if (!peer)
|
||||
return -ESRCH;
|
||||
return ESRCH;
|
||||
|
||||
if (!is_superuser() && m_euid != peer->process().m_uid && m_uid != peer->process().m_uid)
|
||||
return -EPERM;
|
||||
return EPERM;
|
||||
|
||||
peer->set_priority((u32)desired_param.sched_priority);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int Process::sys$sched_getparam(pid_t pid, Userspace<struct sched_param*> user_param)
|
||||
KResultOr<int> Process::sys$sched_getparam(pid_t pid, Userspace<struct sched_param*> user_param)
|
||||
{
|
||||
REQUIRE_PROMISE(proc);
|
||||
int priority;
|
||||
|
@ -88,10 +88,10 @@ int Process::sys$sched_getparam(pid_t pid, Userspace<struct sched_param*> user_p
|
|||
}
|
||||
|
||||
if (!peer)
|
||||
return -ESRCH;
|
||||
return ESRCH;
|
||||
|
||||
if (!is_superuser() && m_euid != peer->process().m_uid && m_uid != peer->process().m_uid)
|
||||
return -EPERM;
|
||||
return EPERM;
|
||||
|
||||
priority = (int)peer->priority();
|
||||
}
|
||||
|
@ -100,7 +100,7 @@ int Process::sys$sched_getparam(pid_t pid, Userspace<struct sched_param*> user_p
|
|||
priority
|
||||
};
|
||||
if (!copy_to_user(user_param, ¶m))
|
||||
return -EFAULT;
|
||||
return EFAULT;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue