summaryrefslogtreecommitdiff
path: root/kernel/cpu
diff options
context:
space:
mode:
authorAnton Kling <anton@kling.gg>2023-11-10 00:34:20 +0100
committerAnton Kling <anton@kling.gg>2023-11-10 00:34:20 +0100
commit8ffef83741948964171ca111fd7c90534515ae87 (patch)
treeb7ea3f6221c2d4ab1f696db22f80276253c13f2a /kernel/cpu
parentdcaf6356e5ede8c5b6a1d81ed47aeb713ed5bde3 (diff)
Syscall: Cleanup code and remove dumb usage of get_vfs_fd.
Diffstat (limited to 'kernel/cpu')
-rw-r--r--kernel/cpu/syscall.c16
1 files changed, 8 insertions, 8 deletions
diff --git a/kernel/cpu/syscall.c b/kernel/cpu/syscall.c
index 4978732..6b4f437 100644
--- a/kernel/cpu/syscall.c
+++ b/kernel/cpu/syscall.c
@@ -70,11 +70,11 @@ int syscall_pread(SYS_PREAD_PARAMS *args) {
}
int syscall_read(SYS_READ_PARAMS *args) {
- if (!get_vfs_fd(args->fd))
+ vfs_fd_t *fd = get_vfs_fd(args->fd);
+ if (!fd)
return -EBADF;
- int rc = vfs_pread(args->fd, args->buf, args->count,
- get_current_task()->file_descriptors[args->fd]->offset);
- get_current_task()->file_descriptors[args->fd]->offset += rc;
+ int rc = vfs_pread(args->fd, args->buf, args->count, fd->offset);
+ fd->offset += rc;
return rc;
}
@@ -83,11 +83,11 @@ int syscall_pwrite(SYS_PWRITE_PARAMS *args) {
}
int syscall_write(int fd, const char *buf, size_t count) {
- if (!get_vfs_fd(fd))
+ vfs_fd_t *fd_ptr = get_vfs_fd(fd);
+ if (!fd_ptr)
return -EBADF;
- int rc = vfs_pwrite(fd, (char *)buf, count,
- get_current_task()->file_descriptors[fd]->offset);
- get_current_task()->file_descriptors[fd]->offset += rc;
+ int rc = vfs_pwrite(fd, (char *)buf, count, fd_ptr->offset);
+ fd_ptr->offset += rc;
return rc;
}