- The file system must keep track of
- which blocks belong to which files.
- in what order the blocks form the file.
- which blocks are free for allocation.
- On disk, the file system may contain information about how to boot an OS stored there, the total number of blocks, the number and
location of free blocks, the directory structure, and individual files.
- Often the file system will contain some of the items shown in Fig. 11.2.
Figure 11.2:
A possible file system layout.
|
- Sector 0 of the disk is called the MBR (Master Boot Record) and is used to boot the computer. The end of the MBR contains the partition table. This table gives the starting and ending addresses of each partition.
- One of the partitions in the table is marked as active. When the computer is booted, the BIOS reads in and executes the MBR. The first thing the MBR program does is locate the active partition, read in its first block, called the boot block.
- A boot control block (per volume) can contain information needed by the system to boot an OS from that volume. It is typically the first block of a volume. In UFS, it is called the boot block; in NTFS, it is the partition boot sector.
- A volume control block (per volume) contains volume (or partition) details, such as the number of blocks in the partition, size of the blocks, freeblock count and free-block pointers, and free FCB count and FCB pointers. In UFS, this is called a superblock; in NTFS, it is stored in the master file table.
- Next might come information about free blocks in the file system, for example in the form of a bitmap or a list of pointers.
- A directory structure per file system is used to organize the files. In UFS, this includes file names and associated inode numbers. In NTFS it is stored in the master file table.
- After that might come the root directory, which contains the top of the file system tree.
- Finally, the remainder of the disk typically contains all the other directories and files.
- A per-file FCB contains many details about the file, including file permissions, ownership, size, and location of the data blocks. In UFS, this is called the inode. In NTFS, this information is actually stored within the master file table, which uses a relational database structure, with a row per file.
- To create a new file,
- an application program calls the logical file system.
- To create a new file, it allocates a new FCB.
- The system then reads the appropriate directory into memory, updates it with the new file name and FCB, and writes it back to the disk.
- A typical FCB is shown in Fig. 11.3.
Figure 11.3:
A typical file-control block.
|
- Some OSs, including UNIX, treat a directory exactly the same as a file-one with a type field indicating that it is a directory.
- When a process closes the file, the per-process table entry is removed, and the system-wide entry's open count is decremented. When all users that have opened the file close it, any updated metadata is copied back to the disk-based directory structure, and the system-wide open-file table entry is removed.
- The operating structures of a file-system implementation are summarized in Fig. 11.4.
Figure 11.4:
In-memory file-system structures. (a) File open. (b) File read.
|
Cem Ozdogan
2011-02-14