1// SPDX-License-Identifier: GPL-3.0-or-later
2
3#pragma once
4
5#include "mos/filesystem/vfs_types.h"
6
7void inode_init(inode_t *inode, superblock_t *sb, u64 ino, file_type_t type);
8inode_t *inode_create(superblock_t *sb, u64 ino, file_type_t type);
9
10/**
11 * @brief Create a new dentry with the given name and parent
12 *
13 * @param sb The superblock of the dentry
14 * @param parent The parent dentry
15 * @param name The name of the dentry
16 *
17 * @return The new dentry, or NULL if the dentry could not be created
18 * @note The returned dentry will have its reference count of 0.
19 */
20dentry_t *dentry_get_from_parent(superblock_t *sb, dentry_t *parent, const char *name);
21
22ssize_t vfs_generic_read(const file_t *file, void *buf, size_t size, off_t offset);
23ssize_t vfs_generic_write(const file_t *file, const void *buf, size_t size, off_t offset);
24ssize_t vfs_generic_lseek(const file_t *file, off_t offset, int whence);
25int vfs_generic_close(const file_t *file);
26
27// ! simple page cache functions
28phyframe_t *simple_fill_cache(inode_cache_t *cache, off_t pgoff);
29bool simple_page_write_begin(inode_cache_t *icache, off_t offset, size_t size, phyframe_t **page, void **private);
30void simple_page_write_end(inode_cache_t *icache, off_t offset, size_t size, phyframe_t *page, void *private);
31long simple_flush_page_discard_data(inode_cache_t *icache, off_t pgoff, phyframe_t *page);
32
33// ! simple in-memory directory iterator
34void vfs_generic_iterate_dir(const dentry_t *dir, vfs_listdir_state_t *state, dentry_iterator_op op);
35