summaryrefslogtreecommitdiffstats
path: root/src/userprog/syscall.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/userprog/syscall.c')
-rw-r--r--src/userprog/syscall.c30
1 files changed, 22 insertions, 8 deletions
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;
}