Learning outcomes
- Explain what files are, list common file attributes and operations.
A file system is the part of the operating system that provides a convenient and organized way to store, retrieve, manage, protect, and share data. It hides the complexity of physical storage devices and presents data to the user and programs in the form of files and directories.
A file is a named collection of related information stored on secondary storage. The file system allows users and programs to treat stored data as organized units rather than as raw disk blocks.
A file may contain text, numbers, executable code, images, audio, video, or structured records. In practice, a file is one of the most basic abstractions provided by the operating system.
A file has not only contents but also metadata, that is, information about the file itself.
| Attribute | Meaning |
|---|---|
| Name | Human-readable file identifier |
| Type | Text, binary, executable, directory, etc. |
| Location | Pointers to data blocks on storage |
| Size | Current file length |
| Owner / Group | Who owns the file |
| Protection | Read, write, execute permissions / ACLs |
| Timestamps | Create, access, and modification dates |
The text’s file-control block example explicitly includes items such as file permissions, file dates, owner/group/ACL, file size, and block pointers. :contentReference[oaicite:2]{index=2}
A file system typically supports operations such as:
The OS text notes that repositioning is also known as file seek, and that many systems maintain an open-file table so repeated directory searching is avoided once a file is opened. :contentReference[oaicite:3]{index=3}
File organization refers to how the contents of a file are logically arranged. Two common ways to view file organization are:
Modern systems such as UNIX usually treat files as byte streams, leaving interpretation to applications.
The access method defines how data is read from or written to a file.
| Access Method | Meaning | Typical Use |
|---|---|---|
| Sequential Access | Records or bytes are processed in order, one after another. | Text files, logs, media streams |
| Direct / Random Access | Any block or record can be accessed directly without reading all previous data. | Databases, indexed files |
| Indexed Access | An index is used to locate records quickly. | Large structured datasets |
A text editor reading a text file line by line uses sequential access.
A database jumping directly to record number 5000 uses direct access.
In random access, the current file-position pointer may be moved to a new location. This is called seek or repositioning. The OS text notes that seek often does not require actual I/O, since it may simply change a pointer. :contentReference[oaicite:4]{index=4}
A directory is a special structure that stores information about files. It provides a way to organize files and locate them by name.
Some operating systems treat a directory as a special kind of file, while others treat it as a separate structure. The OS text explicitly notes that UNIX treats a directory like a file with a special type field, while some systems like Windows treat directories separately. :contentReference[oaicite:5]{index=5}
| Directory Structure | Idea | Strength | Weakness |
|---|---|---|---|
| Single-Level Directory | All files are stored in one directory. | Very simple | Name conflicts, poor organization |
| Two-Level Directory | Each user has a separate directory. | Reduces name conflicts | Limited sharing |
| Tree-Structured Directory | Directories can contain subdirectories. | Good organization and hierarchy | More complex traversal |
| Acyclic Graph Directory | Shared files / subdirectories allowed but cycles avoided. | Supports sharing | Needs reference management |
File sharing means that more than one user or process may access the same file. This is important in multiuser systems, networked systems, and collaborative environments.
The text discusses remote file systems in the client–server model, where a server exports files and a client accesses them over the network. :contentReference[oaicite:6]{index=6}
| Issue | Meaning |
|---|---|
| Concurrency | Two users may try to update the same file simultaneously. |
| Consistency | All users should see valid and predictable file contents. |
| Locking | Used to control simultaneous access. |
| Authentication | Remote sharing must ensure that only authorized users or clients get access. |
In a shared office document, if one user is editing while another is reading, the system must manage permissions, consistency, and possibly file locking.
Internally, the file system must map logical files to physical disk blocks. It must also keep metadata such as file size, block addresses, ownership, permissions, and open-file information.
Each file is represented internally by a control structure, often called a File Control Block (FCB) or inode in UNIX-like systems. The FCB stores the metadata needed to manage the file.
The text explains that once a file is opened, its information is copied into a system-wide open-file table, and a per-process table entry points to that information. This avoids repeated searching of the directory. :contentReference[oaicite:7]{index=7}
| Structure | Purpose |
|---|---|
| System-wide open-file table | Stores FCB-related information and tracks how many processes have the file open. |
| Per-process open-file table | Stores process-specific information such as current file pointer and access mode. |
File allocation defines how file blocks are placed on disk.
| Allocation Method | Main Idea | Strength | Weakness |
|---|---|---|---|
| Contiguous Allocation | File occupies consecutive disk blocks. | Fast sequential and direct access | External fragmentation, hard file growth |
| Linked Allocation | Each block points to the next block. | No external fragmentation | Poor direct access, pointer overhead |
| Indexed Allocation | Index block stores pointers to all file blocks. | Supports direct access well | Index overhead |
The file system must track which disk blocks are free and which are allocated. Common techniques include:
In modern systems, a Virtual File System (VFS) layer provides a common interface for different file systems. The text explains that VFS can call the appropriate function for a file object without needing to know whether it is a local file, directory file, or remote file. :contentReference[oaicite:8]{index=8}
A multiuser operating system must ensure that one user cannot access, modify, or delete another user’s files without permission. Therefore, the file system must provide protection and security.
| Mechanism | Meaning |
|---|---|
| Permissions | Read, write, execute rights for owner, group, others |
| Access Control List (ACL) | More detailed list of users / groups and allowed operations |
| Password / Authentication | Ensures only authorized users log in |
| File locking | Controls simultaneous access to shared files |
| Backup and recovery | Helps restore data after failure or attack |
The text notes that remote file-sharing security involves authentication problems, including client identification and possible spoofing, and that stronger security may require encrypted keys and secure authentication methods. :contentReference[oaicite:9]{index=9}
| Topic | Main idea | What to remember |
|---|---|---|
| File concept | Named logical unit of related data | Files have contents and metadata |
| Access methods | Ways to read/write file data | Sequential, direct, indexed |
| Directories | Structures used to organize and locate files | Single-level, two-level, tree, graph |
| File sharing | Multiple users/processes access the same file | Needs locking, consistency, protection |
| Implementation | Maps logical files to physical storage | FCB, open-file table, allocation methods, free-space management |
| Protection & security | Restrict access and defend files | Permissions, ACLs, authentication, backup |
A file is a named logical collection of related information stored on secondary storage. File attributes include name, size, owner, permissions, timestamps, and block pointers.
Access methods define how file data is processed. Common methods are sequential access, direct access, and indexed access.
Directories organize files and support file naming, searching, listing, and hierarchical storage. Tree-structured directories are widely used because they provide logical organization.
File sharing allows multiple users or processes to access the same file, but it introduces issues such as consistency, locking, and protection.
File-system implementation uses structures such as file-control blocks, open-file tables, allocation methods, and free-space management to map logical files to physical disk blocks.
Protection and security ensure that files are accessed only by authorized users and are protected against accidental damage and malicious attacks.