diff options
Diffstat (limited to 'src/kernel/syscalls.c')
-rw-r--r-- | src/kernel/syscalls.c | 46 |
1 files changed, 23 insertions, 23 deletions
diff --git a/src/kernel/syscalls.c b/src/kernel/syscalls.c index 2a9a7b5..da6b48f 100644 --- a/src/kernel/syscalls.c +++ b/src/kernel/syscalls.c @@ -31,7 +31,7 @@ long _sys_fork(int flags, hid_t __user *fs_front) { if (flags & FORK_NEWFS) { Handle *h; - hid_t hid = proc_handle_init(proc_cur, HANDLE_FS_FRONT, &h); + hid_t hid = hs_hinit(proc_cur->hs, HANDLE_FS_FRONT, &h); if (hid < 0) { child->noreap = true; proc_kill(child, -EMFILE); @@ -124,7 +124,7 @@ long _sys_mount(hid_t hid, const char __user *path, long len) { len--; } - Handle *handle = proc_handle_get(proc_cur, hid); + Handle *handle = hs_get(proc_cur->hs, hid); if (!handle || handle->type != HANDLE_FS_FRONT) goto fail; backend = handle->backend; @@ -155,7 +155,7 @@ fail: } hid_t _sys_dup(hid_t from, hid_t to, int flags) { - SYSCALL_RETURN(proc_handle_dup(proc_cur, from, to, flags)); + SYSCALL_RETURN(hs_dup(proc_cur->hs, from, to, flags)); } static long simple_vfsop( @@ -165,7 +165,7 @@ static long simple_vfsop( assert(vfsop == VFSOP_READ || vfsop == VFSOP_WRITE || vfsop == VFSOP_GETSIZE); - Handle *h = proc_handle_get(proc_cur, hid); + Handle *h = hs_get(proc_cur->hs, hid); if (!h) { SYSCALL_RETURN(-EBADF); } @@ -226,31 +226,31 @@ long _sys_getsize(hid_t hid) { } long _sys_remove(hid_t hid) { - Handle *h = proc_handle_get(proc_cur, hid); + Handle *h = hs_get(proc_cur->hs, hid); if (!h) SYSCALL_RETURN(-EBADF); if (h->type != HANDLE_FILE) { - proc_handle_close(proc_cur, hid); + hs_close(proc_cur->hs, hid); SYSCALL_RETURN(-ENOSYS); } if (!h->writeable) { - proc_handle_close(proc_cur, hid); + hs_close(proc_cur->hs, hid); SYSCALL_RETURN(-EACCES); } vfsreq_create((VfsReq) { - .type = VFSOP_REMOVE, - .id = h->file_id, - .caller = proc_cur, - .backend = h->backend, - }); - proc_handle_close(proc_cur, hid); + .type = VFSOP_REMOVE, + .id = h->file_id, + .caller = proc_cur, + .backend = h->backend, + }); + hs_close(proc_cur->hs, hid); return -1; // dummy } long _sys_close(hid_t hid) { - if (!proc_handle_get(proc_cur, hid)) { + if (!hs_get(proc_cur->hs, hid)) { SYSCALL_RETURN(-EBADF); } - proc_handle_close(proc_cur, hid); + hs_close(proc_cur->hs, hid); SYSCALL_RETURN(0); } @@ -274,7 +274,7 @@ hid_t _sys_fs_wait(char __user *buf, long max_len, struct ufs_request __user *re } long _sys_fs_respond(hid_t hid, const void __user *buf, long ret, int flags) { - Handle *h = proc_handle_get(proc_cur, hid); + Handle *h = hs_get(proc_cur->hs, hid); if (!h || h->type != HANDLE_FS_REQ) SYSCALL_RETURN(-EBADF); VfsReq *req = h->req; if (req) { @@ -291,7 +291,7 @@ long _sys_fs_respond(hid_t hid, const void __user *buf, long ret, int flags) { vfsreq_finish(req, (void __user *)buf, ret, flags, proc_cur); } h->req = NULL; - proc_handle_close(proc_cur, hid); + hs_close(proc_cur->hs, hid); SYSCALL_RETURN(0); } @@ -335,11 +335,11 @@ long _sys_pipe(hid_t __user user_ends[2], int flags) { hid_t ends[2]; Handle *rend, *wend; - ends[0] = proc_handle_init(proc_cur, HANDLE_PIPE, &rend); - ends[1] = proc_handle_init(proc_cur, HANDLE_PIPE, &wend); + ends[0] = hs_hinit(proc_cur->hs, HANDLE_PIPE, &rend); + ends[1] = hs_hinit(proc_cur->hs, HANDLE_PIPE, &wend); if (ends[0] < 0 || ends[1] < 0) { - proc_handle_close(proc_cur, ends[0]); - proc_handle_close(proc_cur, ends[1]); + hs_close(proc_cur->hs, ends[0]); + hs_close(proc_cur->hs, ends[1]); SYSCALL_RETURN(-EMFILE); } wend->pipe.sister = rend; @@ -421,7 +421,7 @@ hid_t _sys_getprocfs(int flags) { proc_ns_create(proc_cur); Handle *h; - hid_t hid = proc_handle_init(proc_cur, HANDLE_FS_FRONT, &h); + hid_t hid = hs_hinit(proc_cur->hs, HANDLE_FS_FRONT, &h); if (hid < 0) { SYSCALL_RETURN(-EMFILE); } @@ -446,7 +446,7 @@ hid_t _sys_getnull(int flags) { SYSCALL_RETURN(-ENOSYS); } - hid_t hid = proc_handle_init(proc_cur, HANDLE_NULL, NULL); + hid_t hid = hs_hinit(proc_cur->hs, HANDLE_NULL, NULL); SYSCALL_RETURN((0 <= hid) ? hid : -EMFILE); } |