mirror of
https://github.com/SerenityOS/serenity.git
synced 2026-11-09 17:52:31 -10:00
There was only one permanent storage location for these: as a member in the Mount class. That member is never modified after Mount initialization, so we don't need to worry about races there.
41 lines
1.0 KiB
C++
41 lines
1.0 KiB
C++
/*
|
|
* Copyright (c) 2018-2021, Andreas Kling <[email protected]>
|
|
* Copyright (c) 2021, Spencer Dixon <[email protected]>
|
|
* Copyright (c) 2021, Liav A. <[email protected]>
|
|
*
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
*/
|
|
|
|
#include <Kernel/FileSystem/ProcFS/FileSystem.h>
|
|
#include <Kernel/FileSystem/ProcFS/Inode.h>
|
|
|
|
namespace Kernel {
|
|
|
|
ErrorOr<NonnullRefPtr<FileSystem>> ProcFS::try_create()
|
|
{
|
|
return TRY(adopt_nonnull_ref_or_enomem(new (nothrow) ProcFS));
|
|
}
|
|
|
|
ProcFS::ProcFS() = default;
|
|
ProcFS::~ProcFS() = default;
|
|
|
|
ErrorOr<NonnullRefPtr<Inode>> ProcFS::get_inode(InodeIdentifier inode_id) const
|
|
{
|
|
if (inode_id.index() == 1)
|
|
return *m_root_inode;
|
|
return TRY(adopt_nonnull_ref_or_enomem(new (nothrow) ProcFSInode(const_cast<ProcFS&>(*this), inode_id.index())));
|
|
}
|
|
|
|
ErrorOr<void> ProcFS::initialize()
|
|
{
|
|
m_root_inode = TRY(adopt_nonnull_ref_or_enomem(new (nothrow) ProcFSInode(const_cast<ProcFS&>(*this), 1)));
|
|
return {};
|
|
}
|
|
|
|
Inode& ProcFS::root_inode()
|
|
{
|
|
return *m_root_inode;
|
|
}
|
|
|
|
}
|