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. A FCB is managed by the operating system, but it resides in the memory of the program that uses the file, not in operating system memory. This allows a process to have as many files open at one time as it wants, provided it can spare enough memory for an FCB per file.
This article has multiple issues. Please help improve it or discuss these issues on the talk page. (Learn how and when to remove these template messages)
|
The FCB originates from CP/M and is also present in most variants of DOS, though only as a backwards compatibility measure in MS-DOS versions 2.0 and later. A full FCB is 36 bytes long; in early versions of CP/M, it was 33 bytes. This fixed size, which could not be increased without breaking application compatibility, led to the FCB's eventual demise as the standard method of accessing files.
The meanings of several of the fields in the FCB differ between CP/M and DOS, and also depending on what operation is being performed. The following fields have consistent meanings:[1]
Offset | Byte size | Contents |
---|---|---|
0x00 | 1 | Drive number — 0 for default, 1 for A:, 2 for B:, ... |
0x01 | 8 | File name and extension — together these form a 8.3 file name. |
0x09 | 3 | |
0x0C | 20 | Implementation dependent — should be initialised to zero before the FCB is opened. |
0x20 | 1 | Record number in the current section of the file — used when performing sequential access. |
0x21 | 3 | Record number to use when performing random access. |
The 20-byte-long field starting at offset 0x0C contained fields which (among others) provided further information about the file:[2]
Offset | Byte size | Contents |
---|---|---|
0x0E | 2 | File's record length in bytes. |
0x10 | 4 | Total file size in bytes. |
0x14 | 2 | Date of last modification to file contents. |
0x16 | 2 | Time of last modification. |
Further values were used by newer versions of DOS until new information could no longer fit in these 20 bytes. Some preceding "negative offset" bytes were squeezed from reserved spaces in CP/M Zero Page and DOS Program Segment Prefix for storing file attributes.[1]