From 2534c317f28f69ca448587ed7473d87bc51b64b8 Mon Sep 17 00:00:00 2001 From: Michael Shaw Date: Sat, 4 Jul 2026 22:20:38 +0200 Subject: [PATCH] vfs: inode: add inode modes and filetypes Signed-off-by: Michael Shaw --- include/fs/inode.h | 14 +++++++------- include/fs/vfs.h | 24 +++++++++++++++++++++++- 2 files changed, 30 insertions(+), 8 deletions(-) diff --git a/include/fs/inode.h b/include/fs/inode.h index 57d1814..c9efcb1 100644 --- a/include/fs/inode.h +++ b/include/fs/inode.h @@ -34,14 +34,14 @@ typedef struct _dirent dirent_t; typedef struct _fs fs_t; struct inode_ops { - /* for all files */ + /* FOR ALL FILES */ ssize_t (*read)(inode_t *inode, char *buf, size_t size, size_t offset); ssize_t (*write)(inode_t *inode, char *buf, size_t size, size_t offset); - /* for directory files */ - int (*creat)(inode_t *inode, const char *name, u64 mode, dirent_t **out); - int (*mkdir)(inode_t *inode, const char *name, dirent_t **out); - int (*link)(inode_t *inode, inode_t *link_inode, const char *name, dirent_t **out); - int (*unlink)(inode_t *inode, const char *name); + + /* FOR DIRECTORY FILES */ + + int (*link)(dirent_t *in, inode_t *to, const char *name, dirent_t **out); + int (*unlink)(dirent_t *dent); ssize_t (*get_dents)(inode_t *parent, dirent_t **dents); }; @@ -49,7 +49,7 @@ struct _inode { u64 mode; u64 ino_num; u64 file_size; - dirent_t *dentry; + dirent_t *dentry; u64 flags; diff --git a/include/fs/vfs.h b/include/fs/vfs.h index 7023b46..7e710f5 100644 --- a/include/fs/vfs.h +++ b/include/fs/vfs.h @@ -10,6 +10,27 @@ #include #include +#define S_IFMT 0xF000 +#define S_IFREG 0x8000 +#define S_IFDIR 0x4000 +#define S_IFLNK 0xA000 +#define S_IFCHR 0x2000 +#define S_IFBLK 0x6000 +#define S_IFIFO 0x1000 +#define S_IFSOCK 0xC000 + +#define FT_MASK 0x07 +#define FT_UNKNOWN 0x00 +#define FT_REG_FILE 0x01 +#define FT_DIR 0x02 +#define FT_CHRDEV 0x03 +#define FT_BLKDEV 0x04 +#define FT_FIFO 0x05 +#define FT_SOCK 0x06 +#define FT_SYMLINK 0x07 + +#define FS_RDONLY 0x00000001 + struct fs_type { char name[256]; dirent_t *(*fs_mount)(int flags, struct block_device *bdev); @@ -17,13 +38,14 @@ struct fs_type { }; struct fs_ops { - int (*alloc_inode)(fs_t *fs, dirent_t **out); + int (*alloc_inode)(fs_t *fs, u64 mode, inode_t **out); int (*free_inode)(fs_t *fs, inode_t *inode); int (*open_inode)(fs_t *fs, u64 id, dirent_t *dirent, inode_t **out); }; struct _fs { u64 type; + u64 flags; size_t block_size; size_t n_blocks;