0% found this document useful (0 votes)
6 views41 pages

File Structure

Chapter 4 of 'Modern Operating Systems' discusses file systems, highlighting their essential requirements for long-term information storage, such as large capacity, data persistence, and concurrent access. It covers the organization of files and directories, file types, naming conventions, attributes, and operations, as well as implementation strategies for storing files on disk. The chapter also differentiates between hard and soft links and explores directory structures and their management.

Uploaded by

HECKER
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views41 pages

File Structure

Chapter 4 of 'Modern Operating Systems' discusses file systems, highlighting their essential requirements for long-term information storage, such as large capacity, data persistence, and concurrent access. It covers the organization of files and directories, file types, naming conventions, attributes, and operations, as well as implementation strategies for storing files on disk. The chapter also differentiates between hard and soft links and explores directory structures and their management.

Uploaded by

HECKER
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 41

Modern Operating Systems

Fifth Edition

Copyright © 2024 Pearson India Education Services Pvt. Ltd


Chapter 4
File Systems

Modern Operating Systems, 5e Authors: Tanenbaum and Bos


File Systems (1)
Three essential requirements for long-term information storage:

Copyright © 2024 Pearson India Education Services Pvt. Ltd


1. It must be possible to store a very large amount of information
2. Information must survive termination of process using it
3. Multiple processes must be able to access information
concurrently

Modern Operating Systems, 5e Authors: Tanenbaum and Bos


File Systems (2)
Think of a disk as a linear sequence of fixed-size blocks and

Copyright © 2024 Pearson India Education Services Pvt. Ltd


supporting two operations:
1. Read block k.
2. Write block k

Modern Operating Systems, 5e Authors: Tanenbaum and Bos


File Systems (3)
Questions that quickly arise:

Copyright © 2024 Pearson India Education Services Pvt. Ltd


– How do you find information?
– How do you keep one user from reading another user’s data?
– How do you know which blocks are free?

Modern Operating Systems, 5e Authors: Tanenbaum and Bos


File Systems (4)
File Systems are:

Copyright © 2024 Pearson India Education Services Pvt. Ltd


• A way to organize and (persistently) store information
• An abstraction over storage devices:
– Hard disk, SS D, network, RA

M,
• Organized in files and (typically) directories.
• Examples:
– FA T12/FA T16: M S-DO S
– NTF S: Windows
– Ext4: Linux
– APF S: mac O S/i O S
Modern Operating Systems, 5e Authors: Tanenbaum and Bos
Overview (1 of 4)

Copyright © 2024 Pearson India Education Services Pvt. Ltd


Modern Operating Systems, 5e Authors: Tanenbaum and Bos
Overview (2 of 4)

Copyright © 2024 Pearson India Education Services Pvt. Ltd


Modern Operating Systems, 5e Authors: Tanenbaum and Bos
Overview (3 of 4)

Copyright © 2024 Pearson India Education Services Pvt. Ltd


Modern Operating Systems, 5e Authors: Tanenbaum and Bos
Overview (4 of 4)

Copyright © 2024 Pearson India Education Services Pvt. Ltd


Modern Operating Systems, 5e Authors: Tanenbaum and Bos
Files
• Abstract storage nodes

Copyright © 2024 Pearson India Education Services Pvt. Ltd


• File access:
– Sequential v s. random access
ersu

• File types:
– Regular files, directories, soft links
– Special files (e.g., device files, metadata files)
• File structure:
– O S’ perspective: Files as streams of bytes
– Program’s perspective: Archives, Executables, etc.

Modern Operating Systems, 5e Authors: Tanenbaum and Bos


File Structure

Copyright © 2024 Pearson India Education Services Pvt. Ltd


Figure 4.2 Three kinds of files. (a) Byte sequence. (b) Record sequence. (c) Tree.

Modern Operating Systems, 5e Authors: Tanenbaum and Bos


File Naming (1 of 2)
• Different file systems have different limitations/conventions for file

Copyright © 2024 Pearson India Education Services Pvt. Ltd


names
• File extensions
• File name length

FAT12: 8.3 characters (later extended to 255)

Ext4: 255 characters
• Special characters in file names

FAT12: No "*/:<>?\| and more

Ext4: No '\0' and '/', or the special names "." and ".."
• Case sensitivity
Modern Operating Systems, 5e Authors: Tanenbaum and Bos
File Naming (2 of 2)
Extension Meaning

Copyright © 2024 Pearson India Education Services Pvt. Ltd


