Kernel/LibC: move file offset back to kernel

This makes keeping track of offsets easier and more proper
This commit is contained in:
Bananymous
2023-05-16 14:14:47 +03:00
parent e0a72defa2
commit 80d9f6131b
10 changed files with 142 additions and 58 deletions

View File

@@ -42,10 +42,13 @@ namespace Kernel
BAN::ErrorOr<int> open(BAN::StringView, int);
BAN::ErrorOr<void> close(int fd);
BAN::ErrorOr<size_t> read(int fd, void* buffer, size_t offset, size_t count);
BAN::ErrorOr<size_t> write(int fd, const void* buffer, size_t offset, size_t count);
BAN::ErrorOr<size_t> read(int fd, void* buffer, size_t count);
BAN::ErrorOr<size_t> write(int fd, const void* buffer, size_t count);
BAN::ErrorOr<void> creat(BAN::StringView name, mode_t);
BAN::ErrorOr<void> seek(int fd, off_t offset, int whence);
BAN::ErrorOr<off_t> tell(int fd);
BAN::ErrorOr<void> fstat(int fd, struct stat*);
BAN::ErrorOr<void> stat(BAN::StringView path, struct stat*);
@@ -77,7 +80,8 @@ namespace Kernel
{
BAN::RefPtr<Inode> inode;
BAN::String path;
uint8_t flags = 0;
off_t offset { 0 };
uint8_t flags { 0 };
};
BAN::ErrorOr<void> validate_fd(int);

View File

@@ -8,6 +8,8 @@
#define SYS_OPEN 6
#define SYS_ALLOC 7
#define SYS_FREE 8
#define SYS_SEEK 9
#define SYS_TELL 10
#include <kernel/Attributes.h>
#include <stdint.h>