Luna/kernel/src/fs/VFS.h

58 lines
1.0 KiB
C
Raw Normal View History

#pragma once
#include <luna/SharedPtr.h>
namespace VFS
{
enum class InodeType
{
RegularFile,
Directory
};
class FileSystem;
class Inode
{
public:
virtual Result<Inode*> find(const char* name) const = 0;
virtual FileSystem& fs() const = 0;
virtual ~Inode() = default;
virtual InodeType type() const = 0;
virtual usize inode_number() const = 0;
};
class FileInode : Inode
{
public:
Result<Inode*> find(const char*) const override
{
return err(ENOTDIR);
}
InodeType type() const override
{
return InodeType::RegularFile;
}
virtual ~FileInode() = default;
};
class FileSystem
{
public:
virtual Inode& root() const = 0;
virtual Result<SharedPtr<Inode>> create_file_inode() = 0;
virtual ~FileSystem() = default;
};
extern SharedPtr<FileSystem> root_fs;
Result<Inode*> resolve_path(const char* path);
}