Update thread and syscall to use local fd counter instead global one, preventing overflow

This commit is contained in:
sBubshait
2024-11-15 15:48:56 +00:00
parent 7daf4fb079
commit 6b1dbdd34f
4 changed files with 8 additions and 6 deletions

View File

@@ -16,8 +16,6 @@
#define MAX_SYSCALL_ARGS 3
#define EXIT_FAILURE -1
static unsigned fd_counter = MIN_USER_FD;
struct open_file
{
int fd; /* File Descriptor / Identifier */
@@ -224,7 +222,7 @@ syscall_open (const char *file)
}
/* Populate the above struct, with a unique FD and the current open file */
file_info->fd = fd_counter++;
file_info->fd = thread_current ()->fd_counter++;
file_info->file = ptr;
/* Add the new FD->file mapping to the hashtable for the current thread */