diff options
| author | Richard Qin <richard.qin.x@gmail.com> | 2026-01-02 00:47:16 +0800 |
|---|---|---|
| committer | Richard Qin <richard.qin.x@gmail.com> | 2026-01-02 00:58:45 +0800 |
| commit | d8eaa13f2efc1eeca4e5f230d5a2d535aaf27338 (patch) | |
| tree | 6ca02e2a2d1b1121620431059e322724a3c94a33 /include/fs/file.h | |
| parent | 2dde56422dcfb94affee2baffc8d240ad16ad4b2 (diff) | |
| download | lume-d8eaa13f2efc1eeca4e5f230d5a2d535aaf27338.tar.gz lume-d8eaa13f2efc1eeca4e5f230d5a2d535aaf27338.tar.xz | |
dev(file-system): establish VFS and Read-only FAT32 File System
Diffstat (limited to 'include/fs/file.h')
| -rw-r--r-- | include/fs/file.h | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/include/fs/file.h b/include/fs/file.h new file mode 100644 index 0000000..fc0c5d9 --- /dev/null +++ b/include/fs/file.h @@ -0,0 +1,35 @@ +#pragma once +#include "common/types.h" +#include "fs/fs.h" + +enum FileType +{ + FD_NONE, + FD_INODE, + FD_DEVICE, + FD_PIPE +}; + +struct file +{ + enum FileType type; + int ref; + char readable; + char writable; + + struct pipe *pipe; // pipeline pointer + Inode *ip; // VFS Inode + uint32 off; // Current Offset +}; + +namespace FileTable +{ + void init(); + struct file *alloc(); // Allocate a free file handle + struct file *dup(struct file *f); // Duplicate handle (sys_dup) + void close(struct file *f); // Close handle + + int stat(struct file *f, uint64 addr); + int read(struct file *f, uint64 addr, int n); + int write(struct file *f, uint64 addr, int n); +} // namespace FileTable |
