`readdir` on APFS is not sorted.
Originator: | me | ||
Number: | rdar://32799008 | Date Originated: | June 15 2017 |
Status: | closed | Resolved: | June 20 2017 |
Product: | macOS | Product Version: | 10.13.0 Developer Preview 1 |
Classification: | Reproducible: | always |
Summary: On APFS, `readdir` does not read a directory in sorted order as it does on HFS+. Steps to Reproduce: In the attachment you will find a small C program along with a Makefile. If you run `make run` it will do the following: 1. Create a directory called `dir` with two sub-directories - `0001.dir` - `0002.dir` and two sub-files - `0003.file` - `0004.file` 2. Run the compiled C program, which lists the contents of `dir` using `readdir`. Expected Results: `make run` should output: ``` mkdir -p dir/0001.dir mkdir -p dir/0002.dir touch dir/0003.file touch dir/0004.file ./dir_entries dir . .. 0001.dir 0002.dir 0003.file 0004.file ``` Observed Results: `make run` outputs the expected result on HFS+. On APFS, however, it outputs: ``` mkdir -p dir/0001.dir mkdir -p dir/0002.dir touch dir/0003.file touch dir/0004.file ./dir_entries dir . .. 0004.file 0002.dir 0001.dir 0003.file ``` Attachments: https://gist.github.com/reitermarkus/cff07a18669ad46be6b9b2faf9f8f9cb
Comments
Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!
Resolved by:
“This is behaves correctly. APFS does not sort lexicographically.”