2021-07-11 00:46:06 +02:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2018-2021, Andreas Kling <kling@serenityos.org>
|
|
|
|
*
|
|
|
|
* 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 {
|
2022-11-21 22:10:56 +02:00
|
|
|
friend class VirtualFileSystem;
|
|
|
|
|
2021-07-11 00:46:06 +02:00
|
|
|
public:
|
|
|
|
Mount(FileSystem&, Custody* host_custody, int flags);
|
|
|
|
Mount(Inode& source, Custody& host_custody, int flags);
|
|
|
|
|
2022-08-21 01:04:35 +02:00
|
|
|
LockRefPtr<Inode const> host() const;
|
|
|
|
LockRefPtr<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:
|
2022-08-19 20:53:40 +02:00
|
|
|
NonnullLockRefPtr<Inode> m_guest;
|
|
|
|
NonnullLockRefPtr<FileSystem> m_guest_fs;
|
2022-11-09 11:39:58 +01:00
|
|
|
SpinlockProtected<RefPtr<Custody>, LockRank::None> m_host_custody;
|
2021-07-11 00:46:06 +02:00
|
|
|
int m_flags;
|
2022-11-21 22:10:56 +02:00
|
|
|
|
|
|
|
IntrusiveListNode<Mount> m_vfs_list_node;
|
2021-07-11 00:46:06 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|