diff options
Diffstat (limited to 'src/kernel')
-rw-r--r-- | src/kernel/proc.h | 2 | ||||
-rw-r--r-- | src/kernel/syscalls.c | 3 | ||||
-rw-r--r-- | src/kernel/vfs/backend.c | 14 | ||||
-rw-r--r-- | src/kernel/vfs/backend.h | 6 |
4 files changed, 24 insertions, 1 deletions
diff --git a/src/kernel/proc.h b/src/kernel/proc.h index 447dac8..0efccde 100644 --- a/src/kernel/proc.h +++ b/src/kernel/proc.h @@ -8,6 +8,8 @@ enum process_state { PS_DEAD, // return message wasn't collected PS_DEADER, // return message was collected PS_WAITS4CHILDDEATH, + PS_WAITS4FS, + PS_WAITS4REQUEST, }; struct process { diff --git a/src/kernel/syscalls.c b/src/kernel/syscalls.c index d2217eb..ddc3d4b 100644 --- a/src/kernel/syscalls.c +++ b/src/kernel/syscalls.c @@ -179,6 +179,9 @@ handle_t _syscall_fs_create(user_ptr back_user) { backend = kmalloc(sizeof(struct vfs_backend)); // TODO never freed backend->type = VFS_BACK_USER; + backend->handler = NULL; + backend->queue = NULL; + process_current->handles[front].fs.backend = backend; process_current->handles[back ].fs.backend = backend; diff --git a/src/kernel/vfs/backend.c b/src/kernel/vfs/backend.c index 9a2b777..0f684a0 100644 --- a/src/kernel/vfs/backend.c +++ b/src/kernel/vfs/backend.c @@ -14,6 +14,20 @@ _Noreturn void vfs_backend_dispatch(struct vfs_backend *backend, struct vfs_op o case VFS_BACK_ROOT: int ret = vfs_root_handler(&req); vfs_backend_finish(&req, ret); + case VFS_BACK_USER: + process_current->state = PS_WAITS4FS; + if (backend->handler == NULL) { // backend not ready yet + if (backend->queue == NULL) { + backend->queue = process_current; + process_switch_any(); + } else { + panic(); // TODO implement a proper queue + } + } else { + if (backend->handler->state != PS_WAITS4REQUEST) + panic(); // invalid state + panic(); // TODO + } default: panic(); } diff --git a/src/kernel/vfs/backend.h b/src/kernel/vfs/backend.h index fe46db1..bf16ee7 100644 --- a/src/kernel/vfs/backend.h +++ b/src/kernel/vfs/backend.h @@ -6,9 +6,13 @@ enum vfs_backend_type { VFS_BACK_USER, }; -// describes something which can acts as an access function +// describes something which can act as an access function struct vfs_backend { enum vfs_backend_type type; + + // only used with VFS_BACK_USER + struct process *handler; + struct process *queue; }; // describes an in-progress vfs call |