/* SPDX-License-Identifier: GPL-2.0-only */ #ifndef _VFS_H_ #define _VFS_H_ #include #include #include #include #include struct fs_type { char name[256]; dirent_t *(*fs_mount)(int flags, struct block_device *bdev); int (*fs_umount)(fs_t *fs); }; struct fs_ops { int (*alloc_inode)(fs_t *fs, inode_t **out); int (*free_inode)(fs_t *fs, inode_t *inode); int (*open_inode)(fs_t *fs, u64 id, inode_t **out); }; struct _fs { u64 type; size_t block_size; size_t n_blocks; dirent_t *root_dirent; bool mounted; dirent_t *mount_point; spinlock_t lock; struct fs_ops fs_ops; }; struct ram_file { u64 type; u64 extra; char *name; size_t name_len; 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, 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); #endif /* _VFS_H_ */