Refactor System Calls and Process for Readability; Change FD to local counter and use it as hash #47

Merged
sb3923 merged 9 commits from task2/refactoring/saleh into master 2024-11-15 16:41:13 +00:00
3 changed files with 92 additions and 33 deletions
Showing only changes of commit 0f1bce2e88 - Show all commits

View File

@@ -191,6 +191,10 @@ start_process (void *proc_start_data)
static bool static bool
process_init_stack (char *cmd_saveptr, void **esp, char *file_name) process_init_stack (char *cmd_saveptr, void **esp, char *file_name)
{ {
ASSERT (cmd_saveptr != NULL);
ASSERT (esp != NULL);
ASSERT (file_name != NULL);
/* Load command line argument *data* to user process stack. /* Load command line argument *data* to user process stack.
This can't cause overflow due to enforcing that the size of This can't cause overflow due to enforcing that the size of
command line input must fit in a page. Also keep track command line input must fit in a page. Also keep track
@@ -202,7 +206,10 @@ process_init_stack (char *cmd_saveptr, void **esp, char *file_name)
int arg_count = 0; int arg_count = 0;
while (arg != NULL) while (arg != NULL)
{ {
push_to_stack (esp, arg, (strlen (arg) + 1) * sizeof (char)); /* filename has already been validated to be a safe-to-access string,
so we can safely use strlen here. Filename has already been
split from the command line arguments. */
push_to_stack (esp, arg, strlen (arg) + 1);
struct arg_elem *arg_elem = malloc (sizeof (struct arg_elem)); struct arg_elem *arg_elem = malloc (sizeof (struct arg_elem));
if (arg_elem == NULL) if (arg_elem == NULL)