l5
"/home/yossef/notes/Su/os2/l5.md"
path: Su/os2/l5.md
- **fileName**: l5
- **Created on**: 2026-01-04 21:22:39
File-System Interface โ Simple Explanation
This explanation covers the full lecture on File-System
Interface from the sources, using simple language to make
it easy to understand.
1. What is a File? (File Concept)
A file is a way to store information in a "contiguous logical
address space". This means the computer sees it as one
continuous piece of data.
-
Types of Files: They can be Data (numbers, text, or
binary) or Programs. -
Structure: Some files are just a long string of bytes.
Others have a "record structure" with fixed or variable
lengths. The Operating System (OS) or the Program
itself decides this structure. -
Attributes: Every file has details like a Name (for
humans), a Unique Identifier (a number for the system),
Type, Location, Size, and Protection settings.
2. How do we use Files? (Operations & Locking)
The OS performs several tasks on files:
-
Basic Tasks: Create, Read, Write, Delete, and
Truncate (clearing file content but keeping the file). -
Open and Close: When you Open a file, the system
moves its info from the disk to the memory. When you
Close it, the info moves back to the disk. -
Managing Open Files: The system tracks a File
Pointer (where you last read or wrote), an Open Count
(how many users are using it), and your Access Rights. -
File Locking: To prevent errors when two users access
one file, the OS uses Locks.- Exclusive Lock: Only one user can write.
- Shared Lock: Many users can read at the same time.
- Mandatory vs. Advisory: Mandatory locks are enforced
by the system. Advisory locks let programs decide what
to do after checking the lock status.
3. How are Files Organized? (Directory & Disk Structure)
-
Disks and Partitions: A disk can be divided into
Partitions (also called minidisks or slices). A
partition that holds a file system is called a Volume. -
Directories: A directory is like a map that contains
nodes pointing to all the files. -
Directory Tasks: You can search for files, create or
delete them, rename them, and traverse (walk through)
the entire file system.
4. Directory Organization Types
The sources describe different ways to organize directories:
-
Single-Level: One big folder for everyone. This makes
naming and grouping files difficult. -
Two-Level: Each user gets their own folder. You use
Path Names to locate files. -
Tree-Structured: The most common type. Folders can
have subfolders. You can use Absolute paths (from the
root) or Relative paths (from the current location). -
Acyclic-Graph: Allows sharing folders or files. One
file can have multiple names (Aliasing). -
General Graph: Allows complex links, but care must be
taken to avoid Cycles (endless loops).
5. Mounting and Sharing
-
Mounting: A file system must be Mounted (attached)
to a specific mount point before it can be accessed. -
Sharing: In multi-user systems, User IDs and
Group IDs control who can access files. -
Remote Systems: Files can be shared over networks
using protocols like NFS (Unix) or CIFS (Windows). -
Failures: Remote access may fail if the server or
network goes down. Stateless protocols (like NFS)
include all needed info in each request, making recovery
easier.
6. Consistency and Protection (Security)
-
Consistency Semantics: Defines how file changes are
seen by users. In Unix, changes are visible
immediately. In AFS, changes appear only after the
file is closed. -
Protection: The file owner controls permissions such
as Read (R), Write (W), Execute (X), Append,
Delete, or List. -
Access Classes:
- Owner: The creator of the file.
- Group: A specific set of users.
- Public: All other users.
-
Example: In Unix, the command
chmod 761 gamegives
the owner full access (7), the group read/write (6), and
the public execute-only access (1).
Analogy
Think of the File System as a huge library.
- Files are the books.
- Attributes are the labels on the book spine.
- Directories are the card catalogs showing where books
are stored. - Mounting is opening a new wing of the library.
- Protection is the library card that decides whether
you can read a book or write in it.
mind map

continue:[[]]
before:./l4.md