mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 05:47:34 +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
|
@ -10,7 +10,7 @@
|
|||
|
||||
namespace Kernel {
|
||||
|
||||
AnonymousFile::AnonymousFile(NonnullRefPtr<Memory::AnonymousVMObject> vmobject)
|
||||
AnonymousFile::AnonymousFile(NonnullLockRefPtr<Memory::AnonymousVMObject> vmobject)
|
||||
: m_vmobject(move(vmobject))
|
||||
{
|
||||
}
|
||||
|
|
|
@ -13,9 +13,9 @@ namespace Kernel {
|
|||
|
||||
class AnonymousFile final : public File {
|
||||
public:
|
||||
static ErrorOr<NonnullRefPtr<AnonymousFile>> try_create(NonnullRefPtr<Memory::AnonymousVMObject> vmobject)
|
||||
static ErrorOr<NonnullLockRefPtr<AnonymousFile>> try_create(NonnullLockRefPtr<Memory::AnonymousVMObject> vmobject)
|
||||
{
|
||||
return adopt_nonnull_ref_or_enomem(new (nothrow) AnonymousFile(move(vmobject)));
|
||||
return adopt_nonnull_lock_ref_or_enomem(new (nothrow) AnonymousFile(move(vmobject)));
|
||||
}
|
||||
|
||||
virtual ~AnonymousFile() override;
|
||||
|
@ -30,9 +30,9 @@ private:
|
|||
virtual ErrorOr<size_t> read(OpenFileDescription&, u64, UserOrKernelBuffer&, size_t) override { return ENOTSUP; }
|
||||
virtual ErrorOr<size_t> write(OpenFileDescription&, u64, UserOrKernelBuffer const&, size_t) override { return ENOTSUP; }
|
||||
|
||||
explicit AnonymousFile(NonnullRefPtr<Memory::AnonymousVMObject>);
|
||||
explicit AnonymousFile(NonnullLockRefPtr<Memory::AnonymousVMObject>);
|
||||
|
||||
NonnullRefPtr<Memory::AnonymousVMObject> m_vmobject;
|
||||
NonnullLockRefPtr<Memory::AnonymousVMObject> m_vmobject;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -20,20 +20,20 @@ SpinlockProtected<Custody::AllCustodiesList>& Custody::all_instances()
|
|||
return s_all_instances;
|
||||
}
|
||||
|
||||
ErrorOr<NonnullRefPtr<Custody>> Custody::try_create(Custody* parent, StringView name, Inode& inode, int mount_flags)
|
||||
ErrorOr<NonnullLockRefPtr<Custody>> Custody::try_create(Custody* parent, StringView name, Inode& inode, int mount_flags)
|
||||
{
|
||||
return all_instances().with([&](auto& all_custodies) -> ErrorOr<NonnullRefPtr<Custody>> {
|
||||
return all_instances().with([&](auto& all_custodies) -> ErrorOr<NonnullLockRefPtr<Custody>> {
|
||||
for (Custody& custody : all_custodies) {
|
||||
if (custody.parent() == parent
|
||||
&& custody.name() == name
|
||||
&& &custody.inode() == &inode
|
||||
&& custody.mount_flags() == mount_flags) {
|
||||
return NonnullRefPtr { custody };
|
||||
return NonnullLockRefPtr { custody };
|
||||
}
|
||||
}
|
||||
|
||||
auto name_kstring = TRY(KString::try_create(name));
|
||||
auto custody = TRY(adopt_nonnull_ref_or_enomem(new (nothrow) Custody(parent, move(name_kstring), inode, mount_flags)));
|
||||
auto custody = TRY(adopt_nonnull_lock_ref_or_enomem(new (nothrow) Custody(parent, move(name_kstring), inode, mount_flags)));
|
||||
all_custodies.prepend(*custody);
|
||||
return custody;
|
||||
});
|
||||
|
|
|
@ -8,17 +8,17 @@
|
|||
|
||||
#include <AK/Error.h>
|
||||
#include <AK/IntrusiveList.h>
|
||||
#include <AK/RefPtr.h>
|
||||
#include <Kernel/Forward.h>
|
||||
#include <Kernel/KString.h>
|
||||
#include <Kernel/Library/ListedRefCounted.h>
|
||||
#include <Kernel/Library/LockRefPtr.h>
|
||||
#include <Kernel/Locking/SpinlockProtected.h>
|
||||
|
||||
namespace Kernel {
|
||||
|
||||
class Custody : public ListedRefCounted<Custody, LockType::Spinlock> {
|
||||
public:
|
||||
static ErrorOr<NonnullRefPtr<Custody>> try_create(Custody* parent, StringView name, Inode&, int mount_flags);
|
||||
static ErrorOr<NonnullLockRefPtr<Custody>> try_create(Custody* parent, StringView name, Inode&, int mount_flags);
|
||||
|
||||
~Custody();
|
||||
|
||||
|
@ -35,9 +35,9 @@ public:
|
|||
private:
|
||||
Custody(Custody* parent, NonnullOwnPtr<KString> name, Inode&, int mount_flags);
|
||||
|
||||
RefPtr<Custody> m_parent;
|
||||
LockRefPtr<Custody> m_parent;
|
||||
NonnullOwnPtr<KString> m_name;
|
||||
NonnullRefPtr<Inode> m_inode;
|
||||
NonnullLockRefPtr<Inode> m_inode;
|
||||
int m_mount_flags { 0 };
|
||||
|
||||
mutable IntrusiveListNode<Custody> m_all_custodies_list_node;
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -20,7 +20,7 @@ class DevPtsFS final : public FileSystem {
|
|||
|
||||
public:
|
||||
virtual ~DevPtsFS() override;
|
||||
static ErrorOr<NonnullRefPtr<FileSystem>> try_create();
|
||||
static ErrorOr<NonnullLockRefPtr<FileSystem>> try_create();
|
||||
|
||||
virtual ErrorOr<void> initialize() override;
|
||||
virtual StringView class_name() const override { return "DevPtsFS"sv; }
|
||||
|
@ -29,9 +29,9 @@ public:
|
|||
|
||||
private:
|
||||
DevPtsFS();
|
||||
ErrorOr<NonnullRefPtr<Inode>> get_inode(InodeIdentifier) const;
|
||||
ErrorOr<NonnullLockRefPtr<Inode>> get_inode(InodeIdentifier) const;
|
||||
|
||||
RefPtr<DevPtsFSInode> m_root_inode;
|
||||
LockRefPtr<DevPtsFSInode> m_root_inode;
|
||||
};
|
||||
|
||||
class DevPtsFSInode final : public Inode {
|
||||
|
@ -50,16 +50,16 @@ private:
|
|||
virtual ErrorOr<size_t> read_bytes(off_t, size_t, UserOrKernelBuffer& buffer, OpenFileDescription*) const override;
|
||||
virtual InodeMetadata metadata() const override;
|
||||
virtual ErrorOr<void> traverse_as_directory(Function<ErrorOr<void>(FileSystem::DirectoryEntryView const&)>) const override;
|
||||
virtual ErrorOr<NonnullRefPtr<Inode>> lookup(StringView name) override;
|
||||
virtual ErrorOr<NonnullLockRefPtr<Inode>> lookup(StringView name) override;
|
||||
virtual ErrorOr<void> flush_metadata() override;
|
||||
virtual ErrorOr<size_t> write_bytes(off_t, size_t, UserOrKernelBuffer const& buffer, OpenFileDescription*) override;
|
||||
virtual ErrorOr<NonnullRefPtr<Inode>> create_child(StringView name, mode_t, dev_t, UserID, GroupID) override;
|
||||
virtual ErrorOr<NonnullLockRefPtr<Inode>> create_child(StringView name, mode_t, dev_t, UserID, GroupID) override;
|
||||
virtual ErrorOr<void> add_child(Inode&, StringView name, mode_t) override;
|
||||
virtual ErrorOr<void> remove_child(StringView name) override;
|
||||
virtual ErrorOr<void> chmod(mode_t) override;
|
||||
virtual ErrorOr<void> chown(UserID, GroupID) override;
|
||||
|
||||
WeakPtr<SlavePTY> m_pty;
|
||||
LockWeakPtr<SlavePTY> m_pty;
|
||||
InodeMetadata m_metadata;
|
||||
};
|
||||
|
||||
|
|
|
@ -11,9 +11,9 @@
|
|||
|
||||
namespace Kernel {
|
||||
|
||||
ErrorOr<NonnullRefPtr<FileSystem>> DevTmpFS::try_create()
|
||||
ErrorOr<NonnullLockRefPtr<FileSystem>> DevTmpFS::try_create()
|
||||
{
|
||||
return TRY(adopt_nonnull_ref_or_enomem(new (nothrow) DevTmpFS));
|
||||
return TRY(adopt_nonnull_lock_ref_or_enomem(new (nothrow) DevTmpFS));
|
||||
}
|
||||
|
||||
DevTmpFS::DevTmpFS() = default;
|
||||
|
@ -30,7 +30,7 @@ DevTmpFS::~DevTmpFS() = default;
|
|||
|
||||
ErrorOr<void> DevTmpFS::initialize()
|
||||
{
|
||||
m_root_inode = TRY(adopt_nonnull_ref_or_enomem(new (nothrow) DevTmpFSRootDirectoryInode(*this)));
|
||||
m_root_inode = TRY(adopt_nonnull_lock_ref_or_enomem(new (nothrow) DevTmpFSRootDirectoryInode(*this)));
|
||||
return {};
|
||||
}
|
||||
|
||||
|
@ -61,7 +61,7 @@ ErrorOr<void> DevTmpFSInode::traverse_as_directory(Function<ErrorOr<void>(FileSy
|
|||
VERIFY_NOT_REACHED();
|
||||
}
|
||||
|
||||
ErrorOr<NonnullRefPtr<Inode>> DevTmpFSInode::lookup(StringView)
|
||||
ErrorOr<NonnullLockRefPtr<Inode>> DevTmpFSInode::lookup(StringView)
|
||||
{
|
||||
VERIFY_NOT_REACHED();
|
||||
}
|
||||
|
@ -76,7 +76,7 @@ ErrorOr<size_t> DevTmpFSInode::write_bytes(off_t, size_t, UserOrKernelBuffer con
|
|||
VERIFY_NOT_REACHED();
|
||||
}
|
||||
|
||||
ErrorOr<NonnullRefPtr<Inode>> DevTmpFSInode::create_child(StringView, mode_t, dev_t, UserID, GroupID)
|
||||
ErrorOr<NonnullLockRefPtr<Inode>> DevTmpFSInode::create_child(StringView, mode_t, dev_t, UserID, GroupID)
|
||||
{
|
||||
VERIFY_NOT_REACHED();
|
||||
}
|
||||
|
@ -214,7 +214,7 @@ ErrorOr<void> DevTmpFSDirectoryInode::traverse_as_directory(Function<ErrorOr<voi
|
|||
return {};
|
||||
}
|
||||
|
||||
ErrorOr<NonnullRefPtr<Inode>> DevTmpFSDirectoryInode::lookup(StringView name)
|
||||
ErrorOr<NonnullLockRefPtr<Inode>> DevTmpFSDirectoryInode::lookup(StringView name)
|
||||
{
|
||||
MutexLocker locker(m_inode_lock);
|
||||
for (auto& node : m_nodes) {
|
||||
|
@ -237,7 +237,7 @@ ErrorOr<void> DevTmpFSDirectoryInode::remove_child(StringView name)
|
|||
return Error::from_errno(ENOENT);
|
||||
}
|
||||
|
||||
ErrorOr<NonnullRefPtr<Inode>> DevTmpFSDirectoryInode::create_child(StringView name, mode_t mode, dev_t device_mode, UserID, GroupID)
|
||||
ErrorOr<NonnullLockRefPtr<Inode>> DevTmpFSDirectoryInode::create_child(StringView name, mode_t mode, dev_t device_mode, UserID, GroupID)
|
||||
{
|
||||
MutexLocker locker(m_inode_lock);
|
||||
for (auto& node : m_nodes) {
|
||||
|
@ -249,7 +249,7 @@ ErrorOr<NonnullRefPtr<Inode>> DevTmpFSDirectoryInode::create_child(StringView na
|
|||
metadata.mode = mode;
|
||||
if (metadata.is_directory()) {
|
||||
auto name_kstring = TRY(KString::try_create(name));
|
||||
auto new_directory_inode = TRY(adopt_nonnull_ref_or_enomem(new (nothrow) DevTmpFSDirectoryInode(fs(), move(name_kstring))));
|
||||
auto new_directory_inode = TRY(adopt_nonnull_lock_ref_or_enomem(new (nothrow) DevTmpFSDirectoryInode(fs(), move(name_kstring))));
|
||||
TRY(new_directory_inode->chmod(mode));
|
||||
m_nodes.append(*new_directory_inode);
|
||||
return new_directory_inode;
|
||||
|
@ -258,14 +258,14 @@ ErrorOr<NonnullRefPtr<Inode>> DevTmpFSDirectoryInode::create_child(StringView na
|
|||
auto name_kstring = TRY(KString::try_create(name));
|
||||
auto major = major_from_encoded_device(device_mode);
|
||||
auto minor = minor_from_encoded_device(device_mode);
|
||||
auto new_device_inode = TRY(adopt_nonnull_ref_or_enomem(new (nothrow) DevTmpFSDeviceInode(fs(), major, minor, is_block_device(mode), move(name_kstring))));
|
||||
auto new_device_inode = TRY(adopt_nonnull_lock_ref_or_enomem(new (nothrow) DevTmpFSDeviceInode(fs(), major, minor, is_block_device(mode), move(name_kstring))));
|
||||
TRY(new_device_inode->chmod(mode));
|
||||
m_nodes.append(*new_device_inode);
|
||||
return new_device_inode;
|
||||
}
|
||||
if (metadata.is_symlink()) {
|
||||
auto name_kstring = TRY(KString::try_create(name));
|
||||
auto new_link_inode = TRY(adopt_nonnull_ref_or_enomem(new (nothrow) DevTmpFSLinkInode(fs(), move(name_kstring))));
|
||||
auto new_link_inode = TRY(adopt_nonnull_lock_ref_or_enomem(new (nothrow) DevTmpFSLinkInode(fs(), move(name_kstring))));
|
||||
TRY(new_link_inode->chmod(mode));
|
||||
m_nodes.append(*new_link_inode);
|
||||
return new_link_inode;
|
||||
|
@ -307,7 +307,7 @@ ErrorOr<size_t> DevTmpFSDeviceInode::read_bytes(off_t offset, size_t count, User
|
|||
{
|
||||
MutexLocker locker(m_inode_lock);
|
||||
VERIFY(!!description);
|
||||
RefPtr<Device> device = DeviceManagement::the().get_device(m_major_number, m_minor_number);
|
||||
LockRefPtr<Device> device = DeviceManagement::the().get_device(m_major_number, m_minor_number);
|
||||
if (!device)
|
||||
return Error::from_errno(ENODEV);
|
||||
if (!device->can_read(*description, offset))
|
||||
|
@ -322,7 +322,7 @@ ErrorOr<size_t> DevTmpFSDeviceInode::write_bytes(off_t offset, size_t count, Use
|
|||
{
|
||||
MutexLocker locker(m_inode_lock);
|
||||
VERIFY(!!description);
|
||||
RefPtr<Device> device = DeviceManagement::the().get_device(m_major_number, m_minor_number);
|
||||
LockRefPtr<Device> device = DeviceManagement::the().get_device(m_major_number, m_minor_number);
|
||||
if (!device)
|
||||
return Error::from_errno(ENODEV);
|
||||
if (!device->can_write(*description, offset))
|
||||
|
|
|
@ -20,7 +20,7 @@ class DevTmpFS final : public FileSystem {
|
|||
|
||||
public:
|
||||
virtual ~DevTmpFS() override;
|
||||
static ErrorOr<NonnullRefPtr<FileSystem>> try_create();
|
||||
static ErrorOr<NonnullLockRefPtr<FileSystem>> try_create();
|
||||
|
||||
virtual ErrorOr<void> initialize() override;
|
||||
virtual StringView class_name() const override { return "DevTmpFS"sv; }
|
||||
|
@ -30,7 +30,7 @@ private:
|
|||
DevTmpFS();
|
||||
size_t allocate_inode_index();
|
||||
|
||||
RefPtr<DevTmpFSRootDirectoryInode> m_root_inode;
|
||||
LockRefPtr<DevTmpFSRootDirectoryInode> m_root_inode;
|
||||
InodeIndex m_next_inode_index { 0 };
|
||||
};
|
||||
|
||||
|
@ -50,11 +50,11 @@ protected:
|
|||
DevTmpFSInode(DevTmpFS&, MajorNumber, MinorNumber);
|
||||
virtual ErrorOr<size_t> read_bytes(off_t, size_t, UserOrKernelBuffer& buffer, OpenFileDescription*) const override;
|
||||
virtual ErrorOr<void> traverse_as_directory(Function<ErrorOr<void>(FileSystem::DirectoryEntryView const&)>) const override;
|
||||
virtual ErrorOr<NonnullRefPtr<Inode>> lookup(StringView name) override;
|
||||
virtual ErrorOr<NonnullLockRefPtr<Inode>> lookup(StringView name) override;
|
||||
virtual ErrorOr<void> flush_metadata() override;
|
||||
virtual InodeMetadata metadata() const override final;
|
||||
virtual ErrorOr<size_t> write_bytes(off_t, size_t, UserOrKernelBuffer const& buffer, OpenFileDescription*) override;
|
||||
virtual ErrorOr<NonnullRefPtr<Inode>> create_child(StringView name, mode_t, dev_t, UserID, GroupID) override;
|
||||
virtual ErrorOr<NonnullLockRefPtr<Inode>> create_child(StringView name, mode_t, dev_t, UserID, GroupID) override;
|
||||
virtual ErrorOr<void> add_child(Inode&, StringView name, mode_t) override;
|
||||
virtual ErrorOr<void> remove_child(StringView name) override;
|
||||
virtual ErrorOr<void> chmod(mode_t) override;
|
||||
|
@ -77,7 +77,7 @@ protected:
|
|||
virtual Type node_type() const = 0;
|
||||
|
||||
private:
|
||||
IntrusiveListNode<DevTmpFSInode, RefPtr<DevTmpFSInode>> m_list_node;
|
||||
IntrusiveListNode<DevTmpFSInode, LockRefPtr<DevTmpFSInode>> m_list_node;
|
||||
};
|
||||
|
||||
class DevTmpFSDeviceInode final : public DevTmpFSInode {
|
||||
|
@ -135,10 +135,10 @@ protected:
|
|||
// ^DevTmpFSInode
|
||||
virtual Type node_type() const override { return Type::Directory; }
|
||||
|
||||
virtual ErrorOr<NonnullRefPtr<Inode>> create_child(StringView name, mode_t, dev_t, UserID, GroupID) override;
|
||||
virtual ErrorOr<NonnullLockRefPtr<Inode>> create_child(StringView name, mode_t, dev_t, UserID, GroupID) override;
|
||||
virtual ErrorOr<void> remove_child(StringView name) override;
|
||||
virtual ErrorOr<void> traverse_as_directory(Function<ErrorOr<void>(FileSystem::DirectoryEntryView const&)>) const override;
|
||||
virtual ErrorOr<NonnullRefPtr<Inode>> lookup(StringView name) override;
|
||||
virtual ErrorOr<NonnullLockRefPtr<Inode>> lookup(StringView name) override;
|
||||
DevTmpFSDirectoryInode(DevTmpFS&, NonnullOwnPtr<KString> name);
|
||||
// ^Inode
|
||||
OwnPtr<KString> m_name;
|
||||
|
|
|
@ -49,9 +49,9 @@ static u8 to_ext2_file_type(mode_t mode)
|
|||
return EXT2_FT_UNKNOWN;
|
||||
}
|
||||
|
||||
ErrorOr<NonnullRefPtr<FileSystem>> Ext2FS::try_create(OpenFileDescription& file_description)
|
||||
ErrorOr<NonnullLockRefPtr<FileSystem>> Ext2FS::try_create(OpenFileDescription& file_description)
|
||||
{
|
||||
return TRY(adopt_nonnull_ref_or_enomem(new (nothrow) Ext2FS(file_description)));
|
||||
return TRY(adopt_nonnull_lock_ref_or_enomem(new (nothrow) Ext2FS(file_description)));
|
||||
}
|
||||
|
||||
Ext2FS::Ext2FS(OpenFileDescription& file_description)
|
||||
|
@ -686,7 +686,7 @@ void Ext2FS::flush_writes()
|
|||
// The problem is that they are quite heavy objects, and use a lot of heap memory
|
||||
// for their (child name lookup) and (block list) caches.
|
||||
|
||||
m_inode_cache.remove_all_matching([](InodeIndex, RefPtr<Ext2FSInode> const& cached_inode) {
|
||||
m_inode_cache.remove_all_matching([](InodeIndex, LockRefPtr<Ext2FSInode> const& cached_inode) {
|
||||
// NOTE: If we're asked to look up an inode by number (via get_inode) and it turns out
|
||||
// to not exist, we remember the fact that it doesn't exist by caching a nullptr.
|
||||
// This seems like a reasonable time to uncache ideas about unknown inodes, so do that.
|
||||
|
@ -763,7 +763,7 @@ ErrorOr<void> Ext2FSInode::flush_metadata()
|
|||
return {};
|
||||
}
|
||||
|
||||
ErrorOr<NonnullRefPtr<Inode>> Ext2FS::get_inode(InodeIdentifier inode) const
|
||||
ErrorOr<NonnullLockRefPtr<Inode>> Ext2FS::get_inode(InodeIdentifier inode) const
|
||||
{
|
||||
MutexLocker locker(m_lock);
|
||||
VERIFY(inode.fsid() == fsid());
|
||||
|
@ -773,7 +773,7 @@ ErrorOr<NonnullRefPtr<Inode>> Ext2FS::get_inode(InodeIdentifier inode) const
|
|||
if (it != m_inode_cache.end()) {
|
||||
if (!it->value)
|
||||
return ENOENT;
|
||||
return NonnullRefPtr<Inode> { *it->value };
|
||||
return NonnullLockRefPtr<Inode> { *it->value };
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -789,7 +789,7 @@ ErrorOr<NonnullRefPtr<Inode>> Ext2FS::get_inode(InodeIdentifier inode) const
|
|||
if (!find_block_containing_inode(inode.index(), block_index, offset))
|
||||
return EINVAL;
|
||||
|
||||
auto new_inode = TRY(adopt_nonnull_ref_or_enomem(new (nothrow) Ext2FSInode(const_cast<Ext2FS&>(*this), inode.index())));
|
||||
auto new_inode = TRY(adopt_nonnull_lock_ref_or_enomem(new (nothrow) Ext2FSInode(const_cast<Ext2FS&>(*this), inode.index())));
|
||||
|
||||
auto buffer = UserOrKernelBuffer::for_kernel_buffer(reinterpret_cast<u8*>(&new_inode->m_raw_inode));
|
||||
TRY(read_block(block_index, &buffer, sizeof(ext2_inode), offset));
|
||||
|
@ -1116,7 +1116,7 @@ ErrorOr<void> Ext2FSInode::write_directory(Vector<Ext2FSDirectoryEntry>& entries
|
|||
return {};
|
||||
}
|
||||
|
||||
ErrorOr<NonnullRefPtr<Inode>> Ext2FSInode::create_child(StringView name, mode_t mode, dev_t dev, UserID uid, GroupID gid)
|
||||
ErrorOr<NonnullLockRefPtr<Inode>> Ext2FSInode::create_child(StringView name, mode_t mode, dev_t dev, UserID uid, GroupID gid)
|
||||
{
|
||||
if (::is_directory(mode))
|
||||
return fs().create_directory(*this, name, mode, uid, gid);
|
||||
|
@ -1434,7 +1434,7 @@ ErrorOr<void> Ext2FS::set_block_allocation_state(BlockIndex block_index, bool ne
|
|||
return update_bitmap_block(bgd.bg_block_bitmap, bit_index, new_state, m_super_block.s_free_blocks_count, bgd.bg_free_blocks_count);
|
||||
}
|
||||
|
||||
ErrorOr<NonnullRefPtr<Inode>> Ext2FS::create_directory(Ext2FSInode& parent_inode, StringView name, mode_t mode, UserID uid, GroupID gid)
|
||||
ErrorOr<NonnullLockRefPtr<Inode>> Ext2FS::create_directory(Ext2FSInode& parent_inode, StringView name, mode_t mode, UserID uid, GroupID gid)
|
||||
{
|
||||
MutexLocker locker(m_lock);
|
||||
VERIFY(is_directory(mode));
|
||||
|
@ -1459,7 +1459,7 @@ ErrorOr<NonnullRefPtr<Inode>> Ext2FS::create_directory(Ext2FSInode& parent_inode
|
|||
return inode;
|
||||
}
|
||||
|
||||
ErrorOr<NonnullRefPtr<Inode>> Ext2FS::create_inode(Ext2FSInode& parent_inode, StringView name, mode_t mode, dev_t dev, UserID uid, GroupID gid)
|
||||
ErrorOr<NonnullLockRefPtr<Inode>> Ext2FS::create_inode(Ext2FSInode& parent_inode, StringView name, mode_t mode, dev_t dev, UserID uid, GroupID gid)
|
||||
{
|
||||
if (name.length() > EXT2_NAME_LEN)
|
||||
return ENAMETOOLONG;
|
||||
|
@ -1517,7 +1517,7 @@ ErrorOr<void> Ext2FSInode::populate_lookup_cache() const
|
|||
return {};
|
||||
}
|
||||
|
||||
ErrorOr<NonnullRefPtr<Inode>> Ext2FSInode::lookup(StringView name)
|
||||
ErrorOr<NonnullLockRefPtr<Inode>> Ext2FSInode::lookup(StringView name)
|
||||
{
|
||||
VERIFY(is_directory());
|
||||
dbgln_if(EXT2_DEBUG, "Ext2FSInode[{}]:lookup(): Looking up '{}'", identifier(), name);
|
||||
|
|
|
@ -38,10 +38,10 @@ private:
|
|||
virtual ErrorOr<size_t> read_bytes(off_t, size_t, UserOrKernelBuffer& buffer, OpenFileDescription*) const override;
|
||||
virtual InodeMetadata metadata() const override;
|
||||
virtual ErrorOr<void> traverse_as_directory(Function<ErrorOr<void>(FileSystem::DirectoryEntryView const&)>) const override;
|
||||
virtual ErrorOr<NonnullRefPtr<Inode>> lookup(StringView name) override;
|
||||
virtual ErrorOr<NonnullLockRefPtr<Inode>> lookup(StringView name) override;
|
||||
virtual ErrorOr<void> flush_metadata() override;
|
||||
virtual ErrorOr<size_t> write_bytes(off_t, size_t, UserOrKernelBuffer const& data, OpenFileDescription*) override;
|
||||
virtual ErrorOr<NonnullRefPtr<Inode>> create_child(StringView name, mode_t, dev_t, UserID, GroupID) override;
|
||||
virtual ErrorOr<NonnullLockRefPtr<Inode>> create_child(StringView name, mode_t, dev_t, UserID, GroupID) override;
|
||||
virtual ErrorOr<void> add_child(Inode& child, StringView name, mode_t) override;
|
||||
virtual ErrorOr<void> remove_child(StringView name) override;
|
||||
virtual ErrorOr<void> set_atime(time_t) override;
|
||||
|
@ -86,7 +86,7 @@ public:
|
|||
FileSize64bits = 1 << 1,
|
||||
};
|
||||
|
||||
static ErrorOr<NonnullRefPtr<FileSystem>> try_create(OpenFileDescription&);
|
||||
static ErrorOr<NonnullLockRefPtr<FileSystem>> try_create(OpenFileDescription&);
|
||||
|
||||
virtual ~Ext2FS() override;
|
||||
virtual ErrorOr<void> initialize() override;
|
||||
|
@ -126,9 +126,9 @@ private:
|
|||
|
||||
virtual StringView class_name() const override { return "Ext2FS"sv; }
|
||||
virtual Ext2FSInode& root_inode() override;
|
||||
ErrorOr<NonnullRefPtr<Inode>> get_inode(InodeIdentifier) const;
|
||||
ErrorOr<NonnullRefPtr<Inode>> create_inode(Ext2FSInode& parent_inode, StringView name, mode_t, dev_t, UserID, GroupID);
|
||||
ErrorOr<NonnullRefPtr<Inode>> create_directory(Ext2FSInode& parent_inode, StringView name, mode_t, UserID, GroupID);
|
||||
ErrorOr<NonnullLockRefPtr<Inode>> get_inode(InodeIdentifier) const;
|
||||
ErrorOr<NonnullLockRefPtr<Inode>> create_inode(Ext2FSInode& parent_inode, StringView name, mode_t, dev_t, UserID, GroupID);
|
||||
ErrorOr<NonnullLockRefPtr<Inode>> create_directory(Ext2FSInode& parent_inode, StringView name, mode_t, UserID, GroupID);
|
||||
virtual void flush_writes() override;
|
||||
|
||||
BlockIndex first_block_index() const;
|
||||
|
@ -159,7 +159,7 @@ private:
|
|||
mutable ext2_super_block m_super_block {};
|
||||
mutable OwnPtr<KBuffer> m_cached_group_descriptor_table;
|
||||
|
||||
mutable HashMap<InodeIndex, RefPtr<Ext2FSInode>> m_inode_cache;
|
||||
mutable HashMap<InodeIndex, LockRefPtr<Ext2FSInode>> m_inode_cache;
|
||||
|
||||
bool m_super_block_dirty { false };
|
||||
bool m_block_group_descriptors_dirty { false };
|
||||
|
@ -180,7 +180,7 @@ private:
|
|||
ErrorOr<void> update_bitmap_block(BlockIndex bitmap_block, size_t bit_index, bool new_state, u32& super_block_counter, u16& group_descriptor_counter);
|
||||
|
||||
Vector<OwnPtr<CachedBitmap>> m_cached_bitmaps;
|
||||
RefPtr<Ext2FSInode> m_root_inode;
|
||||
LockRefPtr<Ext2FSInode> m_root_inode;
|
||||
};
|
||||
|
||||
inline Ext2FS& Ext2FSInode::fs()
|
||||
|
|
|
@ -16,13 +16,13 @@ namespace Kernel {
|
|||
|
||||
static Atomic<int> s_next_fifo_id = 1;
|
||||
|
||||
ErrorOr<NonnullRefPtr<FIFO>> FIFO::try_create(UserID uid)
|
||||
ErrorOr<NonnullLockRefPtr<FIFO>> FIFO::try_create(UserID uid)
|
||||
{
|
||||
auto buffer = TRY(DoubleBuffer::try_create("FIFO: Buffer"sv));
|
||||
return adopt_nonnull_ref_or_enomem(new (nothrow) FIFO(uid, move(buffer)));
|
||||
return adopt_nonnull_lock_ref_or_enomem(new (nothrow) FIFO(uid, move(buffer)));
|
||||
}
|
||||
|
||||
ErrorOr<NonnullRefPtr<OpenFileDescription>> FIFO::open_direction(FIFO::Direction direction)
|
||||
ErrorOr<NonnullLockRefPtr<OpenFileDescription>> FIFO::open_direction(FIFO::Direction direction)
|
||||
{
|
||||
auto description = TRY(OpenFileDescription::try_create(*this));
|
||||
attach(direction);
|
||||
|
@ -30,7 +30,7 @@ ErrorOr<NonnullRefPtr<OpenFileDescription>> FIFO::open_direction(FIFO::Direction
|
|||
return description;
|
||||
}
|
||||
|
||||
ErrorOr<NonnullRefPtr<OpenFileDescription>> FIFO::open_direction_blocking(FIFO::Direction direction)
|
||||
ErrorOr<NonnullLockRefPtr<OpenFileDescription>> FIFO::open_direction_blocking(FIFO::Direction direction)
|
||||
{
|
||||
MutexLocker locker(m_open_lock);
|
||||
|
||||
|
|
|
@ -24,13 +24,13 @@ public:
|
|||
Writer
|
||||
};
|
||||
|
||||
static ErrorOr<NonnullRefPtr<FIFO>> try_create(UserID);
|
||||
static ErrorOr<NonnullLockRefPtr<FIFO>> try_create(UserID);
|
||||
virtual ~FIFO() override;
|
||||
|
||||
UserID uid() const { return m_uid; }
|
||||
|
||||
ErrorOr<NonnullRefPtr<OpenFileDescription>> open_direction(Direction);
|
||||
ErrorOr<NonnullRefPtr<OpenFileDescription>> open_direction_blocking(Direction);
|
||||
ErrorOr<NonnullLockRefPtr<OpenFileDescription>> open_direction(Direction);
|
||||
ErrorOr<NonnullLockRefPtr<OpenFileDescription>> open_direction_blocking(Direction);
|
||||
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Woverloaded-virtual"
|
||||
|
|
|
@ -15,7 +15,7 @@ namespace Kernel {
|
|||
File::File() = default;
|
||||
File::~File() = default;
|
||||
|
||||
ErrorOr<NonnullRefPtr<OpenFileDescription>> File::open(int options)
|
||||
ErrorOr<NonnullLockRefPtr<OpenFileDescription>> File::open(int options)
|
||||
{
|
||||
auto description = OpenFileDescription::try_create(*this);
|
||||
if (!description.is_error()) {
|
||||
|
|
|
@ -8,11 +8,11 @@
|
|||
|
||||
#include <AK/AtomicRefCounted.h>
|
||||
#include <AK/Error.h>
|
||||
#include <AK/NonnullRefPtr.h>
|
||||
#include <AK/StringView.h>
|
||||
#include <AK/Types.h>
|
||||
#include <AK/Weakable.h>
|
||||
#include <Kernel/Forward.h>
|
||||
#include <Kernel/Library/LockWeakable.h>
|
||||
#include <Kernel/Library/NonnullLockRefPtr.h>
|
||||
#include <Kernel/UnixTypes.h>
|
||||
#include <Kernel/UserOrKernelBuffer.h>
|
||||
#include <Kernel/VirtualAddress.h>
|
||||
|
@ -72,13 +72,13 @@ public:
|
|||
|
||||
class File
|
||||
: public AtomicRefCounted<File>
|
||||
, public Weakable<File> {
|
||||
, public LockWeakable<File> {
|
||||
public:
|
||||
virtual bool unref() const { return AtomicRefCounted<File>::unref(); }
|
||||
virtual void will_be_destroyed() { }
|
||||
virtual ~File();
|
||||
|
||||
virtual ErrorOr<NonnullRefPtr<OpenFileDescription>> open(int options);
|
||||
virtual ErrorOr<NonnullLockRefPtr<OpenFileDescription>> open(int options);
|
||||
virtual ErrorOr<void> close();
|
||||
|
||||
virtual bool can_read(OpenFileDescription const&, u64) const = 0;
|
||||
|
|
|
@ -26,7 +26,7 @@ protected:
|
|||
private:
|
||||
virtual bool is_file_backed() const override { return true; }
|
||||
|
||||
mutable NonnullRefPtr<OpenFileDescription> m_file_description;
|
||||
mutable NonnullLockRefPtr<OpenFileDescription> m_file_description;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -53,7 +53,7 @@ void FileSystem::sync()
|
|||
{
|
||||
Inode::sync_all();
|
||||
|
||||
NonnullRefPtrVector<FileSystem, 32> file_systems;
|
||||
NonnullLockRefPtrVector<FileSystem, 32> file_systems;
|
||||
{
|
||||
InterruptDisabler disabler;
|
||||
for (auto& it : all_file_systems())
|
||||
|
|
|
@ -8,10 +8,10 @@
|
|||
|
||||
#include <AK/AtomicRefCounted.h>
|
||||
#include <AK/Error.h>
|
||||
#include <AK/RefPtr.h>
|
||||
#include <AK/StringView.h>
|
||||
#include <Kernel/FileSystem/InodeIdentifier.h>
|
||||
#include <Kernel/Forward.h>
|
||||
#include <Kernel/Library/LockRefPtr.h>
|
||||
#include <Kernel/Locking/Mutex.h>
|
||||
#include <Kernel/UnixTypes.h>
|
||||
#include <Kernel/UserOrKernelBuffer.h>
|
||||
|
|
|
@ -8,15 +8,15 @@
|
|||
#include <AK/CharacterTypes.h>
|
||||
#include <AK/Endian.h>
|
||||
#include <AK/HashFunctions.h>
|
||||
#include <AK/NonnullRefPtr.h>
|
||||
#include <AK/OwnPtr.h>
|
||||
#include <AK/RefPtr.h>
|
||||
#include <AK/StringHash.h>
|
||||
#include <AK/StringView.h>
|
||||
#include <Kernel/Debug.h>
|
||||
#include <Kernel/FileSystem/BlockBasedFileSystem.h>
|
||||
#include <Kernel/Forward.h>
|
||||
#include <Kernel/KBuffer.h>
|
||||
#include <Kernel/Library/LockRefPtr.h>
|
||||
#include <Kernel/Library/NonnullLockRefPtr.h>
|
||||
#include <Kernel/UnixTypes.h>
|
||||
#include <Kernel/UserOrKernelBuffer.h>
|
||||
|
||||
|
@ -28,7 +28,7 @@ constexpr u32 logical_sector_size = 2048;
|
|||
constexpr u32 max_cached_directory_entries = 128;
|
||||
|
||||
struct DirectoryState {
|
||||
RefPtr<ISO9660FS::DirectoryEntry> entry;
|
||||
LockRefPtr<ISO9660FS::DirectoryEntry> entry;
|
||||
u32 offset { 0 };
|
||||
};
|
||||
|
||||
|
@ -168,9 +168,9 @@ private:
|
|||
Vector<DirectoryState> m_directory_stack;
|
||||
};
|
||||
|
||||
ErrorOr<NonnullRefPtr<FileSystem>> ISO9660FS::try_create(OpenFileDescription& description)
|
||||
ErrorOr<NonnullLockRefPtr<FileSystem>> ISO9660FS::try_create(OpenFileDescription& description)
|
||||
{
|
||||
return TRY(adopt_nonnull_ref_or_enomem(new (nothrow) ISO9660FS(description)));
|
||||
return TRY(adopt_nonnull_lock_ref_or_enomem(new (nothrow) ISO9660FS(description)));
|
||||
}
|
||||
|
||||
ISO9660FS::ISO9660FS(OpenFileDescription& description)
|
||||
|
@ -360,7 +360,7 @@ ErrorOr<void> ISO9660FS::visit_directory_record(ISO::DirectoryRecordHeader const
|
|||
return {};
|
||||
}
|
||||
|
||||
ErrorOr<NonnullRefPtr<ISO9660FS::DirectoryEntry>> ISO9660FS::directory_entry_for_record(Badge<ISO9660DirectoryIterator>, ISO::DirectoryRecordHeader const* record)
|
||||
ErrorOr<NonnullLockRefPtr<ISO9660FS::DirectoryEntry>> ISO9660FS::directory_entry_for_record(Badge<ISO9660DirectoryIterator>, ISO::DirectoryRecordHeader const* record)
|
||||
{
|
||||
u32 extent_location = LittleEndian { record->extent_location.little };
|
||||
u32 data_length = LittleEndian { record->data_length.little };
|
||||
|
@ -458,9 +458,9 @@ ErrorOr<void> ISO9660Inode::traverse_as_directory(Function<ErrorOr<void>(FileSys
|
|||
});
|
||||
}
|
||||
|
||||
ErrorOr<NonnullRefPtr<Inode>> ISO9660Inode::lookup(StringView name)
|
||||
ErrorOr<NonnullLockRefPtr<Inode>> ISO9660Inode::lookup(StringView name)
|
||||
{
|
||||
RefPtr<Inode> inode;
|
||||
LockRefPtr<Inode> inode;
|
||||
Array<u8, max_file_identifier_length> file_identifier_buffer;
|
||||
|
||||
TRY(fs().visit_directory_record(m_record, [&](ISO::DirectoryRecordHeader const* record) {
|
||||
|
@ -498,7 +498,7 @@ ErrorOr<size_t> ISO9660Inode::write_bytes(off_t, size_t, UserOrKernelBuffer cons
|
|||
return EROFS;
|
||||
}
|
||||
|
||||
ErrorOr<NonnullRefPtr<Inode>> ISO9660Inode::create_child(StringView, mode_t, dev_t, UserID, GroupID)
|
||||
ErrorOr<NonnullLockRefPtr<Inode>> ISO9660Inode::create_child(StringView, mode_t, dev_t, UserID, GroupID)
|
||||
{
|
||||
return EROFS;
|
||||
}
|
||||
|
@ -553,9 +553,9 @@ ISO9660Inode::ISO9660Inode(ISO9660FS& fs, ISO::DirectoryRecordHeader const& reco
|
|||
|
||||
ISO9660Inode::~ISO9660Inode() = default;
|
||||
|
||||
ErrorOr<NonnullRefPtr<ISO9660Inode>> ISO9660Inode::try_create_from_directory_record(ISO9660FS& fs, ISO::DirectoryRecordHeader const& record, StringView name)
|
||||
ErrorOr<NonnullLockRefPtr<ISO9660Inode>> ISO9660Inode::try_create_from_directory_record(ISO9660FS& fs, ISO::DirectoryRecordHeader const& record, StringView name)
|
||||
{
|
||||
return adopt_nonnull_ref_or_enomem(new (nothrow) ISO9660Inode(fs, record, name));
|
||||
return adopt_nonnull_lock_ref_or_enomem(new (nothrow) ISO9660Inode(fs, record, name));
|
||||
}
|
||||
|
||||
void ISO9660Inode::create_metadata()
|
||||
|
|
|
@ -9,13 +9,13 @@
|
|||
#include <AK/EnumBits.h>
|
||||
#include <AK/Error.h>
|
||||
#include <AK/HashMap.h>
|
||||
#include <AK/NonnullRefPtr.h>
|
||||
#include <AK/RecursionDecision.h>
|
||||
#include <AK/StringView.h>
|
||||
#include <AK/Types.h>
|
||||
#include <Kernel/FileSystem/BlockBasedFileSystem.h>
|
||||
#include <Kernel/FileSystem/Inode.h>
|
||||
#include <Kernel/KBuffer.h>
|
||||
#include <Kernel/Library/NonnullLockRefPtr.h>
|
||||
|
||||
namespace Kernel {
|
||||
|
||||
|
@ -291,9 +291,9 @@ public:
|
|||
// We need it as an OwnPtr to default-construct this struct.
|
||||
OwnPtr<KBuffer> blocks;
|
||||
|
||||
static ErrorOr<NonnullRefPtr<DirectoryEntry>> try_create(u32 extent, u32 length, OwnPtr<KBuffer> blocks)
|
||||
static ErrorOr<NonnullLockRefPtr<DirectoryEntry>> try_create(u32 extent, u32 length, OwnPtr<KBuffer> blocks)
|
||||
{
|
||||
return adopt_nonnull_ref_or_enomem(new (nothrow) DirectoryEntry(extent, length, move(blocks)));
|
||||
return adopt_nonnull_lock_ref_or_enomem(new (nothrow) DirectoryEntry(extent, length, move(blocks)));
|
||||
}
|
||||
|
||||
private:
|
||||
|
@ -305,7 +305,7 @@ public:
|
|||
}
|
||||
};
|
||||
|
||||
static ErrorOr<NonnullRefPtr<FileSystem>> try_create(OpenFileDescription&);
|
||||
static ErrorOr<NonnullLockRefPtr<FileSystem>> try_create(OpenFileDescription&);
|
||||
|
||||
virtual ~ISO9660FS() override;
|
||||
virtual ErrorOr<void> initialize() override;
|
||||
|
@ -317,7 +317,7 @@ public:
|
|||
|
||||
virtual u8 internal_file_type_to_directory_entry_type(DirectoryEntryView const& entry) const override;
|
||||
|
||||
ErrorOr<NonnullRefPtr<DirectoryEntry>> directory_entry_for_record(Badge<ISO9660DirectoryIterator>, ISO::DirectoryRecordHeader const* record);
|
||||
ErrorOr<NonnullLockRefPtr<DirectoryEntry>> directory_entry_for_record(Badge<ISO9660DirectoryIterator>, ISO::DirectoryRecordHeader const* record);
|
||||
|
||||
private:
|
||||
ISO9660FS(OpenFileDescription&);
|
||||
|
@ -331,10 +331,10 @@ private:
|
|||
ErrorOr<void> visit_directory_record(ISO::DirectoryRecordHeader const& record, Function<ErrorOr<RecursionDecision>(ISO::DirectoryRecordHeader const*)> const& visitor) const;
|
||||
|
||||
OwnPtr<ISO::PrimaryVolumeDescriptor> m_primary_volume;
|
||||
RefPtr<ISO9660Inode> m_root_inode;
|
||||
LockRefPtr<ISO9660Inode> m_root_inode;
|
||||
|
||||
mutable u32 m_cached_inode_count { 0 };
|
||||
HashMap<u32, NonnullRefPtr<DirectoryEntry>> m_directory_entry_cache;
|
||||
HashMap<u32, NonnullLockRefPtr<DirectoryEntry>> m_directory_entry_cache;
|
||||
};
|
||||
|
||||
class ISO9660Inode final : public Inode {
|
||||
|
@ -350,10 +350,10 @@ public:
|
|||
virtual ErrorOr<size_t> read_bytes(off_t, size_t, UserOrKernelBuffer& buffer, OpenFileDescription*) const override;
|
||||
virtual InodeMetadata metadata() const override;
|
||||
virtual ErrorOr<void> traverse_as_directory(Function<ErrorOr<void>(FileSystem::DirectoryEntryView const&)>) const override;
|
||||
virtual ErrorOr<NonnullRefPtr<Inode>> lookup(StringView name) override;
|
||||
virtual ErrorOr<NonnullLockRefPtr<Inode>> lookup(StringView name) override;
|
||||
virtual ErrorOr<void> flush_metadata() override;
|
||||
virtual ErrorOr<size_t> write_bytes(off_t, size_t, UserOrKernelBuffer const& buffer, OpenFileDescription*) override;
|
||||
virtual ErrorOr<NonnullRefPtr<Inode>> create_child(StringView name, mode_t, dev_t, UserID, GroupID) override;
|
||||
virtual ErrorOr<NonnullLockRefPtr<Inode>> create_child(StringView name, mode_t, dev_t, UserID, GroupID) override;
|
||||
virtual ErrorOr<void> add_child(Inode&, StringView name, mode_t) override;
|
||||
virtual ErrorOr<void> remove_child(StringView name) override;
|
||||
virtual ErrorOr<void> chmod(mode_t) override;
|
||||
|
@ -370,7 +370,7 @@ private:
|
|||
static constexpr size_t max_file_identifier_length = 256 - sizeof(ISO::DirectoryRecordHeader);
|
||||
|
||||
ISO9660Inode(ISO9660FS&, ISO::DirectoryRecordHeader const& record, StringView name);
|
||||
static ErrorOr<NonnullRefPtr<ISO9660Inode>> try_create_from_directory_record(ISO9660FS&, ISO::DirectoryRecordHeader const& record, StringView name);
|
||||
static ErrorOr<NonnullLockRefPtr<ISO9660Inode>> try_create_from_directory_record(ISO9660FS&, ISO::DirectoryRecordHeader const& record, StringView name);
|
||||
|
||||
static InodeIndex get_inode_index(ISO::DirectoryRecordHeader const& record, StringView name);
|
||||
static StringView get_normalized_filename(ISO::DirectoryRecordHeader const& record, Bytes buffer);
|
||||
|
|
|
@ -6,7 +6,6 @@
|
|||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include <AK/NonnullRefPtrVector.h>
|
||||
#include <AK/Singleton.h>
|
||||
#include <AK/StringView.h>
|
||||
#include <Kernel/API/InodeWatcherEvent.h>
|
||||
|
@ -16,6 +15,7 @@
|
|||
#include <Kernel/FileSystem/OpenFileDescription.h>
|
||||
#include <Kernel/FileSystem/VirtualFileSystem.h>
|
||||
#include <Kernel/KBufferBuilder.h>
|
||||
#include <Kernel/Library/NonnullLockRefPtrVector.h>
|
||||
#include <Kernel/Memory/SharedInodeVMObject.h>
|
||||
#include <Kernel/Net/LocalSocket.h>
|
||||
#include <Kernel/Process.h>
|
||||
|
@ -31,7 +31,7 @@ SpinlockProtected<Inode::AllInstancesList>& Inode::all_instances()
|
|||
|
||||
void Inode::sync_all()
|
||||
{
|
||||
NonnullRefPtrVector<Inode, 32> inodes;
|
||||
NonnullLockRefPtrVector<Inode, 32> inodes;
|
||||
Inode::all_instances().with([&](auto& all_inodes) {
|
||||
for (auto& inode : all_inodes) {
|
||||
if (inode.is_metadata_dirty())
|
||||
|
@ -76,7 +76,7 @@ ErrorOr<NonnullOwnPtr<KBuffer>> Inode::read_entire(OpenFileDescription* descript
|
|||
return entire_file.release_nonnull();
|
||||
}
|
||||
|
||||
ErrorOr<NonnullRefPtr<Custody>> Inode::resolve_as_link(Custody& base, RefPtr<Custody>* out_parent, int options, int symlink_recursion_level) const
|
||||
ErrorOr<NonnullLockRefPtr<Custody>> Inode::resolve_as_link(Custody& base, LockRefPtr<Custody>* out_parent, int options, int symlink_recursion_level) const
|
||||
{
|
||||
// The default implementation simply treats the stored
|
||||
// contents as a path and resolves that. That is, it
|
||||
|
@ -138,7 +138,7 @@ ErrorOr<void> Inode::set_shared_vmobject(Memory::SharedInodeVMObject& vmobject)
|
|||
return {};
|
||||
}
|
||||
|
||||
RefPtr<LocalSocket> Inode::bound_socket() const
|
||||
LockRefPtr<LocalSocket> Inode::bound_socket() const
|
||||
{
|
||||
return m_bound_socket;
|
||||
}
|
||||
|
@ -178,7 +178,7 @@ void Inode::unregister_watcher(Badge<InodeWatcher>, InodeWatcher& watcher)
|
|||
});
|
||||
}
|
||||
|
||||
ErrorOr<NonnullRefPtr<FIFO>> Inode::fifo()
|
||||
ErrorOr<NonnullLockRefPtr<FIFO>> Inode::fifo()
|
||||
{
|
||||
MutexLocker locker(m_inode_lock);
|
||||
VERIFY(metadata().is_fifo());
|
||||
|
@ -187,7 +187,7 @@ ErrorOr<NonnullRefPtr<FIFO>> Inode::fifo()
|
|||
if (!m_fifo)
|
||||
m_fifo = TRY(FIFO::try_create(metadata().uid));
|
||||
|
||||
return NonnullRefPtr { *m_fifo };
|
||||
return NonnullLockRefPtr { *m_fifo };
|
||||
}
|
||||
|
||||
void Inode::set_metadata_dirty(bool metadata_dirty)
|
||||
|
@ -264,7 +264,7 @@ ErrorOr<void> Inode::prepare_to_write_data()
|
|||
return {};
|
||||
}
|
||||
|
||||
RefPtr<Memory::SharedInodeVMObject> Inode::shared_vmobject() const
|
||||
LockRefPtr<Memory::SharedInodeVMObject> Inode::shared_vmobject() const
|
||||
{
|
||||
MutexLocker locker(m_inode_lock);
|
||||
return m_shared_vmobject.strong_ref();
|
||||
|
|
|
@ -11,13 +11,13 @@
|
|||
#include <AK/Function.h>
|
||||
#include <AK/HashTable.h>
|
||||
#include <AK/IntrusiveList.h>
|
||||
#include <AK/WeakPtr.h>
|
||||
#include <Kernel/FileSystem/FIFO.h>
|
||||
#include <Kernel/FileSystem/FileSystem.h>
|
||||
#include <Kernel/FileSystem/InodeIdentifier.h>
|
||||
#include <Kernel/FileSystem/InodeMetadata.h>
|
||||
#include <Kernel/Forward.h>
|
||||
#include <Kernel/Library/ListedRefCounted.h>
|
||||
#include <Kernel/Library/LockWeakPtr.h>
|
||||
#include <Kernel/Locking/Mutex.h>
|
||||
#include <Kernel/Memory/SharedInodeVMObject.h>
|
||||
|
||||
|
@ -29,7 +29,7 @@ enum class ShouldBlock {
|
|||
};
|
||||
|
||||
class Inode : public ListedRefCounted<Inode, LockType::Spinlock>
|
||||
, public Weakable<Inode> {
|
||||
, public LockWeakable<Inode> {
|
||||
friend class VirtualFileSystem;
|
||||
friend class FileSystem;
|
||||
friend class InodeFile;
|
||||
|
@ -61,19 +61,19 @@ public:
|
|||
virtual void did_seek(OpenFileDescription&, off_t) { }
|
||||
virtual ErrorOr<size_t> read_bytes(off_t, size_t, UserOrKernelBuffer& buffer, OpenFileDescription*) const = 0;
|
||||
virtual ErrorOr<void> traverse_as_directory(Function<ErrorOr<void>(FileSystem::DirectoryEntryView const&)>) const = 0;
|
||||
virtual ErrorOr<NonnullRefPtr<Inode>> lookup(StringView name) = 0;
|
||||
virtual ErrorOr<NonnullLockRefPtr<Inode>> lookup(StringView name) = 0;
|
||||
virtual ErrorOr<size_t> write_bytes(off_t, size_t, UserOrKernelBuffer const& data, OpenFileDescription*) = 0;
|
||||
virtual ErrorOr<NonnullRefPtr<Inode>> create_child(StringView name, mode_t, dev_t, UserID, GroupID) = 0;
|
||||
virtual ErrorOr<NonnullLockRefPtr<Inode>> create_child(StringView name, mode_t, dev_t, UserID, GroupID) = 0;
|
||||
virtual ErrorOr<void> add_child(Inode&, StringView name, mode_t) = 0;
|
||||
virtual ErrorOr<void> remove_child(StringView name) = 0;
|
||||
virtual ErrorOr<void> chmod(mode_t) = 0;
|
||||
virtual ErrorOr<void> chown(UserID, GroupID) = 0;
|
||||
virtual ErrorOr<void> truncate(u64) { return {}; }
|
||||
virtual ErrorOr<NonnullRefPtr<Custody>> resolve_as_link(Custody& base, RefPtr<Custody>* out_parent, int options, int symlink_recursion_level) const;
|
||||
virtual ErrorOr<NonnullLockRefPtr<Custody>> resolve_as_link(Custody& base, LockRefPtr<Custody>* out_parent, int options, int symlink_recursion_level) const;
|
||||
|
||||
virtual ErrorOr<int> get_block_address(int) { return ENOTSUP; }
|
||||
|
||||
RefPtr<LocalSocket> bound_socket() const;
|
||||
LockRefPtr<LocalSocket> bound_socket() const;
|
||||
bool bind_socket(LocalSocket&);
|
||||
bool unbind_socket();
|
||||
|
||||
|
@ -90,7 +90,7 @@ public:
|
|||
void will_be_destroyed();
|
||||
|
||||
ErrorOr<void> set_shared_vmobject(Memory::SharedInodeVMObject&);
|
||||
RefPtr<Memory::SharedInodeVMObject> shared_vmobject() const;
|
||||
LockRefPtr<Memory::SharedInodeVMObject> shared_vmobject() const;
|
||||
|
||||
static void sync_all();
|
||||
void sync();
|
||||
|
@ -100,7 +100,7 @@ public:
|
|||
ErrorOr<void> register_watcher(Badge<InodeWatcher>, InodeWatcher&);
|
||||
void unregister_watcher(Badge<InodeWatcher>, InodeWatcher&);
|
||||
|
||||
ErrorOr<NonnullRefPtr<FIFO>> fifo();
|
||||
ErrorOr<NonnullLockRefPtr<FIFO>> fifo();
|
||||
|
||||
bool can_apply_flock(flock const&) const;
|
||||
ErrorOr<void> apply_flock(Process const&, OpenFileDescription const&, Userspace<flock const*>, ShouldBlock);
|
||||
|
@ -125,11 +125,11 @@ private:
|
|||
|
||||
FileSystem& m_file_system;
|
||||
InodeIndex m_index { 0 };
|
||||
WeakPtr<Memory::SharedInodeVMObject> m_shared_vmobject;
|
||||
RefPtr<LocalSocket> m_bound_socket;
|
||||
LockWeakPtr<Memory::SharedInodeVMObject> m_shared_vmobject;
|
||||
LockRefPtr<LocalSocket> m_bound_socket;
|
||||
SpinlockProtected<HashTable<InodeWatcher*>> m_watchers { LockRank::None };
|
||||
bool m_metadata_dirty { false };
|
||||
RefPtr<FIFO> m_fifo;
|
||||
LockRefPtr<FIFO> m_fifo;
|
||||
IntrusiveListNode<Inode> m_inode_list_node;
|
||||
|
||||
struct Flock {
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
|
||||
namespace Kernel {
|
||||
|
||||
InodeFile::InodeFile(NonnullRefPtr<Inode>&& inode)
|
||||
InodeFile::InodeFile(NonnullLockRefPtr<Inode>&& inode)
|
||||
: m_inode(move(inode))
|
||||
{
|
||||
}
|
||||
|
@ -87,7 +87,7 @@ ErrorOr<void> InodeFile::ioctl(OpenFileDescription& description, unsigned reques
|
|||
ErrorOr<Memory::Region*> InodeFile::mmap(Process& process, OpenFileDescription& description, Memory::VirtualRange const& range, u64 offset, int prot, bool shared)
|
||||
{
|
||||
// FIXME: If PROT_EXEC, check that the underlying file system isn't mounted noexec.
|
||||
RefPtr<Memory::InodeVMObject> vmobject;
|
||||
LockRefPtr<Memory::InodeVMObject> vmobject;
|
||||
if (shared)
|
||||
vmobject = TRY(Memory::SharedInodeVMObject::try_create_with_inode(inode()));
|
||||
else
|
||||
|
|
|
@ -14,9 +14,9 @@ class Inode;
|
|||
|
||||
class InodeFile final : public File {
|
||||
public:
|
||||
static ErrorOr<NonnullRefPtr<InodeFile>> create(NonnullRefPtr<Inode>&& inode)
|
||||
static ErrorOr<NonnullLockRefPtr<InodeFile>> create(NonnullLockRefPtr<Inode>&& inode)
|
||||
{
|
||||
auto file = adopt_ref_if_nonnull(new (nothrow) InodeFile(move(inode)));
|
||||
auto file = adopt_lock_ref_if_nonnull(new (nothrow) InodeFile(move(inode)));
|
||||
if (!file)
|
||||
return ENOMEM;
|
||||
return file.release_nonnull();
|
||||
|
@ -49,8 +49,8 @@ public:
|
|||
virtual bool is_inode() const override { return true; }
|
||||
|
||||
private:
|
||||
explicit InodeFile(NonnullRefPtr<Inode>&&);
|
||||
NonnullRefPtr<Inode> m_inode;
|
||||
explicit InodeFile(NonnullLockRefPtr<Inode>&&);
|
||||
NonnullLockRefPtr<Inode> m_inode;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -12,9 +12,9 @@
|
|||
|
||||
namespace Kernel {
|
||||
|
||||
ErrorOr<NonnullRefPtr<InodeWatcher>> InodeWatcher::try_create()
|
||||
ErrorOr<NonnullLockRefPtr<InodeWatcher>> InodeWatcher::try_create()
|
||||
{
|
||||
return adopt_nonnull_ref_or_enomem(new (nothrow) InodeWatcher);
|
||||
return adopt_nonnull_lock_ref_or_enomem(new (nothrow) InodeWatcher);
|
||||
}
|
||||
|
||||
InodeWatcher::~InodeWatcher()
|
||||
|
|
|
@ -40,7 +40,7 @@ private:
|
|||
|
||||
class InodeWatcher final : public File {
|
||||
public:
|
||||
static ErrorOr<NonnullRefPtr<InodeWatcher>> try_create();
|
||||
static ErrorOr<NonnullLockRefPtr<InodeWatcher>> try_create();
|
||||
virtual ~InodeWatcher() override;
|
||||
|
||||
virtual bool can_read(OpenFileDescription const&, u64) const override;
|
||||
|
|
|
@ -6,9 +6,9 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <AK/NonnullRefPtr.h>
|
||||
#include <Kernel/FileSystem/Custody.h>
|
||||
#include <Kernel/Forward.h>
|
||||
#include <Kernel/Library/NonnullLockRefPtr.h>
|
||||
|
||||
namespace Kernel {
|
||||
|
||||
|
@ -32,9 +32,9 @@ public:
|
|||
void set_flags(int flags) { m_flags = flags; }
|
||||
|
||||
private:
|
||||
NonnullRefPtr<Inode> m_guest;
|
||||
NonnullRefPtr<FileSystem> m_guest_fs;
|
||||
RefPtr<Custody> m_host_custody;
|
||||
NonnullLockRefPtr<Inode> m_guest;
|
||||
NonnullLockRefPtr<FileSystem> m_guest_fs;
|
||||
LockRefPtr<Custody> m_host_custody;
|
||||
int m_flags;
|
||||
};
|
||||
|
||||
|
|
|
@ -22,19 +22,19 @@
|
|||
|
||||
namespace Kernel {
|
||||
|
||||
ErrorOr<NonnullRefPtr<OpenFileDescription>> OpenFileDescription::try_create(Custody& custody)
|
||||
ErrorOr<NonnullLockRefPtr<OpenFileDescription>> OpenFileDescription::try_create(Custody& custody)
|
||||
{
|
||||
auto inode_file = TRY(InodeFile::create(custody.inode()));
|
||||
auto description = TRY(adopt_nonnull_ref_or_enomem(new (nothrow) OpenFileDescription(move(inode_file))));
|
||||
auto description = TRY(adopt_nonnull_lock_ref_or_enomem(new (nothrow) OpenFileDescription(move(inode_file))));
|
||||
|
||||
description->m_custody = custody;
|
||||
TRY(description->attach());
|
||||
return description;
|
||||
}
|
||||
|
||||
ErrorOr<NonnullRefPtr<OpenFileDescription>> OpenFileDescription::try_create(File& file)
|
||||
ErrorOr<NonnullLockRefPtr<OpenFileDescription>> OpenFileDescription::try_create(File& file)
|
||||
{
|
||||
auto description = TRY(adopt_nonnull_ref_or_enomem(new (nothrow) OpenFileDescription(file)));
|
||||
auto description = TRY(adopt_nonnull_lock_ref_or_enomem(new (nothrow) OpenFileDescription(file)));
|
||||
TRY(description->attach());
|
||||
return description;
|
||||
}
|
||||
|
|
|
@ -24,8 +24,8 @@ public:
|
|||
|
||||
class OpenFileDescription final : public AtomicRefCounted<OpenFileDescription> {
|
||||
public:
|
||||
static ErrorOr<NonnullRefPtr<OpenFileDescription>> try_create(Custody&);
|
||||
static ErrorOr<NonnullRefPtr<OpenFileDescription>> try_create(File&);
|
||||
static ErrorOr<NonnullLockRefPtr<OpenFileDescription>> try_create(Custody&);
|
||||
static ErrorOr<NonnullLockRefPtr<OpenFileDescription>> try_create(File&);
|
||||
~OpenFileDescription();
|
||||
|
||||
Thread::FileBlocker::BlockFlags should_unblock(Thread::FileBlocker::BlockFlags) const;
|
||||
|
@ -112,7 +112,7 @@ public:
|
|||
|
||||
OwnPtr<OpenFileDescriptionData>& data();
|
||||
|
||||
void set_original_inode(Badge<VirtualFileSystem>, NonnullRefPtr<Inode>&& inode) { m_inode = move(inode); }
|
||||
void set_original_inode(Badge<VirtualFileSystem>, NonnullLockRefPtr<Inode>&& inode) { m_inode = move(inode); }
|
||||
void set_original_custody(Badge<VirtualFileSystem>, Custody& custody);
|
||||
|
||||
ErrorOr<void> truncate(u64);
|
||||
|
@ -138,9 +138,9 @@ private:
|
|||
blocker_set().unblock_all_blockers_whose_conditions_are_met();
|
||||
}
|
||||
|
||||
RefPtr<Custody> m_custody;
|
||||
RefPtr<Inode> m_inode;
|
||||
NonnullRefPtr<File> m_file;
|
||||
LockRefPtr<Custody> m_custody;
|
||||
LockRefPtr<Inode> m_inode;
|
||||
NonnullLockRefPtr<File> m_file;
|
||||
|
||||
struct State {
|
||||
OwnPtr<OpenFileDescriptionData> data;
|
||||
|
|
|
@ -9,9 +9,9 @@
|
|||
|
||||
namespace Kernel {
|
||||
|
||||
ErrorOr<NonnullRefPtr<FileSystem>> Plan9FS::try_create(OpenFileDescription& file_description)
|
||||
ErrorOr<NonnullLockRefPtr<FileSystem>> Plan9FS::try_create(OpenFileDescription& file_description)
|
||||
{
|
||||
return TRY(adopt_nonnull_ref_or_enomem(new (nothrow) Plan9FS(file_description)));
|
||||
return TRY(adopt_nonnull_lock_ref_or_enomem(new (nothrow) Plan9FS(file_description)));
|
||||
}
|
||||
|
||||
Plan9FS::Plan9FS(OpenFileDescription& file_description)
|
||||
|
@ -487,7 +487,7 @@ bool Plan9FS::is_complete(ReceiveCompletion const& completion)
|
|||
return true;
|
||||
}
|
||||
|
||||
ErrorOr<void> Plan9FS::post_message(Message& message, RefPtr<ReceiveCompletion> completion)
|
||||
ErrorOr<void> Plan9FS::post_message(Message& message, LockRefPtr<ReceiveCompletion> completion)
|
||||
{
|
||||
auto const& buffer = message.build();
|
||||
u8 const* data = buffer.data();
|
||||
|
@ -584,7 +584,7 @@ ErrorOr<void> Plan9FS::post_message_and_wait_for_a_reply(Message& message)
|
|||
{
|
||||
auto request_type = message.type();
|
||||
auto tag = message.tag();
|
||||
auto completion = adopt_ref(*new ReceiveCompletion(tag));
|
||||
auto completion = adopt_lock_ref(*new ReceiveCompletion(tag));
|
||||
TRY(post_message(message, completion));
|
||||
if (Thread::current()->block<Plan9FS::Blocker>({}, *this, message, completion).was_interrupted())
|
||||
return EINTR;
|
||||
|
@ -668,9 +668,9 @@ Plan9FSInode::Plan9FSInode(Plan9FS& fs, u32 fid)
|
|||
{
|
||||
}
|
||||
|
||||
ErrorOr<NonnullRefPtr<Plan9FSInode>> Plan9FSInode::try_create(Plan9FS& fs, u32 fid)
|
||||
ErrorOr<NonnullLockRefPtr<Plan9FSInode>> Plan9FSInode::try_create(Plan9FS& fs, u32 fid)
|
||||
{
|
||||
return adopt_nonnull_ref_or_enomem(new (nothrow) Plan9FSInode(fs, fid));
|
||||
return adopt_nonnull_lock_ref_or_enomem(new (nothrow) Plan9FSInode(fs, fid));
|
||||
}
|
||||
|
||||
Plan9FSInode::~Plan9FSInode()
|
||||
|
@ -893,7 +893,7 @@ ErrorOr<void> Plan9FSInode::traverse_as_directory(Function<ErrorOr<void>(FileSys
|
|||
return ENOTIMPL;
|
||||
}
|
||||
|
||||
ErrorOr<NonnullRefPtr<Inode>> Plan9FSInode::lookup(StringView name)
|
||||
ErrorOr<NonnullLockRefPtr<Inode>> Plan9FSInode::lookup(StringView name)
|
||||
{
|
||||
u32 newfid = fs().allocate_fid();
|
||||
Plan9FS::Message message { fs(), Plan9FS::Message::Type::Twalk };
|
||||
|
@ -902,7 +902,7 @@ ErrorOr<NonnullRefPtr<Inode>> Plan9FSInode::lookup(StringView name)
|
|||
return TRY(Plan9FSInode::try_create(fs(), newfid));
|
||||
}
|
||||
|
||||
ErrorOr<NonnullRefPtr<Inode>> Plan9FSInode::create_child(StringView, mode_t, dev_t, UserID, GroupID)
|
||||
ErrorOr<NonnullLockRefPtr<Inode>> Plan9FSInode::create_child(StringView, mode_t, dev_t, UserID, GroupID)
|
||||
{
|
||||
// TODO
|
||||
return ENOTIMPL;
|
||||
|
|
|
@ -20,7 +20,7 @@ class Plan9FS final : public FileBackedFileSystem {
|
|||
|
||||
public:
|
||||
virtual ~Plan9FS() override;
|
||||
static ErrorOr<NonnullRefPtr<FileSystem>> try_create(OpenFileDescription&);
|
||||
static ErrorOr<NonnullLockRefPtr<FileSystem>> try_create(OpenFileDescription&);
|
||||
|
||||
virtual ErrorOr<void> initialize() override;
|
||||
|
||||
|
@ -82,7 +82,7 @@ private:
|
|||
|
||||
class Blocker final : public Thread::Blocker {
|
||||
public:
|
||||
Blocker(Plan9FS& fs, Message& message, NonnullRefPtr<ReceiveCompletion> completion)
|
||||
Blocker(Plan9FS& fs, Message& message, NonnullLockRefPtr<ReceiveCompletion> completion)
|
||||
: m_fs(fs)
|
||||
, m_message(message)
|
||||
, m_completion(move(completion))
|
||||
|
@ -93,7 +93,7 @@ private:
|
|||
virtual Type blocker_type() const override { return Type::Plan9FS; }
|
||||
virtual void will_unblock_immediately_without_blocking(UnblockImmediatelyReason) override;
|
||||
|
||||
NonnullRefPtr<ReceiveCompletion> const& completion() const { return m_completion; }
|
||||
NonnullLockRefPtr<ReceiveCompletion> const& completion() const { return m_completion; }
|
||||
u16 tag() const { return m_completion->tag; }
|
||||
bool is_completed() const;
|
||||
|
||||
|
@ -108,7 +108,7 @@ private:
|
|||
private:
|
||||
Plan9FS& m_fs;
|
||||
Message& m_message;
|
||||
NonnullRefPtr<ReceiveCompletion> m_completion;
|
||||
NonnullLockRefPtr<ReceiveCompletion> m_completion;
|
||||
bool m_did_unblock { false };
|
||||
};
|
||||
friend class Blocker;
|
||||
|
@ -116,7 +116,7 @@ private:
|
|||
virtual StringView class_name() const override { return "Plan9FS"sv; }
|
||||
|
||||
bool is_complete(ReceiveCompletion const&);
|
||||
ErrorOr<void> post_message(Message&, RefPtr<ReceiveCompletion>);
|
||||
ErrorOr<void> post_message(Message&, LockRefPtr<ReceiveCompletion>);
|
||||
ErrorOr<void> do_read(u8* buffer, size_t);
|
||||
ErrorOr<void> read_and_dispatch_one_message();
|
||||
ErrorOr<void> post_message_and_wait_for_a_reply(Message&);
|
||||
|
@ -128,7 +128,7 @@ private:
|
|||
void thread_main();
|
||||
void ensure_thread();
|
||||
|
||||
RefPtr<Plan9FSInode> m_root_inode;
|
||||
LockRefPtr<Plan9FSInode> m_root_inode;
|
||||
Atomic<u16> m_next_tag { (u16)-1 };
|
||||
Atomic<u32> m_next_fid { 1 };
|
||||
|
||||
|
@ -137,10 +137,10 @@ private:
|
|||
|
||||
Mutex m_send_lock { "Plan9FS send"sv };
|
||||
Plan9FSBlockerSet m_completion_blocker;
|
||||
HashMap<u16, NonnullRefPtr<ReceiveCompletion>> m_completions;
|
||||
HashMap<u16, NonnullLockRefPtr<ReceiveCompletion>> m_completions;
|
||||
|
||||
Spinlock m_thread_lock { LockRank::None };
|
||||
RefPtr<Thread> m_thread;
|
||||
LockRefPtr<Thread> m_thread;
|
||||
Atomic<bool> m_thread_running { false };
|
||||
Atomic<bool, AK::MemoryOrder::memory_order_relaxed> m_thread_shutdown { false };
|
||||
};
|
||||
|
@ -159,8 +159,8 @@ public:
|
|||
virtual ErrorOr<size_t> read_bytes(off_t, size_t, UserOrKernelBuffer& buffer, OpenFileDescription*) const override;
|
||||
virtual ErrorOr<size_t> write_bytes(off_t, size_t, UserOrKernelBuffer const& data, OpenFileDescription*) override;
|
||||
virtual ErrorOr<void> traverse_as_directory(Function<ErrorOr<void>(FileSystem::DirectoryEntryView const&)>) const override;
|
||||
virtual ErrorOr<NonnullRefPtr<Inode>> lookup(StringView name) override;
|
||||
virtual ErrorOr<NonnullRefPtr<Inode>> create_child(StringView name, mode_t, dev_t, UserID, GroupID) override;
|
||||
virtual ErrorOr<NonnullLockRefPtr<Inode>> lookup(StringView name) override;
|
||||
virtual ErrorOr<NonnullLockRefPtr<Inode>> create_child(StringView name, mode_t, dev_t, UserID, GroupID) override;
|
||||
virtual ErrorOr<void> add_child(Inode&, StringView name, mode_t) override;
|
||||
virtual ErrorOr<void> remove_child(StringView name) override;
|
||||
virtual ErrorOr<void> chmod(mode_t) override;
|
||||
|
@ -169,7 +169,7 @@ public:
|
|||
|
||||
private:
|
||||
Plan9FSInode(Plan9FS&, u32 fid);
|
||||
static ErrorOr<NonnullRefPtr<Plan9FSInode>> try_create(Plan9FS&, u32 fid);
|
||||
static ErrorOr<NonnullLockRefPtr<Plan9FSInode>> try_create(Plan9FS&, u32 fid);
|
||||
|
||||
enum class GetAttrMask : u64 {
|
||||
Mode = 0x1,
|
||||
|
|
|
@ -37,9 +37,9 @@ UNMAP_AFTER_INIT ProcFSComponentRegistry::ProcFSComponentRegistry()
|
|||
{
|
||||
}
|
||||
|
||||
ErrorOr<NonnullRefPtr<FileSystem>> ProcFS::try_create()
|
||||
ErrorOr<NonnullLockRefPtr<FileSystem>> ProcFS::try_create()
|
||||
{
|
||||
return TRY(adopt_nonnull_ref_or_enomem(new (nothrow) ProcFS));
|
||||
return TRY(adopt_nonnull_lock_ref_or_enomem(new (nothrow) ProcFS));
|
||||
}
|
||||
|
||||
ProcFS::ProcFS() = default;
|
||||
|
@ -73,7 +73,7 @@ ErrorOr<void> ProcFSInode::add_child(Inode&, StringView, mode_t)
|
|||
return EROFS;
|
||||
}
|
||||
|
||||
ErrorOr<NonnullRefPtr<Inode>> ProcFSInode::create_child(StringView, mode_t, dev_t, UserID, GroupID)
|
||||
ErrorOr<NonnullLockRefPtr<Inode>> ProcFSInode::create_child(StringView, mode_t, dev_t, UserID, GroupID)
|
||||
{
|
||||
return EROFS;
|
||||
}
|
||||
|
@ -93,9 +93,9 @@ ErrorOr<void> ProcFSInode::chown(UserID, GroupID)
|
|||
return EPERM;
|
||||
}
|
||||
|
||||
ErrorOr<NonnullRefPtr<ProcFSGlobalInode>> ProcFSGlobalInode::try_create(ProcFS const& fs, ProcFSExposedComponent const& component)
|
||||
ErrorOr<NonnullLockRefPtr<ProcFSGlobalInode>> ProcFSGlobalInode::try_create(ProcFS const& fs, ProcFSExposedComponent const& component)
|
||||
{
|
||||
return adopt_nonnull_ref_or_enomem(new (nothrow) ProcFSGlobalInode(fs, component));
|
||||
return adopt_nonnull_lock_ref_or_enomem(new (nothrow) ProcFSGlobalInode(fs, component));
|
||||
}
|
||||
|
||||
ProcFSGlobalInode::ProcFSGlobalInode(ProcFS const& fs, ProcFSExposedComponent const& component)
|
||||
|
@ -135,7 +135,7 @@ ErrorOr<void> ProcFSGlobalInode::traverse_as_directory(Function<ErrorOr<void>(Fi
|
|||
VERIFY_NOT_REACHED();
|
||||
}
|
||||
|
||||
ErrorOr<NonnullRefPtr<Inode>> ProcFSGlobalInode::lookup(StringView)
|
||||
ErrorOr<NonnullLockRefPtr<Inode>> ProcFSGlobalInode::lookup(StringView)
|
||||
{
|
||||
VERIFY_NOT_REACHED();
|
||||
}
|
||||
|
@ -168,9 +168,9 @@ ErrorOr<size_t> ProcFSGlobalInode::write_bytes(off_t offset, size_t count, UserO
|
|||
return m_associated_component->write_bytes(offset, count, buffer, fd);
|
||||
}
|
||||
|
||||
ErrorOr<NonnullRefPtr<ProcFSDirectoryInode>> ProcFSDirectoryInode::try_create(ProcFS const& procfs, ProcFSExposedComponent const& component)
|
||||
ErrorOr<NonnullLockRefPtr<ProcFSDirectoryInode>> ProcFSDirectoryInode::try_create(ProcFS const& procfs, ProcFSExposedComponent const& component)
|
||||
{
|
||||
return adopt_nonnull_ref_or_enomem(new (nothrow) ProcFSDirectoryInode(procfs, component));
|
||||
return adopt_nonnull_lock_ref_or_enomem(new (nothrow) ProcFSDirectoryInode(procfs, component));
|
||||
}
|
||||
|
||||
ProcFSDirectoryInode::ProcFSDirectoryInode(ProcFS const& fs, ProcFSExposedComponent const& component)
|
||||
|
@ -197,16 +197,16 @@ ErrorOr<void> ProcFSDirectoryInode::traverse_as_directory(Function<ErrorOr<void>
|
|||
return m_associated_component->traverse_as_directory(procfs().fsid(), move(callback));
|
||||
}
|
||||
|
||||
ErrorOr<NonnullRefPtr<Inode>> ProcFSDirectoryInode::lookup(StringView name)
|
||||
ErrorOr<NonnullLockRefPtr<Inode>> ProcFSDirectoryInode::lookup(StringView name)
|
||||
{
|
||||
MutexLocker locker(procfs().m_lock);
|
||||
auto component = TRY(m_associated_component->lookup(name));
|
||||
return component->to_inode(procfs());
|
||||
}
|
||||
|
||||
ErrorOr<NonnullRefPtr<ProcFSLinkInode>> ProcFSLinkInode::try_create(ProcFS const& procfs, ProcFSExposedComponent const& component)
|
||||
ErrorOr<NonnullLockRefPtr<ProcFSLinkInode>> ProcFSLinkInode::try_create(ProcFS const& procfs, ProcFSExposedComponent const& component)
|
||||
{
|
||||
return adopt_nonnull_ref_or_enomem(new (nothrow) ProcFSLinkInode(procfs, component));
|
||||
return adopt_nonnull_lock_ref_or_enomem(new (nothrow) ProcFSLinkInode(procfs, component));
|
||||
}
|
||||
|
||||
ProcFSLinkInode::ProcFSLinkInode(ProcFS const& fs, ProcFSExposedComponent const& component)
|
||||
|
@ -238,9 +238,9 @@ ErrorOr<size_t> ProcFSProcessAssociatedInode::write_bytes(off_t, size_t, UserOrK
|
|||
return ENOTSUP;
|
||||
}
|
||||
|
||||
ErrorOr<NonnullRefPtr<ProcFSProcessDirectoryInode>> ProcFSProcessDirectoryInode::try_create(ProcFS const& procfs, ProcessID pid)
|
||||
ErrorOr<NonnullLockRefPtr<ProcFSProcessDirectoryInode>> ProcFSProcessDirectoryInode::try_create(ProcFS const& procfs, ProcessID pid)
|
||||
{
|
||||
return adopt_nonnull_ref_or_enomem(new (nothrow) ProcFSProcessDirectoryInode(procfs, pid));
|
||||
return adopt_nonnull_lock_ref_or_enomem(new (nothrow) ProcFSProcessDirectoryInode(procfs, pid));
|
||||
}
|
||||
|
||||
ProcFSProcessDirectoryInode::ProcFSProcessDirectoryInode(ProcFS const& procfs, ProcessID pid)
|
||||
|
@ -285,7 +285,7 @@ ErrorOr<void> ProcFSProcessDirectoryInode::traverse_as_directory(Function<ErrorO
|
|||
return process->procfs_traits()->traverse_as_directory(procfs().fsid(), move(callback));
|
||||
}
|
||||
|
||||
ErrorOr<NonnullRefPtr<Inode>> ProcFSProcessDirectoryInode::lookup(StringView name)
|
||||
ErrorOr<NonnullLockRefPtr<Inode>> ProcFSProcessDirectoryInode::lookup(StringView name)
|
||||
{
|
||||
MutexLocker locker(procfs().m_lock);
|
||||
auto process = Process::from_pid(associated_pid());
|
||||
|
@ -316,9 +316,9 @@ ErrorOr<NonnullRefPtr<Inode>> ProcFSProcessDirectoryInode::lookup(StringView nam
|
|||
return ENOENT;
|
||||
}
|
||||
|
||||
ErrorOr<NonnullRefPtr<ProcFSProcessSubDirectoryInode>> ProcFSProcessSubDirectoryInode::try_create(ProcFS const& procfs, SegmentedProcFSIndex::ProcessSubDirectory sub_directory_type, ProcessID pid)
|
||||
ErrorOr<NonnullLockRefPtr<ProcFSProcessSubDirectoryInode>> ProcFSProcessSubDirectoryInode::try_create(ProcFS const& procfs, SegmentedProcFSIndex::ProcessSubDirectory sub_directory_type, ProcessID pid)
|
||||
{
|
||||
return adopt_nonnull_ref_or_enomem(new (nothrow) ProcFSProcessSubDirectoryInode(procfs, sub_directory_type, pid));
|
||||
return adopt_nonnull_lock_ref_or_enomem(new (nothrow) ProcFSProcessSubDirectoryInode(procfs, sub_directory_type, pid));
|
||||
}
|
||||
|
||||
ProcFSProcessSubDirectoryInode::ProcFSProcessSubDirectoryInode(ProcFS const& procfs, SegmentedProcFSIndex::ProcessSubDirectory sub_directory_type, ProcessID pid)
|
||||
|
@ -379,7 +379,7 @@ ErrorOr<void> ProcFSProcessSubDirectoryInode::traverse_as_directory(Function<Err
|
|||
VERIFY_NOT_REACHED();
|
||||
}
|
||||
|
||||
ErrorOr<NonnullRefPtr<Inode>> ProcFSProcessSubDirectoryInode::lookup(StringView name)
|
||||
ErrorOr<NonnullLockRefPtr<Inode>> ProcFSProcessSubDirectoryInode::lookup(StringView name)
|
||||
{
|
||||
MutexLocker locker(procfs().m_lock);
|
||||
auto process = Process::from_pid(associated_pid());
|
||||
|
@ -397,21 +397,21 @@ ErrorOr<NonnullRefPtr<Inode>> ProcFSProcessSubDirectoryInode::lookup(StringView
|
|||
}
|
||||
}
|
||||
|
||||
ErrorOr<NonnullRefPtr<ProcFSProcessPropertyInode>> ProcFSProcessPropertyInode::try_create_for_file_description_link(ProcFS const& procfs, unsigned file_description_index, ProcessID pid)
|
||||
ErrorOr<NonnullLockRefPtr<ProcFSProcessPropertyInode>> ProcFSProcessPropertyInode::try_create_for_file_description_link(ProcFS const& procfs, unsigned file_description_index, ProcessID pid)
|
||||
{
|
||||
return adopt_nonnull_ref_or_enomem(new (nothrow) ProcFSProcessPropertyInode(procfs, file_description_index, pid));
|
||||
return adopt_nonnull_lock_ref_or_enomem(new (nothrow) ProcFSProcessPropertyInode(procfs, file_description_index, pid));
|
||||
}
|
||||
ErrorOr<NonnullRefPtr<ProcFSProcessPropertyInode>> ProcFSProcessPropertyInode::try_create_for_thread_stack(ProcFS const& procfs, ThreadID stack_thread_index, ProcessID pid)
|
||||
ErrorOr<NonnullLockRefPtr<ProcFSProcessPropertyInode>> ProcFSProcessPropertyInode::try_create_for_thread_stack(ProcFS const& procfs, ThreadID stack_thread_index, ProcessID pid)
|
||||
{
|
||||
return adopt_nonnull_ref_or_enomem(new (nothrow) ProcFSProcessPropertyInode(procfs, stack_thread_index, pid));
|
||||
return adopt_nonnull_lock_ref_or_enomem(new (nothrow) ProcFSProcessPropertyInode(procfs, stack_thread_index, pid));
|
||||
}
|
||||
ErrorOr<NonnullRefPtr<ProcFSProcessPropertyInode>> ProcFSProcessPropertyInode::try_create_for_pid_property(ProcFS const& procfs, SegmentedProcFSIndex::MainProcessProperty main_property_type, ProcessID pid)
|
||||
ErrorOr<NonnullLockRefPtr<ProcFSProcessPropertyInode>> ProcFSProcessPropertyInode::try_create_for_pid_property(ProcFS const& procfs, SegmentedProcFSIndex::MainProcessProperty main_property_type, ProcessID pid)
|
||||
{
|
||||
return adopt_nonnull_ref_or_enomem(new (nothrow) ProcFSProcessPropertyInode(procfs, main_property_type, pid));
|
||||
return adopt_nonnull_lock_ref_or_enomem(new (nothrow) ProcFSProcessPropertyInode(procfs, main_property_type, pid));
|
||||
}
|
||||
ErrorOr<NonnullRefPtr<ProcFSProcessPropertyInode>> ProcFSProcessPropertyInode::try_create_for_child_process_link(ProcFS const& procfs, ProcessID child_pid, ProcessID pid)
|
||||
ErrorOr<NonnullLockRefPtr<ProcFSProcessPropertyInode>> ProcFSProcessPropertyInode::try_create_for_child_process_link(ProcFS const& procfs, ProcessID child_pid, ProcessID pid)
|
||||
{
|
||||
return adopt_nonnull_ref_or_enomem(new (nothrow) ProcFSProcessPropertyInode(procfs, child_pid, pid));
|
||||
return adopt_nonnull_lock_ref_or_enomem(new (nothrow) ProcFSProcessPropertyInode(procfs, child_pid, pid));
|
||||
}
|
||||
|
||||
ProcFSProcessPropertyInode::ProcFSProcessPropertyInode(ProcFS const& procfs, SegmentedProcFSIndex::MainProcessProperty main_property_type, ProcessID pid)
|
||||
|
@ -528,7 +528,7 @@ ErrorOr<size_t> ProcFSProcessPropertyInode::read_bytes(off_t offset, size_t coun
|
|||
|
||||
return nread;
|
||||
}
|
||||
ErrorOr<NonnullRefPtr<Inode>> ProcFSProcessPropertyInode::lookup(StringView)
|
||||
ErrorOr<NonnullLockRefPtr<Inode>> ProcFSProcessPropertyInode::lookup(StringView)
|
||||
{
|
||||
return EINVAL;
|
||||
}
|
||||
|
|
|
@ -28,7 +28,7 @@ class ProcFS final : public FileSystem {
|
|||
|
||||
public:
|
||||
virtual ~ProcFS() override;
|
||||
static ErrorOr<NonnullRefPtr<FileSystem>> try_create();
|
||||
static ErrorOr<NonnullLockRefPtr<FileSystem>> try_create();
|
||||
|
||||
virtual ErrorOr<void> initialize() override;
|
||||
virtual StringView class_name() const override { return "ProcFS"sv; }
|
||||
|
@ -38,7 +38,7 @@ public:
|
|||
private:
|
||||
ProcFS();
|
||||
|
||||
RefPtr<ProcFSDirectoryInode> m_root_inode;
|
||||
LockRefPtr<ProcFSDirectoryInode> m_root_inode;
|
||||
};
|
||||
|
||||
class ProcFSInode : public Inode {
|
||||
|
@ -57,7 +57,7 @@ protected:
|
|||
virtual ErrorOr<void> attach(OpenFileDescription& description) override = 0;
|
||||
virtual void did_seek(OpenFileDescription&, off_t) override = 0;
|
||||
virtual ErrorOr<void> flush_metadata() override final;
|
||||
virtual ErrorOr<NonnullRefPtr<Inode>> create_child(StringView name, mode_t, dev_t, UserID, GroupID) override final;
|
||||
virtual ErrorOr<NonnullLockRefPtr<Inode>> create_child(StringView name, mode_t, dev_t, UserID, GroupID) override final;
|
||||
virtual ErrorOr<void> add_child(Inode&, StringView name, mode_t) override final;
|
||||
virtual ErrorOr<void> remove_child(StringView name) override final;
|
||||
virtual ErrorOr<void> chmod(mode_t) override final;
|
||||
|
@ -68,7 +68,7 @@ class ProcFSGlobalInode : public ProcFSInode {
|
|||
friend class ProcFS;
|
||||
|
||||
public:
|
||||
static ErrorOr<NonnullRefPtr<ProcFSGlobalInode>> try_create(ProcFS const&, ProcFSExposedComponent const&);
|
||||
static ErrorOr<NonnullLockRefPtr<ProcFSGlobalInode>> try_create(ProcFS const&, ProcFSExposedComponent const&);
|
||||
virtual ~ProcFSGlobalInode() override {};
|
||||
StringView name() const;
|
||||
|
||||
|
@ -82,18 +82,18 @@ protected:
|
|||
virtual void did_seek(OpenFileDescription&, off_t) override final;
|
||||
virtual InodeMetadata metadata() const override;
|
||||
virtual ErrorOr<void> traverse_as_directory(Function<ErrorOr<void>(FileSystem::DirectoryEntryView const&)>) const override;
|
||||
virtual ErrorOr<NonnullRefPtr<Inode>> lookup(StringView) override;
|
||||
virtual ErrorOr<NonnullLockRefPtr<Inode>> lookup(StringView) override;
|
||||
virtual ErrorOr<void> truncate(u64) override final;
|
||||
virtual ErrorOr<void> set_mtime(time_t) override final;
|
||||
|
||||
NonnullRefPtr<ProcFSExposedComponent> m_associated_component;
|
||||
NonnullLockRefPtr<ProcFSExposedComponent> m_associated_component;
|
||||
};
|
||||
|
||||
class ProcFSLinkInode : public ProcFSGlobalInode {
|
||||
friend class ProcFS;
|
||||
|
||||
public:
|
||||
static ErrorOr<NonnullRefPtr<ProcFSLinkInode>> try_create(ProcFS const&, ProcFSExposedComponent const&);
|
||||
static ErrorOr<NonnullLockRefPtr<ProcFSLinkInode>> try_create(ProcFS const&, ProcFSExposedComponent const&);
|
||||
|
||||
protected:
|
||||
ProcFSLinkInode(ProcFS const&, ProcFSExposedComponent const&);
|
||||
|
@ -104,7 +104,7 @@ class ProcFSDirectoryInode final : public ProcFSGlobalInode {
|
|||
friend class ProcFS;
|
||||
|
||||
public:
|
||||
static ErrorOr<NonnullRefPtr<ProcFSDirectoryInode>> try_create(ProcFS const&, ProcFSExposedComponent const&);
|
||||
static ErrorOr<NonnullLockRefPtr<ProcFSDirectoryInode>> try_create(ProcFS const&, ProcFSExposedComponent const&);
|
||||
virtual ~ProcFSDirectoryInode() override;
|
||||
|
||||
protected:
|
||||
|
@ -112,7 +112,7 @@ protected:
|
|||
// ^Inode
|
||||
virtual InodeMetadata metadata() const override;
|
||||
virtual ErrorOr<void> traverse_as_directory(Function<ErrorOr<void>(FileSystem::DirectoryEntryView const&)>) const override;
|
||||
virtual ErrorOr<NonnullRefPtr<Inode>> lookup(StringView name) override;
|
||||
virtual ErrorOr<NonnullLockRefPtr<Inode>> lookup(StringView name) override;
|
||||
};
|
||||
|
||||
class ProcFSProcessAssociatedInode : public ProcFSInode {
|
||||
|
@ -133,7 +133,7 @@ class ProcFSProcessDirectoryInode final : public ProcFSProcessAssociatedInode {
|
|||
friend class ProcFS;
|
||||
|
||||
public:
|
||||
static ErrorOr<NonnullRefPtr<ProcFSProcessDirectoryInode>> try_create(ProcFS const&, ProcessID);
|
||||
static ErrorOr<NonnullLockRefPtr<ProcFSProcessDirectoryInode>> try_create(ProcFS const&, ProcessID);
|
||||
|
||||
private:
|
||||
ProcFSProcessDirectoryInode(ProcFS const&, ProcessID);
|
||||
|
@ -143,14 +143,14 @@ private:
|
|||
virtual InodeMetadata metadata() const override;
|
||||
virtual ErrorOr<void> traverse_as_directory(Function<ErrorOr<void>(FileSystem::DirectoryEntryView const&)>) const override;
|
||||
virtual ErrorOr<size_t> read_bytes(off_t, size_t, UserOrKernelBuffer& buffer, OpenFileDescription*) const override final;
|
||||
virtual ErrorOr<NonnullRefPtr<Inode>> lookup(StringView name) override;
|
||||
virtual ErrorOr<NonnullLockRefPtr<Inode>> lookup(StringView name) override;
|
||||
};
|
||||
|
||||
class ProcFSProcessSubDirectoryInode final : public ProcFSProcessAssociatedInode {
|
||||
friend class ProcFS;
|
||||
|
||||
public:
|
||||
static ErrorOr<NonnullRefPtr<ProcFSProcessSubDirectoryInode>> try_create(ProcFS const&, SegmentedProcFSIndex::ProcessSubDirectory, ProcessID);
|
||||
static ErrorOr<NonnullLockRefPtr<ProcFSProcessSubDirectoryInode>> try_create(ProcFS const&, SegmentedProcFSIndex::ProcessSubDirectory, ProcessID);
|
||||
|
||||
private:
|
||||
ProcFSProcessSubDirectoryInode(ProcFS const&, SegmentedProcFSIndex::ProcessSubDirectory, ProcessID);
|
||||
|
@ -160,7 +160,7 @@ private:
|
|||
virtual InodeMetadata metadata() const override;
|
||||
virtual ErrorOr<void> traverse_as_directory(Function<ErrorOr<void>(FileSystem::DirectoryEntryView const&)>) const override;
|
||||
virtual ErrorOr<size_t> read_bytes(off_t, size_t, UserOrKernelBuffer& buffer, OpenFileDescription*) const override final;
|
||||
virtual ErrorOr<NonnullRefPtr<Inode>> lookup(StringView name) override;
|
||||
virtual ErrorOr<NonnullLockRefPtr<Inode>> lookup(StringView name) override;
|
||||
|
||||
const SegmentedProcFSIndex::ProcessSubDirectory m_sub_directory_type;
|
||||
};
|
||||
|
@ -169,10 +169,10 @@ class ProcFSProcessPropertyInode final : public ProcFSProcessAssociatedInode {
|
|||
friend class ProcFS;
|
||||
|
||||
public:
|
||||
static ErrorOr<NonnullRefPtr<ProcFSProcessPropertyInode>> try_create_for_file_description_link(ProcFS const&, unsigned, ProcessID);
|
||||
static ErrorOr<NonnullRefPtr<ProcFSProcessPropertyInode>> try_create_for_thread_stack(ProcFS const&, ThreadID, ProcessID);
|
||||
static ErrorOr<NonnullRefPtr<ProcFSProcessPropertyInode>> try_create_for_pid_property(ProcFS const&, SegmentedProcFSIndex::MainProcessProperty, ProcessID);
|
||||
static ErrorOr<NonnullRefPtr<ProcFSProcessPropertyInode>> try_create_for_child_process_link(ProcFS const&, ProcessID, ProcessID);
|
||||
static ErrorOr<NonnullLockRefPtr<ProcFSProcessPropertyInode>> try_create_for_file_description_link(ProcFS const&, unsigned, ProcessID);
|
||||
static ErrorOr<NonnullLockRefPtr<ProcFSProcessPropertyInode>> try_create_for_thread_stack(ProcFS const&, ThreadID, ProcessID);
|
||||
static ErrorOr<NonnullLockRefPtr<ProcFSProcessPropertyInode>> try_create_for_pid_property(ProcFS const&, SegmentedProcFSIndex::MainProcessProperty, ProcessID);
|
||||
static ErrorOr<NonnullLockRefPtr<ProcFSProcessPropertyInode>> try_create_for_child_process_link(ProcFS const&, ProcessID, ProcessID);
|
||||
|
||||
private:
|
||||
ProcFSProcessPropertyInode(ProcFS const&, SegmentedProcFSIndex::MainProcessProperty, ProcessID);
|
||||
|
@ -186,7 +186,7 @@ private:
|
|||
virtual InodeMetadata metadata() const override;
|
||||
virtual ErrorOr<void> traverse_as_directory(Function<ErrorOr<void>(FileSystem::DirectoryEntryView const&)>) const override;
|
||||
virtual ErrorOr<size_t> read_bytes(off_t, size_t, UserOrKernelBuffer& buffer, OpenFileDescription*) const override final;
|
||||
virtual ErrorOr<NonnullRefPtr<Inode>> lookup(StringView name) override final;
|
||||
virtual ErrorOr<NonnullLockRefPtr<Inode>> lookup(StringView name) override final;
|
||||
|
||||
ErrorOr<void> refresh_data(OpenFileDescription& description);
|
||||
ErrorOr<void> try_to_acquire_data(Process& process, KBufferBuilder& builder) const;
|
||||
|
|
|
@ -12,9 +12,9 @@
|
|||
|
||||
namespace Kernel {
|
||||
|
||||
ErrorOr<NonnullRefPtr<FileSystem>> SysFS::try_create()
|
||||
ErrorOr<NonnullLockRefPtr<FileSystem>> SysFS::try_create()
|
||||
{
|
||||
return TRY(adopt_nonnull_ref_or_enomem(new (nothrow) SysFS));
|
||||
return TRY(adopt_nonnull_lock_ref_or_enomem(new (nothrow) SysFS));
|
||||
}
|
||||
|
||||
SysFS::SysFS() = default;
|
||||
|
@ -31,9 +31,9 @@ Inode& SysFS::root_inode()
|
|||
return *m_root_inode;
|
||||
}
|
||||
|
||||
ErrorOr<NonnullRefPtr<SysFSInode>> SysFSInode::try_create(SysFS const& fs, SysFSComponent const& component)
|
||||
ErrorOr<NonnullLockRefPtr<SysFSInode>> SysFSInode::try_create(SysFS const& fs, SysFSComponent const& component)
|
||||
{
|
||||
return adopt_nonnull_ref_or_enomem(new (nothrow) SysFSInode(fs, component));
|
||||
return adopt_nonnull_lock_ref_or_enomem(new (nothrow) SysFSInode(fs, component));
|
||||
}
|
||||
|
||||
SysFSInode::SysFSInode(SysFS const& fs, SysFSComponent const& component)
|
||||
|
@ -68,7 +68,7 @@ ErrorOr<void> SysFSInode::traverse_as_directory(Function<ErrorOr<void>(FileSyste
|
|||
VERIFY_NOT_REACHED();
|
||||
}
|
||||
|
||||
ErrorOr<NonnullRefPtr<Inode>> SysFSInode::lookup(StringView)
|
||||
ErrorOr<NonnullLockRefPtr<Inode>> SysFSInode::lookup(StringView)
|
||||
{
|
||||
VERIFY_NOT_REACHED();
|
||||
}
|
||||
|
@ -96,7 +96,7 @@ ErrorOr<size_t> SysFSInode::write_bytes(off_t offset, size_t count, UserOrKernel
|
|||
return m_associated_component->write_bytes(offset, count, buffer, fd);
|
||||
}
|
||||
|
||||
ErrorOr<NonnullRefPtr<Inode>> SysFSInode::create_child(StringView, mode_t, dev_t, UserID, GroupID)
|
||||
ErrorOr<NonnullLockRefPtr<Inode>> SysFSInode::create_child(StringView, mode_t, dev_t, UserID, GroupID)
|
||||
{
|
||||
return EROFS;
|
||||
}
|
||||
|
@ -131,9 +131,9 @@ ErrorOr<void> SysFSInode::truncate(u64 size)
|
|||
return m_associated_component->truncate(size);
|
||||
}
|
||||
|
||||
ErrorOr<NonnullRefPtr<SysFSLinkInode>> SysFSLinkInode::try_create(SysFS const& sysfs, SysFSComponent const& component)
|
||||
ErrorOr<NonnullLockRefPtr<SysFSLinkInode>> SysFSLinkInode::try_create(SysFS const& sysfs, SysFSComponent const& component)
|
||||
{
|
||||
return adopt_nonnull_ref_or_enomem(new (nothrow) SysFSLinkInode(sysfs, component));
|
||||
return adopt_nonnull_lock_ref_or_enomem(new (nothrow) SysFSLinkInode(sysfs, component));
|
||||
}
|
||||
|
||||
SysFSLinkInode::SysFSLinkInode(SysFS const& fs, SysFSComponent const& component)
|
||||
|
@ -156,9 +156,9 @@ InodeMetadata SysFSLinkInode::metadata() const
|
|||
return metadata;
|
||||
}
|
||||
|
||||
ErrorOr<NonnullRefPtr<SysFSDirectoryInode>> SysFSDirectoryInode::try_create(SysFS const& sysfs, SysFSComponent const& component)
|
||||
ErrorOr<NonnullLockRefPtr<SysFSDirectoryInode>> SysFSDirectoryInode::try_create(SysFS const& sysfs, SysFSComponent const& component)
|
||||
{
|
||||
return adopt_nonnull_ref_or_enomem(new (nothrow) SysFSDirectoryInode(sysfs, component));
|
||||
return adopt_nonnull_lock_ref_or_enomem(new (nothrow) SysFSDirectoryInode(sysfs, component));
|
||||
}
|
||||
|
||||
SysFSDirectoryInode::SysFSDirectoryInode(SysFS const& fs, SysFSComponent const& component)
|
||||
|
@ -186,7 +186,7 @@ ErrorOr<void> SysFSDirectoryInode::traverse_as_directory(Function<ErrorOr<void>(
|
|||
return m_associated_component->traverse_as_directory(fs().fsid(), move(callback));
|
||||
}
|
||||
|
||||
ErrorOr<NonnullRefPtr<Inode>> SysFSDirectoryInode::lookup(StringView name)
|
||||
ErrorOr<NonnullLockRefPtr<Inode>> SysFSDirectoryInode::lookup(StringView name)
|
||||
{
|
||||
MutexLocker locker(fs().m_lock);
|
||||
auto component = m_associated_component->lookup(name);
|
||||
|
|
|
@ -19,7 +19,7 @@ class SysFS final : public FileSystem {
|
|||
|
||||
public:
|
||||
virtual ~SysFS() override;
|
||||
static ErrorOr<NonnullRefPtr<FileSystem>> try_create();
|
||||
static ErrorOr<NonnullLockRefPtr<FileSystem>> try_create();
|
||||
|
||||
virtual ErrorOr<void> initialize() override;
|
||||
virtual StringView class_name() const override { return "SysFS"sv; }
|
||||
|
@ -29,7 +29,7 @@ public:
|
|||
private:
|
||||
SysFS();
|
||||
|
||||
RefPtr<SysFSInode> m_root_inode;
|
||||
LockRefPtr<SysFSInode> m_root_inode;
|
||||
};
|
||||
|
||||
class SysFSInode : public Inode {
|
||||
|
@ -37,18 +37,18 @@ class SysFSInode : public Inode {
|
|||
friend class SysFSDirectoryInode;
|
||||
|
||||
public:
|
||||
static ErrorOr<NonnullRefPtr<SysFSInode>> try_create(SysFS const&, SysFSComponent const&);
|
||||
static ErrorOr<NonnullLockRefPtr<SysFSInode>> try_create(SysFS const&, SysFSComponent const&);
|
||||
StringView name() const { return m_associated_component->name(); }
|
||||
|
||||
protected:
|
||||
SysFSInode(SysFS const&, SysFSComponent const&);
|
||||
virtual ErrorOr<size_t> read_bytes(off_t, size_t, UserOrKernelBuffer& buffer, OpenFileDescription*) const override;
|
||||
virtual ErrorOr<void> traverse_as_directory(Function<ErrorOr<void>(FileSystem::DirectoryEntryView const&)>) const override;
|
||||
virtual ErrorOr<NonnullRefPtr<Inode>> lookup(StringView name) override;
|
||||
virtual ErrorOr<NonnullLockRefPtr<Inode>> lookup(StringView name) override;
|
||||
virtual ErrorOr<void> flush_metadata() override;
|
||||
virtual InodeMetadata metadata() const override;
|
||||
virtual ErrorOr<size_t> write_bytes(off_t, size_t, UserOrKernelBuffer const&, OpenFileDescription*) override;
|
||||
virtual ErrorOr<NonnullRefPtr<Inode>> create_child(StringView name, mode_t, dev_t, UserID, GroupID) override;
|
||||
virtual ErrorOr<NonnullLockRefPtr<Inode>> create_child(StringView name, mode_t, dev_t, UserID, GroupID) override;
|
||||
virtual ErrorOr<void> add_child(Inode&, StringView name, mode_t) override;
|
||||
virtual ErrorOr<void> remove_child(StringView name) override;
|
||||
virtual ErrorOr<void> chmod(mode_t) override;
|
||||
|
@ -59,14 +59,14 @@ protected:
|
|||
virtual ErrorOr<void> attach(OpenFileDescription& description) override final;
|
||||
virtual void did_seek(OpenFileDescription&, off_t) override final;
|
||||
|
||||
NonnullRefPtr<SysFSComponent> m_associated_component;
|
||||
NonnullLockRefPtr<SysFSComponent> m_associated_component;
|
||||
};
|
||||
|
||||
class SysFSLinkInode : public SysFSInode {
|
||||
friend class SysFS;
|
||||
|
||||
public:
|
||||
static ErrorOr<NonnullRefPtr<SysFSLinkInode>> try_create(SysFS const&, SysFSComponent const&);
|
||||
static ErrorOr<NonnullLockRefPtr<SysFSLinkInode>> try_create(SysFS const&, SysFSComponent const&);
|
||||
virtual ~SysFSLinkInode() override;
|
||||
|
||||
protected:
|
||||
|
@ -79,7 +79,7 @@ class SysFSDirectoryInode : public SysFSInode {
|
|||
friend class SysFS;
|
||||
|
||||
public:
|
||||
static ErrorOr<NonnullRefPtr<SysFSDirectoryInode>> try_create(SysFS const&, SysFSComponent const&);
|
||||
static ErrorOr<NonnullLockRefPtr<SysFSDirectoryInode>> try_create(SysFS const&, SysFSComponent const&);
|
||||
virtual ~SysFSDirectoryInode() override;
|
||||
|
||||
SysFS& fs() { return static_cast<SysFS&>(Inode::fs()); }
|
||||
|
@ -90,7 +90,7 @@ protected:
|
|||
// ^Inode
|
||||
virtual InodeMetadata metadata() const override;
|
||||
virtual ErrorOr<void> traverse_as_directory(Function<ErrorOr<void>(FileSystem::DirectoryEntryView const&)>) const override;
|
||||
virtual ErrorOr<NonnullRefPtr<Inode>> lookup(StringView name) override;
|
||||
virtual ErrorOr<NonnullLockRefPtr<Inode>> lookup(StringView name) override;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -124,9 +124,9 @@ ErrorOr<void> SysFSDirectory::traverse_as_directory(FileSystemID fsid, Function<
|
|||
});
|
||||
}
|
||||
|
||||
RefPtr<SysFSComponent> SysFSDirectory::lookup(StringView name)
|
||||
LockRefPtr<SysFSComponent> SysFSDirectory::lookup(StringView name)
|
||||
{
|
||||
return m_child_components.with([&](auto& list) -> RefPtr<SysFSComponent> {
|
||||
return m_child_components.with([&](auto& list) -> LockRefPtr<SysFSComponent> {
|
||||
for (auto& child_component : list) {
|
||||
if (child_component.name() == name) {
|
||||
return child_component;
|
||||
|
@ -141,17 +141,17 @@ SysFSDirectory::SysFSDirectory(SysFSDirectory const& parent_directory)
|
|||
{
|
||||
}
|
||||
|
||||
ErrorOr<NonnullRefPtr<SysFSInode>> SysFSDirectory::to_inode(SysFS const& sysfs_instance) const
|
||||
ErrorOr<NonnullLockRefPtr<SysFSInode>> SysFSDirectory::to_inode(SysFS const& sysfs_instance) const
|
||||
{
|
||||
return TRY(SysFSDirectoryInode::try_create(sysfs_instance, *this));
|
||||
}
|
||||
|
||||
ErrorOr<NonnullRefPtr<SysFSInode>> SysFSSymbolicLink::to_inode(SysFS const& sysfs_instance) const
|
||||
ErrorOr<NonnullLockRefPtr<SysFSInode>> SysFSSymbolicLink::to_inode(SysFS const& sysfs_instance) const
|
||||
{
|
||||
return TRY(SysFSLinkInode::try_create(sysfs_instance, *this));
|
||||
}
|
||||
|
||||
ErrorOr<NonnullRefPtr<SysFSInode>> SysFSComponent::to_inode(SysFS const& sysfs_instance) const
|
||||
ErrorOr<NonnullLockRefPtr<SysFSInode>> SysFSComponent::to_inode(SysFS const& sysfs_instance) const
|
||||
{
|
||||
return SysFSInode::try_create(sysfs_instance, *this);
|
||||
}
|
||||
|
|
|
@ -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>>;
|
||||
|
||||
|
|
|
@ -31,7 +31,7 @@ public:
|
|||
SysFSBusDirectory& buses_directory();
|
||||
|
||||
private:
|
||||
NonnullRefPtr<SysFSRootDirectory> m_root_directory;
|
||||
NonnullLockRefPtr<SysFSRootDirectory> m_root_directory;
|
||||
Spinlock m_root_directory_lock { LockRank::None };
|
||||
};
|
||||
|
||||
|
|
|
@ -13,9 +13,9 @@
|
|||
|
||||
namespace Kernel {
|
||||
|
||||
NonnullRefPtr<SysFSRootDirectory> SysFSRootDirectory::create()
|
||||
NonnullLockRefPtr<SysFSRootDirectory> SysFSRootDirectory::create()
|
||||
{
|
||||
return adopt_ref(*new (nothrow) SysFSRootDirectory);
|
||||
return adopt_lock_ref(*new (nothrow) SysFSRootDirectory);
|
||||
}
|
||||
|
||||
SysFSRootDirectory::SysFSRootDirectory()
|
||||
|
|
|
@ -16,12 +16,12 @@ class SysFSRootDirectory final : public SysFSDirectory {
|
|||
|
||||
public:
|
||||
virtual StringView name() const override { return "."sv; }
|
||||
static NonnullRefPtr<SysFSRootDirectory> create();
|
||||
static NonnullLockRefPtr<SysFSRootDirectory> create();
|
||||
|
||||
private:
|
||||
virtual bool is_root_directory() const override final { return true; }
|
||||
SysFSRootDirectory();
|
||||
RefPtr<SysFSBusDirectory> m_buses_directory;
|
||||
LockRefPtr<SysFSBusDirectory> m_buses_directory;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -10,9 +10,9 @@
|
|||
|
||||
namespace Kernel {
|
||||
|
||||
UNMAP_AFTER_INIT NonnullRefPtr<SysFSBusDirectory> SysFSBusDirectory::must_create(SysFSRootDirectory const& parent_directory)
|
||||
UNMAP_AFTER_INIT NonnullLockRefPtr<SysFSBusDirectory> SysFSBusDirectory::must_create(SysFSRootDirectory const& parent_directory)
|
||||
{
|
||||
auto directory = adopt_ref(*new (nothrow) SysFSBusDirectory(parent_directory));
|
||||
auto directory = adopt_lock_ref(*new (nothrow) SysFSBusDirectory(parent_directory));
|
||||
return directory;
|
||||
}
|
||||
|
||||
|
|
|
@ -16,7 +16,7 @@ class SysFSBusDirectory : public SysFSDirectory {
|
|||
|
||||
public:
|
||||
virtual StringView name() const override { return "bus"sv; }
|
||||
static NonnullRefPtr<SysFSBusDirectory> must_create(SysFSRootDirectory const&);
|
||||
static NonnullLockRefPtr<SysFSBusDirectory> must_create(SysFSRootDirectory const&);
|
||||
|
||||
private:
|
||||
explicit SysFSBusDirectory(SysFSRootDirectory const&);
|
||||
|
|
|
@ -16,7 +16,7 @@ namespace Kernel {
|
|||
|
||||
UNMAP_AFTER_INIT void PCIBusSysFSDirectory::initialize()
|
||||
{
|
||||
auto pci_directory = adopt_ref(*new (nothrow) PCIBusSysFSDirectory());
|
||||
auto pci_directory = adopt_lock_ref(*new (nothrow) PCIBusSysFSDirectory());
|
||||
SysFSComponentRegistry::the().register_new_bus_directory(pci_directory);
|
||||
}
|
||||
|
||||
|
|
|
@ -48,9 +48,9 @@ StringView PCIDeviceAttributeSysFSComponent::name() const
|
|||
}
|
||||
}
|
||||
|
||||
NonnullRefPtr<PCIDeviceAttributeSysFSComponent> PCIDeviceAttributeSysFSComponent::create(PCIDeviceSysFSDirectory const& device, PCI::RegisterOffset offset, size_t field_bytes_width)
|
||||
NonnullLockRefPtr<PCIDeviceAttributeSysFSComponent> PCIDeviceAttributeSysFSComponent::create(PCIDeviceSysFSDirectory const& device, PCI::RegisterOffset offset, size_t field_bytes_width)
|
||||
{
|
||||
return adopt_ref(*new (nothrow) PCIDeviceAttributeSysFSComponent(device, offset, field_bytes_width));
|
||||
return adopt_lock_ref(*new (nothrow) PCIDeviceAttributeSysFSComponent(device, offset, field_bytes_width));
|
||||
}
|
||||
|
||||
PCIDeviceAttributeSysFSComponent::PCIDeviceAttributeSysFSComponent(PCIDeviceSysFSDirectory const& device, PCI::RegisterOffset offset, size_t field_bytes_width)
|
||||
|
|
|
@ -15,7 +15,7 @@ namespace Kernel {
|
|||
|
||||
class PCIDeviceAttributeSysFSComponent : public SysFSComponent {
|
||||
public:
|
||||
static NonnullRefPtr<PCIDeviceAttributeSysFSComponent> create(PCIDeviceSysFSDirectory const& device, PCI::RegisterOffset offset, size_t field_bytes_width);
|
||||
static NonnullLockRefPtr<PCIDeviceAttributeSysFSComponent> create(PCIDeviceSysFSDirectory const& device, PCI::RegisterOffset offset, size_t field_bytes_width);
|
||||
|
||||
virtual ErrorOr<size_t> read_bytes(off_t, size_t, UserOrKernelBuffer&, OpenFileDescription*) const override;
|
||||
virtual ~PCIDeviceAttributeSysFSComponent() {};
|
||||
|
@ -25,7 +25,7 @@ public:
|
|||
protected:
|
||||
ErrorOr<NonnullOwnPtr<KBuffer>> try_to_generate_buffer() const;
|
||||
PCIDeviceAttributeSysFSComponent(PCIDeviceSysFSDirectory const& device, PCI::RegisterOffset offset, size_t field_bytes_width);
|
||||
NonnullRefPtr<PCIDeviceSysFSDirectory> m_device;
|
||||
NonnullLockRefPtr<PCIDeviceSysFSDirectory> m_device;
|
||||
PCI::RegisterOffset m_offset;
|
||||
size_t m_field_bytes_width;
|
||||
};
|
||||
|
|
|
@ -13,11 +13,11 @@
|
|||
|
||||
namespace Kernel {
|
||||
|
||||
UNMAP_AFTER_INIT NonnullRefPtr<PCIDeviceSysFSDirectory> PCIDeviceSysFSDirectory::create(SysFSDirectory const& parent_directory, PCI::Address address)
|
||||
UNMAP_AFTER_INIT NonnullLockRefPtr<PCIDeviceSysFSDirectory> PCIDeviceSysFSDirectory::create(SysFSDirectory const& parent_directory, PCI::Address address)
|
||||
{
|
||||
// FIXME: Handle allocation failure gracefully
|
||||
auto device_name = MUST(KString::formatted("{:04x}:{:02x}:{:02x}.{}", address.domain(), address.bus(), address.device(), address.function()));
|
||||
auto directory = adopt_ref(*new (nothrow) PCIDeviceSysFSDirectory(move(device_name), parent_directory, address));
|
||||
auto directory = adopt_lock_ref(*new (nothrow) PCIDeviceSysFSDirectory(move(device_name), parent_directory, address));
|
||||
MUST(directory->m_child_components.with([&](auto& list) -> ErrorOr<void> {
|
||||
list.append(PCIDeviceAttributeSysFSComponent::create(*directory, PCI::RegisterOffset::VENDOR_ID, 2));
|
||||
list.append(PCIDeviceAttributeSysFSComponent::create(*directory, PCI::RegisterOffset::DEVICE_ID, 2));
|
||||
|
|
|
@ -14,7 +14,7 @@ namespace Kernel {
|
|||
|
||||
class PCIDeviceSysFSDirectory final : public SysFSDirectory {
|
||||
public:
|
||||
static NonnullRefPtr<PCIDeviceSysFSDirectory> create(SysFSDirectory const&, PCI::Address);
|
||||
static NonnullLockRefPtr<PCIDeviceSysFSDirectory> create(SysFSDirectory const&, PCI::Address);
|
||||
PCI::Address const& address() const { return m_address; }
|
||||
|
||||
virtual StringView name() const override { return m_device_directory_name->view(); }
|
||||
|
|
|
@ -40,7 +40,7 @@ UNMAP_AFTER_INIT SysFSUSBBusDirectory::SysFSUSBBusDirectory(SysFSBusDirectory& b
|
|||
|
||||
UNMAP_AFTER_INIT void SysFSUSBBusDirectory::initialize()
|
||||
{
|
||||
auto directory = adopt_ref(*new SysFSUSBBusDirectory(SysFSComponentRegistry::the().buses_directory()));
|
||||
auto directory = adopt_lock_ref(*new SysFSUSBBusDirectory(SysFSComponentRegistry::the().buses_directory()));
|
||||
SysFSComponentRegistry::the().register_new_bus_directory(directory);
|
||||
s_sysfs_usb_bus_directory = directory;
|
||||
}
|
||||
|
|
|
@ -11,10 +11,10 @@
|
|||
|
||||
namespace Kernel {
|
||||
|
||||
ErrorOr<NonnullRefPtr<SysFSUSBDeviceInformation>> SysFSUSBDeviceInformation::create(USB::Device& device)
|
||||
ErrorOr<NonnullLockRefPtr<SysFSUSBDeviceInformation>> SysFSUSBDeviceInformation::create(USB::Device& device)
|
||||
{
|
||||
auto device_name = TRY(KString::number(device.address()));
|
||||
return adopt_nonnull_ref_or_enomem(new (nothrow) SysFSUSBDeviceInformation(move(device_name), device));
|
||||
return adopt_nonnull_lock_ref_or_enomem(new (nothrow) SysFSUSBDeviceInformation(move(device_name), device));
|
||||
}
|
||||
|
||||
SysFSUSBDeviceInformation::SysFSUSBDeviceInformation(NonnullOwnPtr<KString> device_name, USB::Device& device)
|
||||
|
|
|
@ -20,7 +20,7 @@ class SysFSUSBDeviceInformation : public SysFSComponent {
|
|||
public:
|
||||
virtual ~SysFSUSBDeviceInformation() override;
|
||||
|
||||
static ErrorOr<NonnullRefPtr<SysFSUSBDeviceInformation>> create(USB::Device&);
|
||||
static ErrorOr<NonnullLockRefPtr<SysFSUSBDeviceInformation>> create(USB::Device&);
|
||||
virtual StringView name() const override { return m_device_name->view(); }
|
||||
|
||||
protected:
|
||||
|
@ -28,7 +28,7 @@ protected:
|
|||
|
||||
virtual ErrorOr<size_t> read_bytes(off_t offset, size_t count, UserOrKernelBuffer& buffer, OpenFileDescription*) const override;
|
||||
|
||||
NonnullRefPtr<USB::Device> m_device;
|
||||
NonnullLockRefPtr<USB::Device> m_device;
|
||||
|
||||
private:
|
||||
ErrorOr<void> try_generate(KBufferBuilder&);
|
||||
|
|
|
@ -12,9 +12,9 @@ namespace Kernel {
|
|||
|
||||
static SysFSBlockDevicesDirectory* s_the { nullptr };
|
||||
|
||||
NonnullRefPtr<SysFSBlockDevicesDirectory> SysFSBlockDevicesDirectory::must_create(SysFSDeviceIdentifiersDirectory const& devices_directory)
|
||||
NonnullLockRefPtr<SysFSBlockDevicesDirectory> SysFSBlockDevicesDirectory::must_create(SysFSDeviceIdentifiersDirectory const& devices_directory)
|
||||
{
|
||||
return adopt_ref_if_nonnull(new SysFSBlockDevicesDirectory(devices_directory)).release_nonnull();
|
||||
return adopt_lock_ref_if_nonnull(new SysFSBlockDevicesDirectory(devices_directory)).release_nonnull();
|
||||
}
|
||||
SysFSBlockDevicesDirectory::SysFSBlockDevicesDirectory(SysFSDeviceIdentifiersDirectory const& devices_directory)
|
||||
: SysFSDirectory(devices_directory)
|
||||
|
|
|
@ -17,7 +17,7 @@ class SysFSBlockDevicesDirectory final : public SysFSDirectory {
|
|||
|
||||
public:
|
||||
virtual StringView name() const override { return "block"sv; }
|
||||
static NonnullRefPtr<SysFSBlockDevicesDirectory> must_create(SysFSDeviceIdentifiersDirectory const&);
|
||||
static NonnullLockRefPtr<SysFSBlockDevicesDirectory> must_create(SysFSDeviceIdentifiersDirectory const&);
|
||||
|
||||
static SysFSBlockDevicesDirectory& the();
|
||||
|
||||
|
|
|
@ -12,9 +12,9 @@ namespace Kernel {
|
|||
|
||||
static SysFSCharacterDevicesDirectory* s_the { nullptr };
|
||||
|
||||
NonnullRefPtr<SysFSCharacterDevicesDirectory> SysFSCharacterDevicesDirectory::must_create(SysFSDeviceIdentifiersDirectory const& devices_directory)
|
||||
NonnullLockRefPtr<SysFSCharacterDevicesDirectory> SysFSCharacterDevicesDirectory::must_create(SysFSDeviceIdentifiersDirectory const& devices_directory)
|
||||
{
|
||||
return adopt_ref_if_nonnull(new SysFSCharacterDevicesDirectory(devices_directory)).release_nonnull();
|
||||
return adopt_lock_ref_if_nonnull(new SysFSCharacterDevicesDirectory(devices_directory)).release_nonnull();
|
||||
}
|
||||
SysFSCharacterDevicesDirectory::SysFSCharacterDevicesDirectory(SysFSDeviceIdentifiersDirectory const& devices_directory)
|
||||
: SysFSDirectory(devices_directory)
|
||||
|
|
|
@ -17,7 +17,7 @@ class SysFSCharacterDevicesDirectory final : public SysFSDirectory {
|
|||
|
||||
public:
|
||||
virtual StringView name() const override { return "char"sv; }
|
||||
static NonnullRefPtr<SysFSCharacterDevicesDirectory> must_create(SysFSDeviceIdentifiersDirectory const&);
|
||||
static NonnullLockRefPtr<SysFSCharacterDevicesDirectory> must_create(SysFSDeviceIdentifiersDirectory const&);
|
||||
|
||||
static SysFSCharacterDevicesDirectory& the();
|
||||
|
||||
|
|
|
@ -10,11 +10,11 @@
|
|||
|
||||
namespace Kernel {
|
||||
|
||||
NonnullRefPtr<SysFSDeviceComponent> SysFSDeviceComponent::must_create(Device const& device)
|
||||
NonnullLockRefPtr<SysFSDeviceComponent> SysFSDeviceComponent::must_create(Device const& device)
|
||||
{
|
||||
// FIXME: Handle allocation failure gracefully
|
||||
auto device_name = MUST(KString::formatted("{}:{}", device.major(), device.minor()));
|
||||
return adopt_ref_if_nonnull(new SysFSDeviceComponent(move(device_name), device)).release_nonnull();
|
||||
return adopt_lock_ref_if_nonnull(new SysFSDeviceComponent(move(device_name), device)).release_nonnull();
|
||||
}
|
||||
SysFSDeviceComponent::SysFSDeviceComponent(NonnullOwnPtr<KString> major_minor_formatted_device_name, Device const& device)
|
||||
: SysFSComponent()
|
||||
|
|
|
@ -14,12 +14,12 @@ namespace Kernel {
|
|||
|
||||
class SysFSDeviceComponent final
|
||||
: public SysFSComponent
|
||||
, public Weakable<SysFSDeviceComponent> {
|
||||
, public LockWeakable<SysFSDeviceComponent> {
|
||||
friend class SysFSBlockDevicesDirectory;
|
||||
friend class SysFSCharacterDevicesDirectory;
|
||||
|
||||
public:
|
||||
static NonnullRefPtr<SysFSDeviceComponent> must_create(Device const&);
|
||||
static NonnullLockRefPtr<SysFSDeviceComponent> must_create(Device const&);
|
||||
virtual StringView name() const override { return m_major_minor_formatted_device_name->view(); }
|
||||
bool is_block_device() const { return m_block_device; }
|
||||
|
||||
|
|
|
@ -20,9 +20,9 @@ SysFSDeviceIdentifiersDirectory& SysFSDeviceIdentifiersDirectory::the()
|
|||
return *s_the;
|
||||
}
|
||||
|
||||
UNMAP_AFTER_INIT NonnullRefPtr<SysFSDeviceIdentifiersDirectory> SysFSDeviceIdentifiersDirectory::must_create(SysFSRootDirectory const& root_directory)
|
||||
UNMAP_AFTER_INIT NonnullLockRefPtr<SysFSDeviceIdentifiersDirectory> SysFSDeviceIdentifiersDirectory::must_create(SysFSRootDirectory const& root_directory)
|
||||
{
|
||||
auto devices_directory = adopt_ref_if_nonnull(new SysFSDeviceIdentifiersDirectory(root_directory)).release_nonnull();
|
||||
auto devices_directory = adopt_lock_ref_if_nonnull(new SysFSDeviceIdentifiersDirectory(root_directory)).release_nonnull();
|
||||
MUST(devices_directory->m_child_components.with([&](auto& list) -> ErrorOr<void> {
|
||||
list.append(SysFSBlockDevicesDirectory::must_create(*devices_directory));
|
||||
list.append(SysFSCharacterDevicesDirectory::must_create(*devices_directory));
|
||||
|
|
|
@ -14,7 +14,7 @@ namespace Kernel {
|
|||
class SysFSDeviceIdentifiersDirectory final : public SysFSDirectory {
|
||||
public:
|
||||
virtual StringView name() const override { return "dev"sv; }
|
||||
static NonnullRefPtr<SysFSDeviceIdentifiersDirectory> must_create(SysFSRootDirectory const&);
|
||||
static NonnullLockRefPtr<SysFSDeviceIdentifiersDirectory> must_create(SysFSRootDirectory const&);
|
||||
|
||||
static SysFSDeviceIdentifiersDirectory& the();
|
||||
|
||||
|
|
|
@ -11,16 +11,16 @@
|
|||
|
||||
namespace Kernel {
|
||||
|
||||
ErrorOr<NonnullRefPtr<SysFSSymbolicLinkDeviceComponent>> SysFSSymbolicLinkDeviceComponent::try_create(SysFSCharacterDevicesDirectory const& parent_directory, Device const& device, SysFSComponent const& pointed_component)
|
||||
ErrorOr<NonnullLockRefPtr<SysFSSymbolicLinkDeviceComponent>> SysFSSymbolicLinkDeviceComponent::try_create(SysFSCharacterDevicesDirectory const& parent_directory, Device const& device, SysFSComponent const& pointed_component)
|
||||
{
|
||||
auto device_name = TRY(KString::formatted("{}:{}", device.major(), device.minor()));
|
||||
return adopt_nonnull_ref_or_enomem(new (nothrow) SysFSSymbolicLinkDeviceComponent(parent_directory, move(device_name), device, pointed_component));
|
||||
return adopt_nonnull_lock_ref_or_enomem(new (nothrow) SysFSSymbolicLinkDeviceComponent(parent_directory, move(device_name), device, pointed_component));
|
||||
}
|
||||
|
||||
ErrorOr<NonnullRefPtr<SysFSSymbolicLinkDeviceComponent>> SysFSSymbolicLinkDeviceComponent::try_create(SysFSBlockDevicesDirectory const& parent_directory, Device const& device, SysFSComponent const& pointed_component)
|
||||
ErrorOr<NonnullLockRefPtr<SysFSSymbolicLinkDeviceComponent>> SysFSSymbolicLinkDeviceComponent::try_create(SysFSBlockDevicesDirectory const& parent_directory, Device const& device, SysFSComponent const& pointed_component)
|
||||
{
|
||||
auto device_name = TRY(KString::formatted("{}:{}", device.major(), device.minor()));
|
||||
return adopt_nonnull_ref_or_enomem(new (nothrow) SysFSSymbolicLinkDeviceComponent(parent_directory, move(device_name), device, pointed_component));
|
||||
return adopt_nonnull_lock_ref_or_enomem(new (nothrow) SysFSSymbolicLinkDeviceComponent(parent_directory, move(device_name), device, pointed_component));
|
||||
}
|
||||
|
||||
SysFSSymbolicLinkDeviceComponent::SysFSSymbolicLinkDeviceComponent(SysFSCharacterDevicesDirectory const& parent_directory, NonnullOwnPtr<KString> major_minor_formatted_device_name, Device const& device, SysFSComponent const& pointed_component)
|
||||
|
|
|
@ -17,12 +17,12 @@ namespace Kernel {
|
|||
class SysFSDeviceIdentifiersDirectory;
|
||||
class SysFSSymbolicLinkDeviceComponent final
|
||||
: public SysFSSymbolicLink
|
||||
, public Weakable<SysFSSymbolicLinkDeviceComponent> {
|
||||
, public LockWeakable<SysFSSymbolicLinkDeviceComponent> {
|
||||
friend class SysFSComponentRegistry;
|
||||
|
||||
public:
|
||||
static ErrorOr<NonnullRefPtr<SysFSSymbolicLinkDeviceComponent>> try_create(SysFSCharacterDevicesDirectory const& parent_directory, Device const& device, SysFSComponent const& pointed_component);
|
||||
static ErrorOr<NonnullRefPtr<SysFSSymbolicLinkDeviceComponent>> try_create(SysFSBlockDevicesDirectory const& parent_directory, Device const& device, SysFSComponent const& pointed_component);
|
||||
static ErrorOr<NonnullLockRefPtr<SysFSSymbolicLinkDeviceComponent>> try_create(SysFSCharacterDevicesDirectory const& parent_directory, Device const& device, SysFSComponent const& pointed_component);
|
||||
static ErrorOr<NonnullLockRefPtr<SysFSSymbolicLinkDeviceComponent>> try_create(SysFSBlockDevicesDirectory const& parent_directory, Device const& device, SysFSComponent const& pointed_component);
|
||||
|
||||
virtual StringView name() const override { return m_major_minor_formatted_device_name->view(); }
|
||||
bool is_block_device() const { return m_block_device; }
|
||||
|
@ -31,7 +31,7 @@ private:
|
|||
SysFSSymbolicLinkDeviceComponent(SysFSCharacterDevicesDirectory const& parent_directory, NonnullOwnPtr<KString> major_minor_formatted_device_name, Device const&, SysFSComponent const& pointed_component);
|
||||
SysFSSymbolicLinkDeviceComponent(SysFSBlockDevicesDirectory const& parent_directory, NonnullOwnPtr<KString> major_minor_formatted_device_name, Device const&, SysFSComponent const& pointed_component);
|
||||
|
||||
IntrusiveListNode<SysFSSymbolicLinkDeviceComponent, NonnullRefPtr<SysFSSymbolicLinkDeviceComponent>> m_list_node;
|
||||
IntrusiveListNode<SysFSSymbolicLinkDeviceComponent, NonnullLockRefPtr<SysFSSymbolicLinkDeviceComponent>> m_list_node;
|
||||
bool const m_block_device { false };
|
||||
NonnullOwnPtr<KString> m_major_minor_formatted_device_name;
|
||||
};
|
||||
|
|
|
@ -12,9 +12,9 @@
|
|||
|
||||
namespace Kernel {
|
||||
|
||||
UNMAP_AFTER_INIT NonnullRefPtr<SysFSDevicesDirectory> SysFSDevicesDirectory::must_create(SysFSRootDirectory const& root_directory)
|
||||
UNMAP_AFTER_INIT NonnullLockRefPtr<SysFSDevicesDirectory> SysFSDevicesDirectory::must_create(SysFSRootDirectory const& root_directory)
|
||||
{
|
||||
auto devices_directory = adopt_ref_if_nonnull(new (nothrow) SysFSDevicesDirectory(root_directory)).release_nonnull();
|
||||
auto devices_directory = adopt_lock_ref_if_nonnull(new (nothrow) SysFSDevicesDirectory(root_directory)).release_nonnull();
|
||||
MUST(devices_directory->m_child_components.with([&](auto& list) -> ErrorOr<void> {
|
||||
list.append(SysFSStorageDirectory::must_create(*devices_directory));
|
||||
list.append(SysFSGraphicsDirectory::must_create(*devices_directory));
|
||||
|
|
|
@ -14,7 +14,7 @@ namespace Kernel {
|
|||
class SysFSDevicesDirectory final : public SysFSDirectory {
|
||||
public:
|
||||
virtual StringView name() const override { return "devices"sv; }
|
||||
static NonnullRefPtr<SysFSDevicesDirectory> must_create(SysFSRootDirectory const&);
|
||||
static NonnullLockRefPtr<SysFSDevicesDirectory> must_create(SysFSRootDirectory const&);
|
||||
|
||||
private:
|
||||
explicit SysFSDevicesDirectory(SysFSRootDirectory const&);
|
||||
|
|
|
@ -10,9 +10,9 @@
|
|||
|
||||
namespace Kernel {
|
||||
|
||||
UNMAP_AFTER_INIT NonnullRefPtr<SysFSGraphicsDirectory> SysFSGraphicsDirectory::must_create(SysFSDevicesDirectory const& parent_directory)
|
||||
UNMAP_AFTER_INIT NonnullLockRefPtr<SysFSGraphicsDirectory> SysFSGraphicsDirectory::must_create(SysFSDevicesDirectory const& parent_directory)
|
||||
{
|
||||
auto directory = adopt_ref(*new (nothrow) SysFSGraphicsDirectory(parent_directory));
|
||||
auto directory = adopt_lock_ref(*new (nothrow) SysFSGraphicsDirectory(parent_directory));
|
||||
MUST(directory->m_child_components.with([&](auto& list) -> ErrorOr<void> {
|
||||
list.append(SysFSDisplayConnectorsDirectory::must_create(*directory));
|
||||
return {};
|
||||
|
|
|
@ -17,7 +17,7 @@ class SysFSGraphicsDirectory : public SysFSDirectory {
|
|||
|
||||
public:
|
||||
virtual StringView name() const override { return "graphics"sv; }
|
||||
static NonnullRefPtr<SysFSGraphicsDirectory> must_create(SysFSDevicesDirectory const&);
|
||||
static NonnullLockRefPtr<SysFSGraphicsDirectory> must_create(SysFSDevicesDirectory const&);
|
||||
|
||||
private:
|
||||
explicit SysFSGraphicsDirectory(SysFSDevicesDirectory const&);
|
||||
|
|
|
@ -32,9 +32,9 @@ StringView DisplayConnectorAttributeSysFSComponent::name() const
|
|||
}
|
||||
}
|
||||
|
||||
NonnullRefPtr<DisplayConnectorAttributeSysFSComponent> DisplayConnectorAttributeSysFSComponent::must_create(DisplayConnectorSysFSDirectory const& device_directory, Type type)
|
||||
NonnullLockRefPtr<DisplayConnectorAttributeSysFSComponent> DisplayConnectorAttributeSysFSComponent::must_create(DisplayConnectorSysFSDirectory const& device_directory, Type type)
|
||||
{
|
||||
return adopt_ref(*new (nothrow) DisplayConnectorAttributeSysFSComponent(device_directory, type));
|
||||
return adopt_lock_ref(*new (nothrow) DisplayConnectorAttributeSysFSComponent(device_directory, type));
|
||||
}
|
||||
|
||||
DisplayConnectorAttributeSysFSComponent::DisplayConnectorAttributeSysFSComponent(DisplayConnectorSysFSDirectory const& device_directory, Type type)
|
||||
|
|
|
@ -25,7 +25,7 @@ public:
|
|||
};
|
||||
|
||||
public:
|
||||
static NonnullRefPtr<DisplayConnectorAttributeSysFSComponent> must_create(DisplayConnectorSysFSDirectory const& device_directory, Type);
|
||||
static NonnullLockRefPtr<DisplayConnectorAttributeSysFSComponent> must_create(DisplayConnectorSysFSDirectory const& device_directory, Type);
|
||||
|
||||
virtual ErrorOr<size_t> read_bytes(off_t, size_t, UserOrKernelBuffer&, OpenFileDescription*) const override;
|
||||
virtual ~DisplayConnectorAttributeSysFSComponent() {};
|
||||
|
@ -35,7 +35,7 @@ public:
|
|||
protected:
|
||||
ErrorOr<NonnullOwnPtr<KBuffer>> try_to_generate_buffer() const;
|
||||
DisplayConnectorAttributeSysFSComponent(DisplayConnectorSysFSDirectory const& device, Type);
|
||||
NonnullRefPtr<DisplayConnector> m_device;
|
||||
NonnullLockRefPtr<DisplayConnector> m_device;
|
||||
Type const m_type { Type::MutableModeSettingCapable };
|
||||
};
|
||||
|
||||
|
|
|
@ -19,11 +19,11 @@ DisplayConnector const& DisplayConnectorSysFSDirectory::device(Badge<DisplayConn
|
|||
return *m_device;
|
||||
}
|
||||
|
||||
UNMAP_AFTER_INIT NonnullRefPtr<DisplayConnectorSysFSDirectory> DisplayConnectorSysFSDirectory::create(SysFSDirectory const& parent_directory, DisplayConnector const& device)
|
||||
UNMAP_AFTER_INIT NonnullLockRefPtr<DisplayConnectorSysFSDirectory> DisplayConnectorSysFSDirectory::create(SysFSDirectory const& parent_directory, DisplayConnector const& device)
|
||||
{
|
||||
// FIXME: Handle allocation failure gracefully
|
||||
auto device_name = MUST(KString::formatted("{}", device.minor()));
|
||||
auto directory = adopt_ref(*new (nothrow) DisplayConnectorSysFSDirectory(move(device_name), parent_directory, device));
|
||||
auto directory = adopt_lock_ref(*new (nothrow) DisplayConnectorSysFSDirectory(move(device_name), parent_directory, device));
|
||||
MUST(directory->m_child_components.with([&](auto& list) -> ErrorOr<void> {
|
||||
list.append(DisplayConnectorAttributeSysFSComponent::must_create(*directory, DisplayConnectorAttributeSysFSComponent::Type::MutableModeSettingCapable));
|
||||
list.append(DisplayConnectorAttributeSysFSComponent::must_create(*directory, DisplayConnectorAttributeSysFSComponent::Type::DoubleFrameBufferingCapable));
|
||||
|
|
|
@ -15,7 +15,7 @@ namespace Kernel {
|
|||
class DisplayConnectorAttributeSysFSComponent;
|
||||
class DisplayConnectorSysFSDirectory final : public SysFSDirectory {
|
||||
public:
|
||||
static NonnullRefPtr<DisplayConnectorSysFSDirectory> create(SysFSDirectory const&, DisplayConnector const&);
|
||||
static NonnullLockRefPtr<DisplayConnectorSysFSDirectory> create(SysFSDirectory const&, DisplayConnector const&);
|
||||
|
||||
virtual StringView name() const override { return m_device_directory_name->view(); }
|
||||
|
||||
|
@ -23,7 +23,7 @@ public:
|
|||
|
||||
private:
|
||||
DisplayConnectorSysFSDirectory(NonnullOwnPtr<KString> device_directory_name, SysFSDirectory const&, DisplayConnector const&);
|
||||
RefPtr<DisplayConnector> m_device;
|
||||
LockRefPtr<DisplayConnector> m_device;
|
||||
NonnullOwnPtr<KString> m_device_directory_name;
|
||||
};
|
||||
|
||||
|
|
|
@ -16,9 +16,9 @@ namespace Kernel {
|
|||
|
||||
static SysFSDisplayConnectorsDirectory* s_the { nullptr };
|
||||
|
||||
UNMAP_AFTER_INIT NonnullRefPtr<SysFSDisplayConnectorsDirectory> SysFSDisplayConnectorsDirectory::must_create(SysFSGraphicsDirectory const& parent_directory)
|
||||
UNMAP_AFTER_INIT NonnullLockRefPtr<SysFSDisplayConnectorsDirectory> SysFSDisplayConnectorsDirectory::must_create(SysFSGraphicsDirectory const& parent_directory)
|
||||
{
|
||||
auto directory = adopt_ref(*new (nothrow) SysFSDisplayConnectorsDirectory(parent_directory));
|
||||
auto directory = adopt_lock_ref(*new (nothrow) SysFSDisplayConnectorsDirectory(parent_directory));
|
||||
s_the = directory;
|
||||
return directory;
|
||||
}
|
||||
|
|
|
@ -20,7 +20,7 @@ class SysFSDisplayConnectorsDirectory : public SysFSDirectory {
|
|||
public:
|
||||
virtual StringView name() const override { return "connectors"sv; }
|
||||
static SysFSDisplayConnectorsDirectory& the();
|
||||
static NonnullRefPtr<SysFSDisplayConnectorsDirectory> must_create(SysFSGraphicsDirectory const&);
|
||||
static NonnullLockRefPtr<SysFSDisplayConnectorsDirectory> must_create(SysFSGraphicsDirectory const&);
|
||||
|
||||
void plug(Badge<DisplayConnector>, DisplayConnectorSysFSDirectory&);
|
||||
void unplug(Badge<DisplayConnector>, SysFSDirectory&);
|
||||
|
|
|
@ -26,9 +26,9 @@ StringView StorageDeviceAttributeSysFSComponent::name() const
|
|||
}
|
||||
}
|
||||
|
||||
NonnullRefPtr<StorageDeviceAttributeSysFSComponent> StorageDeviceAttributeSysFSComponent::must_create(StorageDeviceSysFSDirectory const& device_directory, Type type)
|
||||
NonnullLockRefPtr<StorageDeviceAttributeSysFSComponent> StorageDeviceAttributeSysFSComponent::must_create(StorageDeviceSysFSDirectory const& device_directory, Type type)
|
||||
{
|
||||
return adopt_ref(*new (nothrow) StorageDeviceAttributeSysFSComponent(device_directory, type));
|
||||
return adopt_lock_ref(*new (nothrow) StorageDeviceAttributeSysFSComponent(device_directory, type));
|
||||
}
|
||||
|
||||
StorageDeviceAttributeSysFSComponent::StorageDeviceAttributeSysFSComponent(StorageDeviceSysFSDirectory const& device_directory, Type type)
|
||||
|
|
|
@ -21,7 +21,7 @@ public:
|
|||
};
|
||||
|
||||
public:
|
||||
static NonnullRefPtr<StorageDeviceAttributeSysFSComponent> must_create(StorageDeviceSysFSDirectory const& device_directory, Type);
|
||||
static NonnullLockRefPtr<StorageDeviceAttributeSysFSComponent> must_create(StorageDeviceSysFSDirectory const& device_directory, Type);
|
||||
|
||||
virtual ErrorOr<size_t> read_bytes(off_t, size_t, UserOrKernelBuffer&, OpenFileDescription*) const override;
|
||||
virtual ~StorageDeviceAttributeSysFSComponent() {};
|
||||
|
@ -31,7 +31,7 @@ public:
|
|||
protected:
|
||||
ErrorOr<NonnullOwnPtr<KBuffer>> try_to_generate_buffer() const;
|
||||
StorageDeviceAttributeSysFSComponent(StorageDeviceSysFSDirectory const& device, Type);
|
||||
NonnullRefPtr<StorageDevice> m_device;
|
||||
NonnullLockRefPtr<StorageDevice> m_device;
|
||||
Type const m_type { Type::EndLBA };
|
||||
};
|
||||
|
||||
|
|
|
@ -19,12 +19,12 @@ StorageDevice const& StorageDeviceSysFSDirectory::device(Badge<StorageDeviceAttr
|
|||
return *m_device;
|
||||
}
|
||||
|
||||
UNMAP_AFTER_INIT NonnullRefPtr<StorageDeviceSysFSDirectory> StorageDeviceSysFSDirectory::create(SysFSDirectory const& parent_directory, StorageDevice const& device)
|
||||
UNMAP_AFTER_INIT NonnullLockRefPtr<StorageDeviceSysFSDirectory> StorageDeviceSysFSDirectory::create(SysFSDirectory const& parent_directory, StorageDevice const& device)
|
||||
{
|
||||
// FIXME: Handle allocation failure gracefully
|
||||
auto lun_address = device.logical_unit_number_address();
|
||||
auto device_name = MUST(KString::formatted("{:02x}:{:02x}.{}", lun_address.controller_id, lun_address.target_id, lun_address.disk_id));
|
||||
auto directory = adopt_ref(*new (nothrow) StorageDeviceSysFSDirectory(move(device_name), parent_directory, device));
|
||||
auto directory = adopt_lock_ref(*new (nothrow) StorageDeviceSysFSDirectory(move(device_name), parent_directory, device));
|
||||
MUST(directory->m_child_components.with([&](auto& list) -> ErrorOr<void> {
|
||||
list.append(StorageDeviceAttributeSysFSComponent::must_create(*directory, StorageDeviceAttributeSysFSComponent::Type::EndLBA));
|
||||
list.append(StorageDeviceAttributeSysFSComponent::must_create(*directory, StorageDeviceAttributeSysFSComponent::Type::SectorSize));
|
||||
|
|
|
@ -15,7 +15,7 @@ namespace Kernel {
|
|||
class StorageDeviceAttributeSysFSComponent;
|
||||
class StorageDeviceSysFSDirectory final : public SysFSDirectory {
|
||||
public:
|
||||
static NonnullRefPtr<StorageDeviceSysFSDirectory> create(SysFSDirectory const&, StorageDevice const&);
|
||||
static NonnullLockRefPtr<StorageDeviceSysFSDirectory> create(SysFSDirectory const&, StorageDevice const&);
|
||||
|
||||
virtual StringView name() const override { return m_device_directory_name->view(); }
|
||||
|
||||
|
@ -23,7 +23,7 @@ public:
|
|||
|
||||
private:
|
||||
StorageDeviceSysFSDirectory(NonnullOwnPtr<KString> device_directory_name, SysFSDirectory const&, StorageDevice const&);
|
||||
RefPtr<StorageDevice> m_device;
|
||||
LockRefPtr<StorageDevice> m_device;
|
||||
NonnullOwnPtr<KString> m_device_directory_name;
|
||||
};
|
||||
|
||||
|
|
|
@ -15,9 +15,9 @@ namespace Kernel {
|
|||
|
||||
static SysFSStorageDirectory* s_the { nullptr };
|
||||
|
||||
UNMAP_AFTER_INIT NonnullRefPtr<SysFSStorageDirectory> SysFSStorageDirectory::must_create(SysFSDevicesDirectory const& parent_directory)
|
||||
UNMAP_AFTER_INIT NonnullLockRefPtr<SysFSStorageDirectory> SysFSStorageDirectory::must_create(SysFSDevicesDirectory const& parent_directory)
|
||||
{
|
||||
auto directory = adopt_ref(*new (nothrow) SysFSStorageDirectory(parent_directory));
|
||||
auto directory = adopt_lock_ref(*new (nothrow) SysFSStorageDirectory(parent_directory));
|
||||
s_the = directory;
|
||||
return directory;
|
||||
}
|
||||
|
|
|
@ -19,7 +19,7 @@ class SysFSStorageDirectory : public SysFSDirectory {
|
|||
public:
|
||||
virtual StringView name() const override { return "storage"sv; }
|
||||
static SysFSStorageDirectory& the();
|
||||
static NonnullRefPtr<SysFSStorageDirectory> must_create(SysFSDevicesDirectory const&);
|
||||
static NonnullLockRefPtr<SysFSStorageDirectory> must_create(SysFSDevicesDirectory const&);
|
||||
|
||||
void plug(Badge<StorageDevice>, StorageDeviceSysFSDirectory&);
|
||||
void unplug(Badge<StorageDevice>, SysFSDirectory&);
|
||||
|
|
|
@ -15,9 +15,9 @@
|
|||
|
||||
namespace Kernel {
|
||||
|
||||
NonnullRefPtr<BIOSSysFSComponent> BIOSSysFSComponent::must_create(Type type, PhysicalAddress blob_paddr, size_t blob_size)
|
||||
NonnullLockRefPtr<BIOSSysFSComponent> BIOSSysFSComponent::must_create(Type type, PhysicalAddress blob_paddr, size_t blob_size)
|
||||
{
|
||||
return adopt_ref_if_nonnull(new (nothrow) BIOSSysFSComponent(type, blob_paddr, blob_size)).release_nonnull();
|
||||
return adopt_lock_ref_if_nonnull(new (nothrow) BIOSSysFSComponent(type, blob_paddr, blob_size)).release_nonnull();
|
||||
}
|
||||
|
||||
UNMAP_AFTER_INIT BIOSSysFSComponent::BIOSSysFSComponent(Type type, PhysicalAddress blob_paddr, size_t blob_size)
|
||||
|
|
|
@ -6,11 +6,11 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <AK/RefPtr.h>
|
||||
#include <AK/Types.h>
|
||||
#include <AK/Vector.h>
|
||||
#include <Kernel/FileSystem/SysFS/Subsystems/Firmware/Directory.h>
|
||||
#include <Kernel/KBuffer.h>
|
||||
#include <Kernel/Library/LockRefPtr.h>
|
||||
#include <Kernel/PhysicalAddress.h>
|
||||
|
||||
namespace Kernel {
|
||||
|
@ -23,7 +23,7 @@ public:
|
|||
};
|
||||
|
||||
public:
|
||||
static NonnullRefPtr<BIOSSysFSComponent> must_create(Type, PhysicalAddress, size_t blob_size);
|
||||
static NonnullLockRefPtr<BIOSSysFSComponent> must_create(Type, PhysicalAddress, size_t blob_size);
|
||||
virtual StringView name() const override;
|
||||
virtual ErrorOr<size_t> read_bytes(off_t, size_t, UserOrKernelBuffer&, OpenFileDescription*) const override;
|
||||
|
||||
|
|
|
@ -39,9 +39,9 @@ UNMAP_AFTER_INIT void BIOSSysFSDirectory::set_dmi_32_bit_entry_initialization_va
|
|||
m_smbios_structure_table_length = smbios_entry.ptr()->legacy_structure.smbios_table_length;
|
||||
}
|
||||
|
||||
UNMAP_AFTER_INIT NonnullRefPtr<BIOSSysFSDirectory> BIOSSysFSDirectory::must_create(FirmwareSysFSDirectory& firmware_directory)
|
||||
UNMAP_AFTER_INIT NonnullLockRefPtr<BIOSSysFSDirectory> BIOSSysFSDirectory::must_create(FirmwareSysFSDirectory& firmware_directory)
|
||||
{
|
||||
auto bios_directory = MUST(adopt_nonnull_ref_or_enomem(new (nothrow) BIOSSysFSDirectory(firmware_directory)));
|
||||
auto bios_directory = MUST(adopt_nonnull_lock_ref_or_enomem(new (nothrow) BIOSSysFSDirectory(firmware_directory)));
|
||||
bios_directory->create_components();
|
||||
return bios_directory;
|
||||
}
|
||||
|
|
|
@ -6,11 +6,11 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <AK/RefPtr.h>
|
||||
#include <AK/Types.h>
|
||||
#include <AK/Vector.h>
|
||||
#include <Kernel/FileSystem/SysFS.h>
|
||||
#include <Kernel/FileSystem/SysFS/Subsystems/Firmware/Directory.h>
|
||||
#include <Kernel/Library/LockRefPtr.h>
|
||||
#include <Kernel/PhysicalAddress.h>
|
||||
|
||||
namespace Kernel {
|
||||
|
@ -18,7 +18,7 @@ namespace Kernel {
|
|||
class BIOSSysFSDirectory : public SysFSDirectory {
|
||||
public:
|
||||
virtual StringView name() const override { return "bios"sv; }
|
||||
static NonnullRefPtr<BIOSSysFSDirectory> must_create(FirmwareSysFSDirectory&);
|
||||
static NonnullLockRefPtr<BIOSSysFSDirectory> must_create(FirmwareSysFSDirectory&);
|
||||
|
||||
void create_components();
|
||||
|
||||
|
|
|
@ -15,7 +15,7 @@ namespace Kernel {
|
|||
|
||||
UNMAP_AFTER_INIT void FirmwareSysFSDirectory::initialize()
|
||||
{
|
||||
auto firmware_directory = adopt_ref_if_nonnull(new (nothrow) FirmwareSysFSDirectory()).release_nonnull();
|
||||
auto firmware_directory = adopt_lock_ref_if_nonnull(new (nothrow) FirmwareSysFSDirectory()).release_nonnull();
|
||||
SysFSComponentRegistry::the().register_new_component(firmware_directory);
|
||||
firmware_directory->create_components();
|
||||
}
|
||||
|
|
|
@ -20,9 +20,9 @@ mode_t PowerStateSwitchNode::permissions() const
|
|||
return S_IRUSR | S_IRGRP | S_IWUSR | S_IWGRP;
|
||||
}
|
||||
|
||||
UNMAP_AFTER_INIT NonnullRefPtr<PowerStateSwitchNode> PowerStateSwitchNode::must_create(FirmwareSysFSDirectory& firmware_directory)
|
||||
UNMAP_AFTER_INIT NonnullLockRefPtr<PowerStateSwitchNode> PowerStateSwitchNode::must_create(FirmwareSysFSDirectory& firmware_directory)
|
||||
{
|
||||
return adopt_ref_if_nonnull(new (nothrow) PowerStateSwitchNode(firmware_directory)).release_nonnull();
|
||||
return adopt_lock_ref_if_nonnull(new (nothrow) PowerStateSwitchNode(firmware_directory)).release_nonnull();
|
||||
}
|
||||
|
||||
UNMAP_AFTER_INIT PowerStateSwitchNode::PowerStateSwitchNode(FirmwareSysFSDirectory&)
|
||||
|
|
|
@ -7,12 +7,12 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <AK/RefPtr.h>
|
||||
#include <AK/Types.h>
|
||||
#include <AK/Vector.h>
|
||||
#include <Kernel/FileSystem/SysFS.h>
|
||||
#include <Kernel/FileSystem/SysFS/Subsystems/Firmware/Directory.h>
|
||||
#include <Kernel/KBuffer.h>
|
||||
#include <Kernel/Library/LockRefPtr.h>
|
||||
#include <Kernel/Memory/MappedROM.h>
|
||||
#include <Kernel/Memory/Region.h>
|
||||
#include <Kernel/PhysicalAddress.h>
|
||||
|
@ -23,7 +23,7 @@ namespace Kernel {
|
|||
class PowerStateSwitchNode final : public SysFSComponent {
|
||||
public:
|
||||
virtual StringView name() const override { return "power_state"sv; }
|
||||
static NonnullRefPtr<PowerStateSwitchNode> must_create(FirmwareSysFSDirectory&);
|
||||
static NonnullLockRefPtr<PowerStateSwitchNode> must_create(FirmwareSysFSDirectory&);
|
||||
virtual mode_t permissions() const override;
|
||||
virtual ErrorOr<size_t> write_bytes(off_t, size_t, UserOrKernelBuffer const&, OpenFileDescription*) override;
|
||||
virtual ErrorOr<void> truncate(u64) override;
|
||||
|
|
|
@ -10,9 +10,9 @@
|
|||
|
||||
namespace Kernel {
|
||||
|
||||
ErrorOr<NonnullRefPtr<FileSystem>> TmpFS::try_create()
|
||||
ErrorOr<NonnullLockRefPtr<FileSystem>> TmpFS::try_create()
|
||||
{
|
||||
return TRY(adopt_nonnull_ref_or_enomem(new (nothrow) TmpFS));
|
||||
return TRY(adopt_nonnull_lock_ref_or_enomem(new (nothrow) TmpFS));
|
||||
}
|
||||
|
||||
TmpFS::TmpFS() = default;
|
||||
|
@ -37,7 +37,7 @@ unsigned TmpFS::next_inode_index()
|
|||
return m_next_inode_index++;
|
||||
}
|
||||
|
||||
TmpFSInode::TmpFSInode(TmpFS& fs, InodeMetadata const& metadata, WeakPtr<TmpFSInode> parent)
|
||||
TmpFSInode::TmpFSInode(TmpFS& fs, InodeMetadata const& metadata, LockWeakPtr<TmpFSInode> parent)
|
||||
: Inode(fs, fs.next_inode_index())
|
||||
, m_metadata(metadata)
|
||||
, m_parent(move(parent))
|
||||
|
@ -47,12 +47,12 @@ TmpFSInode::TmpFSInode(TmpFS& fs, InodeMetadata const& metadata, WeakPtr<TmpFSIn
|
|||
|
||||
TmpFSInode::~TmpFSInode() = default;
|
||||
|
||||
ErrorOr<NonnullRefPtr<TmpFSInode>> TmpFSInode::try_create(TmpFS& fs, InodeMetadata const& metadata, WeakPtr<TmpFSInode> parent)
|
||||
ErrorOr<NonnullLockRefPtr<TmpFSInode>> TmpFSInode::try_create(TmpFS& fs, InodeMetadata const& metadata, LockWeakPtr<TmpFSInode> parent)
|
||||
{
|
||||
return adopt_nonnull_ref_or_enomem(new (nothrow) TmpFSInode(fs, metadata, move(parent)));
|
||||
return adopt_nonnull_lock_ref_or_enomem(new (nothrow) TmpFSInode(fs, metadata, move(parent)));
|
||||
}
|
||||
|
||||
ErrorOr<NonnullRefPtr<TmpFSInode>> TmpFSInode::try_create_root(TmpFS& fs)
|
||||
ErrorOr<NonnullLockRefPtr<TmpFSInode>> TmpFSInode::try_create_root(TmpFS& fs)
|
||||
{
|
||||
InodeMetadata metadata;
|
||||
auto now = kgettimeofday().to_truncated_seconds();
|
||||
|
@ -147,7 +147,7 @@ ErrorOr<size_t> TmpFSInode::write_bytes(off_t offset, size_t size, UserOrKernelB
|
|||
return size;
|
||||
}
|
||||
|
||||
ErrorOr<NonnullRefPtr<Inode>> TmpFSInode::lookup(StringView name)
|
||||
ErrorOr<NonnullLockRefPtr<Inode>> TmpFSInode::lookup(StringView name)
|
||||
{
|
||||
MutexLocker locker(m_inode_lock, Mutex::Mode::Shared);
|
||||
VERIFY(is_directory());
|
||||
|
@ -205,7 +205,7 @@ ErrorOr<void> TmpFSInode::chown(UserID uid, GroupID gid)
|
|||
return {};
|
||||
}
|
||||
|
||||
ErrorOr<NonnullRefPtr<Inode>> TmpFSInode::create_child(StringView name, mode_t mode, dev_t dev, UserID uid, GroupID gid)
|
||||
ErrorOr<NonnullLockRefPtr<Inode>> TmpFSInode::create_child(StringView name, mode_t mode, dev_t dev, UserID uid, GroupID gid)
|
||||
{
|
||||
MutexLocker locker(m_inode_lock);
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@ class TmpFS final : public FileSystem {
|
|||
|
||||
public:
|
||||
virtual ~TmpFS() override;
|
||||
static ErrorOr<NonnullRefPtr<FileSystem>> try_create();
|
||||
static ErrorOr<NonnullLockRefPtr<FileSystem>> try_create();
|
||||
virtual ErrorOr<void> initialize() override;
|
||||
|
||||
virtual StringView class_name() const override { return "TmpFS"sv; }
|
||||
|
@ -31,7 +31,7 @@ public:
|
|||
private:
|
||||
TmpFS();
|
||||
|
||||
RefPtr<TmpFSInode> m_root_inode;
|
||||
LockRefPtr<TmpFSInode> m_root_inode;
|
||||
|
||||
unsigned m_next_inode_index { 1 };
|
||||
unsigned next_inode_index();
|
||||
|
@ -50,10 +50,10 @@ public:
|
|||
virtual ErrorOr<size_t> read_bytes(off_t, size_t, UserOrKernelBuffer& buffer, OpenFileDescription*) const override;
|
||||
virtual InodeMetadata metadata() const override;
|
||||
virtual ErrorOr<void> traverse_as_directory(Function<ErrorOr<void>(FileSystem::DirectoryEntryView const&)>) const override;
|
||||
virtual ErrorOr<NonnullRefPtr<Inode>> lookup(StringView name) override;
|
||||
virtual ErrorOr<NonnullLockRefPtr<Inode>> lookup(StringView name) override;
|
||||
virtual ErrorOr<void> flush_metadata() override;
|
||||
virtual ErrorOr<size_t> write_bytes(off_t, size_t, UserOrKernelBuffer const& buffer, OpenFileDescription*) override;
|
||||
virtual ErrorOr<NonnullRefPtr<Inode>> create_child(StringView name, mode_t, dev_t, UserID, GroupID) override;
|
||||
virtual ErrorOr<NonnullLockRefPtr<Inode>> create_child(StringView name, mode_t, dev_t, UserID, GroupID) override;
|
||||
virtual ErrorOr<void> add_child(Inode&, StringView name, mode_t) override;
|
||||
virtual ErrorOr<void> remove_child(StringView name) override;
|
||||
virtual ErrorOr<void> chmod(mode_t) override;
|
||||
|
@ -64,13 +64,13 @@ public:
|
|||
virtual ErrorOr<void> set_mtime(time_t) override;
|
||||
|
||||
private:
|
||||
TmpFSInode(TmpFS& fs, InodeMetadata const& metadata, WeakPtr<TmpFSInode> parent);
|
||||
static ErrorOr<NonnullRefPtr<TmpFSInode>> try_create(TmpFS&, InodeMetadata const& metadata, WeakPtr<TmpFSInode> parent);
|
||||
static ErrorOr<NonnullRefPtr<TmpFSInode>> try_create_root(TmpFS&);
|
||||
TmpFSInode(TmpFS& fs, InodeMetadata const& metadata, LockWeakPtr<TmpFSInode> parent);
|
||||
static ErrorOr<NonnullLockRefPtr<TmpFSInode>> try_create(TmpFS&, InodeMetadata const& metadata, LockWeakPtr<TmpFSInode> parent);
|
||||
static ErrorOr<NonnullLockRefPtr<TmpFSInode>> try_create_root(TmpFS&);
|
||||
|
||||
struct Child {
|
||||
NonnullOwnPtr<KString> name;
|
||||
NonnullRefPtr<TmpFSInode> inode;
|
||||
NonnullLockRefPtr<TmpFSInode> inode;
|
||||
IntrusiveListNode<Child> list_node {};
|
||||
using List = IntrusiveList<&Child::list_node>;
|
||||
};
|
||||
|
@ -78,7 +78,7 @@ private:
|
|||
Child* find_child_by_name(StringView);
|
||||
|
||||
InodeMetadata m_metadata;
|
||||
WeakPtr<TmpFSInode> m_parent;
|
||||
LockWeakPtr<TmpFSInode> m_parent;
|
||||
|
||||
OwnPtr<KBuffer> m_content;
|
||||
|
||||
|
|
|
@ -239,12 +239,12 @@ ErrorOr<InodeMetadata> VirtualFileSystem::lookup_metadata(StringView path, Custo
|
|||
return custody->inode().metadata();
|
||||
}
|
||||
|
||||
ErrorOr<NonnullRefPtr<OpenFileDescription>> VirtualFileSystem::open(StringView path, int options, mode_t mode, Custody& base, Optional<UidAndGid> owner)
|
||||
ErrorOr<NonnullLockRefPtr<OpenFileDescription>> VirtualFileSystem::open(StringView path, int options, mode_t mode, Custody& base, Optional<UidAndGid> owner)
|
||||
{
|
||||
if ((options & O_CREAT) && (options & O_DIRECTORY))
|
||||
return EINVAL;
|
||||
|
||||
RefPtr<Custody> parent_custody;
|
||||
LockRefPtr<Custody> parent_custody;
|
||||
auto custody_or_error = resolve_path(path, base, &parent_custody, options);
|
||||
if (custody_or_error.is_error()) {
|
||||
// NOTE: ENOENT with a non-null parent custody signals us that the immediate parent
|
||||
|
@ -332,7 +332,7 @@ ErrorOr<void> VirtualFileSystem::mknod(StringView path, mode_t mode, dev_t dev,
|
|||
if (!is_regular_file(mode) && !is_block_device(mode) && !is_character_device(mode) && !is_fifo(mode) && !is_socket(mode))
|
||||
return EINVAL;
|
||||
|
||||
RefPtr<Custody> parent_custody;
|
||||
LockRefPtr<Custody> parent_custody;
|
||||
auto existing_file_or_error = resolve_path(path, base, &parent_custody);
|
||||
if (!existing_file_or_error.is_error())
|
||||
return EEXIST;
|
||||
|
@ -353,7 +353,7 @@ ErrorOr<void> VirtualFileSystem::mknod(StringView path, mode_t mode, dev_t dev,
|
|||
return {};
|
||||
}
|
||||
|
||||
ErrorOr<NonnullRefPtr<OpenFileDescription>> VirtualFileSystem::create(StringView path, int options, mode_t mode, Custody& parent_custody, Optional<UidAndGid> owner)
|
||||
ErrorOr<NonnullLockRefPtr<OpenFileDescription>> VirtualFileSystem::create(StringView path, int options, mode_t mode, Custody& parent_custody, Optional<UidAndGid> owner)
|
||||
{
|
||||
auto basename = KLexicalPath::basename(path);
|
||||
auto parent_path = TRY(parent_custody.try_serialize_absolute_path());
|
||||
|
@ -397,7 +397,7 @@ ErrorOr<void> VirtualFileSystem::mkdir(StringView path, mode_t mode, Custody& ba
|
|||
path = "/"sv;
|
||||
}
|
||||
|
||||
RefPtr<Custody> parent_custody;
|
||||
LockRefPtr<Custody> parent_custody;
|
||||
// FIXME: The errors returned by resolve_path_without_veil can leak information about paths that are not unveiled,
|
||||
// e.g. when the error is EACCESS or similar.
|
||||
auto result = resolve_path_without_veil(path, base, &parent_custody);
|
||||
|
@ -446,7 +446,7 @@ ErrorOr<void> VirtualFileSystem::access(StringView path, int mode, Custody& base
|
|||
return {};
|
||||
}
|
||||
|
||||
ErrorOr<NonnullRefPtr<Custody>> VirtualFileSystem::open_directory(StringView path, Custody& base)
|
||||
ErrorOr<NonnullLockRefPtr<Custody>> VirtualFileSystem::open_directory(StringView path, Custody& base)
|
||||
{
|
||||
auto custody = TRY(resolve_path(path, base));
|
||||
auto& inode = custody->inode();
|
||||
|
@ -480,11 +480,11 @@ ErrorOr<void> VirtualFileSystem::chmod(StringView path, mode_t mode, Custody& ba
|
|||
|
||||
ErrorOr<void> VirtualFileSystem::rename(StringView old_path, StringView new_path, Custody& base)
|
||||
{
|
||||
RefPtr<Custody> old_parent_custody;
|
||||
LockRefPtr<Custody> old_parent_custody;
|
||||
auto old_custody = TRY(resolve_path(old_path, base, &old_parent_custody, O_NOFOLLOW_NOERROR));
|
||||
auto& old_inode = old_custody->inode();
|
||||
|
||||
RefPtr<Custody> new_parent_custody;
|
||||
LockRefPtr<Custody> new_parent_custody;
|
||||
auto new_custody_or_error = resolve_path(new_path, base, &new_parent_custody);
|
||||
if (new_custody_or_error.is_error()) {
|
||||
if (new_custody_or_error.error().code() != ENOENT || !new_parent_custody)
|
||||
|
@ -630,7 +630,7 @@ ErrorOr<void> VirtualFileSystem::link(StringView old_path, StringView new_path,
|
|||
auto old_custody = TRY(resolve_path(old_path, base));
|
||||
auto& old_inode = old_custody->inode();
|
||||
|
||||
RefPtr<Custody> parent_custody;
|
||||
LockRefPtr<Custody> parent_custody;
|
||||
auto new_custody_or_error = resolve_path(new_path, base, &parent_custody);
|
||||
if (!new_custody_or_error.is_error())
|
||||
return EEXIST;
|
||||
|
@ -660,7 +660,7 @@ ErrorOr<void> VirtualFileSystem::link(StringView old_path, StringView new_path,
|
|||
|
||||
ErrorOr<void> VirtualFileSystem::unlink(StringView path, Custody& base)
|
||||
{
|
||||
RefPtr<Custody> parent_custody;
|
||||
LockRefPtr<Custody> parent_custody;
|
||||
auto custody = TRY(resolve_path(path, base, &parent_custody, O_NOFOLLOW_NOERROR | O_UNLINK_INTERNAL));
|
||||
auto& inode = custody->inode();
|
||||
|
||||
|
@ -690,7 +690,7 @@ ErrorOr<void> VirtualFileSystem::unlink(StringView path, Custody& base)
|
|||
|
||||
ErrorOr<void> VirtualFileSystem::symlink(StringView target, StringView linkpath, Custody& base)
|
||||
{
|
||||
RefPtr<Custody> parent_custody;
|
||||
LockRefPtr<Custody> parent_custody;
|
||||
auto existing_custody_or_error = resolve_path(linkpath, base, &parent_custody);
|
||||
if (!existing_custody_or_error.is_error())
|
||||
return EEXIST;
|
||||
|
@ -719,7 +719,7 @@ ErrorOr<void> VirtualFileSystem::symlink(StringView target, StringView linkpath,
|
|||
|
||||
ErrorOr<void> VirtualFileSystem::rmdir(StringView path, Custody& base)
|
||||
{
|
||||
RefPtr<Custody> parent_custody;
|
||||
LockRefPtr<Custody> parent_custody;
|
||||
auto custody = TRY(resolve_path(path, base, &parent_custody));
|
||||
auto& inode = custody->inode();
|
||||
|
||||
|
@ -871,7 +871,7 @@ ErrorOr<void> VirtualFileSystem::validate_path_against_process_veil(StringView p
|
|||
return {};
|
||||
}
|
||||
|
||||
ErrorOr<NonnullRefPtr<Custody>> VirtualFileSystem::resolve_path(StringView path, Custody& base, RefPtr<Custody>* out_parent, int options, int symlink_recursion_level)
|
||||
ErrorOr<NonnullLockRefPtr<Custody>> VirtualFileSystem::resolve_path(StringView path, Custody& base, LockRefPtr<Custody>* out_parent, int options, int symlink_recursion_level)
|
||||
{
|
||||
// FIXME: The errors returned by resolve_path_without_veil can leak information about paths that are not unveiled,
|
||||
// e.g. when the error is EACCESS or similar.
|
||||
|
@ -899,7 +899,7 @@ static bool safe_to_follow_symlink(Inode const& inode, InodeMetadata const& pare
|
|||
return false;
|
||||
}
|
||||
|
||||
ErrorOr<NonnullRefPtr<Custody>> VirtualFileSystem::resolve_path_without_veil(StringView path, Custody& base, RefPtr<Custody>* out_parent, int options, int symlink_recursion_level)
|
||||
ErrorOr<NonnullLockRefPtr<Custody>> VirtualFileSystem::resolve_path_without_veil(StringView path, Custody& base, LockRefPtr<Custody>* out_parent, int options, int symlink_recursion_level)
|
||||
{
|
||||
if (symlink_recursion_level >= symlink_recursion_limit)
|
||||
return ELOOP;
|
||||
|
@ -910,7 +910,7 @@ ErrorOr<NonnullRefPtr<Custody>> VirtualFileSystem::resolve_path_without_veil(Str
|
|||
GenericLexer path_lexer(path);
|
||||
auto& current_process = Process::current();
|
||||
|
||||
NonnullRefPtr<Custody> custody = path[0] == '/' ? root_custody() : base;
|
||||
NonnullLockRefPtr<Custody> custody = path[0] == '/' ? root_custody() : base;
|
||||
bool extra_iteration = path[path.length() - 1] == '/';
|
||||
|
||||
while (!path_lexer.is_eof() || extra_iteration) {
|
||||
|
|
|
@ -12,13 +12,13 @@
|
|||
#include <AK/HashMap.h>
|
||||
#include <AK/NonnullOwnPtrVector.h>
|
||||
#include <AK/OwnPtr.h>
|
||||
#include <AK/RefPtr.h>
|
||||
#include <Kernel/FileSystem/FileSystem.h>
|
||||
#include <Kernel/FileSystem/InodeIdentifier.h>
|
||||
#include <Kernel/FileSystem/InodeMetadata.h>
|
||||
#include <Kernel/FileSystem/Mount.h>
|
||||
#include <Kernel/FileSystem/UnveilNode.h>
|
||||
#include <Kernel/Forward.h>
|
||||
#include <Kernel/Library/LockRefPtr.h>
|
||||
#include <Kernel/Locking/SpinlockProtected.h>
|
||||
|
||||
namespace Kernel {
|
||||
|
@ -50,8 +50,8 @@ public:
|
|||
ErrorOr<void> remount(Custody& mount_point, int new_flags);
|
||||
ErrorOr<void> unmount(Inode& guest_inode);
|
||||
|
||||
ErrorOr<NonnullRefPtr<OpenFileDescription>> open(StringView path, int options, mode_t mode, Custody& base, Optional<UidAndGid> = {});
|
||||
ErrorOr<NonnullRefPtr<OpenFileDescription>> create(StringView path, int options, mode_t mode, Custody& parent_custody, Optional<UidAndGid> = {});
|
||||
ErrorOr<NonnullLockRefPtr<OpenFileDescription>> open(StringView path, int options, mode_t mode, Custody& base, Optional<UidAndGid> = {});
|
||||
ErrorOr<NonnullLockRefPtr<OpenFileDescription>> create(StringView path, int options, mode_t mode, Custody& parent_custody, Optional<UidAndGid> = {});
|
||||
ErrorOr<void> mkdir(StringView path, mode_t mode, Custody& base);
|
||||
ErrorOr<void> link(StringView old_path, StringView new_path, Custody& base);
|
||||
ErrorOr<void> unlink(StringView path, Custody& base);
|
||||
|
@ -67,7 +67,7 @@ public:
|
|||
ErrorOr<void> utimensat(StringView path, Custody& base, timespec const& atime, timespec const& mtime, int options = 0);
|
||||
ErrorOr<void> rename(StringView oldpath, StringView newpath, Custody& base);
|
||||
ErrorOr<void> mknod(StringView path, mode_t, dev_t, Custody& base);
|
||||
ErrorOr<NonnullRefPtr<Custody>> open_directory(StringView path, Custody& base);
|
||||
ErrorOr<NonnullLockRefPtr<Custody>> open_directory(StringView path, Custody& base);
|
||||
|
||||
ErrorOr<void> for_each_mount(Function<ErrorOr<void>(Mount const&)>) const;
|
||||
|
||||
|
@ -76,8 +76,8 @@ public:
|
|||
static void sync();
|
||||
|
||||
Custody& root_custody();
|
||||
ErrorOr<NonnullRefPtr<Custody>> resolve_path(StringView path, Custody& base, RefPtr<Custody>* out_parent = nullptr, int options = 0, int symlink_recursion_level = 0);
|
||||
ErrorOr<NonnullRefPtr<Custody>> resolve_path_without_veil(StringView path, Custody& base, RefPtr<Custody>* out_parent = nullptr, int options = 0, int symlink_recursion_level = 0);
|
||||
ErrorOr<NonnullLockRefPtr<Custody>> resolve_path(StringView path, Custody& base, LockRefPtr<Custody>* out_parent = nullptr, int options = 0, int symlink_recursion_level = 0);
|
||||
ErrorOr<NonnullLockRefPtr<Custody>> resolve_path_without_veil(StringView path, Custody& base, LockRefPtr<Custody>* out_parent = nullptr, int options = 0, int symlink_recursion_level = 0);
|
||||
|
||||
private:
|
||||
friend class OpenFileDescription;
|
||||
|
@ -95,8 +95,8 @@ private:
|
|||
Mount* find_mount_for_host(InodeIdentifier);
|
||||
Mount* find_mount_for_guest(InodeIdentifier);
|
||||
|
||||
RefPtr<Inode> m_root_inode;
|
||||
RefPtr<Custody> m_root_custody;
|
||||
LockRefPtr<Inode> m_root_inode;
|
||||
LockRefPtr<Custody> m_root_custody;
|
||||
|
||||
SpinlockProtected<Vector<Mount, 16>> m_mounts { LockRank::None };
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue