VFS mountpoint backing device system
All checks were successful
Build documentation / build-and-deploy (push) Successful in 2m24s

This commit is contained in:
2026-02-16 23:48:45 +01:00
parent 7726fd2f00
commit 9aea870159
22 changed files with 528 additions and 241 deletions

View File

@@ -1,4 +1,5 @@
#include <fs/ramdiskfs.h>
#include <device/device.h>
#include <fs/tarfs.h>
#include <fs/vfs.h>
#include <libk/fieldsizeof.h>
#include <libk/hash.h>
@@ -30,38 +31,40 @@ static struct vfs_mountpoint* vfs_find_mountpoint (const char* mountpoint) {
return hash_entry (found_link, struct vfs_mountpoint, mount_table_link);
}
struct vfs_mountpoint* vfs_create_mountpoint (const char* key, int fs_type) {
int vfs_create_mountpoint (const char* key, int fs_type, struct device* back_device,
struct device_op_ctx* op_ctx) {
if (strlen_null (key) > fieldsizeof (struct vfs_mountpoint, key))
return NULL;
return -ST_OOB_ERROR;
struct vfs_mountpoint* mountpoint = malloc (sizeof (*mountpoint));
if (mountpoint == NULL)
return NULL;
return -ST_OOM_ERROR;
memset (mountpoint, 0, sizeof (*mountpoint));
memcpy (mountpoint->key, key, strlen_null (key));
mountpoint->fs_type = fs_type;
mountpoint->lock = SPIN_LOCK_INIT;
mountpoint->back_device = back_device;
switch (mountpoint->fs_type) {
case VFS_RAMDISKFS: {
mountpoint->driver_ops.mount = &ramdiskfs_mount;
mountpoint->driver_ops.describe = &ramdiskfs_describe;
mountpoint->driver_ops.read = &ramdiskfs_read;
case VFS_TARFS: {
mountpoint->driver_ops.mount = &tarfs_mount;
mountpoint->driver_ops.describe = &tarfs_describe;
mountpoint->driver_ops.read = &tarfs_read;
} break;
default: {
free (mountpoint);
return NULL;
return -ST_MOUNT_ERROR;
} break;
}
bool ok = mountpoint->driver_ops.mount (mountpoint);
int ret = mountpoint->driver_ops.mount (mountpoint, op_ctx);
if (!ok) {
if (ret < 0) {
free (mountpoint);
return NULL;
return ret;
}
uint32_t mp_hash = hash_fnv32 (mountpoint->key, strlen (mountpoint->key));
@@ -73,7 +76,7 @@ struct vfs_mountpoint* vfs_create_mountpoint (const char* key, int fs_type) {
spin_unlock (&mount_table.lock);
return mountpoint;
return ST_OK;
}
int vfs_open (struct procgroup* procgroup, const char* mountpoint, const char* path) {