lib: c: io: implement lseek()
This commit is contained in:
22
lib/libc/io/unistd/lseek.c
Normal file
22
lib/libc/io/unistd/lseek.c
Normal file
@@ -0,0 +1,22 @@
|
||||
#include <errno.h>
|
||||
#include <mango/handle.h>
|
||||
#include <mango/msg.h>
|
||||
#include <rosetta/fs.h>
|
||||
#include <sys/remote.h>
|
||||
|
||||
off_t lseek(int fd, off_t offset, int whence)
|
||||
{
|
||||
int err;
|
||||
off_t new_offset;
|
||||
|
||||
kern_status_t status = fs_seek(fd, offset, whence, &err, &new_offset);
|
||||
if (status != KERN_OK) {
|
||||
return __set_errno(__errno_from_kern_status(status));
|
||||
}
|
||||
|
||||
if (err != SUCCESS) {
|
||||
return __set_errno(err);
|
||||
}
|
||||
|
||||
return new_offset;
|
||||
}
|
||||
Reference in New Issue
Block a user