mp: separate VFS read and write functions into internal implementations with locking

In preparation for the inevitable switch to a MP supported setup, I have added spinlocks to the VFS_Read and VFS_Write implementations

If I had forgotten to do this, everything would've blown up, the world would have ended, and Israel would no longer exist.

Signed-off-by: kaguya <vpshinomiya@protonmail.com>
This commit is contained in:
kaguya
2026-04-26 02:10:46 -04:00
parent e6e8b1209b
commit d22d5ab2e4
+20 -2
View File
@@ -106,7 +106,7 @@ int VFS_Close(fd_t fd) {
return resp; return resp;
} }
int VFS_Read(fd_t fd, uint8_t* buf, size_t size) int VFS_Read_internal(fd_t fd, uint8_t* buf, size_t size)
{ {
if (fd < 0 || fd >= VFS_MAX_FDS) if (fd < 0 || fd >= VFS_MAX_FDS)
return -1; return -1;
@@ -154,7 +154,16 @@ int VFS_Read(fd_t fd, uint8_t* buf, size_t size)
} }
} }
int VFS_Write(fd_t file, uint8_t* data, size_t size) int VFS_Read(fd_t fd, uint8_t* buf, size_t size)
{
uint64_t flags;
spinlock_acquire_irqsave(&s_vfs_lock, &flags);
int resp = VFS_Read_internal(fd, buf, size);
spinlock_release_irqrestore(&s_vfs_lock, flags);
return resp;
}
int VFS_Write_internal(fd_t file, uint8_t* data, size_t size)
{ {
switch (file) switch (file)
{ {
@@ -210,3 +219,12 @@ int VFS_Write(fd_t file, uint8_t* data, size_t size)
return -1; return -1;
} }
int VFS_Write(fd_t file, uint8_t* data, size_t size)
{
uint64_t flags;
spinlock_acquire_irqsave(&s_vfs_lock, &flags);
int resp = VFS_Write_internal(file, data, size);
spinlock_release_irqrestore(&s_vfs_lock, flags);
return resp;
}