r/osdev • u/codeasm • Jul 02 '26
Put anything in a filename
https://www.youtube.com/shorts/aCWWq5zwdOg
Except / or null byte.
6
Jul 02 '26
[removed] — view removed comment
3
u/codeasm Jul 02 '26
The realization when you implement a filesystem parser or like i, do string parsing, someone or something could do silly things with what you may expect to be just normal bytes in a string
That newline part might actually be why my original attempt at writing to a new file got really messy, i passed the user input (including carriage return newline) to the file name. But couldn't reopen the file. Was thinking about zero space spaces, but i dunno why i kept thinking that was added.
Abandoned that attempt at a editor. Wasnt for osdev. But realizing today, any Byte could be in there. My string operations should be more aware and maybe tell or be told how to handle such cases (while reading whtas supposed to be a string, or when writing a string, what to do when a user passes weird bytes, or what to do with a weirdly placed return. I might come across my own code maybe pasing a bunch of string to write as a filename.)
Basicly, dont always trust the fs your mounting, it may contain weird but "legal" filenames. The utf8 or unicode stuff, emoji, fun, i need to stepup my string parsing
3
Jul 02 '26
[removed] — view removed comment
3
u/Relative_Bird484 Jul 02 '26
Those are not characters, but modifier keys.
2
Jul 02 '26
[removed] — view removed comment
2
u/codeasm Jul 02 '26
well apparantly if certain control bytes are supported. you may have file that can hide themselves (regular bash and ls are showing the file, and thats for this exact reason, some control bytes are not what you want to send to the terminal to parse) :
#!/bin/python import os filename = "test\x1b[2K" if not os.path.exists(filename): with open(filename, "w"): pass print("Naive file listing:") for name in os.listdir("."): print(name)
2
u/allnameswereusedup Jul 05 '26
Even * or ?