mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-05-19 01:22:54 +00:00
This is a preparation before we can create a usable mechanism to use filesystem-specific mount flags. To keep some compatibility with userland code, LibC and LibCore mount functions are kept being usable, but now instead of doing an "atomic" syscall, they do multiple syscalls to perform the complete procedure of mounting a filesystem. The FileBackedFileSystem IntrusiveList in the VFS code is now changed to be protected by a Mutex, because when we mount a new filesystem, we need to check if a filesystem is already created for a given source_fd so we do a scan for that OpenFileDescription in that list. If we fail to find an already-created filesystem we create a new one and register it in the list if we successfully mounted it. We use a Mutex because we might need to initiate disk access during the filesystem creation, which will take other mutexes in other parts of the kernel, therefore making it not possible to take a spinlock while doing this.
68 lines
2.2 KiB
C++
68 lines
2.2 KiB
C++
/*
|
|
* Copyright (c) 2021, sin-ack <sin-ack@protonmail.com>
|
|
*
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <AK/EnumBits.h>
|
|
#include <AK/Error.h>
|
|
#include <AK/HashMap.h>
|
|
#include <AK/RecursionDecision.h>
|
|
#include <AK/StringView.h>
|
|
#include <AK/Types.h>
|
|
#include <Kernel/FileSystem/BlockBasedFileSystem.h>
|
|
#include <Kernel/FileSystem/ISO9660FS/Definitions.h>
|
|
#include <Kernel/FileSystem/ISO9660FS/DirectoryEntry.h>
|
|
#include <Kernel/FileSystem/Inode.h>
|
|
#include <Kernel/Library/KBuffer.h>
|
|
#include <Kernel/Library/NonnullLockRefPtr.h>
|
|
|
|
namespace Kernel {
|
|
|
|
class ISO9660Inode;
|
|
class ISO9660DirectoryIterator;
|
|
|
|
class ISO9660FS final : public BlockBasedFileSystem {
|
|
friend ISO9660Inode;
|
|
friend ISO9660DirectoryIterator;
|
|
|
|
public:
|
|
static ErrorOr<NonnullRefPtr<FileSystem>> try_create(OpenFileDescription&, ReadonlyBytes);
|
|
|
|
virtual ~ISO9660FS() override;
|
|
virtual StringView class_name() const override { return "ISO9660FS"sv; }
|
|
virtual Inode& root_inode() override;
|
|
|
|
virtual unsigned total_block_count() const override;
|
|
virtual unsigned total_inode_count() const override;
|
|
|
|
virtual u8 internal_file_type_to_directory_entry_type(DirectoryEntryView const& entry) const override;
|
|
|
|
ErrorOr<NonnullLockRefPtr<ISO9660FSDirectoryEntry>> directory_entry_for_record(Badge<ISO9660DirectoryIterator>, ISO::DirectoryRecordHeader const* record);
|
|
|
|
private:
|
|
ISO9660FS(OpenFileDescription&);
|
|
|
|
virtual ErrorOr<void> prepare_to_clear_last_mount() override;
|
|
|
|
virtual bool is_initialized_while_locked() override;
|
|
virtual ErrorOr<void> initialize_while_locked() override;
|
|
|
|
ErrorOr<void> parse_volume_set();
|
|
ErrorOr<void> create_root_inode();
|
|
ErrorOr<void> calculate_inode_count() const;
|
|
|
|
u32 calculate_directory_entry_cache_key(ISO::DirectoryRecordHeader const&);
|
|
|
|
ErrorOr<void> visit_directory_record(ISO::DirectoryRecordHeader const& record, Function<ErrorOr<RecursionDecision>(ISO::DirectoryRecordHeader const*)> const& visitor) const;
|
|
|
|
OwnPtr<ISO::PrimaryVolumeDescriptor> m_primary_volume;
|
|
RefPtr<ISO9660Inode> m_root_inode;
|
|
|
|
mutable u32 m_cached_inode_count { 0 };
|
|
HashMap<u32, NonnullLockRefPtr<ISO9660FSDirectoryEntry>> m_directory_entry_cache;
|
|
};
|
|
|
|
}
|