summaryrefslogtreecommitdiffstats
path: root/sys/syscall.c
diff options
context:
space:
mode:
Diffstat (limited to 'sys/syscall.c')
-rw-r--r--sys/syscall.c64
1 files changed, 21 insertions, 43 deletions
diff --git a/sys/syscall.c b/sys/syscall.c
index 7d43d66..30bd851 100644
--- a/sys/syscall.c
+++ b/sys/syscall.c
@@ -8,22 +8,6 @@
#include "sys/link.h"
#include "sys/message.h"
-int __syscall_generic_objpath(jove_owned_obj_t *objdir, size_t payload_bytes, void *payload_data, jove_owned_obj_t **retobj)
-{
- size_t bytes_needed = sizeof(struct syscall_generic_objpath);
- CHECK_TOOSMALL(bytes_needed, payload_bytes,
- "Message too small for payload.");
- struct syscall_generic_objpath *payload = payload_data;
-
- bytes_needed += payload->pathlen << 1;
- CHECK_TOOSMALL(bytes_needed, payload_bytes,
- "Message too small for object path.");
-
- errno = 0;
- *retobj = objdir_getobj(objdir, payload->path, payload->pathlen);
- return errno;
-}
-
int
_syscall_handle_generic(syscall_context_t *ctx)
{
@@ -41,9 +25,6 @@ static const syscall_handle_t s_syscall_handles[128] = {
[JOVE_OBJ_SHMEMORY] = _syscall_handle_generic,
[JOVE_OBJ_PCB] = _syscall_handle_pcb,
[JOVE_OBJ_INT_HANDLE] = _syscall_handle_generic,
- [JOVE_OBJ_INITRD_FILE] = _syscall_handle_initrd_file,
- [JOVE_OBJ_FRAMEBUFFER] = _syscall_handle_generic,
- [JOVE_OBJ_VIRTTERM] = _syscall_handle_vtt,
[JOVE_OBJ_MESSAGE] = _syscall_handle_generic,
[JOVE_OBJ_LINK] = _syscall_handle_generic,
};
@@ -88,10 +69,9 @@ syscall_handler(uintmax_t message_path_raw, uint16_t message_pathlen)
ctx.pcb = process_current();
pcb_t *pcb = obj_deref(ctx.pcb);
- ctx.objdir = lockstack_push(&ctx.lockstack, obj_take(pcb_getrootdir(pcb)));
-
- ctx.message = link_try_traverse_objdir(
- ctx.objdir, &ctx.lockstack, message_pathlen, message_path);
+ ctx.objdir = pcb_getrootdir(pcb);
+ ctx.message = link_traverse_objdir(ctx.objdir, message_pathlen, message_path);
+ lockstack_push(&ctx.lockstack, ctx.message.obj);
if(ctx.message.obj == NULL) {
klogf("Process %i failed to get message %P : %s\n",
@@ -139,28 +119,26 @@ syscall_handler(uintmax_t message_path_raw, uint16_t message_pathlen)
ctx.bytes_left = messagelen - bytes_needed;
ctx.payload = (void*)((uintptr_t)header + bytes_needed);
- ctx.target = link_try_traverse_objdir(
- ctx.objdir, &ctx.lockstack, ctx.header->pathlen, ctx.header->path);
+ if(ctx.header->pathlen == 1) {
+ if(ctx.header->path[0] == PCB_ROOTDIR_SELF_I) {
+ ctx.target = (jove_perm_obj_t) { .permissions = 0xFF, .obj = ctx.pcb };
+ } else if(ctx.header->path[0] == PCB_ROOTDIR_PAGEDIR_I) {
+ ctx.target = (jove_perm_obj_t) { .permissions = 0xFF, .obj = pagedir };
+ } else {
+ ctx.target = link_traverse(objdir_getlocal(ctx.objdir, ctx.header->path[0]));
+ lockstack_push(&ctx.lockstack, ctx.target.obj);
+ }
+ }else{
+ ctx.target = link_traverse_objdir(ctx.objdir, ctx.header->pathlen, ctx.header->path);
+ lockstack_push(&ctx.lockstack, ctx.target.obj);
+ }
if(ctx.target.obj == 0) {
- //Check if we're trying to reference objects we've already locked in this function.
- //If we are, we should set it as the target regardless of lock,
- //since we're the ones with the lock already.
- if(ctx.header->pathlen == 1) {
- if(ctx.header->path[0] == PCB_ROOTDIR_SELF_I)
- ctx.target = (jove_perm_obj_t) { .permissions = 0xFF, .obj = ctx.pcb };
- else if(ctx.header->path[0] == PCB_ROOTDIR_PAGEDIR_I)
- ctx.target = (jove_perm_obj_t) { .permissions = 0xFF, .obj = pagedir };
- else
- goto fail_target_busy;
- }else{
-fail_target_busy:
- //Could not find payload target in pcb rootdir.
- klogf("Process %i tried to call syscall with bad target path %P : %s\n",
- pcb_getpid(pcb), header->path, header->pathlen, errstr(errno));
- sysret = -errno;
- goto remap_return;
- }
+ klogf("Process %i tried to call syscall with bad target path %P : %s\n",
+ pcb_getpid(pcb), header->path, header->pathlen, errstr(errno));
+ sysret = -errno;
+ goto remap_return;
+
}
sysret = _syscall_handle_switch(&ctx);