From fd3dd0d909c09782be4fcb00c6b5f776dd837ac2 Mon Sep 17 00:00:00 2001 From: CCXXXI Date: Sun, 10 Jan 2021 23:02:05 +0800 Subject: [PATCH] syscall create --- src/userprog/syscall.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/userprog/syscall.c b/src/userprog/syscall.c index 03270e4..7ab5391 100644 --- a/src/userprog/syscall.c +++ b/src/userprog/syscall.c @@ -10,6 +10,7 @@ #include "userprog/pagedir.h" #include "userprog/process.h" #include "devices/shutdown.h" +#include "filesys/filesys.h" #define USER_ASSERT(CONDITION) \ if (CONDITION) \ @@ -306,8 +307,13 @@ static void halt(void) would require a open system call. */ static bool create(const char *file, unsigned initial_size) { - // todo - return false; + USER_ASSERT(is_valid_str(file)); + + lock_acquire(&file_lock); + bool ret = filesys_create(file, initial_size); + lock_release(&file_lock); + + return ret; } /* Deletes the file called FILE. Returns true if successful, false