summaryrefslogtreecommitdiff
path: root/src/kernel
diff options
context:
space:
mode:
authordzwdz2021-09-20 19:30:37 +0200
committerdzwdz2021-09-20 19:30:37 +0200
commit6371724809b057b25a4efd6c022e7d95068c42f1 (patch)
tree5cc6484ae767cd27f2ae4ccd24c0fb01e9beb163 /src/kernel
parent9a08099fb7148a69b0655f0e559661b1021b17b5 (diff)
add an offset parameter to read() and write()
Diffstat (limited to 'src/kernel')
-rw-r--r--src/kernel/syscalls.c10
-rw-r--r--src/kernel/vfs/request.c5
-rw-r--r--src/kernel/vfs/request.h1
3 files changed, 10 insertions, 6 deletions
diff --git a/src/kernel/syscalls.c b/src/kernel/syscalls.c
index bc185bd..d321d33 100644
--- a/src/kernel/syscalls.c
+++ b/src/kernel/syscalls.c
@@ -136,7 +136,7 @@ fail:
return -1;
}
-int _syscall_read(handle_t handle_num, char __user *buf, int len) {
+int _syscall_read(handle_t handle_num, char __user *buf, int len, int offset) {
struct handle *handle = &process_current->handles[handle_num];
if (handle_num < 0 || handle_num >= HANDLE_MAX) return -1;
if (handle->type != HANDLE_FILE) return -1;
@@ -147,12 +147,13 @@ int _syscall_read(handle_t handle_num, char __user *buf, int len) {
.len = len,
},
.id = handle->file.id,
+ .offset = offset,
.caller = process_current,
.backend = handle->file.backend,
});
}
-int _syscall_write(handle_t handle_num, const char __user *buf, int len) {
+int _syscall_write(handle_t handle_num, const char __user *buf, int len, int offset) {
struct handle *handle = &process_current->handles[handle_num];
if (handle_num < 0 || handle_num >= HANDLE_MAX) return -1;
if (handle->type != HANDLE_FILE) return -1;
@@ -163,6 +164,7 @@ int _syscall_write(handle_t handle_num, const char __user *buf, int len) {
.len = len,
},
.id = handle->file.id,
+ .offset = offset,
.caller = process_current,
.backend = handle->file.backend,
});
@@ -286,9 +288,9 @@ int _syscall(int num, int a, int b, int c, int d) {
case _SYSCALL_MOUNT:
return _syscall_mount(a, (userptr_t)b, c);
case _SYSCALL_READ:
- return _syscall_read(a, (userptr_t)b, c);
+ return _syscall_read(a, (userptr_t)b, c, d);
case _SYSCALL_WRITE:
- return _syscall_write(a, (userptr_t)b, c);
+ return _syscall_write(a, (userptr_t)b, c, d);
case _SYSCALL_CLOSE:
return _syscall_close(a);
case _SYSCALL_FS_CREATE:
diff --git a/src/kernel/vfs/request.c b/src/kernel/vfs/request.c
index 33a8458..b197f4b 100644
--- a/src/kernel/vfs/request.c
+++ b/src/kernel/vfs/request.c
@@ -64,8 +64,9 @@ _Noreturn void vfs_request_pass2handler(struct vfs_request *req) {
goto fail; // can't copy buffer
}
- res.len = len;
- res.id = req->id;
+ res.len = len;
+ res.id = req->id;
+ res.offset = req->offset;
if (!virt_cpy_to(handler->pages,
handler->awaited_req.res, &res, sizeof res))
diff --git a/src/kernel/vfs/request.h b/src/kernel/vfs/request.h
index a03fba9..0e96db6 100644
--- a/src/kernel/vfs/request.h
+++ b/src/kernel/vfs/request.h
@@ -34,6 +34,7 @@ struct vfs_request {
} output;
int id; // handle.file.id
+ int offset;
struct process *caller;
struct vfs_backend *backend;