diff options
author | Ian Moffett <ian@osmora.org> | 2024-04-26 14:37:22 -0400 |
---|---|---|
committer | Ian Moffett <ian@osmora.org> | 2024-04-26 14:37:22 -0400 |
commit | f5b5210cd6c6f62f012c9fd894f5e2a2bb328cb0 (patch) | |
tree | 07eed7ed6181fae1abc735b198257a221d404daa /sys | |
parent | 314b80e0e9f8fee490b1d59a0c3db543513eb8be (diff) |
kernel: filedesc: Acquire mutex in read()
Signed-off-by: Ian Moffett <ian@osmora.org>
Diffstat (limited to 'sys')
-rw-r--r-- | sys/kern/kern_filedesc.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/sys/kern/kern_filedesc.c b/sys/kern/kern_filedesc.c index f7ca2c8..203eefc 100644 --- a/sys/kern/kern_filedesc.c +++ b/sys/kern/kern_filedesc.c @@ -331,19 +331,24 @@ read(int fd, void *buf, size_t count) return -EBADF; } + mutex_acquire(&fd_desc->lock); if (fd_desc->oflag == O_WRONLY) { - return -EACCES; + bytes_read = -EACCES; + goto done; } sio.offset = fd_desc->offset; vnode = fd_desc->vnode; if (count > MAX_RW_SIZE) { - return -EINVAL; + bytes_read = -EACCES; + goto done; } bytes_read = vfs_read(vnode, &sio); fd_desc->offset += bytes_read; +done: + mutex_release(&fd_desc->lock); return bytes_read; } |