diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/userprog/syscall.c | 54 |
1 files changed, 53 insertions, 1 deletions
diff --git a/src/userprog/syscall.c b/src/userprog/syscall.c index ea55cbe..8bdb42b 100644 --- a/src/userprog/syscall.c +++ b/src/userprog/syscall.c @@ -35,6 +35,12 @@ create (const char *filename, off_t initial_size) return filesys_create (filename, initial_size); } +static bool +remove (const char *filename) +{ + return false; +} + static int open (const char *filename) { @@ -60,6 +66,12 @@ open (const char *filename) return -1; } +static int +filesize (int fd_i) +{ + return 0; +} + static struct file ** get_fd (struct thread *thread, int fd_i) { @@ -147,6 +159,19 @@ write (int fd_i, const void *buf, unsigned size) } static void +seek (int fd_i, unsigned position) +{ + return; +} + +static unsigned +tell (int fd_i) +{ + return 0; +} + + +static void close (int fd_i) { struct thread *thread = thread_current (); @@ -203,7 +228,7 @@ syscall_handler (struct intr_frame *f UNUSED) int *status, *fd_i; off_t *initial_size; tid_t *child_tid; - unsigned *size; + unsigned *size, *position; void **buf; switch (*syscall_number) { @@ -239,6 +264,13 @@ syscall_handler (struct intr_frame *f UNUSED) CHECK_PTR_AND_MAYBE_EXIT (initial_size); f->eax = create (*filename, *initial_size); break; + case 5: + // remove + filename = INTR_ESP (1, char *); + CHECK_PTR_AND_MAYBE_EXIT (filename); + CHECK_PTR_AND_MAYBE_EXIT (*filename); + f->eax = remove (*filename); + break; case 6: // open filename = INTR_ESP (1, char *); @@ -246,6 +278,12 @@ syscall_handler (struct intr_frame *f UNUSED) CHECK_PTR_AND_MAYBE_EXIT (*filename); f->eax = open (*filename); break; + case 7: + // filesize + fd_i = INTR_ESP (1, int); + CHECK_PTR_AND_MAYBE_EXIT (fd_i); + f->eax = filesize (*fd_i); + break; case 8: // read fd_i = INTR_ESP (1, int); @@ -270,6 +308,20 @@ syscall_handler (struct intr_frame *f UNUSED) CHECK_PTR_AND_MAYBE_EXIT (*buf + *size); f->eax = write (*fd_i, *buf, *size); break; + case 10: + // seek + fd_i = INTR_ESP (1, int); + position = INTR_ESP (3, unsigned); + CHECK_PTR_AND_MAYBE_EXIT (fd_i); + CHECK_PTR_AND_MAYBE_EXIT (position); + seek (*fd_i, *position); + break; + case 11: + // tell + fd_i = INTR_ESP (1, int); + CHECK_PTR_AND_MAYBE_EXIT (fd_i); + f->eax = tell (*fd_i); + break; case 12: // close fd_i = INTR_ESP (1, int); |
