Implement filesize and tell system calls, w/ E
This commit is contained in:
@@ -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
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user