51 lines
1,000 B
C
51 lines
1,000 B
C
/* SPDX-License-Identifier: GPL-2.0-only */
|
|
#include <kernel/common.h>
|
|
#include <kernel/slab.h>
|
|
|
|
#include <lib/list.h>
|
|
#include <lib/string.h>
|
|
#include <fs/vfs.h>
|
|
|
|
#include <lib/errno.h>
|
|
|
|
static fs_t *root_fs = NULL;
|
|
|
|
static list_t fs_type_list = {0};
|
|
|
|
ssize_t vfs_write(inode_t *ino, char *buf, size_t size, size_t offset)
|
|
{
|
|
return ino->i_ops.write(ino, buf, size, offset);
|
|
}
|
|
|
|
ssize_t vfs_read(inode_t *ino, char *buf, size_t size, size_t offset)
|
|
{
|
|
return ino->i_ops.read(ino, buf, size, offset);
|
|
}
|
|
|
|
int vfs_mount(const char *mount_point, fs_t *fs_to_mount)
|
|
{
|
|
if (!mount_point || !strcmp(mount_point, "/")) {
|
|
root_fs = fs_to_mount;
|
|
} else {
|
|
}
|
|
|
|
return 0;
|
|
}
|
|
|
|
void vfs_register(struct fs_type *fs)
|
|
{
|
|
struct fs_type *ins = kalloc(sizeof(*fs), ALLOC_KERN);
|
|
|
|
memcpy(ins, fs, sizeof(*fs));
|
|
list_insert(&fs_type_list, ins);
|
|
}
|
|
|
|
void vfs_init()
|
|
{
|
|
void inode_init();
|
|
inode_init();
|
|
root_fs = kalloc(sizeof(fs_t), ALLOC_KERN);
|
|
memset(root_fs, 0, sizeof(*root_fs));
|
|
|
|
list_create(&fs_type_list);
|
|
}
|