Kernel: Make DevFS use the new and better TmpFS instead of RamFS
This commit is contained in:
parent
464737fbe9
commit
b87351f6d5
|
@ -1,11 +1,11 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <kernel/FS/RamFS/Inode.h>
|
#include <kernel/FS/TmpFS/Inode.h>
|
||||||
|
|
||||||
namespace Kernel
|
namespace Kernel
|
||||||
{
|
{
|
||||||
|
|
||||||
class Device : public RamInode
|
class Device : public TmpInode
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
virtual ~Device() = default;
|
virtual ~Device() = default;
|
||||||
|
|
|
@ -1,13 +1,13 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <kernel/Device/Device.h>
|
#include <kernel/Device/Device.h>
|
||||||
#include <kernel/FS/RamFS/FileSystem.h>
|
#include <kernel/FS/TmpFS/FileSystem.h>
|
||||||
#include <kernel/Semaphore.h>
|
#include <kernel/Semaphore.h>
|
||||||
|
|
||||||
namespace Kernel
|
namespace Kernel
|
||||||
{
|
{
|
||||||
|
|
||||||
class DevFileSystem final : public RamFileSystem
|
class DevFileSystem final : public TmpFileSystem
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static void initialize();
|
static void initialize();
|
||||||
|
@ -16,7 +16,7 @@ namespace Kernel
|
||||||
void initialize_device_updater();
|
void initialize_device_updater();
|
||||||
|
|
||||||
void add_device(BAN::RefPtr<Device>);
|
void add_device(BAN::RefPtr<Device>);
|
||||||
void add_inode(BAN::StringView path, BAN::RefPtr<RamInode>);
|
void add_inode(BAN::StringView path, BAN::RefPtr<TmpInode>);
|
||||||
void for_each_device(const BAN::Function<BAN::Iteration(Device*)>& callback);
|
void for_each_device(const BAN::Function<BAN::Iteration(Device*)>& callback);
|
||||||
|
|
||||||
dev_t get_next_dev() const;
|
dev_t get_next_dev() const;
|
||||||
|
@ -25,8 +25,8 @@ namespace Kernel
|
||||||
void initiate_sync(bool should_block);
|
void initiate_sync(bool should_block);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
DevFileSystem(size_t size)
|
DevFileSystem()
|
||||||
: RamFileSystem(size)
|
: TmpFileSystem(-1)
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
|
@ -35,8 +35,8 @@ namespace Kernel
|
||||||
virtual timespec ctime() const override final { return m_inode_info.ctime; }
|
virtual timespec ctime() const override final { return m_inode_info.ctime; }
|
||||||
virtual blksize_t blksize() const override final { return PAGE_SIZE; }
|
virtual blksize_t blksize() const override final { return PAGE_SIZE; }
|
||||||
virtual blkcnt_t blocks() const override final { return m_inode_info.blocks; }
|
virtual blkcnt_t blocks() const override final { return m_inode_info.blocks; }
|
||||||
virtual dev_t dev() const override final { return 0; } // TODO
|
virtual dev_t dev() const override { return 0; } // TODO
|
||||||
virtual dev_t rdev() const override final { return 0; } // TODO
|
virtual dev_t rdev() const override { return 0; } // TODO
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static BAN::ErrorOr<BAN::RefPtr<TmpInode>> create_from_existing(TmpFileSystem&, ino_t, const TmpInodeInfo&);
|
static BAN::ErrorOr<BAN::RefPtr<TmpInode>> create_from_existing(TmpFileSystem&, ino_t, const TmpInodeInfo&);
|
||||||
|
|
|
@ -51,9 +51,6 @@ namespace Kernel
|
||||||
public:
|
public:
|
||||||
virtual bool is_partition() const override { return true; }
|
virtual bool is_partition() const override { return true; }
|
||||||
|
|
||||||
virtual Mode mode() const override { return { Mode::IFBLK | Mode::IRUSR | Mode::IRGRP }; }
|
|
||||||
virtual uid_t uid() const override { return 0; }
|
|
||||||
virtual gid_t gid() const override { return 0; }
|
|
||||||
virtual dev_t rdev() const override { return m_rdev; }
|
virtual dev_t rdev() const override { return m_rdev; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
|
@ -5,7 +5,12 @@ namespace Kernel
|
||||||
{
|
{
|
||||||
|
|
||||||
Device::Device(mode_t mode, uid_t uid, gid_t gid)
|
Device::Device(mode_t mode, uid_t uid, gid_t gid)
|
||||||
: RamInode(DevFileSystem::get(), FullInodeInfo(DevFileSystem::get(), mode, uid, gid))
|
// FIXME: what the fuck is this
|
||||||
|
: TmpInode(
|
||||||
|
DevFileSystem::get(),
|
||||||
|
MUST(DevFileSystem::get().allocate_inode(create_inode_info(mode, uid, gid))),
|
||||||
|
create_inode_info(mode, uid, gid)
|
||||||
|
)
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
}
|
}
|
|
@ -2,7 +2,7 @@
|
||||||
#include <kernel/Device/NullDevice.h>
|
#include <kernel/Device/NullDevice.h>
|
||||||
#include <kernel/Device/ZeroDevice.h>
|
#include <kernel/Device/ZeroDevice.h>
|
||||||
#include <kernel/FS/DevFS/FileSystem.h>
|
#include <kernel/FS/DevFS/FileSystem.h>
|
||||||
#include <kernel/FS/RamFS/Inode.h>
|
#include <kernel/FS/TmpFS/Inode.h>
|
||||||
#include <kernel/LockGuard.h>
|
#include <kernel/LockGuard.h>
|
||||||
#include <kernel/Process.h>
|
#include <kernel/Process.h>
|
||||||
#include <kernel/Storage/StorageDevice.h>
|
#include <kernel/Storage/StorageDevice.h>
|
||||||
|
@ -16,12 +16,10 @@ namespace Kernel
|
||||||
void DevFileSystem::initialize()
|
void DevFileSystem::initialize()
|
||||||
{
|
{
|
||||||
ASSERT(s_instance == nullptr);
|
ASSERT(s_instance == nullptr);
|
||||||
s_instance = new DevFileSystem(1024 * 1024);
|
s_instance = new DevFileSystem();
|
||||||
ASSERT(s_instance);
|
ASSERT(s_instance);
|
||||||
|
|
||||||
auto root_inode = MUST(RamDirectoryInode::create(*s_instance, 0, 0755, 0, 0));
|
MUST(s_instance->TmpFileSystem::initialize(0755, 0, 0));
|
||||||
MUST(s_instance->set_root_inode(root_inode));
|
|
||||||
|
|
||||||
s_instance->add_device(MUST(NullDevice::create(0666, 0, 0)));
|
s_instance->add_device(MUST(NullDevice::create(0666, 0, 0)));
|
||||||
s_instance->add_device(MUST(ZeroDevice::create(0666, 0, 0)));
|
s_instance->add_device(MUST(ZeroDevice::create(0666, 0, 0)));
|
||||||
}
|
}
|
||||||
|
@ -41,10 +39,10 @@ namespace Kernel
|
||||||
{
|
{
|
||||||
s_instance->m_device_lock.lock();
|
s_instance->m_device_lock.lock();
|
||||||
s_instance->for_each_inode(
|
s_instance->for_each_inode(
|
||||||
[](BAN::RefPtr<RamInode> inode)
|
[](BAN::RefPtr<TmpInode> inode)
|
||||||
{
|
{
|
||||||
if (inode->is_device())
|
if (inode->is_device())
|
||||||
((Device*)inode.ptr())->update();
|
reinterpret_cast<Device*>(inode.ptr())->update();
|
||||||
return BAN::Iteration::Continue;
|
return BAN::Iteration::Continue;
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
@ -74,11 +72,11 @@ namespace Kernel
|
||||||
}
|
}
|
||||||
|
|
||||||
s_instance->for_each_inode(
|
s_instance->for_each_inode(
|
||||||
[](BAN::RefPtr<RamInode> inode)
|
[](BAN::RefPtr<TmpInode> inode)
|
||||||
{
|
{
|
||||||
if (inode->is_device())
|
if (inode->is_device())
|
||||||
if (((Device*)inode.ptr())->is_storage_device())
|
if (((Device*)inode.ptr())->is_storage_device())
|
||||||
if (auto ret = ((StorageDevice*)inode.ptr())->sync_disk_cache(); ret.is_error())
|
if (auto ret = reinterpret_cast<StorageDevice*>(inode.ptr())->sync_disk_cache(); ret.is_error())
|
||||||
dwarnln("disk sync: {}", ret.error());
|
dwarnln("disk sync: {}", ret.error());
|
||||||
return BAN::Iteration::Continue;
|
return BAN::Iteration::Continue;
|
||||||
}
|
}
|
||||||
|
@ -120,24 +118,24 @@ namespace Kernel
|
||||||
void DevFileSystem::add_device(BAN::RefPtr<Device> device)
|
void DevFileSystem::add_device(BAN::RefPtr<Device> device)
|
||||||
{
|
{
|
||||||
ASSERT(!device->name().contains('/'));
|
ASSERT(!device->name().contains('/'));
|
||||||
MUST(reinterpret_cast<RamDirectoryInode*>(root_inode().ptr())->add_inode(device->name(), device));
|
MUST(reinterpret_cast<TmpDirectoryInode*>(root_inode().ptr())->link_inode(*device, device->name()));
|
||||||
}
|
}
|
||||||
|
|
||||||
void DevFileSystem::add_inode(BAN::StringView path, BAN::RefPtr<RamInode> inode)
|
void DevFileSystem::add_inode(BAN::StringView path, BAN::RefPtr<TmpInode> inode)
|
||||||
{
|
{
|
||||||
ASSERT(!path.contains('/'));
|
ASSERT(!path.contains('/'));
|
||||||
MUST(reinterpret_cast<RamDirectoryInode*>(root_inode().ptr())->add_inode(path, inode));
|
MUST(reinterpret_cast<TmpDirectoryInode*>(root_inode().ptr())->link_inode(*inode, path));
|
||||||
}
|
}
|
||||||
|
|
||||||
void DevFileSystem::for_each_device(const BAN::Function<BAN::Iteration(Device*)>& callback)
|
void DevFileSystem::for_each_device(const BAN::Function<BAN::Iteration(Device*)>& callback)
|
||||||
{
|
{
|
||||||
LockGuard _(m_device_lock);
|
LockGuard _(m_device_lock);
|
||||||
for_each_inode(
|
for_each_inode(
|
||||||
[&](BAN::RefPtr<Kernel::RamInode> inode)
|
[&](BAN::RefPtr<Kernel::TmpInode> inode)
|
||||||
{
|
{
|
||||||
if (!inode->is_device())
|
if (!inode->is_device())
|
||||||
return BAN::Iteration::Continue;
|
return BAN::Iteration::Continue;
|
||||||
return callback((Device*)inode.ptr());
|
return callback(reinterpret_cast<Device*>(inode.ptr()));
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,7 +33,7 @@ namespace Kernel
|
||||||
if (inode_or_error.is_error())
|
if (inode_or_error.is_error())
|
||||||
{
|
{
|
||||||
if (inode_or_error.error().get_error_code() == ENOENT)
|
if (inode_or_error.error().get_error_code() == ENOENT)
|
||||||
DevFileSystem::get().add_inode("tty"sv, MUST(RamSymlinkInode::create(DevFileSystem::get(), s_tty->name(), 0666, 0, 0)));
|
DevFileSystem::get().add_inode("tty"sv, MUST(TmpSymlinkInode::create_new(DevFileSystem::get(), 0666, 0, 0, s_tty->name())));
|
||||||
else
|
else
|
||||||
dwarnln("{}", inode_or_error.error());
|
dwarnln("{}", inode_or_error.error());
|
||||||
return;
|
return;
|
||||||
|
@ -41,7 +41,7 @@ namespace Kernel
|
||||||
|
|
||||||
auto inode = inode_or_error.release_value();
|
auto inode = inode_or_error.release_value();
|
||||||
if (inode->mode().iflnk())
|
if (inode->mode().iflnk())
|
||||||
MUST(((RamSymlinkInode*)inode.ptr())->set_link_target(name()));
|
MUST(reinterpret_cast<TmpSymlinkInode*>(inode.ptr())->set_link_target(name()));
|
||||||
}
|
}
|
||||||
|
|
||||||
BAN::ErrorOr<void> TTY::tty_ctrl(int command, int flags)
|
BAN::ErrorOr<void> TTY::tty_ctrl(int command, int flags)
|
||||||
|
|
Loading…
Reference in New Issue