Files
mango/syscall/handle.c

40 lines
828 B
C
Raw Normal View History

2026-02-19 19:21:50 +00:00
#include <kernel/sched.h>
#include <kernel/syscall.h>
kern_status_t sys_kern_handle_close(kern_handle_t handle)
{
struct task *self = current_task();
2026-02-19 19:21:50 +00:00
return task_close_handle(self, handle);
}
kern_status_t sys_kern_handle_duplicate(
kern_handle_t handle,
kern_handle_t *out)
{
struct task *self = current_task();
if (!validate_access_w(self, out, sizeof *out)) {
return KERN_MEMORY_FAULT;
}
unsigned long flags;
task_lock_irqsave(self, &flags);
struct object *obj = NULL;
handle_flags_t handle_flags = 0;
kern_status_t status
= task_resolve_handle(self, handle, &obj, &handle_flags);
if (status != KERN_OK) {
task_unlock_irqrestore(self, flags);
return status;
}
status = task_open_handle(self, obj, handle_flags, out);
object_unref(obj);
task_unlock_irqrestore(self, flags);
return status;
}