2021-07-11 01:46:06 +03:00
|
|
|
/*
|
2023-04-02 19:19:20 +03:00
|
|
|
* Copyright (c) 2018-2023, Andreas Kling <kling@serenityos.org>
|
2021-07-11 01:46:06 +03:00
|
|
|
*
|
|
|
|
* 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 {
|
|
|
|
|
2023-04-02 19:19:20 +03:00
|
|
|
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))
|
2021-07-11 01:46:06 +03:00
|
|
|
, m_flags(flags)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2023-04-02 19:19:20 +03:00
|
|
|
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))
|
2021-07-11 01:46:06 +03:00
|
|
|
, m_flags(flags)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2022-01-11 22:26:32 +03:00
|
|
|
ErrorOr<NonnullOwnPtr<KString>> Mount::absolute_path() const
|
2021-07-11 01:46:06 +03:00
|
|
|
{
|
2023-04-02 19:19:20 +03:00
|
|
|
if (!m_host_custody)
|
|
|
|
return KString::try_create("/"sv);
|
|
|
|
return m_host_custody->try_serialize_absolute_path();
|
2021-07-11 01:46:06 +03:00
|
|
|
}
|
|
|
|
|
2023-03-07 14:25:00 +03:00
|
|
|
RefPtr<Inode> Mount::host()
|
2021-07-11 01:46:06 +03:00
|
|
|
{
|
2023-04-02 19:19:20 +03:00
|
|
|
if (!m_host_custody)
|
|
|
|
return nullptr;
|
|
|
|
return m_host_custody->inode();
|
2021-07-11 01:46:06 +03:00
|
|
|
}
|
|
|
|
|
2023-03-07 14:25:00 +03:00
|
|
|
RefPtr<Inode const> Mount::host() const
|
2021-07-11 01:46:06 +03:00
|
|
|
{
|
2023-04-02 19:19:20 +03:00
|
|
|
if (!m_host_custody)
|
|
|
|
return nullptr;
|
|
|
|
return m_host_custody->inode();
|
2021-07-11 01:46:06 +03:00
|
|
|
}
|
|
|
|
|
2023-06-27 16:16:26 +03:00
|
|
|
RefPtr<Custody const> Mount::host_custody() const
|
|
|
|
{
|
|
|
|
return m_host_custody;
|
|
|
|
}
|
|
|
|
|
|
|
|
RefPtr<Custody> Mount::host_custody()
|
|
|
|
{
|
|
|
|
return m_host_custody;
|
|
|
|
}
|
|
|
|
|
2021-07-11 01:46:06 +03:00
|
|
|
}
|