File control block
From Wikipedia, the free encyclopedia
A File Control Block (FCB) is a file system structure in which the state of an open file is maintained. The FCB originates from CP/M and is also present in all versions of MS-DOS. A full FCB is 36 bytes long; in early versions of CP/M, it was 33 bytes.
The meanings of several of the fields in the FCB differ between CP/M and MS-DOS, and also depending on what operation is being performed. The following fields have consistent meanings:
Offset | Size | Contents |
---|---|---|
00 | Byte | Drive number — 0 for default, 1 for A:, 2 for B:,... |
01 | 8 bytes | File name and file type — together these form a 8.3 file name |
09 | 3 bytes | |
0C | 20 bytes | Implementation dependent — should be initialised to zero before the FCB is opened. |
20 | 1 byte | Record number in the current section of the file — used when performing sequential access. |
21 | 3 bytes | Record number to use when performing random access. |
[edit] Usage
In CP/M and MS-DOS 1 (which did not include support for directories), the FCB was the only method of accessing files. When directories were introduced in MS-DOS 2, FCBs were superseded by file handles.
FCBs were supported in all versions of MS-DOS and Windows until the introduction of the FAT32 filesystem. Windows 95, Windows 98 and Windows Me do not support the use of FCBs on FAT32 drives, except to read the volume label. This caused some old DOS applications, including Wordstar, to fail under these versions of Windows. Under versions based on Windows NT, FCBs work correctly whatever underlying filesystem is in use.
The FCB interface does not work properly on Windows NT, 2000, etc either - WordStar does not function properly on these operating systems. The emulator DOSEMU implements the FCB interface properly, and is one way to run older programs.