mirror of
https://github.com/SerenityOS/serenity
synced 2026-05-09 08:32:04 +02:00
There's no point in constructing an object just for the sake of keeping a state that can be touched by anything in the kernel code. Let's reduce everything to be in a C++ namespace called with the previous name "VirtualFileSystem" and keep a smaller textual-footprint struct called "VirtualFileSystemDetails". This change also cleans up old "friend class" statements that were no longer needed, and move methods from the VirtualFileSystem code to more appropriate places as well. Please note that the method of locking all filesystems during shutdown is removed, as in that place there's no meaning to actually locking all filesystems because of running in kernel mode entirely.
69 lines
1.5 KiB
C++
69 lines
1.5 KiB
C++
/*
|
|
* Copyright (c) 2018-2023, Andreas Kling <kling@serenityos.org>
|
|
*
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
*/
|
|
|
|
#include <Kernel/FileSystem/Custody.h>
|
|
#include <Kernel/FileSystem/FileSystem.h>
|
|
#include <Kernel/FileSystem/Inode.h>
|
|
#include <Kernel/FileSystem/Mount.h>
|
|
|
|
namespace Kernel {
|
|
|
|
Mount::Mount(NonnullRefPtr<Inode> source, int flags)
|
|
: m_guest_fs(source->fs())
|
|
, m_guest(move(source))
|
|
, m_flags(flags)
|
|
{
|
|
}
|
|
|
|
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)
|
|
{
|
|
}
|
|
|
|
void Mount::delete_mount_from_list(Mount& mount)
|
|
{
|
|
dbgln("VirtualFileSystem: Unmounting file system {}...", mount.guest_fs().fsid());
|
|
VERIFY(mount.m_vfs_list_node.is_in_list());
|
|
mount.m_vfs_list_node.remove();
|
|
delete &mount;
|
|
}
|
|
|
|
ErrorOr<NonnullOwnPtr<KString>> Mount::absolute_path() const
|
|
{
|
|
if (!m_host_custody)
|
|
return KString::try_create("/"sv);
|
|
return m_host_custody->try_serialize_absolute_path();
|
|
}
|
|
|
|
RefPtr<Inode> Mount::host()
|
|
{
|
|
if (!m_host_custody)
|
|
return nullptr;
|
|
return m_host_custody->inode();
|
|
}
|
|
|
|
RefPtr<Inode const> Mount::host() const
|
|
{
|
|
if (!m_host_custody)
|
|
return nullptr;
|
|
return m_host_custody->inode();
|
|
}
|
|
|
|
RefPtr<Custody const> Mount::host_custody() const
|
|
{
|
|
return m_host_custody;
|
|
}
|
|
|
|
RefPtr<Custody> Mount::host_custody()
|
|
{
|
|
return m_host_custody;
|
|
}
|
|
|
|
}
|