34#define VFS_ROOT_ENTRY_NAME "__root__"
39#define VFS_DEVICE_NAME_NONE "__no_device__"
44typedef struct filesystem
372#define BUFFER_READ(buffer, count, offset, src, size) \
374 uint64_t readCount = (*(offset) <= (size)) ? MIN((count), (size) - *(offset)) : 0; \
375 memcpy((buffer), (src) + *(offset), readCount); \
376 *(offset) += readCount; \
walk_flags_t
Flags for walking a path.
uint64_t vfs_ioctl(file_t *file, uint64_t request, void *argp, uint64_t size)
Perform an ioctl operation on a file.
uint64_t vfs_register_fs(filesystem_t *fs)
Registers a filesystem.
uint64_t vfs_unregister_fs(filesystem_t *fs)
Unregisters a filesystem.
uint64_t vfs_get_new_id(void)
Generates a new unique ID.
uint64_t vfs_seek(file_t *file, int64_t offset, seek_origin_t origin)
Seek in a file.
void * vfs_mmap(file_t *file, void *address, uint64_t length, pml_flags_t flags)
Memory map a file.
void vfs_remove_inode(inode_t *inode)
Remove an inode from the inode cache.
bool vfs_is_name_valid(const char *name)
Check if a name is valid.
uint64_t vfs_walk_parent_and_child(path_t *outParent, path_t *outChild, const pathname_t *pathname, walk_flags_t flags, process_t *process)
Walk a pathname to path and its parent path, starting from the current process's working directory.
filesystem_t * vfs_get_fs(const char *name)
Gets a filesystem by name.
uint64_t vfs_poll(poll_file_t *files, uint64_t amount, clock_t timeout)
Poll multiple files.
uint64_t vfs_getdents(file_t *file, dirent_t *buffer, uint64_t count)
Get directory entries from a directory file.
void vfs_remove_dentry(dentry_t *dentry)
Remove a dentry from the dentry cache.
uint64_t vfs_write(file_t *file, const void *buffer, uint64_t count)
Write to a file.
file_t * vfs_open(const pathname_t *pathname, process_t *process)
Open a file.
uint64_t vfs_add_dentry(dentry_t *dentry)
Add a dentry to the dentry cache.
dentry_t * vfs_get_or_lookup_dentry(const path_t *parent, const char *name)
Get or lookup a dentry for the given name. Will NOT traverse mountpoints.
uint64_t vfs_remove(const pathname_t *pathname, process_t *process)
Remove a file or directory.
dentry_t * vfs_get_dentry(const dentry_t *parent, const char *name)
Get a dentry for the given name. Will NOT traverse mountpoints.
uint64_t vfs_stat(const pathname_t *pathname, stat_t *buffer, process_t *process)
Get file information.
uint64_t vfs_walk_parent(path_t *outPath, const pathname_t *pathname, char *outLastName, walk_flags_t flags, process_t *process)
Walk a pathname to its parent path, starting from the current process's working directory.
void vfs_remove_superblock(superblock_t *superblock)
Remove a superblock from the superblock list.
uint64_t vfs_read(file_t *file, void *buffer, uint64_t count)
Read from a file.
uint64_t vfs_walk(path_t *outPath, const pathname_t *pathname, walk_flags_t flags, process_t *process)
Walk a pathname to a path, starting from the current process's working directory.
void vfs_init(void)
Initializes the VFS.
uint64_t vfs_link(const pathname_t *oldPathname, const pathname_t *newPathname, process_t *process)
Make the same file appear twice in the filesystem.
uint64_t vfs_open2(const pathname_t *pathname, file_t *files[2], process_t *process)
Open one file, returning two file handles.
inode_t * vfs_get_inode(superblock_t *superblock, inode_number_t number)
Get an inode for the given superblock and inode number.
uint64_t vfs_add_inode(inode_t *inode)
Add a inode to the inode cache.
uint64_t inode_number_t
Inode number enum.
uint8_t seek_origin_t
Type for the seek() origin argument.
__UINT64_TYPE__ clock_t
A nanosecond time.
EFI_PHYSICAL_ADDRESS buffer
Directory entry structure.
Filesystem structure, represents a filesystem type, e.g. fat32, ramfs, sysfs, etc.
A entry in a doubly linked list.
A entry in a page table without a specified address or callback ID.
Structure for polling multiple files.
Read-Write Ticket Lock structure.
Helper structure for lists with a lock.
Helper structure for maps with a lock.