diff --git a/kernel/config.cmake.template b/kernel/config.cmake.template index c3de68f7..8efb8a9c 100644 --- a/kernel/config.cmake.template +++ b/kernel/config.cmake.template @@ -10,3 +10,8 @@ # Example: Adding a compiler flag. This will optimize the kernel aggressively (warning: untested, use at your own discretion). # target_compile_options(moon PRIVATE -O3) + +# Uncomment the line below to allow any filename on file/directory creation (by default, the kernel prohibits filenames with +# control characters, leading/trailing spaces, problematic characters and invalid UTF-8). Keep in mind that this restriction +# is only enforced when creating files; existing files with such illegal filenames are parsed correctly and fully usable. +# target_compile_definitions(moon PRIVATE MOON_DISABLE_FILENAME_RESTRICTIONS) diff --git a/kernel/src/fs/VFS.cpp b/kernel/src/fs/VFS.cpp index 340eefdd..3d164733 100644 --- a/kernel/src/fs/VFS.cpp +++ b/kernel/src/fs/VFS.cpp @@ -101,6 +101,10 @@ namespace VFS Result validate_filename(StringView name) { +#ifdef MOON_DISABLE_FILENAME_RESTRICTIONS + return {}; +#endif + // Forbid problematic characters that could cause trouble in shell scripts and the like. if (strpbrk(name.chars(), "*?:[]\"<>\\")) return err(EINVAL);