Kernel: Replace "folder" => "directory" everywhere

Folders are a GUI concept. File systems have directories.
This commit is contained in:
Andreas Kling 2021-07-17 23:15:52 +02:00
parent 22611ca136
commit 2da0581fd2
Notes: sideshowbarker 2024-07-18 08:51:07 +09:00
15 changed files with 246 additions and 246 deletions

View File

@ -61,12 +61,12 @@ UNMAP_AFTER_INIT ACPISysFSComponent::ACPISysFSComponent(String name, PhysicalAdd
UNMAP_AFTER_INIT void ACPISysFSDirectory::initialize()
{
auto acpi_folder = adopt_ref(*new (nothrow) ACPISysFSDirectory());
SysFSComponentRegistry::the().register_new_component(acpi_folder);
auto acpi_directory = adopt_ref(*new (nothrow) ACPISysFSDirectory());
SysFSComponentRegistry::the().register_new_component(acpi_directory);
}
UNMAP_AFTER_INIT ACPISysFSDirectory::ACPISysFSDirectory()
: SysFSDirectory("acpi", SysFSComponentRegistry::the().root_folder())
: SysFSDirectory("acpi", SysFSComponentRegistry::the().root_directory())
{
NonnullRefPtrVector<SysFSComponent> components;
size_t ssdt_count = 0;

View File

@ -95,9 +95,9 @@ UNMAP_AFTER_INIT void BIOSSysFSDirectory::set_dmi_32_bit_entry_initialization_va
UNMAP_AFTER_INIT void BIOSSysFSDirectory::initialize()
{
auto bios_folder = adopt_ref(*new (nothrow) BIOSSysFSDirectory());
SysFSComponentRegistry::the().register_new_component(bios_folder);
bios_folder->create_components();
auto bios_directory = adopt_ref(*new (nothrow) BIOSSysFSDirectory());
SysFSComponentRegistry::the().register_new_component(bios_directory);
bios_directory->create_components();
}
void BIOSSysFSDirectory::create_components()
@ -135,7 +135,7 @@ OwnPtr<KBuffer> BIOSSysFSDirectory::smbios_structure_table() const
}
UNMAP_AFTER_INIT BIOSSysFSDirectory::BIOSSysFSDirectory()
: SysFSDirectory("bios", SysFSComponentRegistry::the().root_folder())
: SysFSDirectory("bios", SysFSComponentRegistry::the().root_directory())
{
auto entry_32bit = find_dmi_entry32bit_point();
m_dmi_entry_point = entry_32bit.value();

View File

@ -368,13 +368,13 @@ void Capability::write32(u32 field, u32 value)
PCI::write32(m_address, m_ptr + field, value);
}
UNMAP_AFTER_INIT NonnullRefPtr<PCIDeviceSysFSDirectory> PCIDeviceSysFSDirectory::create(const SysFSDirectory& parent_folder, Address address)
UNMAP_AFTER_INIT NonnullRefPtr<PCIDeviceSysFSDirectory> PCIDeviceSysFSDirectory::create(const SysFSDirectory& parent_directory, Address address)
{
return adopt_ref(*new (nothrow) PCIDeviceSysFSDirectory(parent_folder, address));
return adopt_ref(*new (nothrow) PCIDeviceSysFSDirectory(parent_directory, address));
}
UNMAP_AFTER_INIT PCIDeviceSysFSDirectory::PCIDeviceSysFSDirectory(const SysFSDirectory& parent_folder, Address address)
: SysFSDirectory(String::formatted("{:04x}:{:04x}:{:02x}.{}", address.seg(), address.bus(), address.device(), address.function()), parent_folder)
UNMAP_AFTER_INIT PCIDeviceSysFSDirectory::PCIDeviceSysFSDirectory(const SysFSDirectory& parent_directory, Address address)
: SysFSDirectory(String::formatted("{:04x}:{:04x}:{:02x}.{}", address.seg(), address.bus(), address.device(), address.function()), parent_directory)
{
m_components.append(PCIDeviceAttributeSysFSComponent::create("vendor", *this, PCI_VENDOR_ID, 2));
m_components.append(PCIDeviceAttributeSysFSComponent::create("device_id", *this, PCI_DEVICE_ID, 2));
@ -388,12 +388,12 @@ UNMAP_AFTER_INIT PCIDeviceSysFSDirectory::PCIDeviceSysFSDirectory(const SysFSDir
UNMAP_AFTER_INIT void PCIBusSysFSDirectory::initialize()
{
auto pci_folder = adopt_ref(*new (nothrow) PCIBusSysFSDirectory());
SysFSComponentRegistry::the().register_new_component(pci_folder);
auto pci_directory = adopt_ref(*new (nothrow) PCIBusSysFSDirectory());
SysFSComponentRegistry::the().register_new_component(pci_directory);
}
UNMAP_AFTER_INIT PCIBusSysFSDirectory::PCIBusSysFSDirectory()
: SysFSDirectory("pci", SysFSComponentRegistry::the().root_folder())
: SysFSDirectory("pci", SysFSComponentRegistry::the().root_directory())
{
PCI::enumerate([&](const Address& address, ID) {
auto pci_device = PCI::PCIDeviceSysFSDirectory::create(*this, address);

View File

@ -70,7 +70,7 @@ static constexpr u8 UHCI_NUMBER_OF_ISOCHRONOUS_TDS = 128;
static constexpr u16 UHCI_NUMBER_OF_FRAMES = 1024;
class ProcFSUSBBusDirectory;
static ProcFSUSBBusDirectory* s_procfs_usb_bus_folder;
static ProcFSUSBBusDirectory* s_procfs_usb_bus_directory;
class ProcFSUSBDeviceInformation : public ProcFSGlobalInformation {
friend class ProcFSUSBBusDirectory;
@ -144,11 +144,11 @@ KResultOr<size_t> ProcFSUSBBusDirectory::entries_count() const
KResult ProcFSUSBBusDirectory::traverse_as_directory(unsigned fsid, Function<bool(FileSystem::DirectoryEntryView const&)> callback) const
{
ScopedSpinLock lock(m_lock);
auto parent_folder = m_parent_folder.strong_ref();
// Note: if the parent folder is null, it means something bad happened as this should not happen for the USB folder.
VERIFY(parent_folder);
auto parent_directory = m_parent_directory.strong_ref();
// Note: if the parent directory is null, it means something bad happened as this should not happen for the USB directory.
VERIFY(parent_directory);
callback({ ".", { fsid, component_index() }, 0 });
callback({ "..", { fsid, parent_folder->component_index() }, 0 });
callback({ "..", { fsid, parent_directory->component_index() }, 0 });
for (auto& device_node : m_device_nodes) {
InodeIdentifier identifier = { fsid, device_node.component_index() };
@ -192,16 +192,16 @@ void ProcFSUSBBusDirectory::unplug(USB::Device& deleted_device)
device_node->m_list_node.remove();
}
UNMAP_AFTER_INIT ProcFSUSBBusDirectory::ProcFSUSBBusDirectory(const ProcFSBusDirectory& buses_folder)
: ProcFSExposedDirectory("usb"sv, buses_folder)
UNMAP_AFTER_INIT ProcFSUSBBusDirectory::ProcFSUSBBusDirectory(const ProcFSBusDirectory& buses_directory)
: ProcFSExposedDirectory("usb"sv, buses_directory)
{
}
UNMAP_AFTER_INIT void ProcFSUSBBusDirectory::initialize()
{
auto folder = adopt_ref(*new ProcFSUSBBusDirectory(ProcFSComponentRegistry::the().buses_folder()));
ProcFSComponentRegistry::the().register_new_bus_folder(folder);
s_procfs_usb_bus_folder = folder;
auto directory = adopt_ref(*new ProcFSUSBBusDirectory(ProcFSComponentRegistry::the().buses_directory()));
ProcFSComponentRegistry::the().register_new_bus_directory(directory);
s_procfs_usb_bus_directory = directory;
}
NonnullRefPtr<ProcFSUSBDeviceInformation> ProcFSUSBDeviceInformation::create(USB::Device& device)
@ -717,14 +717,14 @@ void UHCIController::spawn_port_proc()
dmesgln("UHCI: Device creation failed on port 1 ({})", device.error());
m_devices.at(0) = device.value();
VERIFY(s_procfs_usb_bus_folder);
s_procfs_usb_bus_folder->plug(device.value());
VERIFY(s_procfs_usb_bus_directory);
s_procfs_usb_bus_directory->plug(device.value());
} else {
// FIXME: Clean up (and properly) the RefPtr to the device in m_devices
VERIFY(s_procfs_usb_bus_folder);
VERIFY(s_procfs_usb_bus_directory);
VERIFY(m_devices.at(0));
dmesgln("UHCI: Device detach detected on Root Port 1");
s_procfs_usb_bus_folder->unplug(*m_devices.at(0));
s_procfs_usb_bus_directory->unplug(*m_devices.at(0));
}
}
} else {
@ -755,14 +755,14 @@ void UHCIController::spawn_port_proc()
dmesgln("UHCI: Device creation failed on port 2 ({})", device.error());
m_devices.at(1) = device.value();
VERIFY(s_procfs_usb_bus_folder);
s_procfs_usb_bus_folder->plug(device.value());
VERIFY(s_procfs_usb_bus_directory);
s_procfs_usb_bus_directory->plug(device.value());
} else {
// FIXME: Clean up (and properly) the RefPtr to the device in m_devices
VERIFY(s_procfs_usb_bus_folder);
VERIFY(s_procfs_usb_bus_directory);
VERIFY(m_devices.at(1));
dmesgln("UHCI: Device detach detected on Root Port 2");
s_procfs_usb_bus_folder->unplug(*m_devices.at(1));
s_procfs_usb_bus_directory->unplug(*m_devices.at(1));
}
}
}

View File

@ -227,9 +227,9 @@ KResult DevFSRootDirectoryInode::traverse_as_directory(Function<bool(FileSystem:
callback({ ".", identifier(), 0 });
callback({ "..", identifier(), 0 });
for (auto& folder : m_subfolders) {
InodeIdentifier identifier = { fsid(), folder.index() };
callback({ folder.name(), identifier, 0 });
for (auto& directory : m_subdirectories) {
InodeIdentifier identifier = { fsid(), directory.index() };
callback({ directory.name(), identifier, 0 });
}
for (auto& link : m_links) {
InodeIdentifier identifier = { fsid(), link.index() };
@ -245,9 +245,9 @@ KResult DevFSRootDirectoryInode::traverse_as_directory(Function<bool(FileSystem:
RefPtr<Inode> DevFSRootDirectoryInode::lookup(StringView name)
{
Locker locker(m_parent_fs.m_lock);
for (auto& subfolder : m_subfolders) {
if (subfolder.name() == name)
return subfolder;
for (auto& subdirectory : m_subdirectories) {
if (subdirectory.name() == name)
return subdirectory;
}
for (auto& link : m_links) {
if (link.name() == name)
@ -268,8 +268,8 @@ KResultOr<NonnullRefPtr<Inode>> DevFSRootDirectoryInode::create_child(StringView
InodeMetadata metadata;
metadata.mode = mode;
if (metadata.is_directory()) {
for (auto& folder : m_subfolders) {
if (folder.name() == name)
for (auto& directory : m_subdirectories) {
if (directory.name() == name)
return EEXIST;
}
if (name != "pts")
@ -277,11 +277,11 @@ KResultOr<NonnullRefPtr<Inode>> DevFSRootDirectoryInode::create_child(StringView
auto new_directory_inode = adopt_ref_if_nonnull(new (nothrow) DevFSPtsDirectoryInode(m_parent_fs));
if (!new_directory_inode)
return ENOMEM;
if (!m_subfolders.try_ensure_capacity(m_subfolders.size() + 1))
if (!m_subdirectories.try_ensure_capacity(m_subdirectories.size() + 1))
return ENOMEM;
if (!m_parent_fs.m_nodes.try_ensure_capacity(m_parent_fs.m_nodes.size() + 1))
return ENOMEM;
m_subfolders.append(*new_directory_inode);
m_subdirectories.append(*new_directory_inode);
m_parent_fs.m_nodes.append(*new_directory_inode);
return KResult(KSuccess);
}

View File

@ -151,7 +151,7 @@ private:
virtual RefPtr<Inode> lookup(StringView name) override;
virtual InodeMetadata metadata() const override;
NonnullRefPtrVector<DevFSDirectoryInode> m_subfolders;
NonnullRefPtrVector<DevFSDirectoryInode> m_subdirectories;
NonnullRefPtrVector<DevFSLinkInode> m_links;
DevFS& m_parent_fs;
};

View File

@ -32,33 +32,33 @@ UNMAP_AFTER_INIT void ProcFSComponentRegistry::initialize()
}
UNMAP_AFTER_INIT ProcFSComponentRegistry::ProcFSComponentRegistry()
: m_root_folder(ProcFSRootDirectory::must_create())
: m_root_directory(ProcFSRootDirectory::must_create())
{
}
const ProcFSBusDirectory& ProcFSComponentRegistry::buses_folder() const
const ProcFSBusDirectory& ProcFSComponentRegistry::buses_directory() const
{
return *m_root_folder->m_buses_folder;
return *m_root_directory->m_buses_directory;
}
void ProcFSComponentRegistry::register_new_bus_folder(ProcFSExposedDirectory& new_bus_folder)
void ProcFSComponentRegistry::register_new_bus_directory(ProcFSExposedDirectory& new_bus_directory)
{
VERIFY(!m_root_folder->m_buses_folder.is_null());
m_root_folder->m_buses_folder->m_components.append(new_bus_folder);
VERIFY(!m_root_directory->m_buses_directory.is_null());
m_root_directory->m_buses_directory->m_components.append(new_bus_directory);
}
void ProcFSComponentRegistry::register_new_process(Process& new_process)
{
Locker locker(m_lock);
m_root_folder->m_process_folders.append(ProcFSProcessDirectory::create(new_process));
m_root_directory->m_process_directories.append(ProcFSProcessDirectory::create(new_process));
}
void ProcFSComponentRegistry::unregister_process(Process& deleted_process)
{
auto process_folder = m_root_folder->process_folder_for(deleted_process).release_nonnull();
process_folder->prepare_for_deletion();
process_folder->m_list_node.remove();
dbgln_if(PROCFS_DEBUG, "ProcFSExposedDirectory ref_count now: {}", process_folder->ref_count());
auto process_directory = m_root_directory->process_directory_for(deleted_process).release_nonnull();
process_directory->prepare_for_deletion();
process_directory->m_list_node.remove();
dbgln_if(PROCFS_DEBUG, "ProcFSExposedDirectory ref_count now: {}", process_directory->ref_count());
}
RefPtr<ProcFS> ProcFS::create()
@ -112,7 +112,7 @@ ProcFSInode::~ProcFSInode()
}
ProcFS::ProcFS()
: m_root_inode(ProcFSComponentRegistry::the().root_folder().to_inode(*this))
: m_root_inode(ProcFSComponentRegistry::the().root_directory().to_inode(*this))
{
}

View File

@ -25,14 +25,14 @@ UNMAP_AFTER_INIT void SysFSComponentRegistry::initialize()
}
UNMAP_AFTER_INIT SysFSComponentRegistry::SysFSComponentRegistry()
: m_root_folder(SysFSRootDirectory::create())
: m_root_directory(SysFSRootDirectory::create())
{
}
UNMAP_AFTER_INIT void SysFSComponentRegistry::register_new_component(SysFSComponent& component)
{
Locker locker(m_lock);
m_root_folder->m_components.append(component);
m_root_directory->m_components.append(component);
}
NonnullRefPtr<SysFSRootDirectory> SysFSRootDirectory::create()
@ -64,7 +64,7 @@ NonnullRefPtr<SysFS> SysFS::create()
}
SysFS::SysFS()
: m_root_inode(SysFSComponentRegistry::the().root_folder().to_inode(*this))
: m_root_inode(SysFSComponentRegistry::the().root_directory().to_inode(*this))
{
}

View File

@ -32,12 +32,12 @@ public:
SysFSComponentRegistry();
void register_new_component(SysFSComponent&);
SysFSDirectory& root_folder() { return m_root_folder; }
SysFSDirectory& root_directory() { return m_root_directory; }
Mutex& get_lock() { return m_lock; }
private:
Mutex m_lock;
NonnullRefPtr<SysFSRootDirectory> m_root_folder;
NonnullRefPtr<SysFSRootDirectory> m_root_directory;
};
class SysFS final : public FileSystem {

View File

@ -29,9 +29,9 @@ SysFSComponent::SysFSComponent(StringView name)
KResult SysFSDirectory::traverse_as_directory(unsigned fsid, Function<bool(FileSystem::DirectoryEntryView const&)> callback) const
{
Locker locker(SysFSComponentRegistry::the().get_lock());
VERIFY(m_parent_folder);
VERIFY(m_parent_directory);
callback({ ".", { fsid, component_index() }, 0 });
callback({ "..", { fsid, m_parent_folder->component_index() }, 0 });
callback({ "..", { fsid, m_parent_directory->component_index() }, 0 });
for (auto& component : m_components) {
InodeIdentifier identifier = { fsid, component.component_index() };
@ -55,9 +55,9 @@ SysFSDirectory::SysFSDirectory(StringView name)
{
}
SysFSDirectory::SysFSDirectory(StringView name, SysFSDirectory const& parent_folder)
SysFSDirectory::SysFSDirectory(StringView name, SysFSDirectory const& parent_directory)
: SysFSComponent(name)
, m_parent_folder(parent_folder)
, m_parent_directory(parent_directory)
{
}

View File

@ -52,9 +52,9 @@ public:
protected:
explicit SysFSDirectory(StringView name);
SysFSDirectory(StringView name, SysFSDirectory const& parent_folder);
SysFSDirectory(StringView name, SysFSDirectory const& parent_directory);
NonnullRefPtrVector<SysFSComponent> m_components;
RefPtr<SysFSDirectory> m_parent_folder;
RefPtr<SysFSDirectory> m_parent_directory;
};
}

View File

@ -160,18 +160,18 @@ private:
class ProcFSNetworkDirectory : public ProcFSExposedDirectory {
public:
static NonnullRefPtr<ProcFSNetworkDirectory> must_create(const ProcFSRootDirectory& parent_folder);
static NonnullRefPtr<ProcFSNetworkDirectory> must_create(const ProcFSRootDirectory& parent_directory);
private:
ProcFSNetworkDirectory(const ProcFSRootDirectory& parent_folder);
ProcFSNetworkDirectory(const ProcFSRootDirectory& parent_directory);
};
class ProcFSSystemDirectory : public ProcFSExposedDirectory {
public:
static NonnullRefPtr<ProcFSSystemDirectory> must_create(const ProcFSRootDirectory& parent_folder);
static NonnullRefPtr<ProcFSSystemDirectory> must_create(const ProcFSRootDirectory& parent_directory);
private:
ProcFSSystemDirectory(const ProcFSRootDirectory& parent_folder);
ProcFSSystemDirectory(const ProcFSRootDirectory& parent_directory);
};
UNMAP_AFTER_INIT NonnullRefPtr<ProcFSAdapters> ProcFSAdapters::must_create()
@ -195,15 +195,15 @@ UNMAP_AFTER_INIT NonnullRefPtr<ProcFSUDP> ProcFSUDP::must_create()
return adopt_ref_if_nonnull(new (nothrow) ProcFSUDP).release_nonnull();
}
UNMAP_AFTER_INIT NonnullRefPtr<ProcFSNetworkDirectory> ProcFSNetworkDirectory::must_create(const ProcFSRootDirectory& parent_folder)
UNMAP_AFTER_INIT NonnullRefPtr<ProcFSNetworkDirectory> ProcFSNetworkDirectory::must_create(const ProcFSRootDirectory& parent_directory)
{
auto folder = adopt_ref(*new (nothrow) ProcFSNetworkDirectory(parent_folder));
folder->m_components.append(ProcFSAdapters::must_create());
folder->m_components.append(ProcFSARP::must_create());
folder->m_components.append(ProcFSTCP::must_create());
folder->m_components.append(ProcFSLocalNet::must_create());
folder->m_components.append(ProcFSUDP::must_create());
return folder;
auto directory = adopt_ref(*new (nothrow) ProcFSNetworkDirectory(parent_directory));
directory->m_components.append(ProcFSAdapters::must_create());
directory->m_components.append(ProcFSARP::must_create());
directory->m_components.append(ProcFSTCP::must_create());
directory->m_components.append(ProcFSLocalNet::must_create());
directory->m_components.append(ProcFSUDP::must_create());
return directory;
}
UNMAP_AFTER_INIT ProcFSAdapters::ProcFSAdapters()
@ -226,8 +226,8 @@ UNMAP_AFTER_INIT ProcFSUDP::ProcFSUDP()
: ProcFSGlobalInformation("udp"sv)
{
}
UNMAP_AFTER_INIT ProcFSNetworkDirectory::ProcFSNetworkDirectory(const ProcFSRootDirectory& parent_folder)
: ProcFSExposedDirectory("net"sv, parent_folder)
UNMAP_AFTER_INIT ProcFSNetworkDirectory::ProcFSNetworkDirectory(const ProcFSRootDirectory& parent_directory)
: ProcFSExposedDirectory("net"sv, parent_directory)
{
}
@ -813,54 +813,54 @@ UNMAP_AFTER_INIT ProcFSProfile::ProcFSProfile()
{
}
UNMAP_AFTER_INIT NonnullRefPtr<ProcFSBusDirectory> ProcFSBusDirectory::must_create(const ProcFSRootDirectory& parent_folder)
UNMAP_AFTER_INIT NonnullRefPtr<ProcFSBusDirectory> ProcFSBusDirectory::must_create(const ProcFSRootDirectory& parent_directory)
{
auto folder = adopt_ref(*new (nothrow) ProcFSBusDirectory(parent_folder));
return folder;
auto directory = adopt_ref(*new (nothrow) ProcFSBusDirectory(parent_directory));
return directory;
}
UNMAP_AFTER_INIT NonnullRefPtr<ProcFSSystemDirectory> ProcFSSystemDirectory::must_create(const ProcFSRootDirectory& parent_folder)
UNMAP_AFTER_INIT NonnullRefPtr<ProcFSSystemDirectory> ProcFSSystemDirectory::must_create(const ProcFSRootDirectory& parent_directory)
{
auto folder = adopt_ref(*new (nothrow) ProcFSSystemDirectory(parent_folder));
folder->m_components.append(ProcFSDumpKmallocStacks::must_create(folder));
folder->m_components.append(ProcFSUBSanDeadly::must_create(folder));
folder->m_components.append(ProcFSCapsLockRemap::must_create(folder));
return folder;
auto directory = adopt_ref(*new (nothrow) ProcFSSystemDirectory(parent_directory));
directory->m_components.append(ProcFSDumpKmallocStacks::must_create(directory));
directory->m_components.append(ProcFSUBSanDeadly::must_create(directory));
directory->m_components.append(ProcFSCapsLockRemap::must_create(directory));
return directory;
}
UNMAP_AFTER_INIT ProcFSBusDirectory::ProcFSBusDirectory(const ProcFSRootDirectory& parent_folder)
: ProcFSExposedDirectory("bus"sv, parent_folder)
UNMAP_AFTER_INIT ProcFSBusDirectory::ProcFSBusDirectory(const ProcFSRootDirectory& parent_directory)
: ProcFSExposedDirectory("bus"sv, parent_directory)
{
}
UNMAP_AFTER_INIT ProcFSSystemDirectory::ProcFSSystemDirectory(const ProcFSRootDirectory& parent_folder)
: ProcFSExposedDirectory("sys"sv, parent_folder)
UNMAP_AFTER_INIT ProcFSSystemDirectory::ProcFSSystemDirectory(const ProcFSRootDirectory& parent_directory)
: ProcFSExposedDirectory("sys"sv, parent_directory)
{
}
UNMAP_AFTER_INIT NonnullRefPtr<ProcFSRootDirectory> ProcFSRootDirectory::must_create()
{
auto folder = adopt_ref(*new (nothrow) ProcFSRootDirectory);
folder->m_components.append(ProcFSSelfProcessDirectory::must_create());
folder->m_components.append(ProcFSDiskUsage::must_create());
folder->m_components.append(ProcFSMemoryStatus::must_create());
folder->m_components.append(ProcFSOverallProcesses::must_create());
folder->m_components.append(ProcFSCPUInformation::must_create());
folder->m_components.append(ProcFSDmesg::must_create());
folder->m_components.append(ProcFSInterrupts::must_create());
folder->m_components.append(ProcFSKeymap::must_create());
folder->m_components.append(ProcFSPCI::must_create());
folder->m_components.append(ProcFSDevices::must_create());
folder->m_components.append(ProcFSUptime::must_create());
folder->m_components.append(ProcFSCommandLine::must_create());
folder->m_components.append(ProcFSModules::must_create());
folder->m_components.append(ProcFSProfile::must_create());
auto directory = adopt_ref(*new (nothrow) ProcFSRootDirectory);
directory->m_components.append(ProcFSSelfProcessDirectory::must_create());
directory->m_components.append(ProcFSDiskUsage::must_create());
directory->m_components.append(ProcFSMemoryStatus::must_create());
directory->m_components.append(ProcFSOverallProcesses::must_create());
directory->m_components.append(ProcFSCPUInformation::must_create());
directory->m_components.append(ProcFSDmesg::must_create());
directory->m_components.append(ProcFSInterrupts::must_create());
directory->m_components.append(ProcFSKeymap::must_create());
directory->m_components.append(ProcFSPCI::must_create());
directory->m_components.append(ProcFSDevices::must_create());
directory->m_components.append(ProcFSUptime::must_create());
directory->m_components.append(ProcFSCommandLine::must_create());
directory->m_components.append(ProcFSModules::must_create());
directory->m_components.append(ProcFSProfile::must_create());
folder->m_components.append(ProcFSNetworkDirectory::must_create(*folder));
auto buses_folder = ProcFSBusDirectory::must_create(*folder);
folder->m_components.append(buses_folder);
folder->m_buses_folder = buses_folder;
folder->m_components.append(ProcFSSystemDirectory::must_create(*folder));
return folder;
directory->m_components.append(ProcFSNetworkDirectory::must_create(*directory));
auto buses_directory = ProcFSBusDirectory::must_create(*directory);
directory->m_components.append(buses_directory);
directory->m_buses_directory = buses_directory;
directory->m_components.append(ProcFSSystemDirectory::must_create(*directory));
return directory;
}
KResult ProcFSRootDirectory::traverse_as_directory(unsigned fsid, Function<bool(FileSystem::DirectoryEntryView const&)> callback) const
@ -873,7 +873,7 @@ KResult ProcFSRootDirectory::traverse_as_directory(unsigned fsid, Function<bool(
InodeIdentifier identifier = { fsid, component.component_index() };
callback({ component.name(), identifier, 0 });
}
for (auto& component : m_process_folders) {
for (auto& component : m_process_directories) {
InodeIdentifier identifier = { fsid, component.component_index() };
callback({ component.name(), identifier, 0 });
}
@ -885,7 +885,7 @@ RefPtr<ProcFSExposedComponent> ProcFSRootDirectory::lookup(StringView name)
if (auto candidate = ProcFSExposedDirectory::lookup(name); !candidate.is_null())
return candidate;
for (auto& component : m_process_folders) {
for (auto& component : m_process_directories) {
if (component.name() == name) {
return component;
}
@ -902,12 +902,12 @@ UNMAP_AFTER_INIT ProcFSRootDirectory::~ProcFSRootDirectory()
{
}
RefPtr<ProcFSProcessDirectory> ProcFSRootDirectory::process_folder_for(Process& process)
RefPtr<ProcFSProcessDirectory> ProcFSRootDirectory::process_directory_for(Process& process)
{
RefPtr<Process> checked_process = process;
for (auto& folder : m_process_folders) {
if (folder.associated_process().ptr() == checked_process.ptr())
return folder;
for (auto& directory : m_process_directories) {
if (directory.associated_process().ptr() == checked_process.ptr())
return directory;
}
return {};
}

View File

@ -52,9 +52,9 @@ ProcFSExposedDirectory::ProcFSExposedDirectory(StringView name)
{
}
ProcFSExposedDirectory::ProcFSExposedDirectory(StringView name, const ProcFSExposedDirectory& parent_folder)
ProcFSExposedDirectory::ProcFSExposedDirectory(StringView name, const ProcFSExposedDirectory& parent_directory)
: ProcFSExposedComponent(name)
, m_parent_folder(parent_folder)
, m_parent_directory(parent_directory)
{
}
@ -157,10 +157,10 @@ KResult ProcFSProcessInformation::refresh_data(FileDescription& description) con
// For process-specific inodes, hold the process's ptrace lock across refresh
// and refuse to load data if the process is not dumpable.
// Without this, files opened before a process went non-dumpable could still be used for dumping.
auto parent_folder = const_cast<ProcFSProcessInformation&>(*this).m_parent_folder.strong_ref();
if (parent_folder.is_null())
auto parent_directory = const_cast<ProcFSProcessInformation&>(*this).m_parent_directory.strong_ref();
if (parent_directory.is_null())
return KResult(EINVAL);
auto process = parent_folder->associated_process();
auto process = parent_directory->associated_process();
if (!process)
return KResult(ESRCH);
process->ptrace_lock().lock();
@ -245,11 +245,11 @@ RefPtr<ProcFSExposedComponent> ProcFSExposedDirectory::lookup(StringView name)
KResult ProcFSExposedDirectory::traverse_as_directory(unsigned fsid, Function<bool(FileSystem::DirectoryEntryView const&)> callback) const
{
Locker locker(ProcFSComponentRegistry::the().get_lock());
auto parent_folder = m_parent_folder.strong_ref();
if (parent_folder.is_null())
auto parent_directory = m_parent_directory.strong_ref();
if (parent_directory.is_null())
return KResult(EINVAL);
callback({ ".", { fsid, component_index() }, 0 });
callback({ "..", { fsid, parent_folder->component_index() }, 0 });
callback({ "..", { fsid, parent_directory->component_index() }, 0 });
for (auto& component : m_components) {
InodeIdentifier identifier = { fsid, component.component_index() };

View File

@ -30,19 +30,19 @@ public:
InodeIndex allocate_inode_index() const;
ProcFSComponentRegistry();
void register_new_bus_folder(ProcFSExposedDirectory&);
void register_new_bus_directory(ProcFSExposedDirectory&);
const ProcFSBusDirectory& buses_folder() const;
const ProcFSBusDirectory& buses_directory() const;
void register_new_process(Process&);
void unregister_process(Process&);
ProcFSRootDirectory& root_folder() { return *m_root_folder; }
ProcFSRootDirectory& root_directory() { return *m_root_directory; }
Mutex& get_lock() { return m_lock; }
private:
Mutex m_lock;
NonnullRefPtr<ProcFSRootDirectory> m_root_folder;
NonnullRefPtr<ProcFSRootDirectory> m_root_directory;
};
class ProcFSExposedComponent : public RefCounted<ProcFSExposedComponent> {
@ -105,9 +105,9 @@ public:
protected:
explicit ProcFSExposedDirectory(StringView name);
ProcFSExposedDirectory(StringView name, const ProcFSExposedDirectory& parent_folder);
ProcFSExposedDirectory(StringView name, const ProcFSExposedDirectory& parent_directory);
NonnullRefPtrVector<ProcFSExposedComponent> m_components;
WeakPtr<ProcFSExposedDirectory> m_parent_folder;
WeakPtr<ProcFSExposedDirectory> m_parent_directory;
};
class ProcFSExposedLink : public ProcFSExposedComponent {
@ -163,10 +163,10 @@ class ProcFSBusDirectory : public ProcFSExposedDirectory {
friend class ProcFSComponentRegistry;
public:
static NonnullRefPtr<ProcFSBusDirectory> must_create(const ProcFSRootDirectory& parent_folder);
static NonnullRefPtr<ProcFSBusDirectory> must_create(const ProcFSRootDirectory& parent_directory);
private:
ProcFSBusDirectory(const ProcFSRootDirectory& parent_folder);
ProcFSBusDirectory(const ProcFSRootDirectory& parent_directory);
};
class ProcFSRootDirectory final : public ProcFSExposedDirectory {
@ -175,7 +175,7 @@ class ProcFSRootDirectory final : public ProcFSExposedDirectory {
public:
virtual RefPtr<ProcFSExposedComponent> lookup(StringView name) override;
RefPtr<ProcFSProcessDirectory> process_folder_for(Process&);
RefPtr<ProcFSProcessDirectory> process_directory_for(Process&);
static NonnullRefPtr<ProcFSRootDirectory> must_create();
virtual ~ProcFSRootDirectory();
@ -183,8 +183,8 @@ private:
virtual KResult traverse_as_directory(unsigned, Function<bool(FileSystem::DirectoryEntryView const&)>) const override;
ProcFSRootDirectory();
RefPtr<ProcFSBusDirectory> m_buses_folder;
IntrusiveList<ProcFSProcessDirectory, RefPtr<ProcFSProcessDirectory>, &ProcFSProcessDirectory::m_list_node> m_process_folders;
RefPtr<ProcFSBusDirectory> m_buses_directory;
IntrusiveList<ProcFSProcessDirectory, RefPtr<ProcFSProcessDirectory>, &ProcFSProcessDirectory::m_list_node> m_process_directories;
};
class ProcFSGlobalInformation : public ProcFSExposedComponent {
@ -231,36 +231,36 @@ public:
virtual uid_t owner_user() const override
{
auto parent_folder = m_parent_folder.strong_ref();
if (!parent_folder)
auto parent_directory = m_parent_directory.strong_ref();
if (!parent_directory)
return false;
auto process = parent_folder->associated_process();
auto process = parent_directory->associated_process();
if (!process)
return false;
return process->uid();
}
virtual gid_t owner_group() const override
{
auto parent_folder = m_parent_folder.strong_ref();
if (!parent_folder)
auto parent_directory = m_parent_directory.strong_ref();
if (!parent_directory)
return false;
auto process = parent_folder->associated_process();
auto process = parent_directory->associated_process();
if (!process)
return false;
return process->gid();
}
protected:
ProcFSProcessInformation(StringView name, const ProcFSProcessDirectory& process_folder)
ProcFSProcessInformation(StringView name, const ProcFSProcessDirectory& process_directory)
: ProcFSExposedComponent(name)
, m_parent_folder(process_folder)
, m_parent_directory(process_directory)
{
}
virtual KResult refresh_data(FileDescription&) const override;
virtual bool output(KBufferBuilder& builder) = 0;
WeakPtr<ProcFSProcessDirectory> m_parent_folder;
WeakPtr<ProcFSProcessDirectory> m_parent_directory;
mutable SpinLock<u8> m_refresh_lock;
};

View File

@ -19,15 +19,15 @@ namespace Kernel {
class ProcFSProcessStacks;
class ProcFSThreadStack final : public ProcFSProcessInformation {
public:
// Note: We pass const ProcFSProcessStacks& to enforce creation with this type of folder
static NonnullRefPtr<ProcFSThreadStack> create(const ProcFSProcessDirectory& process_folder, const ProcFSProcessStacks&, const Thread& thread)
// Note: We pass const ProcFSProcessStacks& to enforce creation with this type of directory
static NonnullRefPtr<ProcFSThreadStack> create(const ProcFSProcessDirectory& process_directory, const ProcFSProcessStacks&, const Thread& thread)
{
return adopt_ref(*new (nothrow) ProcFSThreadStack(process_folder, thread));
return adopt_ref(*new (nothrow) ProcFSThreadStack(process_directory, thread));
}
private:
explicit ProcFSThreadStack(const ProcFSProcessDirectory& process_folder, const Thread& thread)
: ProcFSProcessInformation(String::formatted("{}", thread.tid()), process_folder)
explicit ProcFSThreadStack(const ProcFSProcessDirectory& process_directory, const Thread& thread)
: ProcFSProcessInformation(String::formatted("{}", thread.tid()), process_directory)
, m_associated_thread(thread)
{
}
@ -54,7 +54,7 @@ private:
};
class ProcFSProcessStacks final : public ProcFSExposedDirectory {
// Note: This folder is special, because everything that is created here is dynamic!
// Note: This directory is special, because everything that is created here is dynamic!
// This means we don't register anything in the m_components Vector, and every inode
// is created in runtime when called to get it
// Every ProcFSThreadStack (that represents a thread stack) is created only as a temporary object
@ -65,25 +65,25 @@ public:
virtual KResult traverse_as_directory(unsigned, Function<bool(FileSystem::DirectoryEntryView const&)>) const override;
virtual RefPtr<ProcFSExposedComponent> lookup(StringView name) override;
static NonnullRefPtr<ProcFSProcessStacks> create(const ProcFSProcessDirectory& parent_folder)
static NonnullRefPtr<ProcFSProcessStacks> create(const ProcFSProcessDirectory& parent_directory)
{
auto folder = adopt_ref(*new (nothrow) ProcFSProcessStacks(parent_folder));
return folder;
auto directory = adopt_ref(*new (nothrow) ProcFSProcessStacks(parent_directory));
return directory;
}
virtual void prepare_for_deletion() override
{
ProcFSExposedDirectory::prepare_for_deletion();
m_process_folder.clear();
m_process_directory.clear();
}
private:
ProcFSProcessStacks(const ProcFSProcessDirectory& parent_folder)
: ProcFSExposedDirectory("stacks"sv, parent_folder)
, m_process_folder(parent_folder)
ProcFSProcessStacks(const ProcFSProcessDirectory& parent_directory)
: ProcFSExposedDirectory("stacks"sv, parent_directory)
, m_process_directory(parent_directory)
{
}
WeakPtr<ProcFSProcessDirectory> m_process_folder;
WeakPtr<ProcFSProcessDirectory> m_process_directory;
mutable Mutex m_lock;
};
@ -102,13 +102,13 @@ KResultOr<size_t> ProcFSProcessStacks::entries_count() const
KResult ProcFSProcessStacks::traverse_as_directory(unsigned fsid, Function<bool(FileSystem::DirectoryEntryView const&)> callback) const
{
Locker locker(m_lock);
auto parent_folder = m_process_folder.strong_ref();
if (parent_folder.is_null())
auto parent_directory = m_process_directory.strong_ref();
if (parent_directory.is_null())
return KResult(EINVAL);
callback({ ".", { fsid, component_index() }, 0 });
callback({ "..", { fsid, parent_folder->component_index() }, 0 });
callback({ "..", { fsid, parent_directory->component_index() }, 0 });
auto process = parent_folder->associated_process();
auto process = parent_directory->associated_process();
if (process.is_null())
return KResult(ESRCH);
process->for_each_thread([&](const Thread& thread) {
@ -122,10 +122,10 @@ KResult ProcFSProcessStacks::traverse_as_directory(unsigned fsid, Function<bool(
RefPtr<ProcFSExposedComponent> ProcFSProcessStacks::lookup(StringView name)
{
Locker locker(m_lock);
auto parent_folder = m_process_folder.strong_ref();
if (parent_folder.is_null())
auto parent_directory = m_process_directory.strong_ref();
if (parent_directory.is_null())
return nullptr;
auto process = parent_folder->associated_process();
auto process = parent_directory->associated_process();
if (process.is_null())
return nullptr;
RefPtr<ProcFSThreadStack> procfd_stack;
@ -133,7 +133,7 @@ RefPtr<ProcFSExposedComponent> ProcFSProcessStacks::lookup(StringView name)
process->for_each_thread([&](const Thread& thread) {
int tid = thread.tid().value();
if (name == String::number(tid)) {
procfd_stack = ProcFSThreadStack::create(*parent_folder, *this, thread);
procfd_stack = ProcFSThreadStack::create(*parent_directory, *this, thread);
}
});
return procfd_stack;
@ -142,7 +142,7 @@ RefPtr<ProcFSExposedComponent> ProcFSProcessStacks::lookup(StringView name)
class ProcFSProcessFileDescriptions;
class ProcFSProcessFileDescription final : public ProcFSExposedLink {
public:
// Note: we pass const ProcFSProcessFileDescriptions& just to enforce creation of this in the correct folder.
// Note: we pass const ProcFSProcessFileDescriptions& just to enforce creation of this in the correct directory.
static NonnullRefPtr<ProcFSProcessFileDescription> create(unsigned fd_number, const FileDescription& fd, InodeIndex preallocated_index, const ProcFSProcessFileDescriptions&)
{
return adopt_ref(*new (nothrow) ProcFSProcessFileDescription(fd_number, fd, preallocated_index));
@ -164,7 +164,7 @@ private:
};
class ProcFSProcessFileDescriptions final : public ProcFSExposedDirectory {
// Note: This folder is special, because everything that is created here is dynamic!
// Note: This directory is special, because everything that is created here is dynamic!
// This means we don't register anything in the m_components Vector, and every inode
// is created in runtime when called to get it
// Every ProcFSProcessFileDescription (that represents a file descriptor) is created only as a temporary object
@ -175,24 +175,24 @@ public:
virtual KResult traverse_as_directory(unsigned, Function<bool(FileSystem::DirectoryEntryView const&)>) const override;
virtual RefPtr<ProcFSExposedComponent> lookup(StringView name) override;
static NonnullRefPtr<ProcFSProcessFileDescriptions> create(const ProcFSProcessDirectory& parent_folder)
static NonnullRefPtr<ProcFSProcessFileDescriptions> create(const ProcFSProcessDirectory& parent_directory)
{
return adopt_ref(*new (nothrow) ProcFSProcessFileDescriptions(parent_folder));
return adopt_ref(*new (nothrow) ProcFSProcessFileDescriptions(parent_directory));
}
virtual void prepare_for_deletion() override
{
ProcFSExposedDirectory::prepare_for_deletion();
m_process_folder.clear();
m_process_directory.clear();
}
private:
explicit ProcFSProcessFileDescriptions(const ProcFSProcessDirectory& parent_folder)
: ProcFSExposedDirectory("fd"sv, parent_folder)
, m_process_folder(parent_folder)
explicit ProcFSProcessFileDescriptions(const ProcFSProcessDirectory& parent_directory)
: ProcFSExposedDirectory("fd"sv, parent_directory)
, m_process_directory(parent_directory)
{
}
WeakPtr<ProcFSProcessDirectory> m_process_folder;
WeakPtr<ProcFSProcessDirectory> m_process_directory;
mutable Mutex m_lock;
};
@ -210,13 +210,13 @@ KResultOr<size_t> ProcFSProcessFileDescriptions::entries_count() const
KResult ProcFSProcessFileDescriptions::traverse_as_directory(unsigned fsid, Function<bool(FileSystem::DirectoryEntryView const&)> callback) const
{
Locker locker(m_lock);
auto parent_folder = m_process_folder.strong_ref();
if (parent_folder.is_null())
auto parent_directory = m_process_directory.strong_ref();
if (parent_directory.is_null())
return KResult(EINVAL);
callback({ ".", { fsid, component_index() }, 0 });
callback({ "..", { fsid, parent_folder->component_index() }, 0 });
callback({ "..", { fsid, parent_directory->component_index() }, 0 });
auto process = parent_folder->associated_process();
auto process = parent_directory->associated_process();
if (process.is_null())
return KResult(ESRCH);
size_t count = 0;
@ -234,10 +234,10 @@ KResult ProcFSProcessFileDescriptions::traverse_as_directory(unsigned fsid, Func
RefPtr<ProcFSExposedComponent> ProcFSProcessFileDescriptions::lookup(StringView name)
{
Locker locker(m_lock);
auto parent_folder = m_process_folder.strong_ref();
if (parent_folder.is_null())
auto parent_directory = m_process_directory.strong_ref();
if (parent_directory.is_null())
return nullptr;
auto process = parent_folder->associated_process();
auto process = parent_directory->associated_process();
if (process.is_null())
return nullptr;
RefPtr<ProcFSProcessFileDescription> procfd_fd;
@ -258,22 +258,22 @@ RefPtr<ProcFSExposedComponent> ProcFSProcessFileDescriptions::lookup(StringView
class ProcFSProcessPledge final : public ProcFSProcessInformation {
public:
static NonnullRefPtr<ProcFSProcessPledge> create(const ProcFSProcessDirectory& parent_folder)
static NonnullRefPtr<ProcFSProcessPledge> create(const ProcFSProcessDirectory& parent_directory)
{
return adopt_ref(*new (nothrow) ProcFSProcessPledge(parent_folder));
return adopt_ref(*new (nothrow) ProcFSProcessPledge(parent_directory));
}
private:
explicit ProcFSProcessPledge(const ProcFSProcessDirectory& parent_folder)
: ProcFSProcessInformation("pledge"sv, parent_folder)
explicit ProcFSProcessPledge(const ProcFSProcessDirectory& parent_directory)
: ProcFSProcessInformation("pledge"sv, parent_directory)
{
}
virtual bool output(KBufferBuilder& builder) override
{
auto parent_folder = m_parent_folder.strong_ref();
if (parent_folder.is_null())
auto parent_directory = m_parent_directory.strong_ref();
if (parent_directory.is_null())
return false;
auto process = parent_folder->associated_process();
auto process = parent_directory->associated_process();
if (process.is_null())
return false;
JsonObjectSerializer obj { builder };
@ -296,22 +296,22 @@ private:
class ProcFSProcessUnveil final : public ProcFSProcessInformation {
public:
static NonnullRefPtr<ProcFSProcessUnveil> create(const ProcFSProcessDirectory& parent_folder)
static NonnullRefPtr<ProcFSProcessUnveil> create(const ProcFSProcessDirectory& parent_directory)
{
return adopt_ref(*new (nothrow) ProcFSProcessUnveil(parent_folder));
return adopt_ref(*new (nothrow) ProcFSProcessUnveil(parent_directory));
}
private:
explicit ProcFSProcessUnveil(const ProcFSProcessDirectory& parent_folder)
: ProcFSProcessInformation("unveil"sv, parent_folder)
explicit ProcFSProcessUnveil(const ProcFSProcessDirectory& parent_directory)
: ProcFSProcessInformation("unveil"sv, parent_directory)
{
}
virtual bool output(KBufferBuilder& builder) override
{
auto parent_folder = m_parent_folder.strong_ref();
if (parent_folder.is_null())
auto parent_directory = m_parent_directory.strong_ref();
if (parent_directory.is_null())
return false;
auto process = parent_folder->associated_process();
auto process = parent_directory->associated_process();
if (process.is_null())
return false;
JsonArraySerializer array { builder };
@ -340,23 +340,23 @@ private:
class ProcFSProcessPerformanceEvents final : public ProcFSProcessInformation {
public:
static NonnullRefPtr<ProcFSProcessPerformanceEvents> create(const ProcFSProcessDirectory& parent_folder)
static NonnullRefPtr<ProcFSProcessPerformanceEvents> create(const ProcFSProcessDirectory& parent_directory)
{
return adopt_ref(*new (nothrow) ProcFSProcessPerformanceEvents(parent_folder));
return adopt_ref(*new (nothrow) ProcFSProcessPerformanceEvents(parent_directory));
}
private:
explicit ProcFSProcessPerformanceEvents(const ProcFSProcessDirectory& parent_folder)
: ProcFSProcessInformation("perf_events"sv, parent_folder)
explicit ProcFSProcessPerformanceEvents(const ProcFSProcessDirectory& parent_directory)
: ProcFSProcessInformation("perf_events"sv, parent_directory)
{
}
virtual bool output(KBufferBuilder& builder) override
{
InterruptDisabler disabler;
auto parent_folder = m_parent_folder.strong_ref();
if (parent_folder.is_null())
auto parent_directory = m_parent_directory.strong_ref();
if (parent_directory.is_null())
return false;
auto process = parent_folder->associated_process();
auto process = parent_directory->associated_process();
if (process.is_null())
return false;
if (!process->perf_events()) {
@ -369,23 +369,23 @@ private:
class ProcFSProcessOverallFileDescriptions final : public ProcFSProcessInformation {
public:
static NonnullRefPtr<ProcFSProcessOverallFileDescriptions> create(const ProcFSProcessDirectory& parent_folder)
static NonnullRefPtr<ProcFSProcessOverallFileDescriptions> create(const ProcFSProcessDirectory& parent_directory)
{
return adopt_ref(*new (nothrow) ProcFSProcessOverallFileDescriptions(parent_folder));
return adopt_ref(*new (nothrow) ProcFSProcessOverallFileDescriptions(parent_directory));
}
private:
explicit ProcFSProcessOverallFileDescriptions(const ProcFSProcessDirectory& parent_folder)
: ProcFSProcessInformation("fds"sv, parent_folder)
explicit ProcFSProcessOverallFileDescriptions(const ProcFSProcessDirectory& parent_directory)
: ProcFSProcessInformation("fds"sv, parent_directory)
{
}
virtual bool output(KBufferBuilder& builder) override
{
auto parent_folder = m_parent_folder.strong_ref();
if (parent_folder.is_null())
auto parent_directory = m_parent_directory.strong_ref();
if (parent_directory.is_null())
return false;
JsonArraySerializer array { builder };
auto process = parent_folder->associated_process();
auto process = parent_directory->associated_process();
if (process.is_null())
return false;
if (process->fds().open_count() == 0) {
@ -421,23 +421,23 @@ private:
class ProcFSProcessRoot final : public ProcFSExposedLink {
public:
static NonnullRefPtr<ProcFSProcessRoot> create(const ProcFSProcessDirectory& parent_folder)
static NonnullRefPtr<ProcFSProcessRoot> create(const ProcFSProcessDirectory& parent_directory)
{
return adopt_ref(*new (nothrow) ProcFSProcessRoot(parent_folder));
return adopt_ref(*new (nothrow) ProcFSProcessRoot(parent_directory));
}
private:
explicit ProcFSProcessRoot(const ProcFSProcessDirectory& parent_folder)
explicit ProcFSProcessRoot(const ProcFSProcessDirectory& parent_directory)
: ProcFSExposedLink("root"sv)
, m_parent_process_directory(parent_folder)
, m_parent_process_directory(parent_directory)
{
}
virtual bool acquire_link(KBufferBuilder& builder) override
{
auto parent_folder = m_parent_process_directory.strong_ref();
if (parent_folder.is_null())
auto parent_directory = m_parent_process_directory.strong_ref();
if (parent_directory.is_null())
return false;
auto process = parent_folder->associated_process();
auto process = parent_directory->associated_process();
if (process.is_null())
return false;
builder.append_bytes(process->root_directory_relative_to_global_root().absolute_path().to_byte_buffer());
@ -448,22 +448,22 @@ private:
class ProcFSProcessVirtualMemory final : public ProcFSProcessInformation {
public:
static NonnullRefPtr<ProcFSProcessRoot> create(const ProcFSProcessDirectory& parent_folder)
static NonnullRefPtr<ProcFSProcessRoot> create(const ProcFSProcessDirectory& parent_directory)
{
return adopt_ref(*new (nothrow) ProcFSProcessVirtualMemory(parent_folder));
return adopt_ref(*new (nothrow) ProcFSProcessVirtualMemory(parent_directory));
}
private:
explicit ProcFSProcessVirtualMemory(const ProcFSProcessDirectory& parent_folder)
: ProcFSProcessInformation("vm"sv, parent_folder)
explicit ProcFSProcessVirtualMemory(const ProcFSProcessDirectory& parent_directory)
: ProcFSProcessInformation("vm"sv, parent_directory)
{
}
virtual bool output(KBufferBuilder& builder) override
{
auto parent_folder = m_parent_folder.strong_ref();
if (parent_folder.is_null())
auto parent_directory = m_parent_directory.strong_ref();
if (parent_directory.is_null())
return false;
auto process = parent_folder->associated_process();
auto process = parent_directory->associated_process();
if (process.is_null())
return false;
JsonArraySerializer array { builder };
@ -512,23 +512,23 @@ private:
class ProcFSProcessCurrentWorkDirectory final : public ProcFSExposedLink {
public:
static NonnullRefPtr<ProcFSProcessCurrentWorkDirectory> create(const ProcFSProcessDirectory& parent_folder)
static NonnullRefPtr<ProcFSProcessCurrentWorkDirectory> create(const ProcFSProcessDirectory& parent_directory)
{
return adopt_ref(*new (nothrow) ProcFSProcessCurrentWorkDirectory(parent_folder));
return adopt_ref(*new (nothrow) ProcFSProcessCurrentWorkDirectory(parent_directory));
}
private:
explicit ProcFSProcessCurrentWorkDirectory(const ProcFSProcessDirectory& parent_folder)
explicit ProcFSProcessCurrentWorkDirectory(const ProcFSProcessDirectory& parent_directory)
: ProcFSExposedLink("cwd"sv)
, m_parent_process_directory(parent_folder)
, m_parent_process_directory(parent_directory)
{
}
virtual bool acquire_link(KBufferBuilder& builder) override
{
auto parent_folder = m_parent_process_directory.strong_ref();
if (parent_folder.is_null())
auto parent_directory = m_parent_process_directory.strong_ref();
if (parent_directory.is_null())
return false;
auto process = parent_folder->associated_process();
auto process = parent_directory->associated_process();
if (process.is_null())
return false;
builder.append_bytes(process->current_directory().absolute_path().bytes());
@ -540,17 +540,17 @@ private:
class ProcFSProcessBinary final : public ProcFSExposedLink {
public:
static NonnullRefPtr<ProcFSProcessBinary> create(const ProcFSProcessDirectory& parent_folder)
static NonnullRefPtr<ProcFSProcessBinary> create(const ProcFSProcessDirectory& parent_directory)
{
return adopt_ref(*new (nothrow) ProcFSProcessBinary(parent_folder));
return adopt_ref(*new (nothrow) ProcFSProcessBinary(parent_directory));
}
virtual mode_t required_mode() const override
{
auto parent_folder = m_parent_process_directory.strong_ref();
if (parent_folder.is_null())
auto parent_directory = m_parent_process_directory.strong_ref();
if (parent_directory.is_null())
return false;
auto process = parent_folder->associated_process();
auto process = parent_directory->associated_process();
if (process.is_null())
return false;
if (!process->executable())
@ -559,17 +559,17 @@ public:
}
private:
explicit ProcFSProcessBinary(const ProcFSProcessDirectory& parent_folder)
explicit ProcFSProcessBinary(const ProcFSProcessDirectory& parent_directory)
: ProcFSExposedLink("exe"sv)
, m_parent_process_directory(parent_folder)
, m_parent_process_directory(parent_directory)
{
}
virtual bool acquire_link(KBufferBuilder& builder) override
{
auto parent_folder = m_parent_process_directory.strong_ref();
if (parent_folder.is_null())
auto parent_directory = m_parent_process_directory.strong_ref();
if (parent_directory.is_null())
return false;
auto process = parent_folder->associated_process();
auto process = parent_directory->associated_process();
if (process.is_null())
return false;
auto* custody = process->executable();
@ -626,7 +626,7 @@ void ProcFSProcessDirectory::prepare_for_deletion()
}
ProcFSProcessDirectory::ProcFSProcessDirectory(const Process& process)
: ProcFSExposedDirectory(String::formatted("{:d}", process.pid().value()), ProcFSComponentRegistry::the().root_folder())
: ProcFSExposedDirectory(String::formatted("{:d}", process.pid().value()), ProcFSComponentRegistry::the().root_directory())
, m_associated_process(process)
{
}