mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 21:08:12 +00:00
Kernel: Make self-contained locking smart pointers their own classes
Until now, our kernel has reimplemented a number of AK classes to provide automatic internal locking: - RefPtr - NonnullRefPtr - WeakPtr - Weakable This patch renames the Kernel classes so that they can coexist with the original AK classes: - RefPtr => LockRefPtr - NonnullRefPtr => NonnullLockRefPtr - WeakPtr => LockWeakPtr - Weakable => LockWeakable The goal here is to eventually get rid of the Lock* classes in favor of using external locking.
This commit is contained in:
parent
e475263113
commit
11eee67b85
360 changed files with 1703 additions and 1672 deletions
|
@ -9,13 +9,13 @@
|
|||
#include <AK/AtomicRefCounted.h>
|
||||
#include <AK/Error.h>
|
||||
#include <AK/Function.h>
|
||||
#include <AK/RefPtr.h>
|
||||
#include <AK/StringView.h>
|
||||
#include <AK/Types.h>
|
||||
#include <Kernel/FileSystem/File.h>
|
||||
#include <Kernel/FileSystem/FileSystem.h>
|
||||
#include <Kernel/FileSystem/OpenFileDescription.h>
|
||||
#include <Kernel/Forward.h>
|
||||
#include <Kernel/Library/LockRefPtr.h>
|
||||
|
||||
namespace Kernel {
|
||||
|
||||
|
@ -31,7 +31,7 @@ public:
|
|||
virtual StringView name() const = 0;
|
||||
virtual ErrorOr<size_t> read_bytes(off_t, size_t, UserOrKernelBuffer&, OpenFileDescription*) const { return Error::from_errno(ENOTIMPL); }
|
||||
virtual ErrorOr<void> traverse_as_directory(FileSystemID, Function<ErrorOr<void>(FileSystem::DirectoryEntryView const&)>) const { VERIFY_NOT_REACHED(); }
|
||||
virtual RefPtr<SysFSComponent> lookup(StringView) { VERIFY_NOT_REACHED(); };
|
||||
virtual LockRefPtr<SysFSComponent> lookup(StringView) { VERIFY_NOT_REACHED(); };
|
||||
virtual mode_t permissions() const;
|
||||
virtual ErrorOr<void> truncate(u64) { return EPERM; }
|
||||
virtual size_t size() const { return 0; }
|
||||
|
@ -39,7 +39,7 @@ public:
|
|||
virtual ErrorOr<size_t> write_bytes(off_t, size_t, UserOrKernelBuffer const&, OpenFileDescription*) { return EROFS; }
|
||||
virtual ErrorOr<void> refresh_data(OpenFileDescription&) const { return {}; }
|
||||
|
||||
virtual ErrorOr<NonnullRefPtr<SysFSInode>> to_inode(SysFS const&) const;
|
||||
virtual ErrorOr<NonnullLockRefPtr<SysFSInode>> to_inode(SysFS const&) const;
|
||||
|
||||
InodeIndex component_index() const { return m_component_index; };
|
||||
|
||||
|
@ -52,9 +52,9 @@ protected:
|
|||
explicit SysFSComponent(SysFSDirectory const& parent_directory);
|
||||
SysFSComponent();
|
||||
|
||||
RefPtr<SysFSDirectory> m_parent_directory;
|
||||
LockRefPtr<SysFSDirectory> m_parent_directory;
|
||||
|
||||
IntrusiveListNode<SysFSComponent, NonnullRefPtr<SysFSComponent>> m_list_node;
|
||||
IntrusiveListNode<SysFSComponent, NonnullLockRefPtr<SysFSComponent>> m_list_node;
|
||||
|
||||
private:
|
||||
InodeIndex m_component_index {};
|
||||
|
@ -63,7 +63,7 @@ private:
|
|||
class SysFSSymbolicLink : public SysFSComponent {
|
||||
public:
|
||||
virtual ErrorOr<size_t> read_bytes(off_t, size_t, UserOrKernelBuffer&, OpenFileDescription*) const override final;
|
||||
virtual ErrorOr<NonnullRefPtr<SysFSInode>> to_inode(SysFS const& sysfs_instance) const override final;
|
||||
virtual ErrorOr<NonnullLockRefPtr<SysFSInode>> to_inode(SysFS const& sysfs_instance) const override final;
|
||||
|
||||
protected:
|
||||
ErrorOr<NonnullOwnPtr<KString>> try_generate_return_path_to_mount_point() const;
|
||||
|
@ -71,15 +71,15 @@ protected:
|
|||
|
||||
explicit SysFSSymbolicLink(SysFSDirectory const& parent_directory, SysFSComponent const& pointed_component);
|
||||
|
||||
RefPtr<SysFSComponent> m_pointed_component;
|
||||
LockRefPtr<SysFSComponent> m_pointed_component;
|
||||
};
|
||||
|
||||
class SysFSDirectory : public SysFSComponent {
|
||||
public:
|
||||
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 LockRefPtr<SysFSComponent> lookup(StringView name) override final;
|
||||
|
||||
virtual ErrorOr<NonnullRefPtr<SysFSInode>> to_inode(SysFS const& sysfs_instance) const override final;
|
||||
virtual ErrorOr<NonnullLockRefPtr<SysFSInode>> to_inode(SysFS const& sysfs_instance) const override final;
|
||||
|
||||
using ChildList = SpinlockProtected<IntrusiveList<&SysFSComponent::m_list_node>>;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue