From 8556c8e070c5a8476f1a5131538604e22580a9ef Mon Sep 17 00:00:00 2001 From: CCXXXI Date: Mon, 11 Jan 2021 00:10:50 +0800 Subject: [PATCH] syscall seek --- src/userprog/syscall.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/userprog/syscall.c b/src/userprog/syscall.c index f011830..fc8257c 100644 --- a/src/userprog/syscall.c +++ b/src/userprog/syscall.c @@ -457,7 +457,13 @@ static int read(int fd, void *buffer, unsigned size) system and do not require any special effort in system call implementation. */ static void seek(int fd, unsigned position) { - // todo + struct open_file *f = get_file_by_fd(fd); + + USER_ASSERT(f != NULL); + + lock_acquire(&file_lock); + file_seek(f->file, position); + lock_release(&file_lock); } /* Returns the position of the next byte to be read or written in open