vfs: switch to dirent tracking over inode tracking

Signed-off-by: Michael Shaw <m@michaelsshaw.com>
This commit is contained in:
Michael Shaw 2026-07-02 22:09:05 +02:00
commit f9d760993d
4 changed files with 77 additions and 62 deletions

View file

@ -78,6 +78,8 @@ struct _dirent {
u64 type;
spinlock_t lock;
u64 refcount;
char *name;
};
@ -91,5 +93,7 @@ inode_t *inode_create();
void inode_free(inode_t *inode);
void inode_inc_ref(inode_t *inode);
void inode_dec_ref(inode_t *inode);
void dirent_inc_ref(dirent_t *dent);
void dirent_dec_ref(dirent_t *dent);
#endif /* _INODE_H_ */

View file

@ -27,7 +27,7 @@ struct _fs {
size_t block_size;
size_t n_blocks;
inode_t *root_inode;
dirent_t *root_dirent;
bool mounted;
dirent_t *mount_point;
@ -37,22 +37,22 @@ struct _fs {
};
struct ram_file {
u64 type;
u64 extra;
char *name;
size_t name_len;
u64 type;
u64 extra;
char *name;
size_t name_len;
void *data;
size_t data_size;
size_t file_size;
void *data;
size_t data_size;
size_t file_size;
};
/* VFS ops */
void vfs_init();
void vfs_register(struct fs_type *fs);
int vfs_open(const char *abs_path, inode_t **out);
void vfs_close(inode_t *inode);
int vfs_open(const char *abs_path, dirent_t **out);
void vfs_close(dirent_t *dent);
ssize_t vfs_write(inode_t *ino, char *buf, size_t size, size_t offset);
ssize_t vfs_read(inode_t *ino, char *buf, size_t size, size_t offset);