Redesign VFS around handles

This commit is contained in:
2026-02-22 13:57:41 +01:00
parent b571e2dbd3
commit 85872b856b
10 changed files with 210 additions and 196 deletions

View File

@@ -5,7 +5,9 @@
#include <device/device.h>
#include <libk/hash.h>
#include <libk/list.h>
#include <libk/rbtree.h>
#include <libk/std.h>
#include <path.h>
#include <proc/proc.h>
#include <proc/procgroup.h>
#include <proc/reschedule.h>
@@ -13,13 +15,22 @@
#define VFS_TARFS 0
struct vfs_mountpoint;
struct vfs_handle {
int id;
struct vfs_mountpoint* mountpoint;
char path[MAX_PATH];
struct procgroup* ownerpg;
struct rb_node_link handle_tree_link;
struct list_node_link handle_cleanup_link;
spin_lock_t lock;
};
struct vfs_mountpoint {
char key[0x100];
struct hash_node_link mount_table_link;
int fs_type;
spin_lock_t lock;
bool locked;
struct procgroup* ownerpg;
struct {
int (*mount) (struct vfs_mountpoint* mountpoint, struct proc* proc,
struct reschedule_ctx* rctx);
@@ -41,16 +52,19 @@ struct vfs_mount_table {
int vfs_create_mountpoint (const char* key, int fs_type, struct device* back_device,
struct proc* proc, struct reschedule_ctx* rctx);
int vfs_describe (struct procgroup* procgroup, const char* mountpoint, const char* path,
struct desc* desc);
int vfs_describe (struct procgroup* procgroup, int id, struct desc* desc);
int vfs_read (struct procgroup* procgroup, const char* mountpoint, const char* path,
uint8_t* buffer, size_t off, size_t size);
int vfs_read (struct procgroup* procgroup, int id, uint8_t* buffer, size_t off, size_t size);
int vfs_close (struct procgroup* procgroup, const char* mountpoint, const char* path);
int vfs_close (struct procgroup* procgroup, int id);
int vfs_open (struct procgroup* procgroup, const char* mountpoint, const char* path);
int vfs_kernel_read (const char* mountpoint, const char* path, uint8_t* buffer, size_t off,
size_t size);
int vfs_kernel_describe (const char* mountpoint, const char* path, struct desc* desc);
void vfs_procgroup_cleanup (struct procgroup* procgroup);
void vfs_init (void);