mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-01-06 19:19:44 +03:00
aa9fab9c3a
The fact that we used a Vector meant that even if creating a Mount object succeeded, we were still at a risk that appending to the actual mounts Vector could fail due to OOM condition. To guard against this, the mount table is now an IntrusiveList, which always means that when allocation of a Mount object succeeded, then inserting that object to the list will succeed, which allows us to fail early in case of OOM condition.
50 lines
1.2 KiB
C++
50 lines
1.2 KiB
C++
/*
|
|
* Copyright (c) 2018-2021, 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 VirtualFileSystem;
|
|
class Mount {
|
|
friend class VirtualFileSystem;
|
|
|
|
public:
|
|
Mount(FileSystem&, Custody* host_custody, int flags);
|
|
Mount(Inode& source, Custody& host_custody, int flags);
|
|
|
|
LockRefPtr<Inode const> host() const;
|
|
LockRefPtr<Inode> host();
|
|
|
|
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; }
|
|
|
|
private:
|
|
NonnullLockRefPtr<Inode> m_guest;
|
|
NonnullLockRefPtr<FileSystem> m_guest_fs;
|
|
SpinlockProtected<RefPtr<Custody>> m_host_custody;
|
|
int m_flags;
|
|
|
|
IntrusiveListNode<Mount> m_vfs_list_node;
|
|
};
|
|
|
|
}
|