1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 06:48: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:
Andreas Kling 2022-08-19 20:53:40 +02:00
parent e475263113
commit 11eee67b85
360 changed files with 1703 additions and 1672 deletions

View file

@ -12,9 +12,9 @@
namespace Kernel {
ErrorOr<NonnullRefPtr<FileSystem>> DevPtsFS::try_create()
ErrorOr<NonnullLockRefPtr<FileSystem>> DevPtsFS::try_create()
{
return TRY(adopt_nonnull_ref_or_enomem(new (nothrow) DevPtsFS));
return TRY(adopt_nonnull_lock_ref_or_enomem(new (nothrow) DevPtsFS));
}
DevPtsFS::DevPtsFS() = default;
@ -22,7 +22,7 @@ DevPtsFS::~DevPtsFS() = default;
ErrorOr<void> DevPtsFS::initialize()
{
m_root_inode = TRY(adopt_nonnull_ref_or_enomem(new (nothrow) DevPtsFSInode(*this, 1, nullptr)));
m_root_inode = TRY(adopt_nonnull_lock_ref_or_enomem(new (nothrow) DevPtsFSInode(*this, 1, nullptr)));
m_root_inode->m_metadata.inode = { fsid(), 1 };
m_root_inode->m_metadata.mode = 0040555;
m_root_inode->m_metadata.uid = 0;
@ -48,7 +48,7 @@ Inode& DevPtsFS::root_inode()
return *m_root_inode;
}
ErrorOr<NonnullRefPtr<Inode>> DevPtsFS::get_inode(InodeIdentifier inode_id) const
ErrorOr<NonnullLockRefPtr<Inode>> DevPtsFS::get_inode(InodeIdentifier inode_id) const
{
if (inode_id.index() == 1)
return *m_root_inode;
@ -57,7 +57,7 @@ ErrorOr<NonnullRefPtr<Inode>> DevPtsFS::get_inode(InodeIdentifier inode_id) cons
auto* device = DeviceManagement::the().get_device(201, pty_index);
VERIFY(device);
auto inode = TRY(adopt_nonnull_ref_or_enomem(new (nothrow) DevPtsFSInode(const_cast<DevPtsFS&>(*this), inode_id.index(), static_cast<SlavePTY*>(device))));
auto inode = TRY(adopt_nonnull_lock_ref_or_enomem(new (nothrow) DevPtsFSInode(const_cast<DevPtsFS&>(*this), inode_id.index(), static_cast<SlavePTY*>(device))));
inode->m_metadata.inode = inode_id;
inode->m_metadata.size = 0;
inode->m_metadata.uid = device->uid();
@ -117,7 +117,7 @@ ErrorOr<void> DevPtsFSInode::traverse_as_directory(Function<ErrorOr<void>(FileSy
});
}
ErrorOr<NonnullRefPtr<Inode>> DevPtsFSInode::lookup(StringView name)
ErrorOr<NonnullLockRefPtr<Inode>> DevPtsFSInode::lookup(StringView name)
{
VERIFY(identifier().index() == 1);
@ -128,7 +128,7 @@ ErrorOr<NonnullRefPtr<Inode>> DevPtsFSInode::lookup(StringView name)
if (!pty_index.has_value())
return ENOENT;
return SlavePTY::all_instances().with([&](auto& list) -> ErrorOr<NonnullRefPtr<Inode>> {
return SlavePTY::all_instances().with([&](auto& list) -> ErrorOr<NonnullLockRefPtr<Inode>> {
for (SlavePTY& slave_pty : list) {
if (slave_pty.index() != pty_index.value())
continue;
@ -148,7 +148,7 @@ ErrorOr<void> DevPtsFSInode::add_child(Inode&, StringView, mode_t)
return EROFS;
}
ErrorOr<NonnullRefPtr<Inode>> DevPtsFSInode::create_child(StringView, mode_t, dev_t, UserID, GroupID)
ErrorOr<NonnullLockRefPtr<Inode>> DevPtsFSInode::create_child(StringView, mode_t, dev_t, UserID, GroupID)
{
return EROFS;
}