fix: do not acquire filesys_lock for tell and seek

This commit is contained in:
2024-11-24 15:41:18 +00:00
parent e1f0258f8e
commit aedb72246b

View File

@@ -348,12 +348,7 @@ syscall_seek (int fd, unsigned position)
/* Find the file from the FD. If it does not exist, do nothing. */
struct open_file *file_info = fd_get_file (fd);
if (file_info != NULL)
{
/* File exists: Acquire the file system lock to prevent race conditions. */
lock_acquire (&filesys_lock);
file_seek (file_info->file, position);
lock_release (&filesys_lock);
}
}
/* Handles the syscall for returning the next byte in a file referenced by
@@ -367,10 +362,7 @@ syscall_tell (int fd)
if (file_info == NULL)
return 0;
/* Acquire the file system lock to prevent race conditions. */
lock_acquire (&filesys_lock);
unsigned pos = file_tell (file_info->file);
lock_release (&filesys_lock);
/* Return the current position in the file. */
return pos;