Professional Documents
Culture Documents
3.4. File System Implementation-File Strucure
3.4. File System Implementation-File Strucure
Course Outcome:
Upon completion of the session, students shall have ability to
CO5 Apply concepts of file system interface, implementation, and disk management [AP]
to optimize storage utilization and random access to files.
File-System Structure
• File structure
– Logical storage unit
– Collection of related information
• The file system implementation plays a critical role in ensuring the reliability,
performance, and security of an operating system's file storage capabilities.
• Without an effective file system implementation, an operating system
cannot efficiently manage the storage of data on a storage device, resulting
in data loss, corruption, and inefficiency.
• Disk provides in-place rewrite and random access
– I/O transfers performed in blocks of sectors (usually 512 bytes)
• File control block (FCB) – storage structure consisting of information about a
file
• Device driver controls the physical device
• File system organized into layers
File-System Implementation
• We have system calls at the API level, but how do we implement their
functions?
– On-disk and in-memory structures
• Boot control block contains info needed by system to boot OS from
that volume
– Needed if volume contains OS, usually first block of volume
• Volume control block (superblock, master file table) contains
volume details
– Total # of blocks, # of free blocks, block size, free block pointers or
array
• Directory structure organizes the files
– Names and inode numbers, master file table
22CS301 - Operating Systems
• Mount table storing file system mounts, mount points, file system
types
• The following figure illustrates the necessary file system structures
provided by the operating systems
• Figure 12-3(a) refers to opening a file
• Figure 12-3(b) refers to reading a file
• Plus buffers hold data blocks from secondary storage
• Open returns a file handle for subsequent use
• Data from read eventually copied to specified user process
memory address
22CS301 - Operating Systems
File-System Operations
• We have system calls at the API level, but how do we implement their
functions?
– On-disk and in-memory structures
• Boot control block contains info needed by system to boot OS from that
volume
– Needed if volume contains OS, usually first block of volume
• Volume control block (superblock, master file table) contains volume details
– Total # of blocks, # of free blocks, block size, free block pointers or
array
• Directory structure organizes the files
– Names and inode numbers, master file table
Directory Implementation
1. Linear List
1. Linear List
• The implementation of directories using a singly linked list is easy to program but is
time-consuming to execute.
• Implement a directory by using a linear list of filenames with pointers to the data
blocks.
• To create a new file the entire list has to be checked such that the new directory
does not exist previously.
• The new directory then can be added to the end of the list or at the beginning of the
list.
• In order to delete a file, we first search the directory with the name of the file to be
deleted. After searching we can delete that file by releasing the space allocated to it.
• To reuse the directory entry we can mark that entry as unused or we can append it
to the list of free directories.
• To delete a file linked list is the best choice as it takes less time.
• The main disadvantage of using a linked list is that when the user needs to find a
file the user has to do a linear search.
2. Hash Table
2. Hash Table
• In the hash table for each pair in the directory key-value pair is generated.
• The hash function on the file name determines the key and this key points
to the corresponding file stored in the directory.
• This method efficiently decreases the directory search time as the entire
list will not be searched on every operation.
• Using the keys the hash table entries are checked and when the file is
found it is fetched.
• The major drawback of using the hash table is that generally, it has a fixed
size and its dependency on size. But this method is usually faster than
linear search through an entire directory using a linked list.
Try……
Give the purpose of following file system key components:
Try……
The purpose of following file system key components:
• Disk space allocation: Determines how disk space is allocated to files and
directories.
• Directory structure: Defines the organization of files and directories in a
hierarchical structure.
• File metadata: Stores information about files, such as file name, size,
creation/modification timestamps, permissions, and ownership.
• File operations: Provides functions to create, read, write, delete, and modify files.
• File access control: Manages permissions and access rights to files and
directories to ensure security and privacy.
• File system utilities: Includes tools for formatting, checking, and repairing file
systems.
Try……
Try……
• FAT32 (File Allocation Table 32): Commonly used in older versions of Windows
and compatible with various operating systems.
• NTFS (New Technology File System): Used in modern Windows operating
systems, offering improved performance, reliability, and security features.
• ext4 (Fourth Extended File System): Used in Linux distributions, providing
features such as journaling, large file support, and extended file attributes.
• HFS+ (Hierarchical File System Plus): Used in macOS systems prior to macOS
High Sierra, offering support for journaling and case-insensitive file names.
• APFS (Apple File System): Introduced in macOS High Sierra and the default file
system for macOS and iOS devices, featuring enhanced performance, security,
and snapshot capabilities.
• ZFS (Zettabyte File System): A high-performance file system known for its
advanced features, including data integrity, volume management, and efficient
snapshots.
Next Session…
3.5 Allocation Methods