blob: 5a6786dd5f3de258e2f919ef265fa7c69b758ca3 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
#include "arch/x86_64/hal/obj.h"
#include "hal/process.h"
#include "jove.h"
#include "lib/printf.h"
#include "syscall.h"
int
s_syscall_objdir_objtype(
jove_owned_obj_t *objdir,
jove_owned_obj_t *target_dir,
size_t payload_size,
void *payload_data)
{
size_t bytes_needed = 2;
CHECK_TOOSMALL(bytes_needed, payload_size, "Message is too small for payload.");
uint16_t local_idx = *((uint16_t*)payload_data);
if(local_idx > JOVE_OBJDIR_ENTRIES) {
kprintf("%s: Object index is out of bounds (>= 512)\n", __func__);
return EOOB;
}
jove_obj_t local_obj = objdir_peeklocal(target_dir, local_idx);
return obj_peektype(local_obj);
}
int
_syscall_handle_objdir(syscall_context_t *ctx)
{
switch(ctx->header->callid) {
case SYSCALL_OBJDIR_OBJTYPE:
if(ctx->target.permissions & SYSCALL_PERM_OBJDIR_OBJTYPE)
return s_syscall_objdir_objtype(
ctx->objdir, ctx->target.obj, ctx->bytes_left, ctx->payload);
return -EPERM;
default:
return -EBADCALL;
}
}
|