/* * Copyright (c) 2018-2021, Andreas Kling * Copyright (c) 2021, Spencer Dixon * Copyright (c) 2021, Liav A. * * SPDX-License-Identifier: BSD-2-Clause */ #include namespace Kernel { ErrorOr> ProcFSGlobalInode::try_create(ProcFS const& fs, ProcFSExposedComponent const& component) { return adopt_nonnull_lock_ref_or_enomem(new (nothrow) ProcFSGlobalInode(fs, component)); } ProcFSGlobalInode::ProcFSGlobalInode(ProcFS const& fs, ProcFSExposedComponent const& component) : ProcFSInode(fs, component.component_index()) , m_associated_component(component) { } void ProcFSGlobalInode::did_seek(OpenFileDescription& description, off_t new_offset) { if (new_offset != 0) return; auto result = m_associated_component->refresh_data(description); if (result.is_error()) { // Subsequent calls to read will return EIO! dbgln("ProcFS: Could not refresh contents: {}", result.error()); } } ErrorOr ProcFSGlobalInode::attach(OpenFileDescription& description) { return m_associated_component->refresh_data(description); } ErrorOr ProcFSGlobalInode::read_bytes_locked(off_t offset, size_t count, UserOrKernelBuffer& buffer, OpenFileDescription* fd) const { return m_associated_component->read_bytes(offset, count, buffer, fd); } StringView ProcFSGlobalInode::name() const { return m_associated_component->name(); } ErrorOr ProcFSGlobalInode::traverse_as_directory(Function(FileSystem::DirectoryEntryView const&)>) const { VERIFY_NOT_REACHED(); } ErrorOr> ProcFSGlobalInode::lookup(StringView) { VERIFY_NOT_REACHED(); } ErrorOr ProcFSGlobalInode::truncate(u64 size) { return m_associated_component->truncate(size); } ErrorOr ProcFSGlobalInode::update_timestamps(Optional