[kernel] Add handle_clone syscall
Added the handle_clone syscall which allows for cloning a handle with a subset of the original handle's capabilities. Related changes: - srv.init now calls handle_clone on its system handle, and load_program was changed to allow this second system handle to be passed to loaded programs instead. However, as drv.uart is still a driver AND a log reader, this new handle is not actually passed yet. - The definition parser was using a set for the cap list, which meant the order (and thus values) of caps was not static. - Some code in objects/handle.h was made more explicit about what bits meant what.
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
#include <j6/types.h>
|
||||
|
||||
#include "objects/process.h"
|
||||
#include "syscalls/helpers.h"
|
||||
|
||||
using namespace obj;
|
||||
|
||||
@@ -24,4 +25,19 @@ handle_list(j6_handle_t *handles, size_t *handles_len)
|
||||
return j6_status_ok;
|
||||
}
|
||||
|
||||
j6_status_t
|
||||
handle_clone(j6_handle_t orig, j6_handle_t *clone, uint32_t mask)
|
||||
{
|
||||
handle *orig_handle = get_handle<kobject>(orig);
|
||||
if (!orig_handle)
|
||||
return j6_err_invalid_arg;
|
||||
|
||||
process &p = process::current();
|
||||
*clone = p.add_handle(
|
||||
orig_handle->object,
|
||||
orig_handle->caps() & mask);
|
||||
|
||||
return j6_status_ok;
|
||||
}
|
||||
|
||||
} // namespace syscalls
|
||||
|
||||
Reference in New Issue
Block a user