2021-07-10 19:46:06 -03:00
|
|
|
/*
|
2023-04-02 13:19:20 -03:00
|
|
|
* Copyright (c) 2018-2023, Andreas Kling <kling@serenityos.org>
|
2021-07-10 19:46:06 -03:00
|
|
|
*
|
|
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
2022-08-20 20:04:35 -03:00
|
|
|
#include <AK/RefPtr.h>
|
2021-12-15 11:02:22 -03:00
|
|
|
#include <Kernel/FileSystem/Custody.h>
|
2022-11-11 06:11:03 -03:00
|
|
|
#include <Kernel/FileSystem/FileSystem.h>
|
|
|
|
|
#include <Kernel/FileSystem/Inode.h>
|
2021-07-11 06:49:16 -03:00
|
|
|
#include <Kernel/Forward.h>
|
2022-08-19 15:53:40 -03:00
|
|
|
#include <Kernel/Library/NonnullLockRefPtr.h>
|
2021-07-10 19:46:06 -03:00
|
|
|
|
|
|
|
|
namespace Kernel {
|
|
|
|
|
|
2022-11-21 17:10:56 -03:00
|
|
|
class VirtualFileSystem;
|
2021-07-10 19:46:06 -03:00
|
|
|
class Mount {
|
2023-04-02 13:19:20 -03:00
|
|
|
AK_MAKE_NONCOPYABLE(Mount);
|
|
|
|
|
AK_MAKE_NONMOVABLE(Mount);
|
2022-11-21 17:10:56 -03:00
|
|
|
friend class VirtualFileSystem;
|
|
|
|
|
|
2021-07-10 19:46:06 -03:00
|
|
|
public:
|
2023-04-02 13:19:20 -03:00
|
|
|
Mount(NonnullRefPtr<FileSystem>, RefPtr<Custody> host_custody, int flags);
|
|
|
|
|
Mount(NonnullRefPtr<Inode> source, NonnullRefPtr<Custody> host_custody, int flags);
|
2021-07-10 19:46:06 -03:00
|
|
|
|
2023-03-07 08:25:00 -03:00
|
|
|
RefPtr<Inode const> host() const;
|
|
|
|
|
RefPtr<Inode> host();
|
2021-07-10 19:46:06 -03:00
|
|
|
|
2023-06-27 10:16:26 -03:00
|
|
|
RefPtr<Custody const> host_custody() const;
|
|
|
|
|
RefPtr<Custody> host_custody();
|
|
|
|
|
|
2021-07-10 19:46:06 -03:00
|
|
|
Inode const& guest() const { return *m_guest; }
|
|
|
|
|
Inode& guest() { return *m_guest; }
|
|
|
|
|
|
|
|
|
|
FileSystem const& guest_fs() const { return *m_guest_fs; }
|
2021-07-17 20:29:54 -03:00
|
|
|
FileSystem& guest_fs() { return *m_guest_fs; }
|
2021-07-10 19:46:06 -03:00
|
|
|
|
2022-01-11 16:26:32 -03:00
|
|
|
ErrorOr<NonnullOwnPtr<KString>> absolute_path() const;
|
2021-07-10 19:46:06 -03:00
|
|
|
|
|
|
|
|
int flags() const { return m_flags; }
|
|
|
|
|
void set_flags(int flags) { m_flags = flags; }
|
|
|
|
|
|
|
|
|
|
private:
|
2023-04-02 13:19:20 -03:00
|
|
|
NonnullRefPtr<FileSystem> const m_guest_fs;
|
|
|
|
|
NonnullRefPtr<Inode> const m_guest;
|
|
|
|
|
RefPtr<Custody> const m_host_custody;
|
|
|
|
|
int m_flags { 0 };
|
2022-11-21 17:10:56 -03:00
|
|
|
|
|
|
|
|
IntrusiveListNode<Mount> m_vfs_list_node;
|
2021-07-10 19:46:06 -03:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
}
|