summaryrefslogtreecommitdiffstats
path: root/src/userprog/syscall.c
diff options
context:
space:
mode:
authorGustav Sörnäs <gustav@sornas.net>2021-03-14 14:48:08 +0100
committerGustav Sörnäs <gustav@sornas.net>2021-03-14 14:48:08 +0100
commit548f7b19415640ad44502ef9ccb42c98bd92b6d1 (patch)
treefbe7b4d3f0d86aa217735d8aa77341a0873fc2cb /src/userprog/syscall.c
parent7f8b2231df2666213050096448442f887cd57d00 (diff)
downloadpintos-548f7b19415640ad44502ef9ccb42c98bd92b6d1.tar.gz
create empty lab 6 syscalls
Diffstat (limited to 'src/userprog/syscall.c')
-rw-r--r--src/userprog/syscall.c54
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);