tuxera / ntfs-3g

NTFS-3G Safe Read/Write NTFS Driver
https://www.tuxera.com/company/open-source
GNU General Public License v2.0
994 stars 149 forks source link

Directory entries ordering #64

Closed CromFr closed 2 years ago

CromFr commented 2 years ago

Is there a solution for guarantying directory entries are always alphabetically ordered, or is there a tool for reordering entries alphabetically?

Some context

I'm running an application (closed source blob) that displays a list of files without reordering them, relying on the filesystem for providing an alphabetically-sorted list. On Windows, I never witnessed any unordered dir entries for my specific use case (most folders contains <100 entries), but I guess it is technically possible. On Linux with ntfs-3g it happens very often (ls -lU shows some unsorted files near the end of the list). I'm looking for a filesystem option to enforce alphabetical ordering (I didn't find any in the man pages), or a tool that could be executed regularly to reorder existing files on the filesystem.

jpandre commented 2 years ago

Is there a solution for guarantying directory entries are always alphabetically ordered, Assuming this is about the ordering of entries returned by readdir(3), Posix does not specify the ordering and the file system is allowed to be efficiency-driven. ntfs-3g simply returns the successive records containing its btrees. https://pubs.opengroup.org/onlinepubs/9699919799/functions/readdir.html I'm looking for a filesystem option to enforce alphabetical ordering readdir(3) has no argument to request a specific ordering, you have to sort the entries in your own code. Windows may behave differently, it is not Posix compliant. a tool that could be executed regularly to reorder existing files on the filesystem Applications have no control over the internal structure of directories (ntfs uses btrees).

CromFr commented 2 years ago

Thank you very much for your response ! This confirms what I feared when reading ntfs docs and ntfs-3g code.