vbos/include/fs/vfs.h
Michael Shaw a8540494a9 vfs: add vfs_open
vfs_open parses a path and returns the correct inode. The out inode is a
double pointer argument passed to vfs_open, and the return value is an
error code, or 0

Signed-off-by: Michael Shaw <m@michaelsshaw.com>
2026-07-01 23:06:39 +02:00

60 lines
1.1 KiB
C

/* SPDX-License-Identifier: GPL-2.0-only */
#ifndef _VFS_H_
#define _VFS_H_
#include <kernel/spinlock.h>
#include <fs/inode.h>
#include <drivers/block.h>
#include <lib/rwlock.h>
#include <lib/list.h>
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;
inode_t *root_inode;
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, inode_t **out);
void vfs_close(inode_t *inode);
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_ */