From 8ffef83741948964171ca111fd7c90534515ae87 Mon Sep 17 00:00:00 2001 From: Anton Kling Date: Fri, 10 Nov 2023 00:34:20 +0100 Subject: Syscall: Cleanup code and remove dumb usage of get_vfs_fd. --- kernel/cpu/syscall.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'kernel/cpu') 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; } -- cgit v1.2.3