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