A file control block (FCB), also called a file descriptor, is a type of data structure that is temporarily allocated by a computer operating system to maintain the status of a data file that is being created or otherwise manipulated. In most instances, a file control block is used to store basic information about a file, such as its name, extension and location on a logical drive, as well as dynamic information such as the current address within the file that is being read. Originally, a file control block was a very well-defined structure under certain operating systems, but it since has become a more generic term for the structure used to track information about an actively handled file.
One important purpose of a file control block is to help the file system keep track of what state the file is in to prevent different operations from attempting to modify the file in conflicting ways, such as reading from an area of the file that is currently being written to. The structure not only is used for data files, but also can be used to track information about directories, although the data structure usually is shortened to remove unnecessary fields, because a directory cannot contain data.
Two operating systems, specifically the Microsoft Disk Operating System (MS-DOS) and the Control Program for Microprocessors (CP/M), were the first operating systems to use a block scheme to manage files. These systems used very similar structures to help manage files that were being accessed. As other operating systems and file systems were developed, the concept of a block remained, but the implementation changed and the data structure varied greatly from one system to the next. Most computer operating systems in use in 2011 use some form of a file control block, especially when using custom file systems for removable hardware, although the data structure that is employed is not compatible with earlier versions without emulation and generally is larger and hidden from most high-level programming applications.
Broadly, a file control block contains information that can be changed during the use of a file by the operating system. Aside from the name and location, memory pointers to different points within the file itself are maintained. This allows sequential reading and writing, as well as random access reading and writing when paired with a variable in the FCB that stores the size of a random access record. File permissions, such as read-only or executable status, also are tracked. The use of a FCB also provides a mechanism to prevent two or more processes from operating on the same file in an unpredictable way, such as attempting to append information to the end of a file while that same file is being copied to another location.