diff --git a/libs/libc/include/bits/seek.h b/libs/libc/include/bits/seek.h new file mode 100644 index 00000000..ed0e59d3 --- /dev/null +++ b/libs/libc/include/bits/seek.h @@ -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 \ No newline at end of file diff --git a/libs/libc/include/stdio.h b/libs/libc/include/stdio.h index e906d9f9..37303dd3 100644 --- a/libs/libc/include/stdio.h +++ b/libs/libc/include/stdio.h @@ -4,7 +4,7 @@ #include #include -#define SEEK_SET 0 +#include typedef struct { diff --git a/libs/libc/include/unistd.h b/libs/libc/include/unistd.h index e763f171..5a029030 100644 --- a/libs/libc/include/unistd.h +++ b/libs/libc/include/unistd.h @@ -1,6 +1,7 @@ #ifndef _UNISTD_H #define _UNISTD_H +#include #include #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 diff --git a/libs/libc/src/unistd.cpp b/libs/libc/src/unistd.cpp index 7c1479d8..0cd572f6 100644 --- a/libs/libc/src/unistd.cpp +++ b/libs/libc/src/unistd.cpp @@ -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); + } } \ No newline at end of file