OT: Sort directory *entries*

I'm going to assume the capabilities of "fatsort" are strictly "vanilla"; i.e., you can't force the order to be but, rather, whatever the fatsort developer(s) decided were appropriate!

For example, no way to ensure the proper location of IBMBIO.COM in old systems -- if other files having names of AAAA and ZZZZ also existed (?)

Sadly, that is not the case. Windows still uses deferred writes to update removable media. You can minimize your exposure to "self-foot-shooting" by using FATxx formatted filesystems on those media (it appears that Windows flushes these quicker than NTFS formatted removable media??) but there is still a window of vulnerability -- "must LOOK like we're being quick about it -- even when we aren't!"

Actually, I think "sync; sync" is required as sync(2) can return before buffers are completely flushed (even double sync isn't "guaranteed" in light of soft updates -- unless you "tune the fish"! :> )

Reply to
Don Y
Loading thread data ...

At least on Win XP NTFS and later DIR is treated as DIR /ON, so the files are sorted by file name. Try DIR/O-N which should disable any sort activity.

Reply to
upsidedown

No. -N says "sort in reverse order by name" -- like "ls -r".

All bets are off unless you are dealing with a FATxx filesystem. Furthermore, even there, you have no guarantee that the next creat() won't bugger the file order (e.g., if there is an open directory slot anywhere *before* the last entry that the new object can then occupy)

Reply to
Don Y

yeah it seems fairly limited in capability, however you could specify "-I IBMBIO.COM" and hope that the empty string sorts first. probably better to patch it to ignore system files.

--
  \_(?)_
Reply to
Jasen Betts

There is no particular reason to assume this has to be deterministic, or that there is a problem with being random. The VFS and filesystem layers have to be able to handle requests in non-deterministic orders - they don't know what apps may be running, or what they might want to do with files. And with the create requests coming in in non-deterministic ordering, there is no reason to suspect that they should be written to the filesystem itself in a deterministic order (by which I mean determined by the incoming order).

In particular, a high-performance filesystem will re-order the storage or physical orders based on a more complete picture of the overall performance. This may include grouping writes, combining meta-data operations, re-ordering based on access times and disk head position, etc.

Even if the code is entirely deterministic and repeatable for the same set of input parameters (as will usually be the case - /intentional/ randomness is sometimes used in low-level systems, but it is rare), the algorithms can be complex and the input parameters that affect it can include not just the order of incoming requests, but the times between them, timing and ordering information from the disk, the state of caches, and statistics about past behaviour of the processes.

So you are correct that (baring any intentional true random behaviour) the filesystem will react the same way to two identical requests, all other things being equal - it is generally extraordinarily difficult to have all other things being equal. And while the filesystem will normally be fully deterministic, high-performance filesystems are typically very far from being predictable.

So while access to a FAT system on removable media on Windows is intentionally made to be a simple and dumb system, and therefore has reasonably predictable ordering, the same does not apply on Linux, and it does not apply to NTFS on fixed media on Windows.

(An example of intentional randomness is the random hold-off period sometimes used in network communication after collisions. Adding a bit of randomness can also improve the average behaviour of some algorithms by reducing the likelihood of pathological worst cases, such as when running a standard qsort on a sorted list. I have no idea whether this is actually used in real OS's.)

Reply to
David Brown

Why assume something, when it takes seconds to check?

There is no option for manually specifying the order, so you only get the orderings that the authors support, which is usually sufficient for the typical users.

It is open source, and I don't imagine it is a big program - if you want to sort a lot of FAT directories in particular ways, then I expect it is a reasonable place to start for making your own specialised program.

That appears to be correct - unless you can arrange to "cheat" using upper and lower case changes.

I haven't used the program for anything other than sorting files for use on an MP3 player - the typical use-case for the program.

It is impossible to avoid having a window of vulnerability (unless you made USB sticks with transaction processing on the stick, with corresponding costs).

You are right that Windows treats NTFS removable media more like fixed media regarding caching - it is only FAT32 removable media that it is has fast flushing and syncing (since this extra flushing and syncing reduces the performance).

Reply to
David Brown

Hi Don

Sorry, but nope - at least not directly. But programs do exist that for you. Under Linux there's "fatsort" (that works on unmounted filesystems and images). Under Windows it gets more tricky because all volumes "visible" to the system are mounted by default, but there are programs that will unmount a volume, open it for exclusive access, then sort its directory structures and sync the changes.

You can find one here:

formatting link

At least that works on FAT filesystems. NTFS with its tree structure doesn't seem to be sortable in any meaningful way internally.

Dimitrij

Reply to
Dimitrij Klingbeil

You want to sort the entries on the disk itself? It is long ago that people did that...

Or you want to read a directory and pass the entries to a handler in sorted order? That is more usual.

Of course, how to do that depends on the programming or scripting language you are using.

Reply to
Rob

I have been lurking. I am delurking.

You want to arrainge the files in YOUR order. I got the idea. I have an exa mple, in old IE, you favorites. If you never sort them they are in the orde r in which they were created.

Sorting is something else. For example if you put some songs on a CCD in MP

3 format, the order is the order in which you put them. But now make an aud io CD and you do determine the order in which they play and actually I do b elieve how they are put on the disk.

On a harddrive, this all mixed up shit is what it looks for when you defrag . (which is overrated)

Andd I ownder wh this is an issue. Do you think that copying or making a ba ckup will be interrup[ted and you ant the most importasnt (to you) files fi rst ?

Reply to
jurb6006

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.