From 8f637be1a4ce5b15918c7806e135f1a3180052dd Mon Sep 17 00:00:00 2001 From: f2-zakir <farhan2.zakir@live.uwe.ac.uk> Date: Tue, 25 Jul 2023 22:14:49 +0000 Subject: [PATCH] Update syscall.c --- src/userprog/syscall.c | 33 +++------------------------------ 1 file changed, 3 insertions(+), 30 deletions(-) diff --git a/src/userprog/syscall.c b/src/userprog/syscall.c index 1752416..a876ff5 100644 --- a/src/userprog/syscall.c +++ b/src/userprog/syscall.c @@ -13,54 +13,27 @@ static void syscall_handler(struct intr_frame *); bool create(const char *file, unsigned initial_size); tid_t exec(const char *cmd_line); - void syscall_init(void) { intr_register_int(0x30, 3, INTR_ON, syscall_handler, "syscall"); } static void syscall_handler(struct intr_frame *f) { - - // Get the syscall number from the stack int syscall_num = *(int *)f->esp; - switch (syscall_num) { - + case SYS_REMOVE: - // Print current syscall number - printf("Syscall_handler() - %d!\n", syscall_num); filesys_remove(*(char **)(f->esp + 4)); - printf(*(char **)(f->esp + 4)); break; case SYS_EXEC: - // Print current syscall number - printf("Syscall_handler() - %d!\n", syscall_num); - printf("SYS_CALL : EXEC \n"); - exec(*(char **)(f->esp + 4)); + process_execute(*(char **)(f->esp + 4)); break; case SYS_CREATE: - // Print current syscall number - printf("Syscall_handler() - %d!\n", syscall_num); - create(*(int *)(f->esp + 4), (unsigned)*(int *)(f->esp + 8)); + filesys_create(*(char**)(f->esp + 4), (unsigned)*(int *)(f->esp + 8)); break; default: thread_exit(); } } - - -tid_t exec(const char *cmd_line) { - // showing the arg/process in the command line - printf(" \ncmd_line : '%s'\n", cmd_line); - // executing whatever in cmd_line then return to the process id - tid_t pid = process_execute(cmd_line); - return pid; -} - -bool create(const char *file, unsigned initial_size) { - // This creates a new file but doesn't open it - printf("File named '%s' created\n", file); - return filesys_create(file, initial_size); -} \ No newline at end of file -- GitLab