.ba k Backup file
.c C source program
.gi f Compuserve Graphical Interchange Format image
.htm l World Wide Web HyperText Markup Language document
.j p g Still picture encoded with the JPE G standard
.mp 3 Music encoded in MPE G layer 3 audio format
.mp g Movie encoded with the MPE G standard
.o Object file (compiler output, not yet linked)
.pd f Portable Document Format file
.p s PostScript file
.te x Input for the TE X formatting program
.tx t General text file
.zi p Compressed archive

Figure 4.1 Some typical file extensions.

Modern Operating Systems, 5e Authors: Tanenbaum and Bos


File Types

Copyright © 2024 Pearson India Education Services Pvt. Ltd


Figure 4.3 (a) An executable file. (b) An archive

Modern Operating Systems, 5e Authors: Tanenbaum and Bos


File Attributes (1)

Copyright © 2024 Pearson India Education Services Pvt. Ltd


Attribute Meaning
Protection Who can access the file and in what way
Password Password needed to access the file
Creator I D of the person who created the file
Owner Current owner
Read-only flag 0 for read/write; 1 for read only
Hidden flag 0 for normal; 1 for do not display in listings
System flag 0 for normal files; 1 for system file
Archive flag 0 for has been backed up; 1 for needs to be backed up
A SCI I/binary flag 0 for ASCI I file; 1 for binary file
Random access flag 0 for sequential access only; 1 for random access

Figure 4.5 Some possible file attributes.

Modern Operating Systems, 5e Authors: Tanenbaum and Bos


File Attributes (2)

Copyright © 2024 Pearson India Education Services Pvt. Ltd


Attribute Meaning
Temporary flag 0 for normal; 1 for delete file on process exit
Lock flags 0 for unlocked; nonzero for locked
Record length Number of bytes in a record
Key position Offset of the key within each record
Key length Number of bytes in the key field
Creation time Date and time the file was created
Time of last access Date and time the file was last accessed
Time of last change Date and time the file was last changed
Current size Number of bytes in the file
Maximum size Number of bytes the file may grow to

Figure 4.5 Some possible file attributes.

Modern Operating Systems, 5e Authors: Tanenbaum and Bos


File Operations (1)
• Create

Copyright © 2024 Pearson India Education Services Pvt. Ltd


• Delete
• Op
• Close
• Read
• Write
• Append
• Seek
• Get attributes
• Set attributes
• Rename
Modern Operating Systems, 5e Authors: Tanenbaum and Bos
Directories
• Data structures organizing and maintaining information about files

Copyright © 2024 Pearson India Education Services Pvt. Ltd


• Often stored as file entries with special attributes
• Directories are denoted by “/” (Unix) or “\” (Windows)
• Special directory entries:
– . Current directory
– .. Parent directory

Modern Operating Systems, 5e Authors: Tanenbaum and Bos


Single-Level Directory Systems

Copyright © 2024 Pearson India Education Services Pvt. Ltd


Figure 4.7 A single-level directory system containing four files.

Modern Operating Systems, 5e Authors: Tanenbaum and Bos


Hierarchical Directory Systems

Copyright © 2024 Pearson India Education Services Pvt. Ltd


Figure 4.8 A hierarchical directory system.

Modern Operating Systems, 5e Authors: Tanenbaum and Bos


Path Names

Copyright © 2024 Pearson India Education Services Pvt. Ltd


Figure 4.9 A UNI X directory tree.

Modern Operating Systems, 5e Authors: Tanenbaum and Bos


Directory Operations
• Create

Copyright © 2024 Pearson India Education Services Pvt. Ltd


• Delete
• Opendir
• Closedir
• Readdir
• Rename
• Link
• Unlink

Modern Operating Systems, 5e Authors: Tanenbaum and Bos


Virtual File Systems (1)

Copyright © 2024 Pearson India Education Services Pvt. Ltd


Figure 4.21 Position of the virtual file system.

Modern Operating Systems, 5e Authors: Tanenbaum and Bos


Virtual File Systems (2)

Copyright © 2024 Pearson India Education Services Pvt. Ltd


Figure 4.22 A simplified view of the data structures and code
used by the VF S and concrete file system to do a read.

Modern Operating Systems, 5e Authors: Tanenbaum and Bos


File System Implementation (1 of 6)
• How to store files?

Copyright © 2024 Pearson India Education Services Pvt. Ltd


• How to implement directories?
• How to manage disk space?
• How to ensure file system performance?
• How to ensure file system dependability?

Modern Operating Systems, 5e Authors: Tanenbaum and Bos


File System Implementation (2 of 6)
• How to store files?

Copyright © 2024 Pearson India Education Services Pvt. Ltd


• How to implement directories?
• How to manage disk space?
• How to ensure file system performance?
• How to ensure file system dependability?

