kernel - whatever

This commit is contained in:
RaphProductions 2025-05-14 18:15:15 +02:00
parent 0772a48c29
commit 31e53e88b9
10 changed files with 112 additions and 32 deletions

19
kernel/src/fs/vfs.c Normal file
View file

@ -0,0 +1,19 @@
#include "fs/vfs.h"
#include "mm/liballoc/liballoc.h"
#include "mm/memop.h"
#include "lib/string.h"
vnode_t *vfs_create_node(char *name, vnode_type_t type) {
vnode_t *node = (vnode_t *)malloc(sizeof(vnode_t));
if (!node) {
return NULL;
}
memset(node, 0, sizeof(vnode_t));
strncpy(node->name, name, sizeof(node->name) - 1);
node->type = type;
node->ops = NULL;
//node->parent = NULL;
//node->child = NULL;
//node->next = NULL;
return node;
}

View file

@ -11,27 +11,36 @@ struct vnode;
typedef uint32_t vnode_type_t;
typedef struct vnode_ops {
int (*read)(struct vnode* vn, void* buf, size_t size);
int (*read)(struct vnode* vn, void* buf, size_t off, size_t size);
struct vnode* (*lookup)(struct vnode* vn, const char* name);
} vnode_ops_t;
typedef struct vnode {
char name[256];
vnode_type_t type;
struct vnode* parent;
struct vnode* child;
struct vnode* next;
uint32_t refcount;
//struct vnode* parent;
//struct vnode* child;
//struct vnode* next;
struct vnode_ops* ops;
void* internal;
} vnode_t;
typedef struct mountpoint {
char name[32];
struct fs* fs;
vnode_t* mountpoint;
} mountpoint_t;
typedef struct fs {
char name[32];
int (*mount)(struct vnode** root);
struct vnode* root;
int (*mount)(struct vnode* mountpoint);
} fs_t;
void vfs_init(void);
int vfs_mount(char *path, fs_t* fs);
int vfs_unmount(char *path);
int vfs_open(const char* path, vnode_t** result);
int vfs_read(vnode_t* vn, void* buf, size_t size);
int vfs_read(vnode_t* vn, void* buf, size_t off, size_t size);

2
kernel/src/fs/vnodes.md Normal file
View file

@ -0,0 +1,2 @@
# Soaplin vnodes
...