Files
serenity/Kernel/FileSystem/Mount.h
Liav A. 3692af528e Kernel: Move most of VirtualFileSystem code to be in a namespace
There's no point in constructing an object just for the sake of keeping
a state that can be touched by anything in the kernel code.

Let's reduce everything to be in a C++ namespace called with the
previous name "VirtualFileSystem" and keep a smaller textual-footprint
struct called "VirtualFileSystemDetails".

This change also cleans up old "friend class" statements that were no
longer needed, and move methods from the VirtualFileSystem code to more
appropriate places as well.
Please note that the method of locking all filesystems during shutdown
is removed, as in that place there's no meaning to actually locking all
filesystems because of running in kernel mode entirely.
2024-07-21 11:44:23 +02:00

58 lines
1.5 KiB
C++

/*
* 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 {
AK_MAKE_NONCOPYABLE(Mount);
AK_MAKE_NONMOVABLE(Mount);
friend class VFSRootContext;
public:
// 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_guest; }
Inode& guest() { return *m_guest; }
FileSystem const& guest_fs() const { return *m_guest_fs; }
FileSystem& guest_fs() { return *m_guest_fs; }
ErrorOr<NonnullOwnPtr<KString>> absolute_path() const;
int flags() const { return m_flags; }
void set_flags(int flags) { m_flags = flags; }
static void delete_mount_from_list(Mount&);
private:
NonnullRefPtr<FileSystem> const m_guest_fs;
NonnullRefPtr<Inode> const m_guest;
RefPtr<Custody> const m_host_custody;
int m_flags { 0 };
IntrusiveListNode<Mount> m_vfs_list_node;
};
}