-
Notifications
You must be signed in to change notification settings - Fork 3.3k
Expand file tree
/
Copy pathMount.h
More file actions
70 lines (50 loc) · 1.84 KB
/
Mount.h
File metadata and controls
70 lines (50 loc) · 1.84 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
/*
* Copyright (c) 2018-2023, Andreas Kling <kling@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include <AK/RefPtr.h>
#include <Kernel/FileSystem/Custody.h>
#include <Kernel/FileSystem/FileSystem.h>
#include <Kernel/FileSystem/Inode.h>
#include <Kernel/Forward.h>
#include <Kernel/Library/NonnullLockRefPtr.h>
namespace Kernel {
class Mount : public AtomicRefCounted<Mount> {
AK_MAKE_NONCOPYABLE(Mount);
AK_MAKE_NONMOVABLE(Mount);
friend class VFSRootContext;
public:
struct Details {
NonnullRefPtr<FileSystem> guest_fs;
NonnullRefPtr<Inode> guest;
};
// NOTE: This constructor is valid for VFSRootContext root inodes (as for the "/" directory)
Mount(NonnullRefPtr<Inode> source, int flags);
Mount(NonnullRefPtr<Inode> source, NonnullRefPtr<Custody> host_custody, int flags);
RefPtr<Inode const> host() const;
RefPtr<Inode> host();
RefPtr<Custody const> host_custody() const;
RefPtr<Custody> host_custody();
Inode const& guest() const { return *m_details.guest; }
Inode& guest() { return *m_details.guest; }
FileSystem const& guest_fs() const { return *m_details.guest_fs; }
FileSystem& guest_fs() { return *m_details.guest_fs; }
ErrorOr<NonnullOwnPtr<KString>> absolute_path() const;
int flags() const
{
return m_flags.with([](auto const& current_flags) -> int { return current_flags; });
}
void set_flags(int flags);
static void delete_mount_from_list(Mount&);
bool is_immutable() const { return m_immutable.was_set(); }
Details const& details() const { return m_details; }
private:
Details const m_details;
RefPtr<Custody> const m_host_custody;
SpinlockProtected<int, LockRank::None> m_flags { 0 };
SetOnce m_immutable;
IntrusiveListNode<Mount, NonnullRefPtr<Mount>> m_vfs_list_node;
};
}