kernel: Make the filename restrictions configurable
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
apio 2023-06-22 20:22:43 +02:00
parent 3d157b760c
commit fdf2bb2501
Signed by: apio
GPG Key ID: B8A7D06E42258954
2 changed files with 9 additions and 0 deletions

View File

@ -10,3 +10,8 @@
# Example: Adding a compiler flag. This will optimize the kernel aggressively (warning: untested, use at your own discretion). # Example: Adding a compiler flag. This will optimize the kernel aggressively (warning: untested, use at your own discretion).
# target_compile_options(moon PRIVATE -O3) # 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)

View File

@ -101,6 +101,10 @@ namespace VFS
Result<void> validate_filename(StringView name) Result<void> validate_filename(StringView name)
{ {
#ifdef MOON_DISABLE_FILENAME_RESTRICTIONS
return {};
#endif
// Forbid problematic characters that could cause trouble in shell scripts and the like. // Forbid problematic characters that could cause trouble in shell scripts and the like.
if (strpbrk(name.chars(), "*?:[]\"<>\\")) return err(EINVAL); if (strpbrk(name.chars(), "*?:[]\"<>\\")) return err(EINVAL);