mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-12-27 13:11:46 +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.
27 lines
562 B
C++
27 lines
562 B
C++
/*
|
|
* Copyright (c) 2018-2021, Andreas Kling <kling@serenityos.org>
|
|
*
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
*/
|
|
|
|
#include <Kernel/FileSystem/FileBackedFileSystem.h>
|
|
|
|
namespace Kernel {
|
|
|
|
FileBackedFileSystem::FileBackedFileSystem(OpenFileDescription& file_description)
|
|
: m_file_description(file_description)
|
|
{
|
|
}
|
|
|
|
FileBackedFileSystem::~FileBackedFileSystem() = default;
|
|
|
|
ErrorOr<void> FileBackedFileSystem::initialize()
|
|
{
|
|
MutexLocker locker(m_lock);
|
|
if (is_initialized_while_locked())
|
|
return {};
|
|
return initialize_while_locked();
|
|
}
|
|
|
|
}
|