/* * Copyright (c) 2018-2021, Andreas Kling * * SPDX-License-Identifier: BSD-2-Clause */ #include #include #include #include namespace Kernel { Mount::Mount(FileSystem& guest_fs, Custody* host_custody, int flags) : m_guest(guest_fs.root_inode()) , m_guest_fs(guest_fs) , m_host_custody(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) , m_flags(flags) { } ErrorOr> Mount::absolute_path() const { return m_host_custody.with([&](auto& host_custody) -> ErrorOr> { if (!host_custody) return KString::try_create("/"sv); return host_custody->try_serialize_absolute_path(); }); } LockRefPtr Mount::host() { return m_host_custody.with([](auto& host_custody) -> LockRefPtr { if (!host_custody) return nullptr; return &host_custody->inode(); }); } LockRefPtr Mount::host() const { return m_host_custody.with([](auto& host_custody) -> LockRefPtr { if (!host_custody) return nullptr; return &host_custody->inode(); }); } }