feat(fs): add VFS, initrd, and filesystem interface headers
This commit is contained in:
1 parent
455e81de5e
commit
94747d8c53
3 files changed
+98
No files matched your search
@@ -0,0 +1,32 @@
|
|||||||
|
#ifndef FROSTBYTE_FS_H
|
||||||
|
#define FROSTBYTE_FS_H
|
||||||
|
|
||||||
|
#define oReadOnly 0x0
|
||||||
|
#define oWriteOnly 0x1
|
||||||
|
#define oReadWrite 0x2
|
||||||
|
#define oCreate 0x40
|
||||||
|
#define oTrunc 0x200
|
||||||
|
#define oAppend 0x400
|
||||||
|
|
||||||
|
#define seekSet 0
|
||||||
|
#define seekCur 1
|
||||||
|
#define seekEnd 2
|
||||||
|
|
||||||
|
#define fsTypeFile 1
|
||||||
|
#define fsTypeDir 2
|
||||||
|
|
||||||
|
#define fsNameMax 64
|
||||||
|
|
||||||
|
typedef struct FbStat {
|
||||||
|
unsigned long size;
|
||||||
|
unsigned int type;
|
||||||
|
unsigned int mode;
|
||||||
|
} FbStat;
|
||||||
|
|
||||||
|
typedef struct FbDirent {
|
||||||
|
unsigned int type;
|
||||||
|
unsigned int nameLength;
|
||||||
|
char name[fsNameMax];
|
||||||
|
} FbDirent;
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
#ifndef FROSTBYTE_INITRD_H
|
||||||
|
#define FROSTBYTE_INITRD_H
|
||||||
|
|
||||||
|
#include "types.h"
|
||||||
|
|
||||||
|
typedef struct UstarEntry {
|
||||||
|
const char* name;
|
||||||
|
const uint8* data;
|
||||||
|
uint64 size;
|
||||||
|
bool isDir;
|
||||||
|
} UstarEntry;
|
||||||
|
|
||||||
|
void initrdInit(uint64 start, uint64 end);
|
||||||
|
uint32 initrdCount(void);
|
||||||
|
bool initrdAt(uint32 index, UstarEntry* out);
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -0,0 +1,49 @@
|
|||||||
|
#ifndef FROSTBYTE_VFS_H
|
||||||
|
#define FROSTBYTE_VFS_H
|
||||||
|
|
||||||
|
#include "types.h"
|
||||||
|
#include "fs.h"
|
||||||
|
|
||||||
|
struct VfsNode;
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
fdFree = 0,
|
||||||
|
fdConsole = 1,
|
||||||
|
fdFile = 2
|
||||||
|
} FdKind;
|
||||||
|
|
||||||
|
typedef struct FileDescriptor {
|
||||||
|
struct VfsNode* node;
|
||||||
|
uint64 offset;
|
||||||
|
uint32 kind;
|
||||||
|
uint32 flags;
|
||||||
|
} FileDescriptor;
|
||||||
|
|
||||||
|
#define maxOpenFiles 16
|
||||||
|
|
||||||
|
void vfsInit(void);
|
||||||
|
void vfsMountUstar(uint64 start, uint64 end);
|
||||||
|
void vfsMountTmpfs(const char* path);
|
||||||
|
void vfsFdInit(FileDescriptor* fds);
|
||||||
|
|
||||||
|
int vfsOpen(const char* path, uint32 flags);
|
||||||
|
int vfsClose(int fd);
|
||||||
|
int64 vfsRead(int fd, void* buffer, uint64 length);
|
||||||
|
int64 vfsWrite(int fd, const void* buffer, uint64 length);
|
||||||
|
int64 vfsLseek(int fd, int64 offset, int whence);
|
||||||
|
int vfsStat(const char* path, FbStat* out);
|
||||||
|
int64 vfsGetdents(int fd, void* buffer, uint64 length);
|
||||||
|
int vfsMkdir(const char* path);
|
||||||
|
int vfsUnlink(const char* path);
|
||||||
|
|
||||||
|
typedef struct VfsNode VfsNode;
|
||||||
|
VfsNode* vfsLookup(const char* path);
|
||||||
|
VfsNode* vfsChild(VfsNode* dir);
|
||||||
|
VfsNode* vfsNext(VfsNode* node);
|
||||||
|
const char* vfsName(VfsNode* node);
|
||||||
|
bool vfsIsDir(VfsNode* node);
|
||||||
|
uint64 vfsSize(VfsNode* node);
|
||||||
|
const void* vfsFileData(VfsNode* node);
|
||||||
|
void vfsPath(VfsNode* node, char* out, uint64 cap);
|
||||||
|
|
||||||
|
#endif
|
||||||
Reference in new issue
Block a user