FAT File System

As mentioned earlier, the FAT file system is named for its method of organization—the file allocation table. This table of values provides links from one allocation unit (one or more sectors) to another, as shown in Figure 5.1.

Figure 5.1 File Allocation Table

This illustration includes three files. The file named FILE1.TXT is a file that is large enough to take the space of three allocation units. A small file, FILE3.TXT, takes space in only one allocation unit. The third file, FILE2.TXT, is a large, fragmented file. In each case, the directory entry points to the first allocation unit containing the file. If the file contents go beyond one allocation unit, the first allocation unit points to the next in the chain. FFF indicates the end of the chain.

The FAT file system is a simple file system originally designed for small disks and simple directory structures. Its design has been improved over the years to work more effectively with larger disks and more powerful personal computers. With MS-DOS version 4.0, the FAT entries grew from 12 bits to 16 bits in size, thus allowing for partitions larger than 32 MB.

Figure 5.2 illustrates how the FAT file system organizes the disk.

Figure 5.2 FAT Disk Partition (Volume)

The root directory has a fixed size and location on the disk. Directories are special files with 32-byte entries for each file contained in that directory. The entry for each file includes the following information:

This information is used by all operating systems that support the FAT file system. In addition, Windows NT can store additional time stamps in a FAT directory entry. These time stamps show when the file was created or last accessed and are used principally by POSIX applications.

Bits in the attribute byte of the directory entry of a file indicate whether the file has certain attributes. One bit indicates that the file is a subdirectory, while another bit marks the file as a volume label. Normally, only the operating system controls the settings of these bits. In addition, a FAT files has four special attributes that can be turned on or off by the user — archive file, system file, hidden file, and read-only file.

Windows NT versions 3.5 and later use these attribute bits to support long filenames up to 256 characters on FAT partitions in a way that does not interfere with how MS-DOS or OS/2 access the partition. Whenever a user creates a file with a long filename (that is, a filename that exceeds the eight-plus-three limits of the FAT file system on MS-DOS and OS/2 or that contains extended or mixed-case characters), Windows NT creates a conventional directory entry for the file, supplying an eight-plus-three name in the same manner as for a file on an NTFS volume. (For information about how Windows NT creates the short filename, see "Generating Short Filenames" later in this chapter.) In addition to this conventional entry, Windows NT creates one or more secondary directory entries for the file, one for each 13 characters in the long filename. Each of these secondary directory entries stores a corresponding part of the long filename in Unicode. Windows NT sets the volume, read-only, system, and hidden file attribute bits of the secondary directory entry to mark it as part of a long filename. MS-DOS and OS/2 generally ignore directory entries with all four of these attribute bits set, so these entries are effectively invisible to these operating systems. Instead, MS-DOS and OS/2 access the file using the eight-plus-three filename contained in the conventional directory entry for the file.

Some third-party disk utilities that directly manipulate the FAT might regard the long-filename directory entries created by Windows NT as errors in the logical structure of the disk volume and so may damage the directory entries or even the file itself trying to correct the error. Do not use a third-party disk utility to repair or defragment a FAT partition used by Windows NT unless the disk utility has been certified as being compatible with Windows NT version 3.5 or later. You can, safely use the Scandisk and Chkdsk utilities supplied with MS-DOS version 6.0 and later to repair a damaged FAT partition, but do not use the Defrag utility to defragment a FAT partition containing long filenames because it tends to discard long filename information.

By default, Windows NT 3.5 supports long filenames on FAT partitions. If you want to be able to use third-party disk utilities to repair or defragment FAT partitions used by Windows NT, set the Win31FileSystem parameter of the following Registry entry to 1:


HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\FileSystem

Setting this value will prevent Windows NT from creating new long filenames on all FAT partitions; it does not affect existing long filenames. See Chapter 10, "Overview of the Windows NT Registry," and Chapter 11, "Registry Editor and Registry Administration," for information about adding and changing entries in the Registry.