FAT File System Errors
As a result of how the FAT file system allocates space and chains file together, there are several common types of errors that can crop up over time. Note that I am talking here about errors in the logical structure of the disk, not physical disk errors, bad sectors, etc. Most of these errors can be detected by using a standard disk error-checking program that analyzes the file system's integrity, such as Microsoft's SCANDISK or Norton's Disk Doctor (NDD). In fact, I highly recommend that every hard disk volume be scanned for routine file system problems on a daily basis.
File system errors are occasionally the result of corruption on the disk that can have at its root a real hardware problem. These errors can therefore result from any system problem that can cause disk corruption, such as resource conflicts, bad drivers, etc. Far more often, however, file system problems occur as a result of a software problem. Program crashes, for example, often leave around clusters that had space allocated to them but not assigned to a file.
A power failure on a PC running Windows will often result in one or more file system errors due to files not being closed properly. This is why you are always supposed to exit Windows before shutting down a PC. It is also why the newest version of Windows 95 (OEM SR2) automatically scans the disk for errors when it starts, if it detects that Windows ended without doing a proper file system shutdown.
The following are the most common errors encountered on a FAT disk:
- Lost Clusters: Virtually every DOS user has come across this problem. Lost
clusters are simply clusters that are marked in the FAT as being in use, but that the
system cannot link to any file. Every file consists of a
series of clusters that can be traced by starting with the directory entry and
following the linked list of clusters to the end of the file. Disk checking programs can
check an entire disk volume for lost clusters using the following procedure (or something
similar to it). First, create a copy in memory of the FAT, noting all of the clusters
marked as in use. Starting at the root directory, trace through the clusters used by each
file and mark them as "accounted for", since they have been seen to be connected
to a file. Then do the same for all the subdirectories of the root directory, and then their
subdirectories, and so on. When finished, every cluster that is marked in the FAT as in
use should be accounted for. Any that are in use but not accounted for are
"orphans" that don't belong to any file.
Lost clusters are usually the result of interrupted file activity of some sort. The program that detects them will usually give you the choice of clearing them (marking them as "available" and returning them to the pool of free clusters) or saving them as a file. In the latter case, the program generates a file name and links the lost clusters to that name, so that a real file is formed. Usually this file will then be corrupted or damaged in some way, but you can often at least see what this orphaned data was and in some cases, recover it. - Cross-Linked Files: On rare occasions, two files can end up pointing to the same data on the disk. Both files will have the starting cluster number in the directory entry pointing to the same cluster number. Obviously this is a problem, since each time you use either file, you will overwrite the other one. The only solution to this problem is to make new copies of each of the affected files. You will generally lose the contents of one or the other of the files (in fact, by the time you discover this problem, you have already lost the contents of one of them, since no sector can contain information from two files at the same time).
- Invalid Files or Directories: Very rarely, the internal structures of file or directories can become damaged so that some entries are no longer following the "rules" for how a file or directory is supposed to be laid out. An example would be a directory that doesn't have a pointer to its parent directory, or a file that has an invalid start cluster. Sometimes files get assigned an invalid date or time by a buggy piece of software. These problems can usually be fixed by the disk scanning software.
- Allocation or FAT Errors: Occasionally the entries in the FAT can become corrupted or set to invalid values. Again, most disk-checking utilities will detect and correct these sorts of problems on the fly.