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.
27 lines
489 B
C
27 lines
489 B
C
/*
|
|
* Copyright (c) 2022-2023, Liav A. <liavalb@hotmail.co.il>
|
|
*
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <AK/Types.h>
|
|
|
|
#define MOUNT_SPECIFIC_FLAG_KEY_STRING_MAX_LENGTH 64
|
|
|
|
struct MountSpecificFlag {
|
|
u32 key_string_length;
|
|
u32 value_length;
|
|
|
|
enum class ValueType : u32 {
|
|
Boolean = 0,
|
|
UnsignedInteger,
|
|
SignedInteger,
|
|
};
|
|
|
|
ValueType value_type;
|
|
unsigned char const* key_string_addr;
|
|
void const* value_addr;
|
|
};
|