BCS401 Operating System Semester IV · AY 2025-26 onward
Unit 5 · I/O, Disk Scheduling & File Systems

Lecture 6: File concept, attributes & operations

Learning outcomes

  • Explain what files are, list common file attributes and operations.
Lecture Notes

Main content

File System

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.

File Concept Access Methods Directories File Sharing Implementation Protection Security

1. File Concept

1.1 Meaning of a file

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.

Simple definition: A file is a logical storage unit used to store related data under one name.

1.2 File attributes

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}

1.3 Basic file operations

A file system typically supports operations such as:

  • Create a file
  • Open a file
  • Read from a file
  • Write to a file
  • Reposition within a file (seek)
  • Close a file
  • Delete a file
  • Truncate a file

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}

User Process Logical File System Open-File Table Disk Blocks
Figure 1: File operations typically go through the logical file system and open-file table before reaching disk blocks.

2. File Organization and Access Mechanisms

2.1 File organization

File organization refers to how the contents of a file are logically arranged. Two common ways to view file organization are:

  • Byte stream / character stream – file is treated as a sequence of bytes
  • Record-based organization – file consists of records, either fixed-length or variable-length

Modern systems such as UNIX usually treat files as byte streams, leaving interpretation to applications.

2.2 Access methods

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

Sequential Access Example

A text editor reading a text file line by line uses sequential access.

Direct Access Example

A database jumping directly to record number 5000 uses direct access.

2.3 Repositioning / Seek

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}

3. File Directories

3.1 Meaning of a directory

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}

3.2 Main directory operations

  • Create directory
  • Delete directory
  • Search for a file
  • List directory contents
  • Rename a file or directory
  • Traverse the directory tree

3.3 Directory structures

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
Root User A Docs User B file1.txt file2.c notes.pdf shared.doc
Figure 2: A simple tree-structured directory organization.

4. File Sharing

4.1 Meaning

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.

4.2 Types of sharing

  • Local sharing – multiple processes on the same machine access a file
  • Remote sharing – files are accessed across a network from a server

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}

4.3 Sharing issues

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.

Example

In a shared office document, if one user is editing while another is reading, the system must manage permissions, consistency, and possibly file locking.

5. File-System Implementation Issues

5.1 Main implementation idea

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.

5.2 File Control Block (FCB) / inode idea

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.

5.3 Open-file tables

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.

5.4 File allocation methods

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

5.5 Free-space management

The file system must track which disk blocks are free and which are allocated. Common techniques include:

  • bit maps / bit vectors,
  • linked free lists,
  • grouping,
  • counting.

5.6 VFS idea

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}

Main implementation issue: The file system must efficiently map names and metadata to physical storage blocks while supporting fast access, sharing, and protection.

6. File-System Protection and Security

6.1 Need for protection

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.

6.2 Protection mechanisms

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

6.3 Security concerns

  • Unauthorized access
  • Accidental deletion or corruption
  • Malware or ransomware attacks
  • Spoofing in remote file systems
  • Improper sharing permissions

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}

Important: Protection controls who may access a file. Security protects the file system against unauthorized or malicious actions.

7. Quick Comparison Snapshot

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

8. One-Page Summary

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.

9. Likely University Questions

  1. What is a file? Explain file attributes and basic file operations.
  2. Differentiate between sequential, direct, and indexed access methods.
  3. Explain directory structures with suitable examples.
  4. What is file sharing? What problems arise in shared file access?
  5. Explain file allocation methods: contiguous, linked, and indexed.
  6. What is the role of the open-file table in file-system implementation?
  7. What is free-space management? Explain common methods.
  8. Explain file-system protection and security mechanisms.