Crosslinked files -- what causes them?

Just to make it clear:

DOS and Windows up to Windows 2000 use a file system called FAT (File Allocation Table). A pretty simple and decent file system.

PROBLEM IS, the heart of it is the FAT. When this was first invented, the OS was written so that the “live” copy of the FAT was kept in memory and only written back to disk when a file was written or closed.

If the OS crashed before the in-memory FAT was sync’ed with the disk FAT, the disk FAT could end up with entries for free space that really pointed to data, or entries for data that really pointed to free space, and so forth. Multiple crashes put the disk FAT more and more out-of-sync with the in-memory FAT. The inevitable result was cross-linked files and lost data.

Now back when I was a boy and we coded in Windows 3.1 SDK in C (by candlelight), we put a chkdsk command in for each drive as part of AUTOEXEC.BAT. That way, every time you had to reboot, you had your disk checked. It was a Norton Utilities program first, BTW. DOS didn’t have one until 6.2 (as I remember).

Nowadays, Windows 2000 and Win XP have a different file system called NTFS. I don’t know much about NTFS, but my experience is that it avoids most sync problems. May even use a file control table that’s always on disk. I know that you can screw up XP so badly that it automatically runs a checkdisk when you reboot, but this is rare.

Last time I looked, UNIX file systems had this same problem, which is why you do NOT want to turn the power off on a UNIX box without doing a bunch of stuff first. The problem with cross-linking is much less likely to happen, because 1) it’s very hard to crash UNIX and 2) you hardly ever have to reboot it.

We all know that even XP has to be rebooted after a system change. So, with luck you’re talking once every couple of weeks. A fairly stable UNIX system can run for months without a reboot.