mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 15:57:45 +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,12 +9,12 @@
|
|||
#include <AK/AtomicRefCounted.h>
|
||||
#include <AK/Error.h>
|
||||
#include <AK/Function.h>
|
||||
#include <AK/RefPtr.h>
|
||||
#include <AK/Types.h>
|
||||
#include <Kernel/FileSystem/File.h>
|
||||
#include <Kernel/FileSystem/FileSystem.h>
|
||||
#include <Kernel/FileSystem/OpenFileDescription.h>
|
||||
#include <Kernel/KBufferBuilder.h>
|
||||
#include <Kernel/Library/LockRefPtr.h>
|
||||
#include <Kernel/Time/TimeManagement.h>
|
||||
#include <Kernel/UserOrKernelBuffer.h>
|
||||
|
||||
|
@ -63,7 +63,7 @@ public:
|
|||
|
||||
private:
|
||||
Mutex m_lock;
|
||||
NonnullRefPtr<ProcFSRootDirectory> m_root_directory;
|
||||
NonnullLockRefPtr<ProcFSRootDirectory> m_root_directory;
|
||||
};
|
||||
|
||||
class ProcFSExposedComponent : public AtomicRefCounted<ProcFSExposedComponent> {
|
||||
|
@ -71,7 +71,7 @@ public:
|
|||
StringView name() const { return m_name->view(); }
|
||||
virtual ErrorOr<size_t> read_bytes(off_t, size_t, UserOrKernelBuffer&, OpenFileDescription*) const { VERIFY_NOT_REACHED(); }
|
||||
virtual ErrorOr<void> traverse_as_directory(FileSystemID, Function<ErrorOr<void>(FileSystem::DirectoryEntryView const&)>) const { VERIFY_NOT_REACHED(); }
|
||||
virtual ErrorOr<NonnullRefPtr<ProcFSExposedComponent>> lookup(StringView) { VERIFY_NOT_REACHED(); };
|
||||
virtual ErrorOr<NonnullLockRefPtr<ProcFSExposedComponent>> lookup(StringView) { VERIFY_NOT_REACHED(); };
|
||||
virtual ErrorOr<size_t> write_bytes(off_t, size_t, UserOrKernelBuffer const&, OpenFileDescription*) { return EROFS; }
|
||||
virtual ErrorOr<void> truncate(u64) { return EPERM; }
|
||||
virtual ErrorOr<void> set_mtime(time_t) { return ENOTIMPL; }
|
||||
|
@ -87,7 +87,7 @@ public:
|
|||
return {};
|
||||
}
|
||||
|
||||
virtual ErrorOr<NonnullRefPtr<Inode>> to_inode(ProcFS const& procfs_instance) const;
|
||||
virtual ErrorOr<NonnullLockRefPtr<Inode>> to_inode(ProcFS const& procfs_instance) const;
|
||||
|
||||
virtual InodeIndex component_index() const { return m_component_index; }
|
||||
|
||||
|
@ -104,12 +104,12 @@ private:
|
|||
|
||||
class ProcFSExposedDirectory
|
||||
: public ProcFSExposedComponent
|
||||
, public Weakable<ProcFSExposedDirectory> {
|
||||
, public LockWeakable<ProcFSExposedDirectory> {
|
||||
friend class ProcFSComponentRegistry;
|
||||
|
||||
public:
|
||||
virtual ErrorOr<void> traverse_as_directory(FileSystemID, Function<ErrorOr<void>(FileSystem::DirectoryEntryView const&)>) const override;
|
||||
virtual ErrorOr<NonnullRefPtr<ProcFSExposedComponent>> lookup(StringView name) override;
|
||||
virtual ErrorOr<NonnullLockRefPtr<ProcFSExposedComponent>> lookup(StringView name) override;
|
||||
void add_component(ProcFSExposedComponent const&);
|
||||
|
||||
virtual void prepare_for_deletion() override
|
||||
|
@ -120,18 +120,18 @@ public:
|
|||
}
|
||||
virtual mode_t required_mode() const override { return 0555; }
|
||||
|
||||
virtual ErrorOr<NonnullRefPtr<Inode>> to_inode(ProcFS const& procfs_instance) const override final;
|
||||
virtual ErrorOr<NonnullLockRefPtr<Inode>> to_inode(ProcFS const& procfs_instance) const override final;
|
||||
|
||||
protected:
|
||||
explicit ProcFSExposedDirectory(StringView name);
|
||||
ProcFSExposedDirectory(StringView name, ProcFSExposedDirectory const& parent_directory);
|
||||
NonnullRefPtrVector<ProcFSExposedComponent> m_components;
|
||||
WeakPtr<ProcFSExposedDirectory> m_parent_directory;
|
||||
NonnullLockRefPtrVector<ProcFSExposedComponent> m_components;
|
||||
LockWeakPtr<ProcFSExposedDirectory> m_parent_directory;
|
||||
};
|
||||
|
||||
class ProcFSExposedLink : public ProcFSExposedComponent {
|
||||
public:
|
||||
virtual ErrorOr<NonnullRefPtr<Inode>> to_inode(ProcFS const& procfs_instance) const override final;
|
||||
virtual ErrorOr<NonnullLockRefPtr<Inode>> to_inode(ProcFS const& procfs_instance) const override final;
|
||||
|
||||
virtual ErrorOr<size_t> read_bytes(off_t offset, size_t count, UserOrKernelBuffer& buffer, OpenFileDescription* description) const override;
|
||||
|
||||
|
@ -149,8 +149,8 @@ class ProcFSRootDirectory final : public ProcFSExposedDirectory {
|
|||
friend class ProcFSComponentRegistry;
|
||||
|
||||
public:
|
||||
virtual ErrorOr<NonnullRefPtr<ProcFSExposedComponent>> lookup(StringView name) override;
|
||||
static NonnullRefPtr<ProcFSRootDirectory> must_create();
|
||||
virtual ErrorOr<NonnullLockRefPtr<ProcFSExposedComponent>> lookup(StringView name) override;
|
||||
static NonnullLockRefPtr<ProcFSRootDirectory> must_create();
|
||||
|
||||
virtual ~ProcFSRootDirectory();
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue