3 ms·
I wonder what's the point to support newlines as a valid character in file names. And, for that matter, any other ASCII characters in the 0x00..0x1f range. Of
by nine_k 2y ago
I wonder what's the point to support newlines as a valid character in file names. And, for that matter, any other ASCII characters in the 0x00..0x1f range.
Of course, file names are not characters but bytes, and this allows filesystems to transparently support various filename encodings, which are handled by locale, not by filesystem. On the other hand, there are few practical encodings that involve bytes that are control characters in ASCII. Obviously not UTF-8, not 8-bit stuff like ISO-8859-*, nor the widespread Japanese, Korean, or Chinese encodings, as much as I'm aware. UCS2 filenames would be impossible though, but I suspect nobody uses UCS2 as a locale in practice (even ironically).
I think adding a mount flag that would disallow non-printable ASCII bytes in filenames could improve security, and is also really trivial to implement. I cannot be the first person to suggest it. I wonder why it was never implemented.
- userbinator 2y agoI wonder what's the point to support newlines as a valid character in file names. And, for that matter, any other ASCII characters in the 0x00..0x1f range. 0 is reserved for the terminator so you can't have a null byte, but I think instead of looking at this from the perspective of "what's the point to support", you should think of it as "why add additional code just for restriction, when we can consider that an upper-layer concern". The same goes for case sensitivity --- it makes the FS code in the kernel more generic and simpler. Contrast this with the other extreme, filesystems that have to effectively implement a subset of Unicode because they're case-insensitive beyond ASCII. Even Apple abandoned that idea over time: https://news.ycombinator.com/item?id=13953800 https://news.ycombinator.com/item?id=13953800
- coldtea 2y ago>you should think of it as "why add additional code just for restriction, when we can consider that an upper-layer concern". Because that way you solve the problem at the root? Of course that's not the "not my problem" Jersey-style approach. But tons of our current problems are because of that Jersey-style approach.
- coldtea 2y ago>Of course, file names are not characters but bytes Depends on the filesystem. Some expect them to be characters.