summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/init/main.c8
-rw-r--r--src/init/syscalls.c4
-rw-r--r--src/kernel/proc.h1
-rw-r--r--src/kernel/syscalls.c5
-rw-r--r--src/kernel/vfs/request.c4
-rw-r--r--src/shared/syscalls.h2
6 files changed, 15 insertions, 9 deletions
diff --git a/src/init/main.c b/src/init/main.c
index 1842156..15afaf5 100644
--- a/src/init/main.c
+++ b/src/init/main.c
@@ -47,19 +47,19 @@ void fs_test(void) {
void fs_server(handle_t back) {
static char buf[64];
- int len;
+ int len, id;
for (;;) {
len = 64;
- switch (_syscall_fs_wait(back, buf, &len)) {
+ switch (_syscall_fs_wait(back, buf, &len, &id)) {
case VFSOP_OPEN:
_syscall_write(tty_fd, buf, len);
log(" was opened. ");
- _syscall_fs_respond(NULL, 0); // doesn't check the path yet
+ _syscall_fs_respond(NULL, 32); // doesn't check the path yet
break;
case VFSOP_WRITE:
// uppercase the buffer
- for (int i = 0; i < len; i++) buf[i] &= ~32;
+ for (int i = 0; i < len; i++) buf[i] &= ~id; // id == 32
// and passthrough to tty
_syscall_write(tty_fd, buf, len);
_syscall_fs_respond(NULL, len); // return the amt of bytes written
diff --git a/src/init/syscalls.c b/src/init/syscalls.c
index fb50c35..6e00895 100644
--- a/src/init/syscalls.c
+++ b/src/init/syscalls.c
@@ -39,8 +39,8 @@ handle_t _syscall_fs_create(handle_t __user *back) {
return _syscall(_SYSCALL_FS_CREATE, (int)back, 0, 0, 0);
}
-int _syscall_fs_wait(handle_t back, char __user *buf, int __user *len) {
- return _syscall(_SYSCALL_FS_WAIT, back, (int)buf, (int)len, 0);
+int _syscall_fs_wait(handle_t back, char __user *buf, int __user *len, int __user *id) {
+ return _syscall(_SYSCALL_FS_WAIT, back, (int)buf, (int)len, (int)id);
}
int _syscall_fs_respond(char __user *buf, int ret) {
diff --git a/src/kernel/proc.h b/src/kernel/proc.h
index 73a6651..bd7a843 100644
--- a/src/kernel/proc.h
+++ b/src/kernel/proc.h
@@ -34,6 +34,7 @@ struct process {
struct {
char __user *buf;
int __user *len;
+ int __user *id;
} awaited_req; // PS_WAITS4REQUEST
};
struct vfs_request *handled_req;
diff --git a/src/kernel/syscalls.c b/src/kernel/syscalls.c
index 3ed4877..48e67db 100644
--- a/src/kernel/syscalls.c
+++ b/src/kernel/syscalls.c
@@ -195,7 +195,7 @@ fail:
return -1;
}
-int _syscall_fs_wait(handle_t back, char __user *buf, int __user *len) {
+int _syscall_fs_wait(handle_t back, char __user *buf, int __user *len, int __user *id) {
struct handle *back_handle;
if (back < 0 || back >= HANDLE_MAX) return -1;
@@ -209,6 +209,7 @@ int _syscall_fs_wait(handle_t back, char __user *buf, int __user *len) {
* vfs_request_pass2handler simpler. TODO? */
process_current->awaited_req.buf = buf;
process_current->awaited_req.len = len;
+ process_current->awaited_req.id = id;
if (back_handle->fs.backend->queue) {
// handle queued requests
@@ -271,7 +272,7 @@ int _syscall(int num, int a, int b, int c, int d) {
case _SYSCALL_FS_CREATE:
return _syscall_fs_create((userptr_t)a);
case _SYSCALL_FS_WAIT:
- return _syscall_fs_wait(a, (userptr_t)b, (userptr_t)c);
+ return _syscall_fs_wait(a, (userptr_t)b, (userptr_t)c, (userptr_t)d);
case _SYSCALL_FS_RESPOND:
return _syscall_fs_respond((userptr_t)a, b);
case _SYSCALL_MEMFLAG:
diff --git a/src/kernel/vfs/request.c b/src/kernel/vfs/request.c
index 5836b94..9a51688 100644
--- a/src/kernel/vfs/request.c
+++ b/src/kernel/vfs/request.c
@@ -66,6 +66,10 @@ _Noreturn void vfs_request_pass2handler(struct vfs_request *req) {
handler->awaited_req.len, &len, sizeof len))
goto fail; // can't copy new length
+ if (!virt_cpy_to(handler->pages,
+ handler->awaited_req.id, &req->id, sizeof req->id))
+ goto fail; // can't copy id
+
regs_savereturn(&handler->regs, req->type);
process_switch(handler);
fail:
diff --git a/src/shared/syscalls.h b/src/shared/syscalls.h
index 11abf66..36588b6 100644
--- a/src/shared/syscalls.h
+++ b/src/shared/syscalls.h
@@ -56,7 +56,7 @@ int _syscall_close(handle_t);
* @param back a pointer to a handle_t which will store the back pointer
*/
handle_t _syscall_fs_create(handle_t __user *back);
-int _syscall_fs_wait(handle_t back, char __user *buf, int __user *len);
+int _syscall_fs_wait(handle_t back, char __user *buf, int __user *len, int __user *id);
int _syscall_fs_respond(char __user *buf, int ret);
int _syscall_memflag(void __user *addr, size_t len, int flags);