libc: Add lseek()

This commit is contained in:
apio 2022-10-12 15:37:29 +02:00
parent 928ade123c
commit 4a5db1dca7
4 changed files with 18 additions and 1 deletions

View File

@ -0,0 +1,8 @@
#ifndef _BITS_SEEK_H
#define _BITS_SEEK_H
#define SEEK_SET 0 // Seek from beginning of file.
#define SEEK_CUR 1 // Seek from current position.
#define SEEK_END 2 // Seek from end of file.
#endif

View File

@ -4,7 +4,7 @@
#include <stdarg.h>
#include <stddef.h>
#define SEEK_SET 0
#include <bits/seek.h>
typedef struct
{

View File

@ -1,6 +1,7 @@
#ifndef _UNISTD_H
#define _UNISTD_H
#include <bits/seek.h>
#include <sys/types.h>
#ifdef __cplusplus
@ -32,6 +33,9 @@ extern "C"
/* Closes the file descriptor fd. */
int close(int fd);
/* Moves the read/write file offset for fd to offset, depending on whence. */
off_t lseek(int fd, off_t offset, int whence);
#ifdef __cplusplus
}
#endif

View File

@ -89,4 +89,9 @@ extern "C"
{
return (int)syscall(SYS_close, fd);
}
off_t lseek(int fd, off_t offset, int whence)
{
return syscall(SYS_seek, fd, offset, whence);
}
}