Files
banan-os/kernel/include/kernel/FS/VirtualFileSystem.h
Bananymous b048630e5b Kernel: Improve locking in Process, VFS and ATAController
We used to block on all process access. This meant that shell
reading the keyboard input would block all VFS access making disk
accesses practically impossible. We now block only when it is
necessary :)
2023-03-30 22:02:16 +03:00

46 lines
979 B
C++

#pragma once
#include <BAN/String.h>
#include <BAN/Vector.h>
#include <kernel/FS/FileSystem.h>
#include <kernel/SpinLock.h>
namespace Kernel
{
class VirtualFileSystem : public FileSystem
{
public:
static BAN::ErrorOr<void> initialize(BAN::StringView);
static VirtualFileSystem& get();
virtual ~VirtualFileSystem() {};
virtual BAN::RefPtr<Inode> root_inode() override { return m_root_fs->root_inode(); }
BAN::ErrorOr<void> mount(BAN::StringView, BAN::StringView);
BAN::ErrorOr<void> mount(FileSystem*, BAN::StringView);
struct File
{
BAN::RefPtr<Inode> inode;
BAN::String canonical_path;
};
BAN::ErrorOr<File> file_from_absolute_path(BAN::StringView);
private:
VirtualFileSystem() = default;
struct MountPoint
{
File host;
FileSystem* target;
};
MountPoint* mount_point_for_inode(BAN::RefPtr<Inode>);
private:
SpinLock m_lock;
FileSystem* m_root_fs = nullptr;
BAN::Vector<MountPoint> m_mount_points;
};
}