gitignore: add .cpio

Signed-off-by: Michael Shaw <m@michaelsshaw.com>
This commit is contained in:
Michael Shaw 2026-05-13 04:47:59 -04:00
commit f0a9ff299b
27 changed files with 253 additions and 245 deletions

View file

@ -1,5 +1,4 @@
/* SPDX-License-Identifier: GPL-2.0-only */
#include "lib/rbtree.h"
#include <kernel/common.h>
#include <kernel/slab.h>
@ -13,65 +12,30 @@ static fs_t *root_fs = NULL;
static list_t fs_type_list = {0};
int vfs_mount(inode_t *mount_point, fs_t *fs_to_mount)
ssize_t vfs_write(inode_t *ino, char *buf, size_t size, size_t offset)
{
if (!mount_point) {
if (root_fs) {
return -EBUSY;
} else {
root_fs = fs_to_mount;
}
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;
}
static int iter_inode_dirent(inode_t *ino, const char *name, inode_t **out)
{
fs_t *fs = ino->fs;
dirent_t *d = inode_find_dirent(ino, name);
if (d) {
if (d->inode)
*out = d->inode;
else
return fs->fs_ops.open_inode(fs, d->ino_num, out);
}
return 0;
}
int vfs_get_inode(const char *path, inode_t *ret)
{
inode_t *ino = root_fs->root_inode;
char name[512] = {0};
char c;
int i = 0;
while (i < 256 && ino) {
c = *path++;
if (c == '/' || c == '\0') {
name[i] = 0;
i = 0;
int res = iter_inode_dirent(ino, name, &ino);
if (res)
return res;
if (c == '\0')
break;
} else {
name[i] = c;
i++;
}
}
return -ENOENT;
}
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);
}