News for hackers. Stuff that matters.
Re:A brief history of APFS (Apple File System) in honour of ... by Someone on Tuesday March 28, 2023 @04:16AM (#35337373)
“Bags of bytes” has its own problems. If the idea of ‘character encoding’ is alien to the file system, the application layer cannot reliably show file names to users, other than as sequence of byte values. It cannot even assume 0x41 is an ‘A’, for example.

Historically, you configured your OS to match (what you thought was) the encoding used on your disk, but that starts to break when you have network disks or when users exchange floppies.

In practice, I think about every Unix/Linux file system at least assumes ASCII encoding for the printable ASCII range. How else does, for example, your shell find “ls” on your disk when you type those characters?

So, not even in Unix/Linux is a file name “a bag of bytes”

I think file systems should enforce an encoding, and provide a way for users of the file system to find out what it is.

Apple’s HFS, for example, stored explicit ‘code page’ ID so that the Finder knew, for example, to use the Apple Cyrillic encoding to interpret the bytes describing file names on disk for that disk.

The modern way is to just say file names are valid Unicode strings, with UTF-8 being the popular choice. Unfortunately that introduces the normalization problem.

Re:A brief history of APFS (Apple File System) in honour of ... by gpderetta on Tuesday March 28, 2023 @05:50AM (#35338114)
> the application layer cannot reliably show file names to users, other than as sequence of byte values.

As you say, it can just show the sequence of bytes (plus some visual hints that they are escaped). It is not like nonsensical filenames with seem composed of random numbers are uncommon (e.g. look into your .git dir)

> How else does, for example, your shell find “ls” on your disk when you type those characters?

This is purely a presentation layer issue. The filesystem assumes nothing.

Re:A brief history of APFS (Apple File System) in honour of ... by klausa on Tuesday March 28, 2023 @06:34AM (#35338493)
The git files aren't supposed to be seen by a human being.

What you're suggesting would mean that a Korean user saving a file on their desktop and naming it in Korean would in turn see the filename turn into garbage, which, I hope we can all agree, is not a reasonable suggestion.

Re:A brief history of APFS (Apple File System) in honour of ... by gpderetta on Tuesday March 28, 2023 @06:41AM (#35338563)
Of course if the file-name is correctly decodeable in the user preferred encoding (hopefully UTF-8) it should be shown as such. But giving up on supposedly malformed filenames shouldn't be an option for robust software.
Re:A brief history of APFS (Apple File System) in honour of ... by CorrectHorseBat on Tuesday March 28, 2023 @06:52AM (#35338655)
Why though? What do you lose by forcing utf-8 at the filesystem level?
Re:A brief history of APFS (Apple File System) in honour of ... by gpderetta on Tuesday March 28, 2023 @07:17AM (#35338844)
Compatibility with a few decades of data and with other systems.
Re:A brief history of APFS (Apple File System) in honour of ... by eviks on Tuesday March 28, 2023 @12:15PM (#35343432)
But the future is longer than a few decades, so why extend the mistake further?
Re:A brief history of APFS (Apple File System) in honour of ... by sacnoradhq on Tuesday March 28, 2023 @08:22PM (#35350183)
Because change costs way more to than you think: maybe billions of dollars and impacting billions of users.

Creating 2 different systems carries risks: it has a learning curve, a support cost, and breaks everything that came before.

Perhaps, in a utopian green field, we redo a systems language, a portable systems API, and a common operating system with a compatibility layer to the old way on top.

Re:A brief history of APFS (Apple File System) in honour of ... by eviks on Wednesday March 29, 2023 @12:18AM (#35352472)
Change has already partially happened since there is no one single filesystem with one behavior.

Not changing impacts many more users (all the future billions) and costs even more: the learning/support/etc. is all there, and it's harder to learn about a buggy system since you have more papercuts

Also, it doesn't break everything, we're not living in a dystopia

Re:A brief history of APFS (Apple File System) in honour of ... by actionfromafar on Wednesday March 29, 2023 @04:59AM (#35354430)
This is all true. We should also fix global warming, it's the same kind of problem. Massive investments now or even more massive losses tomorrow.
Re:A brief history of APFS (Apple File System) in honour of ... by gpderetta on Wednesday March 29, 2023 @04:43AM (#35354316)
1) Not everybody, or even a majority, agrees that the current state is a mistake

2) Change what to what? There are multiple filesystems systems (and OSs) with different and sometimes incompatible filename encodings. Who picks the winner?

3) There is irony on dropping backward compat and requiring UTF-8, an econding whose claim to fame is backward compatibility with ASCII based systems (and not coincidentally was designed by UNIX Elder Ones)

Re:A brief history of APFS (Apple File System) in honour of ... by eviks on Wednesday March 29, 2023 @11:58AM (#35359091)
I was responding to your specific argument ignoring the bigger future for the smaller past, not sure how the broader questions about what others think etc is relevant

1) so? That will be true for anything

2) sequence of bytes to human encoding. Who picked the loser??? This would similarly be some unidentifiable group of people. You can start by picking the winner for yourself, even at a conceptual level

3) no irony, sequence of bytes is not ASCII

Re:A brief history of APFS (Apple File System) in honour of ... by sacnoradhq on Tuesday March 28, 2023 @08:16PM (#35350124)
Are you running EBCDIC or a localization other than UTF-8 anywhere?

The filesystem shouldn't arbitrate localization issues. It's the wrong place to do it in terms of performance, area-of-responsibility, and portability.

NUL-terminated UTF-8 in memory and size+data on disk is the best encoding.

Normalization is a multifaceted problem that needs to be handled at or before where the filename argument hits the standard library. Sometimes, normalization is NOT desirable and it is preferrable to normalize for comparison only to other strings and to faithfully store whatever was provided verbatim.

Side-effects and doing 737 MAX MCAS underneath users is the road to ruin.