Modern Operating Systems, 5e Authors: Tanenbaum and Bos


File System Layout

Copyright © 2024 Pearson India Education Services Pvt. Ltd


Figure 4.10 A possible file system layout.

Modern Operating Systems, 5e Authors: Tanenbaum and Bos


Unified Extensible Firmware Interface (UEF I)

Copyright © 2024 Pearson India Education Services Pvt. Ltd


Figure 4.11 Layout for UEF I with partition
table
Modern Operating Systems, 5e Authors: Tanenbaum and Bos
How to Store Files on the Disk? (1 of 2)

Contiguous allocation

Copyright © 2024 Pearson India Education Services Pvt. Ltd


• Store files as a contiguous stream of bytes
• Requires max file size, prone to fragmentation

Modern Operating Systems, 5e Authors: Tanenbaum and Bos


Implementing Files Contiguous Layout

Copyright © 2024 Pearson India Education Services Pvt. Ltd


Figure 4.12 (a) Contiguous allocation of disk space for seven files.
(b) The state of the disk after files D and F have been removed.

Modern Operating Systems, 5e Authors: Tanenbaum and Bos


How to Store Files on the Disk? (2 of 2)

Contiguous allocation

Copyright © 2024 Pearson India Education Services Pvt. Ltd


• Store files as a contiguous stream of bytes
• Requires max file size, prone to fragmentation

Block-based strategies
• Linked List
• File Allocation Table
• i-nodes

Modern Operating Systems, 5e Authors: Tanenbaum and Bos


Implementing Files Linked List Allocation

Copyright © 2024 Pearson India Education Services Pvt. Ltd


Figure 4.13 Storing a file as a linked list of disk blocks.

Modern Operating Systems, 5e Authors: Tanenbaum and Bos


Implementing Files Linked List - Table in Memory

Copyright © 2024 Pearson India Education Services Pvt. Ltd


Figure 4.14 Linked list allocation using a file allocation table in main memory.

Modern Operating Systems, 5e Authors: Tanenbaum and Bos


Implementing Files I-nodes

Copyright © 2024 Pearson India Education Services Pvt. Ltd


Figure 4.15 An example i-node

Modern Operating Systems, 5e Authors: Tanenbaum and Bos


Implementing Files I-nodes with Indirect Blocks
• Store list of block addresses per file in an i-node

Copyright © 2024 Pearson India Education Services Pvt. Ltd


• Better scalability: only require metadata for in-use files
• Large-file i-nodes point to indirect blocks with more addresses

Figure 4.35 A UNI X i-node

Modern Operating Systems, 5e Authors: Tanenbaum and Bos


File System Implementation (3 of 6)
• How to store files?

Copyright © 2024 Pearson India Education Services Pvt. Ltd


• How to implement directories?
• How to manage disk space?
• How to ensure file system performance?
• How to ensure file system dependability?

Modern Operating Systems, 5e Authors: Tanenbaum and Bos


Directory Implementation
• How to store directory entries and attributes?

Copyright © 2024 Pearson India Education Services Pvt. Ltd


• How to find the root directory?
• How to find any other directory?

Modern Operating Systems, 5e Authors: Tanenbaum and Bos


Directory Entries and Attributes

Copyright © 2024 Pearson India Education Services Pvt. Ltd


Figure 4.16 (a) A simple directory containing fixed-size entries with the disk addresses and
attributes in the directory entry. (b) A directory in which each entry just refers to an i-node.

Modern Operating Systems, 5e Authors: Tanenbaum and Bos


Other Ways to Handle Long File Names

Copyright © 2024 Pearson India Education Services Pvt. Ltd


Figure 4.17 Two ways of handling long file names in a directory. (a) In-line. (b) In a heap.

Modern Operating Systems, 5e Authors: Tanenbaum and Bos


UNI X Directory Entry

Copyright © 2024 Pearson India Education Services Pvt. Ltd


• Directory entry stores only name and #i-node
• Attributes are stored in the i-node
• One i-node per file, first i-node is the root
• Where are i-nodes stored?
Modern Operating Systems, 5e Authors: Tanenbaum and Bos
Hard Links v s. Soft Links ersu

• Hard links reference a shared file (i-node)

Copyright © 2024 Pearson India Education Services Pvt. Ltd


– The file is removed only with no hard links left
– Space-efficient (only 1 directory entry per hard link)
– Good to manage shared files across owners
• Soft (or symbolic) links reference a file name
– Removing the file renders its soft links invalid
– Less space-efficient (need 1 i-node per soft link)
– More flexible (can reference file names across F Ses)

Modern Operating Systems, 5e Authors: Tanenbaum and Bos

You might also like