diff --git a/src/userprog/syscall.c b/src/userprog/syscall.c index 506498b..04d763f 100644 --- a/src/userprog/syscall.c +++ b/src/userprog/syscall.c @@ -1,14 +1,18 @@ #include "userprog/syscall.h" #include "devices/shutdown.h" #include "devices/input.h" +#include "filesys/filesys.h" #include "threads/vaddr.h" #include "threads/interrupt.h" #include "threads/thread.h" +#include "threads/synch.h" #include "userprog/process.h" #include "userprog/pagedir.h" #include #include +static struct lock filesys_lock; + static void syscall_handler (struct intr_frame *); /* A syscall_function is a function that receives up to 3 arguments, the @@ -68,6 +72,7 @@ void syscall_init (void) { intr_register_int (0x30, 3, INTR_ON, syscall_handler, "syscall"); + lock_init (&filesys_lock); } static void @@ -126,8 +131,13 @@ syscall_wait (pid_t pid) static bool syscall_create (const char *file UNUSED, unsigned initial_size UNUSED) { - //TODO - return 0; + validate_user_pointer (file, 1); + + lock_acquire (&filesys_lock); + bool status = filesys_create (file, initial_size); + lock_release (&filesys_lock); + + return status; } static bool