written 6.0 years ago by |
File system stores several important data structures on the disk:
A boot control block (per volume) can contain information needed by the system to boot an operating system from that volume. If the disk does not contain an operating system, this block can be empty. 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, free block count and free-block pointers, and free FCB count and FCB pointers.
A directory structure per file system is used to organize the files. In UFS, this includes file names and associated inodenumbers. In NTFS it is stored in the master file table.
The in-memory information is used for both file-system management and performance improvement via caching. The data are loaded at mount time and discarded at dismount. The structures may include the ones described below:
An in-memory mount table contains information about each mounted volume.
An in-memory directory-structure cache holds the directory information of recently accessed directories. (For directories at which volumes are mounted, it can contain a pointer to the volume table.)
The operating structures of a file-system implementation are summarized as:
a. To create a new file, an application program calls the logical file system. The logical file system knows the format of the directory structures. To create a new file, it allocates a new FCB.
b. 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.
c. Now that a file has been created, it can be used for I/O. First, though, it must be opened. The open() call passes a file name to the file system. If it is, a per-process open-file table entry is created pointing to the existing system-wide open-file table.
d. When a file is opened, the directory structure is searched for the given file name. Parts of the directory structure are usually cached in memory to speed directory operations. Once the file is found, the FCB is copied into a system-wide open-file table in memory.
Figure 4: File System Implementation
e. Consequently, as long as the file is not closed, all file operations are done on the open-file table.When a process closes the file, the per-process table entry is removed, and the system-wide entry's open count is decremented.
f. 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.
g. Some systems complicate this scheme further by using the file system as an interface to other system aspects, such as networking. For example, in UFS, the system-wide open-file table holds the inodes and other information for files and directories. It also holds similar information for network connections and devices.