9#include <abi-bits/stat.h>
24#define FILESYSTEM_DEFINE(var, fsname, mountfn, unmountfn) \
25 filesystem_t var = { \
28 .unmount = unmountfn, \
31#define FILESYSTEM_AUTOREGISTER(fs) \
32 static void __register_##fs() \
34 vfs_register_filesystem(&fs); \
36 MOS_INIT(VFS, __register_##fs)
132typedef struct _inode_cache_ops
148typedef struct _inode_cache
MOSAPI void(1, 2) fatal_abort(const char *fmt
list_node_t list_head
A linked list head.
basic_string_view< char > string_view
mos::basic_string< char, mos::default_allocator > string
superblock_t * superblock
bool(* open)(inode_t *inode, file_t *file, bool created)
called when a file is opened, or created
off_t(* seek)(file_t *file, off_t offset, io_seek_whence_t whence)
seek to a new position in the file
bool(* munmap)(file_t *file, vmap_t *vmap, bool *unmapped)
unmap the file from memory
void(* release)(file_t *file)
called when the last reference to the file is dropped
ssize_t(* read)(const file_t *file, void *buf, size_t size, off_t offset)
read from the file
ssize_t(* write)(const file_t *file, const void *buf, size_t size, off_t offset)
write to the file
bool(* mmap)(file_t *file, vmap_t *vmap, off_t offset)
map the file into memory
void(* unmount)(filesystem_t *fs, dentry_t *mountpoint)
PtrResult< dentry_t >(* mount)(filesystem_t *fs, const char *dev_name, const char *mount_options)
PtrResult< phyframe_t >(* fill_cache)(inode_cache_t *cache, uint64_t pgoff)
Read a page from the underlying storage, at file offset pgoff * MOS_PAGE_SIZE.
long(* flush_page)(inode_cache_t *cache, uint64_t pgoff, phyframe_t *page)
Flush a page to the underlying storage.
bool(* page_write_begin)(inode_cache_t *cache, off_t file_offset, size_t inpage_size, phyframe_t **page_out, void **data)
void(* page_write_end)(inode_cache_t *cache, off_t file_offset, size_t inpage_size, phyframe_t *page, void *data)
mos::HashMap< size_t, phyframe_t * > pages
const inode_cache_ops_t * ops
bool(* mkdir)(inode_t *dir, dentry_t *dentry, file_perm_t perm)
create a new directory
size_t(* readlink)(dentry_t *dentry, char *buffer, size_t buflen)
read the contents of a symbolic link
bool(* unlink)(inode_t *dir, dentry_t *dentry)
remove a file name, this is called after nlinks is decremented
bool(* hardlink)(dentry_t *old_dentry, inode_t *dir, dentry_t *new_dentry)
create a hard link
bool(* newfile)(inode_t *dir, dentry_t *dentry, file_type_t type, file_perm_t perm)
create a new file
bool(* rmdir)(inode_t *dir, dentry_t *dentry)
remove a directory
bool(* lookup)(inode_t *dir, dentry_t *dentry)
lookup a file in a directory, if it's unset for a directory, the VFS will use the default lookup
void(* iterate_dir)(dentry_t *dentry, vfs_listdir_state_t *iterator_state, dentry_iterator_op op)
iterate over the contents of a directory
bool(* symlink)(inode_t *dir, dentry_t *dentry, const char *symname)
create a symbolic link
bool(* rename)(inode_t *old_dir, dentry_t *old_dentry, inode_t *new_dir, dentry_t *new_dentry)
rename a file
bool(* mknode)(inode_t *dir, dentry_t *dentry, file_type_t type, file_perm_t perm, dev_t dev)
create a new device file
superblock_t * superblock
const file_ops_t * file_ops
atomic_t refcount
number of references to this inode
superblock_t * superblock
bool(* drop_inode)(inode_t *inode)
The inode has zero links and the last reference to the file has been dropped.
long(* sync_inode)(inode_t *inode)
flush the inode to disk
const superblock_ops_t * ops
size_t read_offset
user has read up to this offset, start from this offset when reading more entries
size_t n_count
number of entries in the list
std::atomic_size_t atomic_t
mos::string dentry_name(const dentry_t *dentry)
void dentry_iterator_op(vfs_listdir_state_t *state, u64 ino, mos::string_view name, file_type_t type)