[kernel] Add process_give_handle syscall

This syscall allows a process to give another process access to an
object it has a handle to. The value of the handle as seen in the
receiver process is returned to the caller, so that the caller may
notify the recipient which handle was given.
This commit is contained in:
Justin C. Miller
2022-01-15 09:37:55 -08:00
parent 4d9b33ecd4
commit 11eef8d892
2 changed files with 21 additions and 0 deletions

View File

@@ -56,4 +56,18 @@ process_exit(int32_t status)
return j6_err_unexpected;
}
j6_status_t
process_give_handle(j6_handle_t handle, j6_handle_t sender, j6_handle_t *receiver)
{
process *dest = get_handle<process>(handle);
if (!dest) return j6_err_invalid_arg;
kobject *o = get_handle<kobject>(sender);
j6_handle_t out = dest->add_handle(o);
if (receiver)
*receiver = out;
return j6_status_ok;
}
} // namespace syscalls