2020-01-06 20:25:06 +01:00
|
|
|
#include <kernel/fs/vfs.h>
|
|
|
|
#include <kernel/process.h>
|
|
|
|
|
|
|
|
off_t sys_lseek(int fd, off_t offset, int whence)
|
|
|
|
{
|
2020-01-12 15:58:35 +01:00
|
|
|
extern struct process *process_current;
|
2020-01-06 20:25:06 +01:00
|
|
|
|
|
|
|
// Check fd
|
2020-03-20 22:47:05 +01:00
|
|
|
if (fd < 0 || fd - 3 >= PROCESS_NB_OPEN_FILE)
|
2020-01-06 20:25:06 +01:00
|
|
|
return (-1);
|
|
|
|
|
2020-03-20 22:47:05 +01:00
|
|
|
// Check virtual file (TTY)
|
|
|
|
if (fd < 3)
|
|
|
|
return (0);
|
|
|
|
|
|
|
|
// Call VFS lseek primitive
|
|
|
|
return (vfs_lseek(&process_current->opfile[fd - 3].file, offset, whence));
|
2020-01-06 20:25:06 +01:00
|
|
|
}
|