[kernel] Let process::add_handle take a handle argument

The process::add_handle() method takes an id and an object. This change
adds an overridden version that accecpts an actual handle object to
copy.
This commit is contained in:
Justin C. Miller
2022-02-03 00:04:09 -08:00
parent 7d5feb943f
commit ad5ebae304
2 changed files with 19 additions and 1 deletions

View File

@@ -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)
{

View File

@@ -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