Luna/kernel/src/fs/tmpfs/FileSystem.h
apio 34e1ef36b1
kernel: Make pivot_root() reset the parent entry of the new root directory
Otherwise it would just be pointing to the old parent fs, and we don't want that.
2023-06-25 20:35:38 +02:00

46 lines
1.2 KiB
C++

#pragma once
#include "fs/VFS.h"
#include "fs/devices/DeviceRegistry.h"
#include <luna/Atomic.h>
namespace TmpFS
{
class FileSystem : public VFS::FileSystem
{
public:
SharedPtr<VFS::Inode> root_inode() const override
{
return m_root_inode;
}
Result<SharedPtr<VFS::Inode>> create_file_inode() override;
Result<SharedPtr<VFS::Inode>> create_dir_inode(SharedPtr<VFS::Inode> parent) override;
Result<SharedPtr<VFS::Inode>> create_device_inode(u32 major, u32 minor) override;
Result<SharedPtr<VFS::Inode>> create_symlink_inode(StringView link) override;
Result<void> set_mount_dir(SharedPtr<VFS::Inode> parent) override;
Result<void> reset_mount_dir() override;
static Result<SharedPtr<VFS::FileSystem>> create();
dev_t host_device_id() const override
{
return m_host_device_id;
}
virtual ~FileSystem() = default;
private:
FileSystem();
void set_root(SharedPtr<VFS::Inode> root);
SharedPtr<VFS::Inode> m_root_inode;
Atomic<usize> m_next_inode_number { 2 };
dev_t m_host_device_id;
};
}