Implement complete stack initialization, process_wait, and all system calls correctly except exec #34

Merged
td1223 merged 46 commits from userprog-merge into master 2024-11-11 22:56:29 +00:00
4 changed files with 146 additions and 23 deletions
Showing only changes of commit 2a1cc3c361 - Show all commits

View File

@@ -193,10 +193,17 @@ syscall_open (const char *file)
}
static int
syscall_filesize (int fd UNUSED)
syscall_filesize (int fd)
{
//TODO
return 0;
struct open_file *file_info = fd_get_file (fd);
if (file_info == NULL)
return -1;
lock_acquire (&filesys_lock);
int bytes = file_length (file_info->file);
lock_release (&filesys_lock);
return bytes;
}
static int
@@ -261,10 +268,17 @@ syscall_seek (int fd, unsigned position)
}
static unsigned
syscall_tell (int fd UNUSED)
syscall_tell (int fd)
{
//TODO
return 0;
struct open_file *file_info = fd_get_file (fd);
if (file_info == NULL)
return 0;
lock_acquire (&filesys_lock);
unsigned pos = file_tell (file_info->file);
lock_release (&filesys_lock);
return pos;
}
static void