File Management: File System Concepts, Attributes, Operations, Types & Access Methods
Overview: Sequential access suits reading a log from start to finish.
Concept of a File and File System
- From a user’s perspective, the File System is the most visible part of an Operating System.
- What is a File? A File is a named collection of related information (programs or data) that is recorded on **non-volatile secondary…
- What is a File System? The mechanism and data structures used by the Operating System to control **how data is stored, organized, named, protected,…
File Attributes (File Metadata)
- Every file has a set of properties stored inside the directory structure on disk called File Attributes:
- 1. Name Human-readable symbolic file name (e.g., syllabus.pdf )
- 2. Identifier (Inode) Unique internal number tag that identifies the file inside the OS
- 3. Type Indicates file format (e.g., .txt , .exe , .jpg )
- 4. Location Pointer to the device and exact starting block address on the disk
- 5. Size Current size of the file in bytes, kilobytes, or blocks
- 6. Protection Access control permissions: Who can Read (R), Write (W), or Execute (X)
- Time, Date, and User Identification: Stores timestamps for Creation, Last Modification, and Last Access, along with the Owner ID (crucial for…
View diagram · Figure 5.1: The 7 Standard Attributes of a File in an Operating System
Basic File Operations (6 Standard Operations)
- An Operating System provides System Calls to perform 6 basic operations on any file:
- Creating a File (
create): - Writing a File (
write): - Reading a File (
read): - Repositioning Within a File (
seek): - Deleting a File (
delete): - Truncating a File (
truncate):
File Types, Functions & Types of File Systems
- 1. Executable:
.exe,.com,.bin, none (UNIX) - 2. Source Code:
.c,.cpp,.java,.py,.html - 3. Object File:
.obj,.o,.class - 4. Text / Document:
.txt,.doc,.pdf,.rtf - 5. Archive / Compressed:
.zip,.rar,.tar,.jar - 6. Multimedia:
.mp3,.mp4,.jpg,.png,.mkv - B. Core Functions of a File System: Tracking free and allocated disk blocks (using Bitmaps or Linked Lists).
- Maintaining Directory Structures and mapping file names to physical disk blocks.
File Access Methods (Sequential, Direct & Indexed)
- How does a program read information stored inside a file?
- 1. Sequential Access Method: How It Works: The simplest and most common access method.
- To read Record 50, you must first read or skip through Records 1 to 49!
- Analogy: An old Magnetic Audio Cassette Tape.
- Operations:
read next(reads current record and advances pointer by +1),write next(appends to end of file), andrewind(resets… - Used By: Compilers, Text Editors, Log files.
- 2. Direct Access (or Relative / Random Access) Method: How It Works: A file is viewed as a numbered sequence of fixed-length logical blocks or records (
Block 0, Block 1, Block 2...). - Programs can read or write ANY block rapidly in any arbitrary order!
View diagram · Figure 5.2: The Three File Access Methods in Operating Systems
Directory Structures & File Allocation Methods (Contiguous, Linked, Indexed)
Overview: A directory maps a name to information about a file.
Directory Structure in Operating Systems
- A modern computer hard disk stores ratusan of thousands of files.
- What is a Directory? A Directory can be viewed as a Symbol Table that translates human-readable file names into their corresponding…
- 1. Single-Level Directory: Structure: The simplest directory structure.
- Drawback (Naming Problem & Grouping Problem): Since all files are in one folder, no two files can have the same name (if User A creates
test.c, User B cannot create… - 2. Two-Level Directory: Structure: Solves the naming collision between different users by creating a separate directory for each user!
- At the top sits the MFD (Master File Directory), indexed by Username/Account Number.
- Each MFD entry points to that user’s private UFD (User File Directory).
- Benefit: Two different users can now both have a file named
notes.txt(User1/notes.txtandUser2/notes.txt).
View diagram · Figure 5.3: The 5 Types of Directory Structures in Operating Systems
File Allocation Methods (How Files Are Stored on Disk Blocks)
- A hard disk is divided into thousands of equal-sized physical Disk Blocks (
Block 0, Block 1, Block 2...). - 1. Contiguous Allocation File occupies a continuous sequence of adjacent blocks (e.g., Blocks 10, 11, 12, 13)
- 2. Linked Allocation File blocks are scattered anywhere; each block holds a pointer to the next block (
9 → 16 → 1 → 10) - 3. Indexed Allocation All block pointers of a file are collected together inside one special Index Block !
- Method 1: Contiguous Allocation: How It Works: Each file occupies a set of contiguous (adjacent) blocks on the disk.
- Directory Entry Stores Only 2 Numbers:
- Starting Block Address (
Start = 10) - Length in Blocks (
Length = 4)
View diagram · Figure 5.4: The 3 Disk File Allocation Methods in Operating Systems View diagram · Figure 5.5: How Indexed Allocation Works Using an Index Block
Master Comparison: Contiguous vs Linked vs Indexed Allocation
- 1. Storage Method: Stored in continuous adjacent disk blocks.
- 2. Directory Entry: Stores
Start Block+Length. - 3. Direct (Random) Access?: ✅ Yes (Fastest)
- 4. External Fragmentation?: ❌ Yes (Needs Defragmentation)
- 5. Dynamic File Growth?: Difficult (cannot expand if next block is full).
Disk Management: Disk Structure & Disk Scheduling Algorithms
Overview: If the disk head is near track 50, shortest-seek-time-first may serve nearby requests repeatedly while a distant request waits.
Magnetic Disk Structure & Disk Access Time
- To understand how the OS schedules disk requests, let us first understand the physical geometry of a Hard Disk Drive (HDD):
- Platters Circular magnetic metal disks spinning at 5,400 to 15,000 RPM on a central Spindle
- Sectors Each Track is subdivided into hundreds of pie-slice segments called Sectors (Typically 512 Bytes )
- 3 Components of Disk Access Time (Why We Need Disk Scheduling!): When the OS reads or writes a disk block, the total time taken consists of three parts:
- Seek Time (Largest Delay!):
- Rotational Latency:
- Transfer Time:
- Goal of Disk Scheduling: Since mechanical Seek Time (moving the disk arm across tracks) is by far the slowest part of disk I/O,…
The 5 Disk Scheduling Algorithms in Your Syllabus
- Let us solve all 5 Disk Scheduling Algorithms (
FCFS,SSTF,SCAN,C-SCAN,LOOK) using the **exact same standard textbook… - Common Numerical Problem Setup: A disk has 200 cylinders/tracks numbered from
0to199. - The Read/Write Head is currently at Track
53(moving toward199for SCAN/C-SCAN/LOOK). - Disk Request Queue:
98, 183, 37, 122, 14, 124, 65, 67 - 1. FCFS (First-Come, First-Served) Disk Scheduling: How It Works: The simplest algorithm.
- Head Movement Sequence (Starting at
53): - Formula: 53 → 98 → 183 → 37 → 122 → 14 → 124 → 65 → 67
- Total Head Movement Calculation:
Quick Summary Table of All 5 Disk Scheduling Algorithms
- 1. FCFS: Services requests strictly in arrival order.
- 2. SSTF: Services the closest track to current head position next.
- 3. SCAN (Elevator): Moves in one direction to the end of disk (
199), then reverses. - 4. C-SCAN: Scans to
199, jumps to0, and scans in the same direction again. - 5. LOOK: Like SCAN, but reverses at the last request (
183) instead of hitting199.
Swap Space Management, Disk Reliability (RAID) & Disk Recovery
Overview: Swap space helps the OS move inactive memory contents out of RAM.
Swap-Space Management
- In Unit 4, we learned that Virtual Memory and Swapping move inactive pages or entire processes out of Main Memory (RAM) onto the Hard Disk/SSD.
- Three Key Aspects of Swap-Space Management: Swap space reserves backing storage for memory contents removed from RAM.
- 1. Swap-Space Use: How much swap space does an OS need?
- If swap space runs out completely, the OS may be forced to abort processes or refuse to start new programs.
- 2. Swap-Space Location (Where Does Swap Space Reside on Disk?): Swap space can be created in two places:
- Approach A — Inside the Normal File System (Swap File):
- Pros: Easy to create, resize, or delete using standard file-system routines.
- Cons: Slightly slower because navigating directory structures and disk allocation tables adds extra overhead.
View diagram · Figure 5.7: The Three Core Aspects of Swap-Space Management
Disk Reliability (RAID — Redundant Array of Independent Disks)
- A single hard disk has mechanical moving parts and can fail at any moment—causing permanent loss of critical data and system downtime.
- Two Core Techniques Used in RAID: Data Striping (For High Speed / Performance):
- Redundancy — Mirroring or Parity (For High Reliability):
- Block-Level Striping (No Redundancy) Fastest read/write speed, but 0% fault tolerance (If 1 disk fails, all data is lost)
- Disk Mirroring (100% Duplicate Copy) Every write is duplicated onto a Mirror Disk — Highest Reliability , but costs 2× disk space
- Block-Level Striping with Distributed Parity Distributes data + error-correcting Parity across N disks; survives any 1 disk failure using only 1 disk’s worth of overhead!
- Striped Mirrors (Mirroring + Striping) Combines the speed of RAID 0 with the bullet-proof reliability of RAID 1 (Needs min 4 disks)
View diagram · Figure 5.8: Key RAID Levels Used for Disk Reliability and Performance
Disk Recovery & File System Recovery
- When a disk sector physically wears out or the computer suddenly loses power in the middle of writing a file, how does the Operating System…
- 1. Bad-Block Recovery (Hardware/Controller Level): Over time, certain magnetic sectors on a hard disk become damaged and unreadable, known as Bad Blocks.
- Sector Sparing (Forwarding): The disk manufacturer sets aside extra hidden “Spare Sectors” on every cylinder.
- Sector Slipping: Shifts all sectors after the bad block down by one position to free up a healthy replacement sector right in sequence.
- 2. Consistency Checking (
fsck/chkdsk): If a system crashes or loses power while directory metadata is still cached in RAM, the directory structure on disk becomes… - On reboot, the OS runs a Consistency Checker (
fsckin UNIX/Linux,chkdskin Windows) that compares the data in the directory… - 3. Log-Structured / Journaling File Systems (Modern Recovery): Modern file systems (NTFS, ext4, APFS) use Database Journaling (Write-Ahead Logging)!
- Before making any change to a file or directory, the OS first writes the intended transaction into a circular Journal (Log) on disk.
OS Security: Threats, Policy Mechanism, Protection, Trusted Systems, Authentication & Windows Security
Overview: A password proves a claimed identity only as well as the authentication process allows.
Security vs Protection in Operating Systems
- Students often use the words Protection and Security interchangeably, but in Operating Systems they have distinct meanings:
- Protection (Internal Defense): Any mechanism that controls the access of internal processes and users to the resources defined by the computer system…
- Security (External & Overall Defense): Defending the system against external and internal malicious attacks (viruses, hackers, unauthorized logins) to preserve…
- Confidentiality (Only authorized users can read data)
- Integrity (Only authorized users can modify data)
- Availability (System remains accessible to authorized users without DoS crashes)
OS Security Threats (Program Threats vs System/Network Threats)
- Security threats to an Operating System are classified into two major categories:
- 1. Program Threats (Malicious Code) Trojan Horse: Fake useful app that secretly steals data or installs spyware
- 2. System & Network Threats Worms: Standalone malware that replicates across networks automatically without human action
View diagram · Figure 5.9: Classification of Operating System Security Threats
Security Policy vs Security Mechanism
- A fundamental design principle of Operating Systems is the Separation of Policy and Mechanism:
- 1. Definition: A high-level rule or decision specifying WHAT is allowed and who is authorized to access which resource.
- 2. Question Answered: Answers “WHAT” needs to be protected and from whom.
- 3. Who Decides It?: Decided by the System Administrator / Organization Management.
- 4. Real-Life Example: Policy: “Only BCA Faculty can edit marksheets; students can only view them.”
Protection in OS: Domains of Protection & Access Matrix
- How does the OS enforce internal Protection?
- A. Protection Domain: A computer system is a collection of Processes and Objects (hardware objects like CPU, RAM, Printers, and software objects like…
- A Protection Domain is a set of
<Object, Rights-Set>pairs that specifies which objects a process can access and what operations… - B. The Access Matrix Model: The general model of protection is viewed abstractly as a 2D table called an Access Matrix:
- Rows represent Domains (Users / Roles) (D1, D2, D3).
- Columns represent Objects (Files / Devices) (F1, F2, Printer).
- Cell
Access(i, j)defines the exact set of operations that a process executing in Domain Di can invoke on Object Oj! - D1 (Student):
Read
Trusted Systems, User Authentication & Internal Access Authorization
- A. Trusted Systems (Trusted Computing Base — TCB): A Trusted System is a hardware and software system that has been rigorously verified and certified to enforce a strict **Multilevel…
- At the core of a Trusted System is the TCB (Trusted Computing Base) and a tamper-proof Reference Monitor that mediates every single…
- B. User Authentication (Verifying “Who You Are”): Before the OS grants any permissions, it must verify the identity of the user logging in (Authentication) based on three…
- Something the User KNOWS: Passwords, PINs, Passphrases (stored on disk as one-way Salted Cryptographic Hashes, never in plain text!).
- Something the User HAS: Smart Cards, Hardware Security Keys (YubiKey), Mobile OTP token.
- Something the User IS (Biometrics): Fingerprint scanner, Face ID / Iris scan, Voice recognition.
- C. Internal Access Authorization (Controlling “What You Can Do”): Once a user is authenticated, Internal Access Authorization determines which internal system files, memory segments, and…
Windows Security Architecture (Windows NT / 10 / 11)
- Your DAVV Unit 5 syllabus explicitly includes Windows Security!
- SID (Security Identifier):
- LSASS (Local Security Authority Subsystem Service) & Access Token:
- Security Descriptor (DACL & SACL) on NTFS Objects:
- DACL (Discretionary Access Control List): Specifies which users/SIDs are allowed or denied access (
Full Control,Modify,Read & Execute,Write). - SACL (System Access Control List): Controls security auditing and event logging when someone tries to access the file.
- SRM (Security Reference Monitor):
View diagram · Figure 5.10: How Windows Security Architecture Works