49 lines
1,011 B
C
49 lines
1,011 B
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, dirent_t **out);
|
|
int (*free_inode)(fs_t *fs, inode_t *inode);
|
|
int (*open_inode)(fs_t *fs, u64 id, dirent_t *dirent, 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;
|
|
};
|
|
|
|
/* 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_ */
|