mirror of
https://github.com/SerenityOS/serenity
synced 2026-05-09 08:32:04 +02:00
Instead of using a raw `KBuffer` and letting each implementation to populating the specific flags on its own, we change things so we only let each FileSystem implementation to validate the flag and its value but then store it in a HashMap which its key is the flag name and the value is a special new class called `FileSystemSpecificOption` which wraps around `AK::Variant<...>`. This approach has multiple advantages over the previous: - It allows runtime inspection of what the user has set on a `MountFile` description for a specific filesystem. - It ensures accidental overriding of filesystem specific option that was already set is not possible - It removes ugly casting of a `KBuffer` contents to a strongly-typed values. Instead, a strongly-typed `AK::Variant` is used which ensures we always get a value without doing any casting. Please note that we have removed support for ASCII string-oriented flags as there were no actual use cases, and supporting such type would make `FileSystemSpecificOption` more complicated unnecessarily for now.
47 lines
1.2 KiB
C++
47 lines
1.2 KiB
C++
/*
|
|
* Copyright (c) 2024, the SerenityOS developers.
|
|
*
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <AK/Types.h>
|
|
#include <Kernel/Devices/FUSEDevice.h>
|
|
#include <Kernel/FileSystem/FUSE/FUSEConnection.h>
|
|
#include <Kernel/FileSystem/FileSystem.h>
|
|
#include <Kernel/FileSystem/FileSystemSpecificOption.h>
|
|
#include <Kernel/FileSystem/Inode.h>
|
|
|
|
namespace Kernel {
|
|
|
|
class FUSEInode;
|
|
|
|
class FUSE final : public FileSystem {
|
|
friend class FUSEInode;
|
|
|
|
public:
|
|
virtual ~FUSE() override;
|
|
static ErrorOr<NonnullRefPtr<FileSystem>> try_create(FileSystemSpecificOptions const&);
|
|
|
|
static ErrorOr<void> validate_mount_unsigned_integer_flag(StringView key, u64);
|
|
|
|
virtual ErrorOr<void> initialize() override;
|
|
virtual StringView class_name() const override { return "FUSE"sv; }
|
|
|
|
virtual Inode& root_inode() override;
|
|
|
|
private:
|
|
virtual u8 internal_file_type_to_directory_entry_type(DirectoryEntryView const& entry) const override;
|
|
|
|
FUSE(NonnullRefPtr<FUSEConnection> connection, u64 rootmode, u64 gid, u64 uid);
|
|
|
|
RefPtr<FUSEInode> m_root_inode;
|
|
NonnullRefPtr<FUSEConnection> m_connection;
|
|
u64 m_rootmode { 0 };
|
|
u64 m_gid { 0 };
|
|
u64 m_uid { 0 };
|
|
};
|
|
|
|
}
|