diff --git a/Kernel/CMakeLists.txt b/Kernel/CMakeLists.txt index 48401971fc0..fd0babb4b6d 100644 --- a/Kernel/CMakeLists.txt +++ b/Kernel/CMakeLists.txt @@ -132,15 +132,8 @@ set(KERNEL_SOURCES FileSystem/Plan9FS/Inode.cpp FileSystem/Plan9FS/Message.cpp FileSystem/ProcFS/ComponentRegistry.cpp - FileSystem/ProcFS/DirectoryInode.cpp FileSystem/ProcFS/FileSystem.cpp - FileSystem/ProcFS/GlobalInode.cpp FileSystem/ProcFS/Inode.cpp - FileSystem/ProcFS/LinkInode.cpp - FileSystem/ProcFS/ProcessAssociatedInode.cpp - FileSystem/ProcFS/ProcessDirectoryInode.cpp - FileSystem/ProcFS/ProcessPropertyInode.cpp - FileSystem/ProcFS/ProcessSubDirectoryInode.cpp FileSystem/SysFS/Component.cpp FileSystem/SysFS/DirectoryInode.cpp FileSystem/SysFS/FileSystem.cpp diff --git a/Kernel/FileSystem/ProcFS/DirectoryInode.cpp b/Kernel/FileSystem/ProcFS/DirectoryInode.cpp deleted file mode 100644 index 569fa480fde..00000000000 --- a/Kernel/FileSystem/ProcFS/DirectoryInode.cpp +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright (c) 2018-2021, Andreas Kling - * Copyright (c) 2021, Spencer Dixon - * Copyright (c) 2021, Liav A. - * - * SPDX-License-Identifier: BSD-2-Clause - */ - -#include - -namespace Kernel { - -ErrorOr> ProcFSDirectoryInode::try_create(ProcFS const& procfs, ProcFSExposedComponent const& component) -{ - return adopt_nonnull_lock_ref_or_enomem(new (nothrow) ProcFSDirectoryInode(procfs, component)); -} - -ProcFSDirectoryInode::ProcFSDirectoryInode(ProcFS const& fs, ProcFSExposedComponent const& component) - : ProcFSGlobalInode(fs, component) -{ -} - -ProcFSDirectoryInode::~ProcFSDirectoryInode() = default; - -InodeMetadata ProcFSDirectoryInode::metadata() const -{ - MutexLocker locker(m_inode_lock); - InodeMetadata metadata; - metadata.inode = { fsid(), m_associated_component->component_index() }; - metadata.mode = S_IFDIR | m_associated_component->required_mode(); - metadata.uid = m_associated_component->owner_user(); - metadata.gid = m_associated_component->owner_group(); - metadata.size = 0; - metadata.mtime = m_associated_component->modified_time(); - return metadata; -} - -ErrorOr ProcFSDirectoryInode::traverse_as_directory(Function(FileSystem::DirectoryEntryView const&)> callback) const -{ - MutexLocker locker(procfs().m_lock); - return m_associated_component->traverse_as_directory(procfs().fsid(), move(callback)); -} - -ErrorOr> ProcFSDirectoryInode::lookup(StringView name) -{ - MutexLocker locker(procfs().m_lock); - auto component = TRY(m_associated_component->lookup(name)); - return component->to_inode(procfs()); -} - -} diff --git a/Kernel/FileSystem/ProcFS/DirectoryInode.h b/Kernel/FileSystem/ProcFS/DirectoryInode.h deleted file mode 100644 index 173af61667d..00000000000 --- a/Kernel/FileSystem/ProcFS/DirectoryInode.h +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright (c) 2018-2020, Andreas Kling - * - * SPDX-License-Identifier: BSD-2-Clause - */ - -#pragma once - -#include - -namespace Kernel { - -class ProcFSDirectoryInode final : public ProcFSGlobalInode { - friend class ProcFS; - -public: - static ErrorOr> try_create(ProcFS const&, ProcFSExposedComponent const&); - virtual ~ProcFSDirectoryInode() override; - -protected: - ProcFSDirectoryInode(ProcFS const&, ProcFSExposedComponent const&); - // ^Inode - virtual InodeMetadata metadata() const override; - virtual ErrorOr traverse_as_directory(Function(FileSystem::DirectoryEntryView const&)>) const override; - virtual ErrorOr> lookup(StringView name) override; -}; - -} diff --git a/Kernel/FileSystem/ProcFS/FileSystem.cpp b/Kernel/FileSystem/ProcFS/FileSystem.cpp index 7ea12c63442..e573c3ff374 100644 --- a/Kernel/FileSystem/ProcFS/FileSystem.cpp +++ b/Kernel/FileSystem/ProcFS/FileSystem.cpp @@ -6,8 +6,8 @@ * SPDX-License-Identifier: BSD-2-Clause */ -#include #include +#include #include namespace Kernel { @@ -22,7 +22,7 @@ ProcFS::~ProcFS() = default; ErrorOr ProcFS::initialize() { - m_root_inode = static_ptr_cast(TRY(ProcFSComponentRegistry::the().root_directory().to_inode(*this))); + m_root_inode = TRY(ProcFSComponentRegistry::the().root_directory().to_inode(*this)); return {}; } diff --git a/Kernel/FileSystem/ProcFS/FileSystem.h b/Kernel/FileSystem/ProcFS/FileSystem.h index f8d127e3c91..217ab7b7e27 100644 --- a/Kernel/FileSystem/ProcFS/FileSystem.h +++ b/Kernel/FileSystem/ProcFS/FileSystem.h @@ -14,18 +14,8 @@ namespace Kernel { class ProcFSInode; -class ProcFSProcessDirectoryInode; -class ProcFSGlobalInode; -class ProcFSAssociatedProcessInode; -class ProcFSProcessSubDirectoryInode; - class ProcFS final : public FileSystem { friend class ProcFSInode; - friend class ProcFSDirectoryInode; - friend class ProcFSProcessDirectoryInode; - friend class ProcFSGlobalInode; - friend class ProcFSAssociatedProcessInode; - friend class ProcFSProcessSubDirectoryInode; public: virtual ~ProcFS() override; @@ -39,7 +29,7 @@ public: private: ProcFS(); - LockRefPtr m_root_inode; + LockRefPtr m_root_inode; }; } diff --git a/Kernel/FileSystem/ProcFS/GlobalInode.cpp b/Kernel/FileSystem/ProcFS/GlobalInode.cpp deleted file mode 100644 index c0eab41690b..00000000000 --- a/Kernel/FileSystem/ProcFS/GlobalInode.cpp +++ /dev/null @@ -1,88 +0,0 @@ -/* - * Copyright (c) 2018-2021, Andreas Kling - * Copyright (c) 2021, Spencer Dixon - * Copyright (c) 2021, Liav A. - * - * SPDX-License-Identifier: BSD-2-Clause - */ - -#include - -namespace Kernel { - -ErrorOr> ProcFSGlobalInode::try_create(ProcFS const& fs, ProcFSExposedComponent const& component) -{ - return adopt_nonnull_lock_ref_or_enomem(new (nothrow) ProcFSGlobalInode(fs, component)); -} - -ProcFSGlobalInode::ProcFSGlobalInode(ProcFS const& fs, ProcFSExposedComponent const& component) - : ProcFSInode(fs, component.component_index()) - , m_associated_component(component) -{ -} - -void ProcFSGlobalInode::did_seek(OpenFileDescription& description, off_t new_offset) -{ - if (new_offset != 0) - return; - auto result = m_associated_component->refresh_data(description); - if (result.is_error()) { - // Subsequent calls to read will return EIO! - dbgln("ProcFS: Could not refresh contents: {}", result.error()); - } -} - -ErrorOr ProcFSGlobalInode::attach(OpenFileDescription& description) -{ - return m_associated_component->refresh_data(description); -} - -ErrorOr ProcFSGlobalInode::read_bytes_locked(off_t offset, size_t count, UserOrKernelBuffer& buffer, OpenFileDescription* fd) const -{ - return m_associated_component->read_bytes(offset, count, buffer, fd); -} - -StringView ProcFSGlobalInode::name() const -{ - return m_associated_component->name(); -} - -ErrorOr ProcFSGlobalInode::traverse_as_directory(Function(FileSystem::DirectoryEntryView const&)>) const -{ - VERIFY_NOT_REACHED(); -} - -ErrorOr> ProcFSGlobalInode::lookup(StringView) -{ - VERIFY_NOT_REACHED(); -} - -ErrorOr ProcFSGlobalInode::truncate(u64 size) -{ - return m_associated_component->truncate(size); -} - -ErrorOr ProcFSGlobalInode::update_timestamps(Optional