diff --git a/src/kernel/objects/process.cpp b/src/kernel/objects/process.cpp index 6041255..3f55842 100644 --- a/src/kernel/objects/process.cpp +++ b/src/kernel/objects/process.cpp @@ -135,6 +135,19 @@ process::add_handle(kobject *obj, j6_cap_t caps) return id; } +j6_handle_t +process::add_handle(const handle &hnd) +{ + if (!hnd.object || hnd.id == j6_handle_invalid) + return j6_handle_invalid; + + handle h {m_next_handle++, hnd.object, hnd.caps()}; + j6_handle_t id = h.id; + + m_handles.insert(id, h); + return id; +} + bool process::remove_handle(j6_handle_t id) { diff --git a/src/kernel/objects/process.h b/src/kernel/objects/process.h index 1e19b45..89ad87e 100644 --- a/src/kernel/objects/process.h +++ b/src/kernel/objects/process.h @@ -62,9 +62,14 @@ public: /// Start tracking an object with a handle. /// \args obj The object this handle refers to /// \args caps The capabilities on this handle - /// \returns The new handle for this object + /// \returns The new handle id for this object j6_handle_t add_handle(kobject *obj, j6_cap_t caps); + /// Start tracking an object with a handle. + /// \args hnd An existing handle to copy into this process + /// \returns The new handle id for this object + j6_handle_t add_handle(const handle &hnd); + /// Stop tracking an object with a handle. /// \args handle The handle that refers to the object /// \returns True if the handle was removed