File-System Interface
CONTENTS
1. Introduction to File Systems 2. File Attributes 3. File Operations
4. File Types, structure 5. Directory Structure 6. Access Control in File Systems
7. File Sharing 8. Protection
1. Introduction to File Systems
1 File System
A file system is a method for storing, organizing, and retrieving files
on storage devices
2 Importance
Provides a logical interface between users and the physical storage hardware.
3 Types
Different types of file systems exist, each with unique characteristics.
FAT32, NTFS, ext4, APFS, HFS+.
2. File Attributes
Each file has properties or metadata that describe its structure, permissions,
and storage details.
These are stored in a data structure called the File Control Block (FCB) (in
Windows) or in ode (in UNIX).
Attribute
Size: How large the file is (in bytes or blocks). It
Name: Human-readable identifier (e.g., tells the OS how much space to allocate and how
[Link]). It’s what users see. to display file size to users.
Identifier: A unique internal number used by the Protection: Specifies who can read, write, or
OS to distinguish files, even if names are the execute the file. Common models include the
same. Think of it like a file’s “ID card.” UNIX “rwx” scheme (Owner, Group, Others).
Type: Defines what kind of file it is or how to
Timestamps :Record when the file was created,
interpret its contents — text, binary, image,
last modified, and last accessed — useful for
audio, executable, etc. In Windows, the extension
backups, auditing, and version control.
(.exe, .jpg) indicates this; in UNIX, it’s stored
in metadata.
Location: The address of the file’s data on
secondary storage — usually a list of disk block
numbers.
[Link] Operations
Operation Description Command Example Purpose / Notes
Allocates a new empty file in the system Initializes metadata (name, size, permissions)
Create open("[Link]", O_CREAT)
and registers it in the directory. and reserves space.
Loads file metadata (from FCB/inode) into fd = open("[Link]",
Open Required before any read/write operation.
memory and assigns a file descriptor. O_RDONLY)
Retrieves data from the file starting at the Moves file pointer forward by number of bytes
Read read(fd, buffer, 100)
current pointer position. read.
Modifies or appends data to a file at the
Write write(fd, buffer, 50) Updates file contents, size, and timestamps.
current pointer position.
Seek / Enables direct (random) access instead of
Moves the file pointer to a specific location. lseek(fd, offset, whence)
Reposition sequential.
Releases file descriptor and updates Ensures all writes are saved and resources
Close close(fd)
metadata (timestamps, buffers). freed.
Removes the file’s directory entry and
Delete unlink("[Link]") or rm [Link] Permanently removes the file from storage.
releases its storage space.
Changes the file name without affecting
Rename rename("[Link]", "[Link]") Updates directory entry only.
contents or identifier.
Duplicates a file with a new name or
Copy cp [Link] [Link] Creates a new FCB and physical data copy.
location.
Move Transfers a file to another directory. mv [Link] /dir/ Updates directory reference or copies + deletes.
Removes all contents but keeps file name
Truncate truncate("[Link]", 0) Resets file size to zero without deleting it.
and attributes.
[Link] types & Structure
A file type defines the nature of the contents stored inside a file — how data is represented and how it should
be interpreted by the operating system or an application.
Each file type determines:
• Which program can open it
• How the OS should handle it
• Whether it can be executed, read, or displayed
Common File Types
Type Description Examples
Text Files Contain readable characters encoded in ASCII or Unicode. .txt, .csv, .html
Binary Files Contain raw data not meant for direct reading by humans. .bin, .dat
Contain machine code or scripts that can be run by the
Executable Files .exe, .sh, .bat
system.
Image Files Contain pixel data for graphics or photos. .png, .jpg, .bmp
Audio/Video Files Store multimedia data in compressed or raw formats. .mp3, .mp4, .wav
Database Files Contain structured data used by database systems. .db, .sql, .mdb
5. Directory Structures
Modern file systems can store millions of files across terabytes of
storage.
To manage all this data, the operating system organizes storage in two
main levels:
1. Partition Level (Low-level Organization)
•A disk is divided into one or more partitions (also called volumes in
Windows/macOS, or minidisks in IBM systems).
•Each partition acts like a virtual disk — a separate logical area where files and
directories are stored.
•Some systems allow multiple partitions on one disk, while others allow a single
partition to span multiple disks (logical volume).
2. Directory Level (Logical Organization)
Each partition has a directory — a table or symbol map that stores information about files on that partition.
The directory (also called a Volume Table of Contents) holds:
File names
File locations (on disk)
File types and sizes
File attributes (read/write/execute permissions)
So, the directory acts as a lookup table between human-readable file names and the actual storage information on disk.
Common Directory Structure Schemes
Different operating systems use different directory organization models.
Here are the most common logical structures:
1️⃣ Single-Level Directory 2️⃣ Two-Level Directory
Structure: Structure:
•Solves name-conflict problems by giving each user their own directory.
•All files are stored in one single directory.
•A Master File Directory (MFD) maps usernames → User File Directories
•Every file must have a unique name.
(UFD).
Advantages: Example:
•Very simple to design and use. MFD
•Easy to search in small systems. ├── UserA → ([Link], [Link])
Disadvantages: ├── UserB → ([Link], [Link])
•Name conflicts when multiple users create files Advantages:
with the same name. Avoids name collisions between users.
•Hard to organize and manage when file count Protects each user’s files from accidental deletion.
Disadvantages:
grows.
Users cannot easily share files with each other.
•Confusing for multi-user systems.
Isolates users — collaboration is limited.
3️⃣ Tree-Structured Directory
Structure:
•The most common structure in modern OSs.
•Allows directories within directories — forming a hierarchy.
•A root directory (/ or C:\) is at the top.
•Users can create subdirectories to organize files logically.
[Link] Control in File Systems
General Explanation
Access control is the security mechanism used by operating systems to regulate which users or processes can access which files —
and what actions they can perform.
Its main goal is to protect data integrity, confidentiality, and availability by preventing unauthorized access or modification of files.
Why Access Control Is Needed
•Multiple users or applications share the same file system.
•Not every user should have equal rights to all files.
•Some files (like system configuration or sensitive data) must be restricted.
For example:
•A regular user may read a system log but not edit it.
•An administrator can read and write system files.
•A guest user may have read-only access to public folders.
Without access control, the file system would be vulnerable to accidental damage or malicious attacks
Each file or directory typically supports three types of permissions:
Right Meaning These rights can be applied to different categories of users:
Read (r) View or copy the contents of a file. •Owner (the file’s creator)
Write (w) Modify or delete the file’s contents. •Group (other users in the same team/project)
•Others (all other system users)
Execute (x) Run the file as a program or script.
Main Access Control Models
[Link] Control Lists (ACLs)
Each file keeps a list of which users or groups can perform which operations.
It’s file-centric — permissions stored with the file itself.
[Link] Lists
Each user or process holds a list of what resources (files) they can access.
It’s user-centric — permissions stored with the user or process.
Both models aim to ensure that only authorized entities can perform specific actions.
7. File Sharing
File sharing means allowing multiple users or processes to access the same file — either simultaneously or at different times.
It’s essential in multi-user and networked systems, where users collaborate or where programs share common data.
Why File Sharing Is Important
•Enables collaboration — multiple users can read or edit shared documents.
•Reduces data duplication — one copy of a file can be used by many users.
•Supports distributed systems — shared databases, network drives, or cloud storage.
•Essential for multi-processing — different programs or threads working on shared data.
File Sharing Models
There are two main contexts for file sharing:
[Link] File Sharing (same system)
[Link] File Sharing (network-based)
Let’s explain both
1️⃣ Local File Sharing (Same Computer or Server) 2️⃣ Remote File Sharing (Over a Network)
In a multi-user OS (like UNIX or Windows Server), several users can access the same file Used in distributed or cloud environments.
located on the same machine. A network file system allows users on different
The operating system manages: computers to access files as if they were local.
•Ownership Examples:
•Permissions •NFS (Network File System) → UNIX/Linux
•Locks (to prevent conflicts) systems.
For example: •SMB/CIFS (Server Message Block / Common
•Alice and Bob share [Link]. Internet File System) → Windows.
•Alice opens it for editing (write mode). •AFS (Andrew File System) → distributed
•The OS locks the file to prevent Bob from writing at the same time — avoiding corruption. environments.
Advantages and Challenges of File Sharing
Advantages Challenges
Promotes collaboration Requires strict security controls
Reduces redundancy May cause version conflicts
Centralized data management Needs proper locking mechanisms
Enables remote access Synchronization overhead
Summary Table
Concept Description
File Sharing Multiple users/processes accessing the same file.
Local Sharing Access within one system (multi-user OS).
Remote Sharing Access over a network (NFS, SMB).
Locks Prevent simultaneous conflicting writes.
Access Control Defines who can read/write/execute shared files.
Consistency Ensures all users see the same file version.
8. Protection
Protection ensures that a computer system controls access to files — allowing only
authorized users or processes to perform specific operations (like reading, writing, or
executing).
It’s the OS’s mechanism to maintain data security, integrity, and privacy within the file
system.
Goals of Protection
Prevent unauthorized access (security)
Maintain data integrity (no unwanted modification)
Ensure system stability (avoid accidental or malicious damage)
Protection Policies
Policy Description
Discretionary Access Control Owner decides who can access their files
(DAC) (UNIX/Windows).
Mandatory Access Control System enforces strict security rules (used in
(MAC) military systems).
Role-Based Access Control Access based on roles like admin, staff, or
(RBAC) guest.
Aspect Protection Access Control
Protection A broad concept that ensures the
A mechanism or method used to
vs. Access Definition OS prevents unauthorized or
harmful access to system resources.
enforce protection policies.
Control Scope
Concerned with overall system
security, including files, memory,
Concerned mainly with who can
access what and how (e.g., read,
devices, and processes. write, execute).
To define, manage, and enforce To apply these rules — verifying
• Protection = The “what Purpose rules that guarantee correct and permissions for each access
and why” of keeping safe use of system resources. attempt.
resources safe. “The OS checks the Access Control
“Only authorized users can modify
• Access Control = The Example Concept
files.”
List (ACL) before allowing a write
“how” — the practical operation.”
enforcement mechanism. Implemented through mechanisms
Implemented through policies like like Access Control Lists (ACLs),
Implementation
DAC, MAC, or RBAC. Capability Lists, or Access Control
Matrices.
Conceptual and policy-level (what Technical and operational (how
Level of Operation
should be protected). protection is enforced).
Protection is the security plan of a Access control is the lock system
Analogy
building. that enforces that plan.
Thank You