2022-10-24 09:41:31 +03:00
|
|
|
/*
|
|
|
|
|
* Copyright (c) 2018-2021, Andreas Kling <kling@serenityos.org>
|
|
|
|
|
* Copyright (c) 2021, Spencer Dixon <spencercdixon@gmail.com>
|
|
|
|
|
* Copyright (c) 2021, Liav A. <liavalb@hotmail.co.il>
|
|
|
|
|
*
|
|
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include <Kernel/FileSystem/ProcFS/FileSystem.h>
|
2022-11-25 22:29:27 +02:00
|
|
|
#include <Kernel/FileSystem/ProcFS/Inode.h>
|
2022-10-24 09:41:31 +03:00
|
|
|
|
|
|
|
|
namespace Kernel {
|
|
|
|
|
|
|
|
|
|
ErrorOr<NonnullLockRefPtr<FileSystem>> ProcFS::try_create()
|
|
|
|
|
{
|
|
|
|
|
return TRY(adopt_nonnull_lock_ref_or_enomem(new (nothrow) ProcFS));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ProcFS::ProcFS() = default;
|
|
|
|
|
ProcFS::~ProcFS() = default;
|
|
|
|
|
|
2023-02-20 17:51:18 +02:00
|
|
|
ErrorOr<NonnullLockRefPtr<Inode>> ProcFS::get_inode(InodeIdentifier inode_id) const
|
|
|
|
|
{
|
|
|
|
|
if (inode_id.index() == 1)
|
|
|
|
|
return *m_root_inode;
|
|
|
|
|
return TRY(adopt_nonnull_lock_ref_or_enomem(new (nothrow) ProcFSInode(const_cast<ProcFS&>(*this), inode_id.index())));
|
|
|
|
|
}
|
|
|
|
|
|
2022-10-24 09:41:31 +03:00
|
|
|
ErrorOr<void> ProcFS::initialize()
|
|
|
|
|
{
|
2023-02-20 17:51:18 +02:00
|
|
|
m_root_inode = TRY(adopt_nonnull_lock_ref_or_enomem(new (nothrow) ProcFSInode(const_cast<ProcFS&>(*this), 1)));
|
2022-10-24 09:41:31 +03:00
|
|
|
return {};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Inode& ProcFS::root_inode()
|
|
|
|
|
{
|
|
|
|
|
return *m_root_inode;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|