lib: c: io: implement lseek()

This commit is contained in:
2026-03-21 10:44:58 +00:00
parent 8c09909d07
commit 3bf995cdf6
2 changed files with 25 additions and 0 deletions

View File

@@ -2,6 +2,7 @@
#define UNISTD_H_
#include <stddef.h>
#include <sys/types.h>
extern int open(const char *path, int flags);
extern int close(int fd);
@@ -9,4 +10,6 @@ extern int close(int fd);
extern int read(int fd, void *buf, size_t count);
extern int write(int fd, const void *buf, size_t count);
extern off_t lseek(int fd, off_t offset, int whence);
#endif

View 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;
}