[kernel] Add capabilities to handles
This change finally adds capabilities to handles. Included changes: - j6_handle_t is now again 64 bits, with the highest 8 bits being a type code, and the next highest 24 bits being the capability mask, so that programs can check type/caps without calling the kernel. - The definitions grammar now includes a `capabilities [ ]` section on objects, to list what capabilities are relevant. - j6/caps.h is auto-generated from object capability lists - init_libj6 again sets __handle_self and __handle_sys, this is a bit of a hack. - A new syscall, j6_handle_list, will return the list of existing handles owned by the calling process. - syscall_verify.cpp.cog now actually checks that the needed capabilities exist on handles before allowing the call.
This commit is contained in:
27
src/kernel/syscalls/handle.cpp
Normal file
27
src/kernel/syscalls/handle.cpp
Normal file
@@ -0,0 +1,27 @@
|
||||
#include <j6/errors.h>
|
||||
#include <j6/types.h>
|
||||
|
||||
#include "objects/process.h"
|
||||
|
||||
using namespace obj;
|
||||
|
||||
namespace syscalls {
|
||||
|
||||
j6_status_t
|
||||
handle_list(j6_handle_t *handles, size_t *handles_len)
|
||||
{
|
||||
if (!handles_len || (*handles_len && !handles))
|
||||
return j6_err_invalid_arg;
|
||||
|
||||
process &p = process::current();
|
||||
size_t requested = *handles_len;
|
||||
|
||||
*handles_len = p.list_handles(handles, requested);
|
||||
|
||||
if (*handles_len < requested)
|
||||
return j6_err_insufficient;
|
||||
|
||||
return j6_status_ok;
|
||||
}
|
||||
|
||||
} // namespace syscalls
|
||||
Reference in New Issue
Block a user