summaryrefslogtreecommitdiff
path: root/Kernel/FileSystem/Mount.cpp
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2023-04-02 18:19:20 +0200
committerAndreas Kling <kling@serenityos.org>2023-04-04 10:33:42 +0200
commit19084ef743fc6a616d0639d201f18b673d77d08a (patch)
tree642039b241bf0a16cdfece76995939b04c4a3f81 /Kernel/FileSystem/Mount.cpp
parent673592dea83981bb0829ff14c521a78ebb543e69 (diff)
downloadserenity-19084ef743fc6a616d0639d201f18b673d77d08a.zip
Kernel: Simplify Mount internals
- The host custody never changes after initialization, so there's no need to protect it with a spinlock. - To enforce the fact that some members don't change after initialization, make them const.
Diffstat (limited to 'Kernel/FileSystem/Mount.cpp')
-rw-r--r--Kernel/FileSystem/Mount.cpp42
1 files changed, 18 insertions, 24 deletions
diff --git a/Kernel/FileSystem/Mount.cpp b/Kernel/FileSystem/Mount.cpp
index 3dbb888477..dd7ec867dc 100644
--- a/Kernel/FileSystem/Mount.cpp
+++ b/Kernel/FileSystem/Mount.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2018-2021, Andreas Kling <kling@serenityos.org>
+ * Copyright (c) 2018-2023, Andreas Kling <kling@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
@@ -11,47 +11,41 @@
namespace Kernel {
-Mount::Mount(NonnullRefPtr<FileSystem> guest_fs, Custody* host_custody, int flags)
- : m_guest(guest_fs->root_inode())
- , m_guest_fs(guest_fs)
- , m_host_custody(host_custody)
+Mount::Mount(NonnullRefPtr<FileSystem> guest_fs, RefPtr<Custody> host_custody, int flags)
+ : m_guest_fs(move(guest_fs))
+ , m_guest(m_guest_fs->root_inode())
+ , m_host_custody(move(host_custody))
, m_flags(flags)
{
}
-Mount::Mount(Inode& source, Custody& host_custody, int flags)
- : m_guest(source)
- , m_guest_fs(source.fs())
- , m_host_custody(host_custody)
+Mount::Mount(NonnullRefPtr<Inode> source, NonnullRefPtr<Custody> host_custody, int flags)
+ : m_guest_fs(source->fs())
+ , m_guest(move(source))
+ , m_host_custody(move(host_custody))
, m_flags(flags)
{
}
ErrorOr<NonnullOwnPtr<KString>> Mount::absolute_path() const
{
- return m_host_custody.with([&](auto& host_custody) -> ErrorOr<NonnullOwnPtr<KString>> {
- if (!host_custody)
- return KString::try_create("/"sv);
- return host_custody->try_serialize_absolute_path();
- });
+ if (!m_host_custody)
+ return KString::try_create("/"sv);
+ return m_host_custody->try_serialize_absolute_path();
}
RefPtr<Inode> Mount::host()
{
- return m_host_custody.with([](auto& host_custody) -> RefPtr<Inode> {
- if (!host_custody)
- return nullptr;
- return &host_custody->inode();
- });
+ if (!m_host_custody)
+ return nullptr;
+ return m_host_custody->inode();
}
RefPtr<Inode const> Mount::host() const
{
- return m_host_custody.with([](auto& host_custody) -> RefPtr<Inode const> {
- if (!host_custody)
- return nullptr;
- return &host_custody->inode();
- });
+ if (!m_host_custody)
+ return nullptr;
+ return m_host_custody->inode();
}
}