diff options
| -rw-r--r-- | src/userprog/build/fail | 4 | ||||
| -rw-r--r-- | src/userprog/syscall.c | 30 |
2 files changed, 26 insertions, 8 deletions
diff --git a/src/userprog/build/fail b/src/userprog/build/fail new file mode 100644 index 0000000..d6016ef --- /dev/null +++ b/src/userprog/build/fail @@ -0,0 +1,4 @@ +FAIL tests/filesys/base/lg-random +FAIL tests/filesys/base/sm-random +FAIL tests/filesys/base/syn-remove +FAIL tests/filesys/base/syn-write diff --git a/src/userprog/syscall.c b/src/userprog/syscall.c index 8bdb42b..b9acb17 100644 --- a/src/userprog/syscall.c +++ b/src/userprog/syscall.c @@ -38,7 +38,7 @@ create (const char *filename, off_t initial_size) static bool remove (const char *filename) { - return false; + return filesys_remove (filename); } static int @@ -66,12 +66,6 @@ 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) { @@ -158,15 +152,35 @@ write (int fd_i, const void *buf, unsigned size) } } +static int +filesize (int fd_i) +{ + struct thread *thread = thread_current (); + struct file **fd = get_fd (thread, fd_i); + if (fd && *fd) { + return file_length (*fd); + } + return -1; +} + static void seek (int fd_i, unsigned position) { - return; + struct thread *thread = thread_current (); + struct file **fd = get_fd (thread, fd_i); + if (fd && *fd) { + file_seek (*fd, position); + } } static unsigned tell (int fd_i) { + struct thread *thread = thread_current (); + struct file **fd = get_fd (thread, fd_i); + if (fd && *fd) { + return file_tell (*fd); + } return 0; } |
