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
|
@ -30,7 +30,7 @@
|
|||
|
||||
namespace Kernel {
|
||||
|
||||
int Process::sys$sigprocmask(int how, Userspace<const sigset_t*> set, Userspace<sigset_t*> old_set)
|
||||
KResultOr<int> Process::sys$sigprocmask(int how, Userspace<const sigset_t*> set, Userspace<sigset_t*> old_set)
|
||||
{
|
||||
REQUIRE_PROMISE(sigaction);
|
||||
auto current_thread = Thread::current();
|
||||
|
@ -38,7 +38,7 @@ int Process::sys$sigprocmask(int how, Userspace<const sigset_t*> set, Userspace<
|
|||
if (set) {
|
||||
sigset_t set_value;
|
||||
if (!copy_from_user(&set_value, set))
|
||||
return -EFAULT;
|
||||
return EFAULT;
|
||||
switch (how) {
|
||||
case SIG_BLOCK:
|
||||
previous_signal_mask = current_thread->signal_mask_block(set_value, true);
|
||||
|
@ -50,46 +50,46 @@ int Process::sys$sigprocmask(int how, Userspace<const sigset_t*> set, Userspace<
|
|||
previous_signal_mask = current_thread->update_signal_mask(set_value);
|
||||
break;
|
||||
default:
|
||||
return -EINVAL;
|
||||
return EINVAL;
|
||||
}
|
||||
} else {
|
||||
previous_signal_mask = current_thread->signal_mask();
|
||||
}
|
||||
if (old_set && !copy_to_user(old_set, &previous_signal_mask))
|
||||
return -EFAULT;
|
||||
return EFAULT;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int Process::sys$sigpending(Userspace<sigset_t*> set)
|
||||
KResultOr<int> Process::sys$sigpending(Userspace<sigset_t*> set)
|
||||
{
|
||||
REQUIRE_PROMISE(stdio);
|
||||
auto pending_signals = Thread::current()->pending_signals();
|
||||
if (!copy_to_user(set, &pending_signals))
|
||||
return -EFAULT;
|
||||
return EFAULT;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int Process::sys$sigaction(int signum, const sigaction* act, sigaction* old_act)
|
||||
KResultOr<int> Process::sys$sigaction(int signum, const sigaction* act, sigaction* old_act)
|
||||
{
|
||||
REQUIRE_PROMISE(sigaction);
|
||||
if (signum < 1 || signum >= 32 || signum == SIGKILL || signum == SIGSTOP)
|
||||
return -EINVAL;
|
||||
return EINVAL;
|
||||
InterruptDisabler disabler; // FIXME: This should use a narrower lock. Maybe a way to ignore signals temporarily?
|
||||
auto& action = Thread::current()->m_signal_action_data[signum];
|
||||
if (old_act) {
|
||||
if (!copy_to_user(&old_act->sa_flags, &action.flags))
|
||||
return -EFAULT;
|
||||
return EFAULT;
|
||||
if (!copy_to_user(&old_act->sa_sigaction, &action.handler_or_sigaction, sizeof(action.handler_or_sigaction)))
|
||||
return -EFAULT;
|
||||
return EFAULT;
|
||||
}
|
||||
if (!copy_from_user(&action.flags, &act->sa_flags))
|
||||
return -EFAULT;
|
||||
return EFAULT;
|
||||
if (!copy_from_user(&action.handler_or_sigaction, &act->sa_sigaction, sizeof(action.handler_or_sigaction)))
|
||||
return -EFAULT;
|
||||
return EFAULT;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int Process::sys$sigreturn([[maybe_unused]] RegisterState& registers)
|
||||
KResultOr<int> Process::sys$sigreturn([[maybe_unused]] RegisterState& registers)
|
||||
{
|
||||
REQUIRE_PROMISE(stdio);
|
||||
SmapDisabler disabler;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue