From fb54483e42df053bcb5c967af1c90b28f157e40c Mon Sep 17 00:00:00 2001 From: kamkow1 Date: Thu, 12 Feb 2026 15:51:59 +0100 Subject: [PATCH] Lock VFS mountpoint access for ops --- kernel/fs/vfs.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/kernel/fs/vfs.c b/kernel/fs/vfs.c index 09b52f2..fdd5552 100644 --- a/kernel/fs/vfs.c +++ b/kernel/fs/vfs.c @@ -80,7 +80,13 @@ int vfs_describe (const char* mountpoint, const char* path, struct fs_desc_buffe if (vmp == NULL) return -VFS_NOT_FOUND; - return vmp->driver_ops.describe (vmp, path, desc); + spin_lock (&vmp->lock); + + int ret = vmp->driver_ops.describe (vmp, path, desc); + + spin_unlock (&vmp->lock); + + return ret; } int vfs_read (const char* mountpoint, const char* path, uint8_t* buffer, size_t off, size_t size) { @@ -89,7 +95,13 @@ int vfs_read (const char* mountpoint, const char* path, uint8_t* buffer, size_t if (vmp == NULL) return -VFS_NOT_FOUND; - return vmp->driver_ops.read (vmp, path, buffer, off, size); + spin_lock (&vmp->lock); + + int ret = vmp->driver_ops.read (vmp, path, buffer, off, size); + + spin_unlock (&vmp->lock); + + return ret; } void vfs_init (void) {