diff options
author | dzwdz | 2024-07-20 23:17:36 +0200 |
---|---|---|
committer | dzwdz | 2024-07-20 23:17:36 +0200 |
commit | 1fc2d9c88af77c3af81b6bd461e6b019b97d2dbb (patch) | |
tree | 56d19935958983882872495f556bdb74c8ae26b8 /src/kernel/syscalls.c | |
parent | e88aee660ea668cc96d8a5a11060b6e02b2f0fd7 (diff) |
*: moving files
Diffstat (limited to 'src/kernel/syscalls.c')
-rw-r--r-- | src/kernel/syscalls.c | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/src/kernel/syscalls.c b/src/kernel/syscalls.c index 3fc09fa..23a8883 100644 --- a/src/kernel/syscalls.c +++ b/src/kernel/syscalls.c @@ -456,6 +456,37 @@ hid_t _sys_getnull(int flags) { SYSCALL_RETURN((0 <= hid) ? hid : -EMFILE); } +long _sys_duplex(hid_t from, hid_t to, int flags) { + if ((flags & ~DUPLEX_REMOVE) != 0) { + SYSCALL_RETURN(-ENOSYS); + } + + Handle *fromh = hs_get(proc_cur->hs, from); + Handle *toh = hs_get(proc_cur->hs, to); + if (fromh == NULL || toh == NULL) { + SYSCALL_RETURN(-EBADF); + } + if (fromh->type != HANDLE_FILE || toh->type != HANDLE_FILE) { + SYSCALL_RETURN(-ENOSYS); + } + if (fromh->backend != toh->backend) { + SYSCALL_RETURN(-ENOSYS); + } + if (!fromh->readable || !fromh->writeable || !toh->writeable) { + SYSCALL_RETURN(-EACCES); + } + + vfsreq_dispatchcopy((VfsReq) { + .type = VFSOP_DUPLEX, + .id = fromh->file_id, + .id2 = toh->file_id, + .flags = flags, + .caller = proc_cur, + .backend = fromh->backend, + }); + return -1; // dummy +} + long _sys_execbuf(void __user *ubuf, size_t len) { if (len == 0) SYSCALL_RETURN(0); static_assert(EXECBUF_MAX_LEN <= KMALLOC_MAX); @@ -512,6 +543,7 @@ long _syscall(long num, long a, long b, long c, long d, long e) { break; case _SYS_GETPROCFS: _sys_getprocfs(a); break; case _SYS_TIME: _sys_time(a); break; case _SYS_GETNULL: _sys_getnull(a); + break; case _SYS_DUPLEX: _sys_duplex(a, b, c); break; case _SYS_EXECBUF: _sys_execbuf((userptr_t)a, b); break; case _SYS_DEBUG_KLOG: _sys_debug_klog((userptr_t)a, b); break; |