mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-13 01:59:14 +03:00
0fd7b688af
The idea is to enable mounting FileSystem objects across multiple mounts in contrast to what happened until now - each mount has its own unique FileSystem object being attached to it. Considering a situation of mounting a block device at 2 different mount points at in system, there were a couple of critical flaws due to how the previous "design" worked: 1. BlockBasedFileSystem(s) that pointed to the same actual device had a separate DiskCache object being attached to them. Because both instances were not synchronized by any means, corruption of the filesystem is most likely achieveable by a simple cache flush of either of the instances. 2. For superblock-oriented filesystems (such as the ext2 filesystem), lack of synchronization between both instances can lead to severe corruption in the superblock, which could render the entire filesystem unusable. 3. Flags of a specific filesystem implementation (for example, with xfs on Linux, one can instruct to mount it with the discard option) must be honored across multiple mounts, to ensure expected behavior against a particular filesystem. This patch put the foundations to start fix the issues mentioned above. However, there are still major issues to solve, so this is only a start.
44 lines
1.4 KiB
C++
44 lines
1.4 KiB
C++
/*
|
|
* Copyright (c) 2018-2021, Andreas Kling <kling@serenityos.org>
|
|
*
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <Kernel/FileSystem/FileSystem.h>
|
|
#include <Kernel/FileSystem/OpenFileDescription.h>
|
|
|
|
namespace Kernel {
|
|
|
|
class FileBackedFileSystem : public FileSystem {
|
|
friend class VirtualFileSystem;
|
|
|
|
public:
|
|
virtual ~FileBackedFileSystem() override;
|
|
|
|
File& file() { return m_file_description->file(); }
|
|
OpenFileDescription& file_description() { return *m_file_description; }
|
|
File const& file() const { return m_file_description->file(); }
|
|
OpenFileDescription& file_description() const { return *m_file_description; }
|
|
|
|
protected:
|
|
explicit FileBackedFileSystem(OpenFileDescription&);
|
|
|
|
// Note: We require all FileBackedFileSystem to implement something that actually
|
|
// takes into account the fact that we will clean the last mount of the filesystem,
|
|
// therefore, removing the file system with it from the Kernel memory.
|
|
virtual ErrorOr<void> prepare_to_clear_last_mount() override = 0;
|
|
|
|
virtual ErrorOr<void> initialize_while_locked() = 0;
|
|
virtual bool is_initialized_while_locked() = 0;
|
|
|
|
private:
|
|
virtual ErrorOr<void> initialize() override final;
|
|
virtual bool is_file_backed() const override { return true; }
|
|
|
|
IntrusiveListNode<FileBackedFileSystem> m_file_backed_file_system_node;
|
|
mutable NonnullLockRefPtr<OpenFileDescription> m_file_description;
|
|
};
|
|
}
|