diff options
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 |
