Implement filesize and tell system calls, w/ E
This commit is contained in:
@@ -193,10 +193,17 @@ syscall_open (const char *file)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
syscall_filesize (int fd UNUSED)
|
syscall_filesize (int fd)
|
||||||
{
|
{
|
||||||
//TODO
|
struct open_file *file_info = fd_get_file (fd);
|
||||||
return 0;
|
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
|
static int
|
||||||
@@ -261,10 +268,17 @@ syscall_seek (int fd, unsigned position)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static unsigned
|
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;
|
return 0;
|
||||||
|
|
||||||
|
lock_acquire (&filesys_lock);
|
||||||
|
unsigned pos = file_tell (file_info->file);
|
||||||
|
lock_release (&filesys_lock);
|
||||||
|
|
||||||
|
return pos;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|||||||
Reference in New Issue
Block a user