mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 07:37:35 +00:00
Kernel/SysFS: Mark SysFSDirectory traverse and lookup methods as final
This enforces us to remove duplicated code across the SysFS code. This results in great simplification of how the SysFS works now, because we enforce one way to treat SysFSDirectory objects.
This commit is contained in:
parent
6733f19b3c
commit
70afa0b171
18 changed files with 114 additions and 178 deletions
|
@ -25,6 +25,8 @@ struct SysFSInodeData : public OpenFileDescriptionData {
|
|||
|
||||
class SysFSDirectory;
|
||||
class SysFSComponent : public RefCounted<SysFSComponent> {
|
||||
friend class SysFSDirectory;
|
||||
|
||||
public:
|
||||
virtual StringView name() const = 0;
|
||||
virtual ErrorOr<size_t> read_bytes(off_t, size_t, UserOrKernelBuffer&, OpenFileDescription*) const { return Error::from_errno(ENOTIMPL); }
|
||||
|
@ -52,6 +54,8 @@ protected:
|
|||
|
||||
RefPtr<SysFSDirectory> m_parent_directory;
|
||||
|
||||
IntrusiveListNode<SysFSComponent, NonnullRefPtr<SysFSComponent>> m_list_node;
|
||||
|
||||
private:
|
||||
InodeIndex m_component_index {};
|
||||
};
|
||||
|
@ -72,17 +76,19 @@ protected:
|
|||
|
||||
class SysFSDirectory : public SysFSComponent {
|
||||
public:
|
||||
virtual ErrorOr<void> traverse_as_directory(FileSystemID, Function<ErrorOr<void>(FileSystem::DirectoryEntryView const&)>) const override;
|
||||
virtual RefPtr<SysFSComponent> lookup(StringView name) override;
|
||||
virtual ErrorOr<void> traverse_as_directory(FileSystemID, Function<ErrorOr<void>(FileSystem::DirectoryEntryView const&)>) const override final;
|
||||
virtual RefPtr<SysFSComponent> lookup(StringView name) override final;
|
||||
|
||||
virtual ErrorOr<NonnullRefPtr<SysFSInode>> to_inode(SysFS const& sysfs_instance) const override final;
|
||||
|
||||
using ChildList = SpinlockProtected<IntrusiveList<&SysFSComponent::m_list_node>>;
|
||||
|
||||
protected:
|
||||
virtual bool is_root_directory() const { return false; }
|
||||
|
||||
SysFSDirectory() {};
|
||||
explicit SysFSDirectory(SysFSDirectory const& parent_directory);
|
||||
NonnullRefPtrVector<SysFSComponent> m_components;
|
||||
|
||||
mutable Mutex m_traverse_lock;
|
||||
ChildList m_child_components;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue