mirror of
https://github.com/RGBCube/serenity
synced 2025-07-24 21:37:34 +00:00
Kernel: Rename DevFS => DevTmpFS
The current implementation of DevFS resembles the linux devtmpfs, and not the traditional DevFS, so let's rename it to better represent the direction of the development in regard to this filesystem. The abbreviation for DevTmpFS is still "dev", because it doesn't add value as a commandline option to make it longer. In quick summary - DevFS in unix OSes is simply a static filesystem, so device nodes are generated and removed by the kernel code. DevTmpFS is a "modern reinvention" of the DevFS, so it is much more like a TmpFS in the sense that not only it's stored entirely in RAM, but the userland is responsible to add and remove devices nodes as it sees fit, and no kernel code is directly being involved to keep the filesystem in sync.
This commit is contained in:
parent
750ca2190b
commit
3d5ddbab74
5 changed files with 110 additions and 108 deletions
|
@ -109,8 +109,8 @@ set(KERNEL_SOURCES
|
||||||
FileSystem/AnonymousFile.cpp
|
FileSystem/AnonymousFile.cpp
|
||||||
FileSystem/BlockBasedFileSystem.cpp
|
FileSystem/BlockBasedFileSystem.cpp
|
||||||
FileSystem/Custody.cpp
|
FileSystem/Custody.cpp
|
||||||
FileSystem/DevFS.cpp
|
|
||||||
FileSystem/DevPtsFS.cpp
|
FileSystem/DevPtsFS.cpp
|
||||||
|
FileSystem/DevTmpFS.cpp
|
||||||
FileSystem/Ext2FileSystem.cpp
|
FileSystem/Ext2FileSystem.cpp
|
||||||
FileSystem/FIFO.cpp
|
FileSystem/FIFO.cpp
|
||||||
FileSystem/File.cpp
|
FileSystem/File.cpp
|
||||||
|
|
|
@ -5,21 +5,21 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <AK/StringView.h>
|
#include <AK/StringView.h>
|
||||||
#include <Kernel/FileSystem/DevFS.h>
|
#include <Kernel/FileSystem/DevTmpFS.h>
|
||||||
#include <Kernel/FileSystem/VirtualFileSystem.h>
|
#include <Kernel/FileSystem/VirtualFileSystem.h>
|
||||||
|
|
||||||
namespace Kernel {
|
namespace Kernel {
|
||||||
|
|
||||||
KResultOr<NonnullRefPtr<DevFS>> DevFS::try_create()
|
KResultOr<NonnullRefPtr<DevTmpFS>> DevTmpFS::try_create()
|
||||||
{
|
{
|
||||||
return adopt_nonnull_ref_or_enomem(new (nothrow) DevFS);
|
return adopt_nonnull_ref_or_enomem(new (nothrow) DevTmpFS);
|
||||||
}
|
}
|
||||||
|
|
||||||
DevFS::DevFS()
|
DevTmpFS::DevTmpFS()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t DevFS::allocate_inode_index()
|
size_t DevTmpFS::allocate_inode_index()
|
||||||
{
|
{
|
||||||
MutexLocker locker(m_lock);
|
MutexLocker locker(m_lock);
|
||||||
m_next_inode_index = m_next_inode_index.value() + 1;
|
m_next_inode_index = m_next_inode_index.value() + 1;
|
||||||
|
@ -27,96 +27,96 @@ size_t DevFS::allocate_inode_index()
|
||||||
return 1 + m_next_inode_index.value();
|
return 1 + m_next_inode_index.value();
|
||||||
}
|
}
|
||||||
|
|
||||||
DevFS::~DevFS()
|
DevTmpFS::~DevTmpFS()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
KResult DevFS::initialize()
|
KResult DevTmpFS::initialize()
|
||||||
{
|
{
|
||||||
m_root_inode = TRY(adopt_nonnull_ref_or_enomem(new (nothrow) DevFSRootDirectoryInode(*this)));
|
m_root_inode = TRY(adopt_nonnull_ref_or_enomem(new (nothrow) DevTmpFSRootDirectoryInode(*this)));
|
||||||
return KSuccess;
|
return KSuccess;
|
||||||
}
|
}
|
||||||
|
|
||||||
Inode& DevFS::root_inode()
|
Inode& DevTmpFS::root_inode()
|
||||||
{
|
{
|
||||||
return *m_root_inode;
|
return *m_root_inode;
|
||||||
}
|
}
|
||||||
|
|
||||||
DevFSInode::DevFSInode(DevFS& fs)
|
DevTmpFSInode::DevTmpFSInode(DevTmpFS& fs)
|
||||||
: Inode(fs, fs.allocate_inode_index())
|
: Inode(fs, fs.allocate_inode_index())
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
KResultOr<size_t> DevFSInode::read_bytes(off_t, size_t, UserOrKernelBuffer&, OpenFileDescription*) const
|
KResultOr<size_t> DevTmpFSInode::read_bytes(off_t, size_t, UserOrKernelBuffer&, OpenFileDescription*) const
|
||||||
{
|
{
|
||||||
VERIFY_NOT_REACHED();
|
VERIFY_NOT_REACHED();
|
||||||
}
|
}
|
||||||
|
|
||||||
KResult DevFSInode::traverse_as_directory(Function<bool(FileSystem::DirectoryEntryView const&)>) const
|
KResult DevTmpFSInode::traverse_as_directory(Function<bool(FileSystem::DirectoryEntryView const&)>) const
|
||||||
{
|
{
|
||||||
VERIFY_NOT_REACHED();
|
VERIFY_NOT_REACHED();
|
||||||
}
|
}
|
||||||
|
|
||||||
KResultOr<NonnullRefPtr<Inode>> DevFSInode::lookup(StringView)
|
KResultOr<NonnullRefPtr<Inode>> DevTmpFSInode::lookup(StringView)
|
||||||
{
|
{
|
||||||
VERIFY_NOT_REACHED();
|
VERIFY_NOT_REACHED();
|
||||||
}
|
}
|
||||||
|
|
||||||
void DevFSInode::flush_metadata()
|
void DevTmpFSInode::flush_metadata()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
KResultOr<size_t> DevFSInode::write_bytes(off_t, size_t, const UserOrKernelBuffer&, OpenFileDescription*)
|
KResultOr<size_t> DevTmpFSInode::write_bytes(off_t, size_t, const UserOrKernelBuffer&, OpenFileDescription*)
|
||||||
{
|
{
|
||||||
VERIFY_NOT_REACHED();
|
VERIFY_NOT_REACHED();
|
||||||
}
|
}
|
||||||
|
|
||||||
KResultOr<NonnullRefPtr<Inode>> DevFSInode::create_child(StringView, mode_t, dev_t, UserID, GroupID)
|
KResultOr<NonnullRefPtr<Inode>> DevTmpFSInode::create_child(StringView, mode_t, dev_t, UserID, GroupID)
|
||||||
{
|
{
|
||||||
return EROFS;
|
return EROFS;
|
||||||
}
|
}
|
||||||
|
|
||||||
KResult DevFSInode::add_child(Inode&, const StringView&, mode_t)
|
KResult DevTmpFSInode::add_child(Inode&, const StringView&, mode_t)
|
||||||
{
|
{
|
||||||
return EROFS;
|
return EROFS;
|
||||||
}
|
}
|
||||||
|
|
||||||
KResult DevFSInode::remove_child(const StringView&)
|
KResult DevTmpFSInode::remove_child(const StringView&)
|
||||||
{
|
{
|
||||||
return EROFS;
|
return EROFS;
|
||||||
}
|
}
|
||||||
|
|
||||||
KResult DevFSInode::chmod(mode_t)
|
KResult DevTmpFSInode::chmod(mode_t)
|
||||||
{
|
{
|
||||||
return EPERM;
|
return EPERM;
|
||||||
}
|
}
|
||||||
|
|
||||||
KResult DevFSInode::chown(UserID, GroupID)
|
KResult DevTmpFSInode::chown(UserID, GroupID)
|
||||||
{
|
{
|
||||||
return EPERM;
|
return EPERM;
|
||||||
}
|
}
|
||||||
|
|
||||||
KResult DevFSInode::truncate(u64)
|
KResult DevTmpFSInode::truncate(u64)
|
||||||
{
|
{
|
||||||
return EPERM;
|
return EPERM;
|
||||||
}
|
}
|
||||||
|
|
||||||
StringView DevFSLinkInode::name() const
|
StringView DevTmpFSLinkInode::name() const
|
||||||
{
|
{
|
||||||
return m_name->view();
|
return m_name->view();
|
||||||
}
|
}
|
||||||
|
|
||||||
DevFSLinkInode::~DevFSLinkInode()
|
DevTmpFSLinkInode::~DevTmpFSLinkInode()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
DevFSLinkInode::DevFSLinkInode(DevFS& fs, NonnullOwnPtr<KString> name)
|
DevTmpFSLinkInode::DevTmpFSLinkInode(DevTmpFS& fs, NonnullOwnPtr<KString> name)
|
||||||
: DevFSInode(fs)
|
: DevTmpFSInode(fs)
|
||||||
, m_name(move(name))
|
, m_name(move(name))
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
KResultOr<size_t> DevFSLinkInode::read_bytes(off_t offset, size_t, UserOrKernelBuffer& buffer, OpenFileDescription*) const
|
KResultOr<size_t> DevTmpFSLinkInode::read_bytes(off_t offset, size_t, UserOrKernelBuffer& buffer, OpenFileDescription*) const
|
||||||
{
|
{
|
||||||
MutexLocker locker(m_inode_lock);
|
MutexLocker locker(m_inode_lock);
|
||||||
VERIFY(offset == 0);
|
VERIFY(offset == 0);
|
||||||
|
@ -125,7 +125,7 @@ KResultOr<size_t> DevFSLinkInode::read_bytes(off_t offset, size_t, UserOrKernelB
|
||||||
return m_link->length();
|
return m_link->length();
|
||||||
}
|
}
|
||||||
|
|
||||||
InodeMetadata DevFSLinkInode::metadata() const
|
InodeMetadata DevTmpFSLinkInode::metadata() const
|
||||||
{
|
{
|
||||||
InodeMetadata metadata;
|
InodeMetadata metadata;
|
||||||
metadata.inode = { fsid(), index() };
|
metadata.inode = { fsid(), index() };
|
||||||
|
@ -137,7 +137,7 @@ InodeMetadata DevFSLinkInode::metadata() const
|
||||||
return metadata;
|
return metadata;
|
||||||
}
|
}
|
||||||
|
|
||||||
KResultOr<size_t> DevFSLinkInode::write_bytes(off_t offset, size_t count, UserOrKernelBuffer const& buffer, OpenFileDescription*)
|
KResultOr<size_t> DevTmpFSLinkInode::write_bytes(off_t offset, size_t count, UserOrKernelBuffer const& buffer, OpenFileDescription*)
|
||||||
{
|
{
|
||||||
auto new_string = TRY(buffer.try_copy_into_kstring(count));
|
auto new_string = TRY(buffer.try_copy_into_kstring(count));
|
||||||
|
|
||||||
|
@ -148,15 +148,15 @@ KResultOr<size_t> DevFSLinkInode::write_bytes(off_t offset, size_t count, UserOr
|
||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
|
|
||||||
DevFSDirectoryInode::DevFSDirectoryInode(DevFS& fs)
|
DevTmpFSDirectoryInode::DevTmpFSDirectoryInode(DevTmpFS& fs)
|
||||||
: DevFSInode(fs)
|
: DevTmpFSInode(fs)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
DevFSDirectoryInode::~DevFSDirectoryInode()
|
DevTmpFSDirectoryInode::~DevTmpFSDirectoryInode()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
InodeMetadata DevFSDirectoryInode::metadata() const
|
InodeMetadata DevTmpFSDirectoryInode::metadata() const
|
||||||
{
|
{
|
||||||
InodeMetadata metadata;
|
InodeMetadata metadata;
|
||||||
metadata.inode = { fsid(), 1 };
|
metadata.inode = { fsid(), 1 };
|
||||||
|
@ -168,12 +168,12 @@ InodeMetadata DevFSDirectoryInode::metadata() const
|
||||||
return metadata;
|
return metadata;
|
||||||
}
|
}
|
||||||
|
|
||||||
DevFSRootDirectoryInode::DevFSRootDirectoryInode(DevFS& fs)
|
DevTmpFSRootDirectoryInode::DevTmpFSRootDirectoryInode(DevTmpFS& fs)
|
||||||
: DevFSDirectoryInode(fs)
|
: DevTmpFSDirectoryInode(fs)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
KResult DevFSRootDirectoryInode::traverse_as_directory(Function<bool(FileSystem::DirectoryEntryView const&)> callback) const
|
KResult DevTmpFSRootDirectoryInode::traverse_as_directory(Function<bool(FileSystem::DirectoryEntryView const&)> callback) const
|
||||||
{
|
{
|
||||||
MutexLocker locker(fs().m_lock);
|
MutexLocker locker(fs().m_lock);
|
||||||
callback({ ".", identifier(), 0 });
|
callback({ ".", identifier(), 0 });
|
||||||
|
@ -185,7 +185,7 @@ KResult DevFSRootDirectoryInode::traverse_as_directory(Function<bool(FileSystem:
|
||||||
return KSuccess;
|
return KSuccess;
|
||||||
}
|
}
|
||||||
|
|
||||||
KResultOr<NonnullRefPtr<Inode>> DevFSRootDirectoryInode::lookup(StringView name)
|
KResultOr<NonnullRefPtr<Inode>> DevTmpFSRootDirectoryInode::lookup(StringView name)
|
||||||
{
|
{
|
||||||
MutexLocker locker(fs().m_lock);
|
MutexLocker locker(fs().m_lock);
|
||||||
for (auto& node : m_nodes) {
|
for (auto& node : m_nodes) {
|
||||||
|
@ -195,7 +195,7 @@ KResultOr<NonnullRefPtr<Inode>> DevFSRootDirectoryInode::lookup(StringView name)
|
||||||
return ENOENT;
|
return ENOENT;
|
||||||
}
|
}
|
||||||
|
|
||||||
KResult DevFSRootDirectoryInode::remove_child(const StringView& name)
|
KResult DevTmpFSRootDirectoryInode::remove_child(const StringView& name)
|
||||||
{
|
{
|
||||||
MutexLocker locker(fs().m_lock);
|
MutexLocker locker(fs().m_lock);
|
||||||
for (auto& node : m_nodes) {
|
for (auto& node : m_nodes) {
|
||||||
|
@ -206,7 +206,8 @@ KResult DevFSRootDirectoryInode::remove_child(const StringView& name)
|
||||||
}
|
}
|
||||||
return KResult(ENOENT);
|
return KResult(ENOENT);
|
||||||
}
|
}
|
||||||
KResultOr<NonnullRefPtr<Inode>> DevFSRootDirectoryInode::create_child(StringView name, mode_t mode, dev_t device_mode, UserID, GroupID)
|
|
||||||
|
KResultOr<NonnullRefPtr<Inode>> DevTmpFSRootDirectoryInode::create_child(StringView name, mode_t mode, dev_t device_mode, UserID, GroupID)
|
||||||
{
|
{
|
||||||
MutexLocker locker(fs().m_lock);
|
MutexLocker locker(fs().m_lock);
|
||||||
|
|
||||||
|
@ -220,7 +221,7 @@ KResultOr<NonnullRefPtr<Inode>> DevFSRootDirectoryInode::create_child(StringView
|
||||||
if (metadata.is_directory()) {
|
if (metadata.is_directory()) {
|
||||||
if (name != "pts")
|
if (name != "pts")
|
||||||
return EROFS;
|
return EROFS;
|
||||||
auto new_directory_inode = TRY(adopt_nonnull_ref_or_enomem(new (nothrow) DevFSPtsDirectoryInode(fs())));
|
auto new_directory_inode = TRY(adopt_nonnull_ref_or_enomem(new (nothrow) DevTmpFSPtsDirectoryInode(fs())));
|
||||||
m_nodes.append(*new_directory_inode);
|
m_nodes.append(*new_directory_inode);
|
||||||
return new_directory_inode;
|
return new_directory_inode;
|
||||||
}
|
}
|
||||||
|
@ -228,24 +229,24 @@ KResultOr<NonnullRefPtr<Inode>> DevFSRootDirectoryInode::create_child(StringView
|
||||||
auto name_kstring = TRY(KString::try_create(name));
|
auto name_kstring = TRY(KString::try_create(name));
|
||||||
unsigned major = major_from_encoded_device(device_mode);
|
unsigned major = major_from_encoded_device(device_mode);
|
||||||
unsigned minor = minor_from_encoded_device(device_mode);
|
unsigned minor = minor_from_encoded_device(device_mode);
|
||||||
auto new_device_inode = TRY(adopt_nonnull_ref_or_enomem(new (nothrow) DevFSDeviceInode(fs(), major, minor, is_block_device(mode), move(name_kstring))));
|
auto new_device_inode = TRY(adopt_nonnull_ref_or_enomem(new (nothrow) DevTmpFSDeviceInode(fs(), major, minor, is_block_device(mode), move(name_kstring))));
|
||||||
TRY(new_device_inode->chmod(mode));
|
TRY(new_device_inode->chmod(mode));
|
||||||
m_nodes.append(*new_device_inode);
|
m_nodes.append(*new_device_inode);
|
||||||
return new_device_inode;
|
return new_device_inode;
|
||||||
}
|
}
|
||||||
if (metadata.is_symlink()) {
|
if (metadata.is_symlink()) {
|
||||||
auto name_kstring = TRY(KString::try_create(name));
|
auto name_kstring = TRY(KString::try_create(name));
|
||||||
auto new_link_inode = TRY(adopt_nonnull_ref_or_enomem(new (nothrow) DevFSLinkInode(fs(), move(name_kstring))));
|
auto new_link_inode = TRY(adopt_nonnull_ref_or_enomem(new (nothrow) DevTmpFSLinkInode(fs(), move(name_kstring))));
|
||||||
m_nodes.append(*new_link_inode);
|
m_nodes.append(*new_link_inode);
|
||||||
return new_link_inode;
|
return new_link_inode;
|
||||||
}
|
}
|
||||||
return EROFS;
|
return EROFS;
|
||||||
}
|
}
|
||||||
|
|
||||||
DevFSRootDirectoryInode::~DevFSRootDirectoryInode()
|
DevTmpFSRootDirectoryInode::~DevTmpFSRootDirectoryInode()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
InodeMetadata DevFSRootDirectoryInode::metadata() const
|
InodeMetadata DevTmpFSRootDirectoryInode::metadata() const
|
||||||
{
|
{
|
||||||
InodeMetadata metadata;
|
InodeMetadata metadata;
|
||||||
metadata.inode = { fsid(), 1 };
|
metadata.inode = { fsid(), 1 };
|
||||||
|
@ -257,8 +258,8 @@ InodeMetadata DevFSRootDirectoryInode::metadata() const
|
||||||
return metadata;
|
return metadata;
|
||||||
}
|
}
|
||||||
|
|
||||||
DevFSDeviceInode::DevFSDeviceInode(DevFS& fs, unsigned major_number, unsigned minor_number, bool block_device, NonnullOwnPtr<KString> name)
|
DevTmpFSDeviceInode::DevTmpFSDeviceInode(DevTmpFS& fs, unsigned major_number, unsigned minor_number, bool block_device, NonnullOwnPtr<KString> name)
|
||||||
: DevFSInode(fs)
|
: DevTmpFSInode(fs)
|
||||||
, m_name(move(name))
|
, m_name(move(name))
|
||||||
, m_major_number(major_number)
|
, m_major_number(major_number)
|
||||||
, m_minor_number(minor_number)
|
, m_minor_number(minor_number)
|
||||||
|
@ -266,11 +267,11 @@ DevFSDeviceInode::DevFSDeviceInode(DevFS& fs, unsigned major_number, unsigned mi
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
DevFSDeviceInode::~DevFSDeviceInode()
|
DevTmpFSDeviceInode::~DevTmpFSDeviceInode()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
KResult DevFSDeviceInode::chown(UserID uid, GroupID gid)
|
KResult DevTmpFSDeviceInode::chown(UserID uid, GroupID gid)
|
||||||
{
|
{
|
||||||
MutexLocker locker(m_inode_lock);
|
MutexLocker locker(m_inode_lock);
|
||||||
m_uid = uid;
|
m_uid = uid;
|
||||||
|
@ -278,7 +279,7 @@ KResult DevFSDeviceInode::chown(UserID uid, GroupID gid)
|
||||||
return KSuccess;
|
return KSuccess;
|
||||||
}
|
}
|
||||||
|
|
||||||
KResult DevFSDeviceInode::chmod(mode_t mode)
|
KResult DevTmpFSDeviceInode::chmod(mode_t mode)
|
||||||
{
|
{
|
||||||
MutexLocker locker(m_inode_lock);
|
MutexLocker locker(m_inode_lock);
|
||||||
mode &= 0777;
|
mode &= 0777;
|
||||||
|
@ -288,12 +289,12 @@ KResult DevFSDeviceInode::chmod(mode_t mode)
|
||||||
return KSuccess;
|
return KSuccess;
|
||||||
}
|
}
|
||||||
|
|
||||||
StringView DevFSDeviceInode::name() const
|
StringView DevTmpFSDeviceInode::name() const
|
||||||
{
|
{
|
||||||
return m_name->view();
|
return m_name->view();
|
||||||
}
|
}
|
||||||
|
|
||||||
KResultOr<size_t> DevFSDeviceInode::read_bytes(off_t offset, size_t count, UserOrKernelBuffer& buffer, OpenFileDescription* description) const
|
KResultOr<size_t> DevTmpFSDeviceInode::read_bytes(off_t offset, size_t count, UserOrKernelBuffer& buffer, OpenFileDescription* description) const
|
||||||
{
|
{
|
||||||
MutexLocker locker(m_inode_lock);
|
MutexLocker locker(m_inode_lock);
|
||||||
VERIFY(!!description);
|
VERIFY(!!description);
|
||||||
|
@ -308,7 +309,7 @@ KResultOr<size_t> DevFSDeviceInode::read_bytes(off_t offset, size_t count, UserO
|
||||||
return result.value();
|
return result.value();
|
||||||
}
|
}
|
||||||
|
|
||||||
InodeMetadata DevFSDeviceInode::metadata() const
|
InodeMetadata DevTmpFSDeviceInode::metadata() const
|
||||||
{
|
{
|
||||||
MutexLocker locker(m_inode_lock);
|
MutexLocker locker(m_inode_lock);
|
||||||
InodeMetadata metadata;
|
InodeMetadata metadata;
|
||||||
|
@ -322,7 +323,7 @@ InodeMetadata DevFSDeviceInode::metadata() const
|
||||||
metadata.minor_device = m_minor_number;
|
metadata.minor_device = m_minor_number;
|
||||||
return metadata;
|
return metadata;
|
||||||
}
|
}
|
||||||
KResultOr<size_t> DevFSDeviceInode::write_bytes(off_t offset, size_t count, const UserOrKernelBuffer& buffer, OpenFileDescription* description)
|
KResultOr<size_t> DevTmpFSDeviceInode::write_bytes(off_t offset, size_t count, const UserOrKernelBuffer& buffer, OpenFileDescription* description)
|
||||||
{
|
{
|
||||||
MutexLocker locker(m_inode_lock);
|
MutexLocker locker(m_inode_lock);
|
||||||
VERIFY(!!description);
|
VERIFY(!!description);
|
||||||
|
@ -337,11 +338,11 @@ KResultOr<size_t> DevFSDeviceInode::write_bytes(off_t offset, size_t count, cons
|
||||||
return result.value();
|
return result.value();
|
||||||
}
|
}
|
||||||
|
|
||||||
DevFSPtsDirectoryInode::DevFSPtsDirectoryInode(DevFS& fs)
|
DevTmpFSPtsDirectoryInode::DevTmpFSPtsDirectoryInode(DevTmpFS& fs)
|
||||||
: DevFSDirectoryInode(fs)
|
: DevTmpFSDirectoryInode(fs)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
KResult DevFSPtsDirectoryInode::traverse_as_directory(Function<bool(FileSystem::DirectoryEntryView const&)> callback) const
|
KResult DevTmpFSPtsDirectoryInode::traverse_as_directory(Function<bool(FileSystem::DirectoryEntryView const&)> callback) const
|
||||||
{
|
{
|
||||||
MutexLocker locker(m_inode_lock);
|
MutexLocker locker(m_inode_lock);
|
||||||
callback({ ".", identifier(), 0 });
|
callback({ ".", identifier(), 0 });
|
||||||
|
@ -349,15 +350,15 @@ KResult DevFSPtsDirectoryInode::traverse_as_directory(Function<bool(FileSystem::
|
||||||
return KSuccess;
|
return KSuccess;
|
||||||
}
|
}
|
||||||
|
|
||||||
KResultOr<NonnullRefPtr<Inode>> DevFSPtsDirectoryInode::lookup(StringView)
|
KResultOr<NonnullRefPtr<Inode>> DevTmpFSPtsDirectoryInode::lookup(StringView)
|
||||||
{
|
{
|
||||||
return ENOENT;
|
return ENOENT;
|
||||||
}
|
}
|
||||||
|
|
||||||
DevFSPtsDirectoryInode::~DevFSPtsDirectoryInode()
|
DevTmpFSPtsDirectoryInode::~DevTmpFSPtsDirectoryInode()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
InodeMetadata DevFSPtsDirectoryInode::metadata() const
|
InodeMetadata DevTmpFSPtsDirectoryInode::metadata() const
|
||||||
{
|
{
|
||||||
InodeMetadata metadata;
|
InodeMetadata metadata;
|
||||||
metadata.inode = { fsid(), index() };
|
metadata.inode = { fsid(), index() };
|
|
@ -14,39 +14,39 @@
|
||||||
|
|
||||||
namespace Kernel {
|
namespace Kernel {
|
||||||
|
|
||||||
class DevFS final : public FileSystem {
|
class DevTmpFS final : public FileSystem {
|
||||||
friend class DevFSInode;
|
friend class DevTmpFSInode;
|
||||||
friend class DevFSRootDirectoryInode;
|
friend class DevTmpFSRootDirectoryInode;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
virtual ~DevFS() override;
|
virtual ~DevTmpFS() override;
|
||||||
static KResultOr<NonnullRefPtr<DevFS>> try_create();
|
static KResultOr<NonnullRefPtr<DevTmpFS>> try_create();
|
||||||
|
|
||||||
virtual KResult initialize() override;
|
virtual KResult initialize() override;
|
||||||
virtual StringView class_name() const override { return "DevFS"sv; }
|
virtual StringView class_name() const override { return "DevTmpFS"sv; }
|
||||||
virtual Inode& root_inode() override;
|
virtual Inode& root_inode() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
DevFS();
|
DevTmpFS();
|
||||||
size_t allocate_inode_index();
|
size_t allocate_inode_index();
|
||||||
|
|
||||||
RefPtr<DevFSRootDirectoryInode> m_root_inode;
|
RefPtr<DevTmpFSRootDirectoryInode> m_root_inode;
|
||||||
InodeIndex m_next_inode_index { 0 };
|
InodeIndex m_next_inode_index { 0 };
|
||||||
};
|
};
|
||||||
|
|
||||||
class DevFSInode : public Inode {
|
class DevTmpFSInode : public Inode {
|
||||||
friend class DevFS;
|
friend class DevTmpFS;
|
||||||
friend class DevFSRootDirectoryInode;
|
friend class DevTmpFSRootDirectoryInode;
|
||||||
friend class DevFSDirectoryInode;
|
friend class DevTmpFSDirectoryInode;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
virtual StringView name() const = 0;
|
virtual StringView name() const = 0;
|
||||||
|
|
||||||
DevFS& fs() { return static_cast<DevFS&>(Inode::fs()); }
|
DevTmpFS& fs() { return static_cast<DevTmpFS&>(Inode::fs()); }
|
||||||
DevFS const& fs() const { return static_cast<DevFS const&>(Inode::fs()); }
|
DevTmpFS const& fs() const { return static_cast<DevTmpFS const&>(Inode::fs()); }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
DevFSInode(DevFS&);
|
DevTmpFSInode(DevTmpFS&);
|
||||||
virtual KResultOr<size_t> read_bytes(off_t, size_t, UserOrKernelBuffer& buffer, OpenFileDescription*) const override;
|
virtual KResultOr<size_t> read_bytes(off_t, size_t, UserOrKernelBuffer& buffer, OpenFileDescription*) const override;
|
||||||
virtual KResult traverse_as_directory(Function<bool(FileSystem::DirectoryEntryView const&)>) const override;
|
virtual KResult traverse_as_directory(Function<bool(FileSystem::DirectoryEntryView const&)>) const override;
|
||||||
virtual KResultOr<NonnullRefPtr<Inode>> lookup(StringView name) override;
|
virtual KResultOr<NonnullRefPtr<Inode>> lookup(StringView name) override;
|
||||||
|
@ -60,19 +60,20 @@ protected:
|
||||||
virtual KResult truncate(u64) override;
|
virtual KResult truncate(u64) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
IntrusiveListNode<DevFSInode, RefPtr<DevFSInode>> m_list_node;
|
IntrusiveListNode<DevTmpFSInode, RefPtr<DevTmpFSInode>> m_list_node;
|
||||||
};
|
};
|
||||||
|
|
||||||
class DevFSDeviceInode : public DevFSInode {
|
class DevTmpFSDeviceInode : public DevTmpFSInode {
|
||||||
friend class DevFS;
|
friend class DevTmpFS;
|
||||||
friend class DevFSRootDirectoryInode;
|
friend class DevTmpFSRootDirectoryInode;
|
||||||
|
friend class DevTmpFSDirectoryInode;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
virtual StringView name() const override;
|
virtual StringView name() const override;
|
||||||
virtual ~DevFSDeviceInode() override;
|
virtual ~DevTmpFSDeviceInode() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
DevFSDeviceInode(DevFS&, unsigned, unsigned, bool, NonnullOwnPtr<KString> name);
|
DevTmpFSDeviceInode(DevTmpFS&, unsigned, unsigned, bool, NonnullOwnPtr<KString> name);
|
||||||
// ^Inode
|
// ^Inode
|
||||||
virtual KResultOr<size_t> read_bytes(off_t, size_t, UserOrKernelBuffer& buffer, OpenFileDescription*) const override;
|
virtual KResultOr<size_t> read_bytes(off_t, size_t, UserOrKernelBuffer& buffer, OpenFileDescription*) const override;
|
||||||
virtual InodeMetadata metadata() const override;
|
virtual InodeMetadata metadata() const override;
|
||||||
|
@ -89,16 +90,16 @@ private:
|
||||||
GroupID m_gid { 0 };
|
GroupID m_gid { 0 };
|
||||||
};
|
};
|
||||||
|
|
||||||
class DevFSLinkInode : public DevFSInode {
|
class DevTmpFSLinkInode : public DevTmpFSInode {
|
||||||
friend class DevFS;
|
friend class DevTmpFS;
|
||||||
friend class DevFSRootDirectoryInode;
|
friend class DevTmpFSRootDirectoryInode;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
virtual StringView name() const override;
|
virtual StringView name() const override;
|
||||||
virtual ~DevFSLinkInode() override;
|
virtual ~DevTmpFSLinkInode() override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
DevFSLinkInode(DevFS&, NonnullOwnPtr<KString>);
|
DevTmpFSLinkInode(DevTmpFS&, NonnullOwnPtr<KString>);
|
||||||
// ^Inode
|
// ^Inode
|
||||||
virtual KResultOr<size_t> read_bytes(off_t, size_t, UserOrKernelBuffer& buffer, OpenFileDescription*) const override;
|
virtual KResultOr<size_t> read_bytes(off_t, size_t, UserOrKernelBuffer& buffer, OpenFileDescription*) const override;
|
||||||
virtual InodeMetadata metadata() const override;
|
virtual InodeMetadata metadata() const override;
|
||||||
|
@ -108,45 +109,45 @@ protected:
|
||||||
OwnPtr<KString> m_link;
|
OwnPtr<KString> m_link;
|
||||||
};
|
};
|
||||||
|
|
||||||
class DevFSDirectoryInode : public DevFSInode {
|
class DevTmpFSDirectoryInode : public DevTmpFSInode {
|
||||||
friend class DevFS;
|
friend class DevTmpFS;
|
||||||
friend class DevFSRootDirectoryInode;
|
friend class DevTmpFSRootDirectoryInode;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
virtual ~DevFSDirectoryInode() override;
|
virtual ~DevTmpFSDirectoryInode() override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
DevFSDirectoryInode(DevFS&);
|
DevTmpFSDirectoryInode(DevTmpFS&);
|
||||||
// ^Inode
|
// ^Inode
|
||||||
virtual InodeMetadata metadata() const override;
|
virtual InodeMetadata metadata() const override;
|
||||||
|
|
||||||
IntrusiveList<DevFSInode, NonnullRefPtr<DevFSInode>, &DevFSInode::m_list_node> m_nodes;
|
IntrusiveList<DevTmpFSInode, NonnullRefPtr<DevTmpFSInode>, &DevTmpFSInode::m_list_node> m_nodes;
|
||||||
};
|
};
|
||||||
|
|
||||||
class DevFSPtsDirectoryInode final : public DevFSDirectoryInode {
|
class DevTmpFSPtsDirectoryInode final : public DevTmpFSDirectoryInode {
|
||||||
friend class DevFS;
|
friend class DevTmpFS;
|
||||||
friend class DevFSRootDirectoryInode;
|
friend class DevTmpFSRootDirectoryInode;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
virtual ~DevFSPtsDirectoryInode() override;
|
virtual ~DevTmpFSPtsDirectoryInode() override;
|
||||||
virtual StringView name() const override { return "pts"; };
|
virtual StringView name() const override { return "pts"; };
|
||||||
|
|
||||||
private:
|
private:
|
||||||
explicit DevFSPtsDirectoryInode(DevFS&);
|
explicit DevTmpFSPtsDirectoryInode(DevTmpFS&);
|
||||||
virtual KResult traverse_as_directory(Function<bool(FileSystem::DirectoryEntryView const&)>) const override;
|
virtual KResult traverse_as_directory(Function<bool(FileSystem::DirectoryEntryView const&)>) const override;
|
||||||
virtual KResultOr<NonnullRefPtr<Inode>> lookup(StringView name) override;
|
virtual KResultOr<NonnullRefPtr<Inode>> lookup(StringView name) override;
|
||||||
virtual InodeMetadata metadata() const override;
|
virtual InodeMetadata metadata() const override;
|
||||||
};
|
};
|
||||||
|
|
||||||
class DevFSRootDirectoryInode final : public DevFSDirectoryInode {
|
class DevTmpFSRootDirectoryInode final : public DevTmpFSDirectoryInode {
|
||||||
friend class DevFS;
|
friend class DevTmpFS;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
virtual ~DevFSRootDirectoryInode() override;
|
virtual ~DevTmpFSRootDirectoryInode() override;
|
||||||
virtual StringView name() const override { return "."; }
|
virtual StringView name() const override { return "."; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
explicit DevFSRootDirectoryInode(DevFS&);
|
explicit DevTmpFSRootDirectoryInode(DevTmpFS&);
|
||||||
virtual KResultOr<NonnullRefPtr<Inode>> create_child(StringView name, mode_t, dev_t, UserID, GroupID) override;
|
virtual KResultOr<NonnullRefPtr<Inode>> create_child(StringView name, mode_t, dev_t, UserID, GroupID) override;
|
||||||
virtual KResult traverse_as_directory(Function<bool(FileSystem::DirectoryEntryView const&)>) const override;
|
virtual KResult traverse_as_directory(Function<bool(FileSystem::DirectoryEntryView const&)>) const override;
|
||||||
virtual KResultOr<NonnullRefPtr<Inode>> lookup(StringView name) override;
|
virtual KResultOr<NonnullRefPtr<Inode>> lookup(StringView name) override;
|
|
@ -15,11 +15,11 @@ class BlockDevice;
|
||||||
class CharacterDevice;
|
class CharacterDevice;
|
||||||
class Coredump;
|
class Coredump;
|
||||||
class Custody;
|
class Custody;
|
||||||
class DevFSDeviceInode;
|
class DevTmpFSDeviceInode;
|
||||||
class DevFSDirectoryInode;
|
class DevTmpFSDirectoryInode;
|
||||||
class DevFSInode;
|
class DevTmpFSInode;
|
||||||
class DevFSPtsDirectoryInode;
|
class DevTmpFSPtsDirectoryInode;
|
||||||
class DevFSRootDirectoryInode;
|
class DevTmpFSRootDirectoryInode;
|
||||||
class Device;
|
class Device;
|
||||||
class DiskCache;
|
class DiskCache;
|
||||||
class DoubleBuffer;
|
class DoubleBuffer;
|
||||||
|
|
|
@ -5,8 +5,8 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <Kernel/FileSystem/Custody.h>
|
#include <Kernel/FileSystem/Custody.h>
|
||||||
#include <Kernel/FileSystem/DevFS.h>
|
|
||||||
#include <Kernel/FileSystem/DevPtsFS.h>
|
#include <Kernel/FileSystem/DevPtsFS.h>
|
||||||
|
#include <Kernel/FileSystem/DevTmpFS.h>
|
||||||
#include <Kernel/FileSystem/Ext2FileSystem.h>
|
#include <Kernel/FileSystem/Ext2FileSystem.h>
|
||||||
#include <Kernel/FileSystem/ISO9660FileSystem.h>
|
#include <Kernel/FileSystem/ISO9660FileSystem.h>
|
||||||
#include <Kernel/FileSystem/Plan9FileSystem.h>
|
#include <Kernel/FileSystem/Plan9FileSystem.h>
|
||||||
|
@ -82,8 +82,8 @@ KResultOr<FlatPtr> Process::sys$mount(Userspace<const Syscall::SC_mount_params*>
|
||||||
fs = TRY(ProcFS::try_create());
|
fs = TRY(ProcFS::try_create());
|
||||||
} else if (fs_type == "devpts"sv || fs_type == "DevPtsFS"sv) {
|
} else if (fs_type == "devpts"sv || fs_type == "DevPtsFS"sv) {
|
||||||
fs = TRY(DevPtsFS::try_create());
|
fs = TRY(DevPtsFS::try_create());
|
||||||
} else if (fs_type == "dev"sv || fs_type == "DevFS"sv) {
|
} else if (fs_type == "dev"sv || fs_type == "DevTmpFS"sv) {
|
||||||
fs = TRY(DevFS::try_create());
|
fs = TRY(DevTmpFS::try_create());
|
||||||
} else if (fs_type == "sys"sv || fs_type == "SysFS"sv) {
|
} else if (fs_type == "sys"sv || fs_type == "SysFS"sv) {
|
||||||
fs = TRY(SysFS::try_create());
|
fs = TRY(SysFS::try_create());
|
||||||
} else if (fs_type == "tmp"sv || fs_type == "TmpFS"sv) {
|
} else if (fs_type == "tmp"sv || fs_type == "TmpFS"sv) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue