Refactor System Calls and Process for Readability; Change FD to local counter and use it as hash #47
@@ -209,7 +209,7 @@ process_init_stack (char *cmd_saveptr, void **esp, char *file_name)
|
|||||||
/* filename has already been validated to be a safe-to-access string,
|
/* filename has already been validated to be a safe-to-access string,
|
||||||
so we can safely use strlen here. Filename has already been
|
so we can safely use strlen here. Filename has already been
|
||||||
split from the command line arguments. */
|
split from the command line arguments. */
|
||||||
push_to_stack (esp, arg, strlen (arg) + 1);
|
push_to_stack (esp, arg, (strlen (arg) + 1) * sizeof (char));
|
||||||
|
|
||||||
/* Try to allocate memory for the argument pointer. */
|
/* Try to allocate memory for the argument pointer. */
|
||||||
struct arg_elem *arg_elem = malloc (sizeof (struct arg_elem));
|
struct arg_elem *arg_elem = malloc (sizeof (struct arg_elem));
|
||||||
@@ -376,9 +376,10 @@ process_exit (void)
|
|||||||
/* Clean up all open files */
|
/* Clean up all open files */
|
||||||
hash_destroy (&cur->open_files, fd_cleanup);
|
hash_destroy (&cur->open_files, fd_cleanup);
|
||||||
|
|
||||||
/* Close the executable file. */
|
/* Close the executable file, implicitly allowing it to be written to. */
|
||||||
if (cur->exec_file != NULL)
|
if (cur->exec_file != NULL)
|
||||||
{
|
{
|
||||||
|
/* Acquire the file system lock to prevent race conditions. */
|
||||||
lock_acquire (&filesys_lock);
|
lock_acquire (&filesys_lock);
|
||||||
file_close (cur->exec_file);
|
file_close (cur->exec_file);
|
||||||
lock_release (&filesys_lock);
|
lock_release (&filesys_lock);
|
||||||
|
|||||||
Reference in New Issue
Block a user