diff --git a/Kernel/FileSystem/Custody.cpp b/Kernel/FileSystem/Custody.cpp index 84b7479c33..81532d731f 100644 --- a/Kernel/FileSystem/Custody.cpp +++ b/Kernel/FileSystem/Custody.cpp @@ -10,20 +10,19 @@ #include #include #include -#include namespace Kernel { -static Singleton> s_all_custodies; +static Singleton> s_all_instances; -static MutexProtected& all_custodies() +MutexProtected& Custody::all_instances() { - return s_all_custodies; + return s_all_instances; } ErrorOr> Custody::try_create(Custody* parent, StringView name, Inode& inode, int mount_flags) { - return all_custodies().with_exclusive([&](auto& all_custodies) -> ErrorOr> { + return all_instances().with_exclusive([&](auto& all_custodies) -> ErrorOr> { for (Custody& custody : all_custodies) { if (custody.parent() == parent && custody.name() == name @@ -40,20 +39,6 @@ ErrorOr> Custody::try_create(Custody* parent, StringView }); } -bool Custody::unref() const -{ - bool should_destroy = all_custodies().with_exclusive([&](auto&) { - if (deref_base()) - return false; - m_all_custodies_list_node.remove(); - return true; - }); - - if (should_destroy) - delete this; - return should_destroy; -} - Custody::Custody(Custody* parent, NonnullOwnPtr name, Inode& inode, int mount_flags) : m_parent(parent) , m_name(move(name)) diff --git a/Kernel/FileSystem/Custody.h b/Kernel/FileSystem/Custody.h index 64a4c4dae1..b688ae660c 100644 --- a/Kernel/FileSystem/Custody.h +++ b/Kernel/FileSystem/Custody.h @@ -8,20 +8,19 @@ #include #include -#include #include #include #include #include +#include +#include namespace Kernel { // FIXME: Custody needs some locking. -class Custody : public RefCountedBase { +class Custody : public ListedRefCounted { public: - bool unref() const; - static ErrorOr> try_create(Custody* parent, StringView name, Inode&, int mount_flags); ~Custody(); @@ -49,6 +48,7 @@ private: public: using AllCustodiesList = IntrusiveList<&Custody::m_all_custodies_list_node>; + static MutexProtected& all_instances(); }; }