Implement filesize and tell system calls, w/ E

This commit is contained in:
sBubshait
2024-11-08 16:14:41 +00:00
parent 3cfbe198e0
commit 2a1cc3c361

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
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