OS UNIT 5
OS UNIT 5
1
File Access Methods in Operating System
File access methods in an operating system are the techniques and processes used to read from
and write to files stored on a computer’s storage devices. There are several ways to access this
information in the file. Some systems provide only one access method for files. Other systems,
such as those of IBM, support many access methods, and choosing the right one for a particular
application is a major design problem.
These methods determine how data is organized, retrieved, and modified within a file system.
Understanding file access methods is crucial for efficient data management and system
performance. In this article, we are going to discuss different types of methods to access the
file.
File Access Methods
There are three ways to access a file in a computer system:
Sequential-Access
Direct Access
Index sequential Method
Sequential Access
It is the simplest access method. Information in the file is processed in order, one record after
the other. This mode of access is by far the most common; for example, the editor and
compiler usually access the file in this fashion.
Read and write make up the bulk of the operation on a file. A read operation -read next- reads
the next position of the file and automatically advances a file pointer, which keeps track of the
I/O location. Similarly, for the -write next- append to the end of the file and advance to the
newly written material.
2
Key Points related to Sequential Access
Data is accessed from one record right after another record in an order.
When we use the read command, it moves ahead pointer by one.
When we use the write command, it will allocate memory and move the pointer to the end
of the file.
Such a method is reasonable for tape.
Advantages of Sequential Access Method
It is simple to implement this file access mechanism.
It useslexicographic order to quickly access the next entry.
It is suitable for applications that require access to all records in a file, in a specific order.
It is less prone to data corruption as the data is written sequentially and not randomly.
It is a more efficient method for reading large files, as it only reads the required data and
does not waste time reading unnecessary data.
It is a reliable method forbackup and restore operations, as the data is stored sequentially
and can be easily restored if required.
Disadvantages of Sequential Access Method
If the file record that needs to be accessed next is not present next to the current record, this
type of file access method is slow.
Moving a sizable chunk of the file may be necessary to insert a new record.
It does not allow for quick access to specific records in the file. The entire file must be
searched sequentially to find a specific record, which can be time-consuming.
It is not well-suited for applications that require frequent updates or modifications to the
file. Updating or inserting a record in the middle of a large file can be a slow and
cumbersome process.
Sequential access can also result in wasted storage space if records are of varying lengths.
The space between records cannot be used by other records, which can result in inefficient
use of storage.
3
Direct Access Method
4
It control the pointer by using index.
Advantages of Index Sequential Method
Efficient Searching : Index sequential method allows for quick searches through the index.
Balanced Performance : It combines the simplicity of sequential access with the speed of
direct access, offering a balanced approach that can handle various types of data access
needs efficiently.
Flexibility : This method allows both sequential and random access to data, making it
versatile for different types of applications, such as batch processing and real-time
querying.
Improved Data Management : Indexing helps in better organization and management of
data. It makes data retrieval faster and more efficient, especially in large databases.
Reduced Access Time : By using an index to directly locate data blocks, the time spent
searching for data within large datasets is significantly reduced.
Disadvantages of Index Sequential Method
Complex Implementation : The index sequential method is more complex to implement
A directory is a container that is used to contain folders and files. It organizes files and folders
in a hierarchical manner. In other words, directories are like folders that help organize files on a
computer. Just like you use folders to keep your papers and documents in order, the operating
5
system uses directories to keep track of files and where they are stored. Different structures of
directories can be used to organize these files, making it easier to find and manage them.
Understanding these directory structures is important because it helps in efficiently organizing
and accessing files on your computer. Following are the logical structures of a directory, each
providing a solution to the problem faced in the previous type of directory structure.
6
1) Single-Level Directory
The single-level directory is the simplest directory structure. In it, all files are contained in the
same directory which makes it easy to support and understand.
A single level directory has a significant limitation, however, when the number of files increases
or when the system has more than one user. Since all the files are in the same directory, they
must have a unique name. If two users call their dataset test, then the unique name rule violated.
Advantages
Since it is a single directory, so its implementation is very easy.
If the files are smaller in size, searching will become faster.
The operations like file creation, searching, deletion, updating are very easy in such a
directory structure.
Logical Organization : Directory structures help to logically organize files and directories in
a hierarchical structure. This provides an easy way to navigate and manage files, making it
easier for users to access the data they need.
Increased Efficiency: Directory structures can increase the efficiency of the file system by
reducing the time required to search for files. This is because directory structures are
optimized for fast file access, allowing users to quickly locate the file they need.
Improved Security : Directory structures can provide better security for files by allowing
access to be restricted at the directory level. This helps to prevent unauthorized access to
sensitive data and ensures that important files are protected.
Facilitates Backup and Recovery : Directory structures make it easier to backup and
recover files in the event of a system failure or data loss. By storing related files in the same
directory, it is easier to locate and backup all the files that need to be protected.
7
Scalability: Directory structures are scalable, making it easy to add new directories and files
as needed. This helps to accommodate growth in the system and makes it easier to manage
large amounts of data.
Disadvantages
There may chance of name collision because two files can have the same name.
Searching will become time taking if the directory is large.
This can not group the same type of files together.
2) Two-Level Directory
As we have seen, a single level directory often leads to confusion of files names among different
users. The solution to this problem is to create a separate directory for each user.
In the two-level directory structure, each user has their own user files directory (UFD). The
UFDs have similar structures, but each lists only the files of a single user. System’s master file
directory (MFD) is searched whenever a new user id is created.
Advantages
The main advantage is there can be more than two files with same name, and would be very
helpful if there are multiple users.
8
A security would be there which would prevent user to access other user’s files.
Searching of the files becomes very easy in this directory structure.
Disadvantages
As there is advantage of security, there is also disadvantage that the user cannot share the file
with the other users.
Unlike the advantage users can create their own files, users don’t have the ability to create
subdirectories.
Scalability is not possible because one user can’t group the same types of files together.
3) Tree Structure/ Hierarchical Structure
Tree directory structure of operating system is most commonly used in our personal computers.
User can create files and subdirectories too, which was a disadvantage in the previous directory
structures.
This directory structure resembles a real tree upside down, where the root directory is at the
peak. This root contains all the directories for each user. The users can create subdirectories and
even store files in their directory.
A user do not have access to the root directory data and cannot modify it. And, even in this
directory the user do not have access to other user’s directories. The structure of tree directory is
given below which shows how there are files and subdirectories in each user’s directory.
9
Tree/Hierarchical Directory Structure
Advantages
This directory structure allows subdirectories inside a directory.
The searching is easier.
File sorting of important and unimportant becomes easier.
This directory is more scalable than the other two directory structures explained.
Disadvantages
As the user isn’t allowed to access other user’s directory, this prevents the file sharing among
users.
As the user has the capability to make subdirectories, if the number of subdirectories increase
the searching may become complicated.
Users cannot modify the root directory data.
If files do not fit in one, they might have to be fit into other directories.
4) Acyclic Graph Structure
As we have seen the above three directory structures, where none of them have the capability to
access one file from multiple directories. The file or the subdirectory could be accessed through
the directory it was present in, but not from the other directory.
This problem is solved in acyclic graph directory structure, where a file in one directory can be
accessed from multiple directories. In this way, the files could be shared in between the users. It
is designed in a way that multiple directories point to a particular directory or file with the help
of links.
In the below figure, this explanation can be nicely observed, where a file is shared between
multiple users. If any user makes a change, it would be reflected to both the users.
10
Advantages
Sharing of files and directories is allowed between multiple users.
Searching becomes too easy.
Flexibility is increased as file sharing and editing access is there for multiple users.
Disadvantages
Because of the complex structure it has, it is difficult to implement this directory structure.
The user must be very cautious to edit or even deletion of file as the file is accessed by
multiple users.
If we need to delete the file, then we need to delete all the references of the file inorder to
delete it permanently.
5) General-Graph Directory Structure
Unlike the acyclic-graph directory, which avoids loops, the general-graph directory can have
cycles, meaning a directory can contain paths that loop back to the starting point. This can make
navigating and managing files more complex.
11
In the above image, you can see that a cycle is formed in the User 2 directory. While this
structure offers more flexibility, it is also more complicated to implement.
Advantages of General-Graph Directory
More flexible than other directory structures.
Allows cycles, meaning directories can loop back to each other.
Disadvantages of General-Graph Directory
More expensive to implement compared to other solutions.
Requires garbage collection to manage and clean up unused files and directories.
12
Security and Permissions: The file system implementation includes features for managing
file security and permissions. This includes access control lists (ACLs), file permissions, and
ownership management.
Recovery and Fault Tolerance: The file system implementation includes features for
recovering from system failures and maintaining data integrity. This includes techniques such
as journaling and file system snapshots.
Different Types of File Systems
There are several types of file systems, each designed for specific purposes and compatible with
different operating systems. Some common file system types include:
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.
13
Layers in File System
A file system in an operating system is organized into multiple layers, each responsible for
different aspects of file management and storage. Here are the key layers in a typical file system:
Application Programs: This is the topmost layer where users interact with files through
applications. It provides the user interface for file operations like creating, deleting, reading,
writing, and modifying files. Examples include text editors, file browsers, and command-line
interfaces.
Logical File system – It manages metadata information about a file i.e includes all details
about a file except the actual contents of the file. It also maintains via file control blocks. File
control block (FCB) has information about a file – owner, size, permissions, and location of
file contents.
File Organization Module – It has information about files, the location of files and their
logical and physical blocks. Physical blocks do not match with logical numbers of logical
blocks numbered from 0 to N. It also has a free space that tracks unallocated blocks.
14
Basic File system – It Issues general commands to the device driver to read and write
physical blocks on disk. It manages the memory buffers and caches. A block in the buffer can
hold the contents of the disk block and the cache stores frequently used file system metadata.
I/O Control level – Device drivers act as an interface between devices and OS, they help to
transfer data between disk and main memory. It takes block number as input and as output, it
gives low-level hardware-specific instruction.
Devices Layer: The bottommost layer, consisting of the actual hardware devices. It performs
the actual reading and writing of data to the physical storage medium. This includes hard
drives, SSDs, optical disks, and other storage devices.
Implementation Issues
Management of Disc pace: To prevent space wastage and to guarantee that files can always
be stored in contiguous blocks, file systems must manage disc space effectively. Free space
management, fragmentation prevention, and garbage collection are methods for managing
disc space.
Checking for Consistency and Repairing Errors: The consistency and error-free operation
of files and directories must be guaranteed by file systems. Journaling, checksumming, and
redundancy are methods for consistency checking and error recovery. File systems may need
to perform recovery operations if errors happen in order to restore lost or damaged data.
Locking Files and Managing Concurrency: To prevent conflicts and guarantee data
integrity, file systems must control how many processes or users can access a file at once.
File locking, semaphore, and other concurrency-controlling methods are available.
Performance Optimization: File systems need to optimize performance by reducing file
access times, increasing throughput, and minimizing system overhead. Caching, buffering,
prefetching, and parallel processing are methods for improving performance.
Key Steps Involved in File System Implementation
File system implementation is a crucial component of an operating system, as it provides an
interface between the user and the physical storage device. Here are the key steps involved in file
system implementation:
Partitioning The Storage Device: The first step in file system implementation is to partition
the physical storage device into one or more logical partitions. Each partition is formatted
with a specific file system that defines the way files and directories are organized and stored.
15
File System Structures: File system structures are the data structures used by the operating
system to manage files and directories. Some of the key file system structures include the
superblock, inode table, directory structure, and file allocation table.
Allocation of Storage Space: The file system must allocate storage space for each file and
directory on the storage device. There are several methods for allocating storage space,
including contiguous, linked, and indexed allocation.
File Operations: The file system provides a set of operations that can be performed on files
and directories, including create, delete, read, write, open, close, and seek. These operations
are implemented using the file system structures and the storage allocation methods.
File System Security: The file system must provide security mechanisms to protect files and
directories from unauthorized access or modification. This can be done by setting file
permissions, access control lists, or encryption.
File System Maintenance: The file system must be maintained to ensure efficient and
reliable operation. This includes tasks such as disk defragmentation, disk checking,
and backup and recovery.
Overall, file system implementation is a complex and critical component of an operating system.
The efficiency and reliability of the file system have a significant impact on the performance and
stability of the entire system.
16
To perform any operation on a file, it must first be opened. The open() system call in Linux
and CreateFile() in Windows are used to open files. Reading and writing are done
using read() and write() in Linux, and ReadFile() and WriteFile() in Windows1.
using unlink() and remove() in Linux, and DeleteFile() and RemoveDirectory() in Windows1.
Windows. Moving files relocates them from one location to another, using mv in Linux
Linear List
In this method, all files in a directory are maintained as a singly linked list. Each file contains
pointers to the data blocks assigned to it and the next file in the directory. This approach is
simple to program but can be inefficient in terms of performance.
17
Characteristics
Creation: When a new file is created, the entire list is checked to ensure the new file name
does not match an existing one. If it doesn't exist, the file can be added at the beginning or end
of the list.
Deletion: To delete a file, the directory is searched for the file name, and the file is then
removed by releasing the space allocated to it.
Updating: Any operation on the files (creation, deletion, updating) requires traversing the
entire list, making the system inefficient12.
Disadvantages
Search Time: Searching for a file requires a linear search through the entire list, which can be
time-consuming.
Performance: The system becomes inefficient as the list needs to be traversed for every
operation12.
Hash Table
To overcome the drawbacks of the linear list, the hash table approach is used. This method
combines a hash table with linked lists to store directory entries.
18
Characteristics
Key-Value Pair: For each file in the directory, a key-value pair is generated and stored in the
hash table. The key is determined by applying a hash function to the file name, and it points to
the corresponding file stored in the directory.
Efficiency: Searching becomes efficient as only the hash table entries are checked using the
key. If an entry is found, the corresponding file is fetched using the value12.
Disadvantages
Fixed Size: Hash tables generally have a fixed size, which can be a limitation.
Dependency on Size: The performance of the hash table depends on its size
Contiguous Allocation
In contiguous allocation, each file occupies a contiguous set of blocks on the disk. For example,
if a file requires n blocks and starts at block b , it will occupy blocks b, b+1, b+2, ..., b+n-1 .
19
The directory entry for a file contains the address of the starting block and the length of the
allocated portion.
Advantages:
Supports both sequential and direct access.
Fast access due to minimal seek time.
Disadvantages:
Suffers from internal and external fragmentation.
Difficult to increase file size due to the need for contiguous memory.
Linked Allocation
In linked allocation, each file is a linked list of disk blocks, which can be scattered anywhere on
the disk. The directory entry contains pointers to the starting and ending blocks, and each block
contains a pointer to the next block.
Advantages:
Flexible in terms of file size.
20
No external fragmentation.
Disadvantages:
Slower access due to the need to follow pointers.
Does not support direct access.
Extra overhead for storing pointers.
Indexed Allocation
In indexed allocation, a special block known as the index block contains pointers to all the
blocks occupied by a file. Each file has its own index block, and the directory entry contains the
address of this index block.
Advantages:
Supports direct access to file blocks.
No external fragmentation.
Disadvantages:
Higher pointer overhead compared to linked allocation.
Inefficient for very small files.
Single index block may not suffice for very large files.
Variations of Indexed Allocation
21
To handle large files, indexed allocation can use:
Linked Scheme: Links multiple index blocks together.
Multilevel Index: Uses a hierarchy of index blocks.
Combined Scheme: Uses an inode that contains pointers to direct and indirect blocks.
FAT is a file system that uses a table to store information about file allocation. It allows random
access to blocks and reduces head seeks by caching the FAT.
Advantages:
Supports random access.
Reduces the impact of bad disk blocks.
Disadvantages:
Increased FAT size with more entries.
Potential for internal fragmentation.
Inode
22
In UNIX-based systems, an inode stores metadata about a file and pointers to its blocks. It
supports direct, single indirect, double indirect, and triple indirect blocks.
Advantages:
Easy file access with metadata and block addresses stored in the inode.
Supports file renaming without losing address.
Disadvantages:
System issues when inodes are fully utilized.
In conclusion, each file allocation method has its own strengths and weaknesses, and the choice
of method depends on the specific requirements of the operating system and applications.
23
Free Space Management Techniques
Linked Allocation: In this technique, each file is represented by a linked list of disk blocks.
When a file is created, the operating system finds enough free space on the disk and links the
blocks of the file to form a chain. This method is simple to implement but can lead to
fragmentation and waste of space.
Contiguous Allocation: In this technique, each file is stored as a contiguous block of disk
space. When a file is created, the operating system finds a contiguous block of free space and
assigns it to the file. This method is efficient as it minimizes fragmentation but suffers from
the problem of external fragmentation.
Indexed Allocation: In this technique, a separate index block is used to store the addresses
of all the disk blocks that make up a file. When a file is created, the operating system creates
an index block and stores the addresses of all the blocks in the file. This method is efficient
in terms of storage space and minimizes fragmentation.
File Allocation Table (FAT): In this technique, the operating system uses a file allocation
table to keep track of the location of each file on the disk. When a file is created, the
operating system updates the file allocation table with the address of the disk blocks that
make up the file. This method is widely used in Microsoft Windows operating systems.
Volume Shadow Copy: This is a technology used in Microsoft Windows operating
systems to create backup copies of files or entire volumes. When a file is modified, the
operating system creates a shadow copy of the file and stores it in a separate location. This
method is useful for data recovery and protection against accidental file deletion.
Overall, free space management is a crucial function of operating systems, as it ensures that
storage devices are utilized efficiently and effectively.
The system keeps tracks of the free disk blocks for allocating space to files when they are
created. Also, to reuse the space released from deleting the files, free space management
becomes crucial. The system maintains a free space list which keeps track of the disk blocks that
are not allocated to some file or directory. The free space list can be implemented mainly as:
1. Bitmap or Bit vector
A Bitmap or Bit Vector is series or collection of bits where each bit corresponds to a disk block.
The bit can take two values: 0 and 1: 0 indicates that the block is free and 1 indicates an
allocated block. The given instance of disk blocks on the disk in Figure 1 (where green blocks
24
are allocated) can be represented by a bitmap of 16 bits as: 1111000111111001.
Advantages:
Simple to understand.
Finding the first free block is efficient. It requires scanning the words (a group of 8 bits) in a
bitmap for a non-zero word. (A 0-valued word has all bits 0). The first free block is then
found by scanning for the first 1 bit in the non-zero word.
Disadvantages:
For finding a free block, Operating System needs to iterate all the blocks which is time
consuming.
The efficiency of this method reduces as the disk size increases.
2. Linked List
In this approach, the free disk blocks are linked together i.e. a free block contains a pointer to the
next free block. The block number of the very first disk block is stored at a separate location on
25
disk and is also cached in memory. In Figure-2,
the free space list head points to Block 5 which points to Block 6, the next free block and so on.
The last free block would contain a null pointer indicating the end of free list. A drawback of this
method is the I/O required for free space list traversal.
Advantages:
The total available space is used efficiently using this method.
Dynamic allocation in Linked List is easy, thus can add the space as per the requirement
dynamically.
Disadvantages:
When the size of Linked List increases, the headache of miniating pointers is also increases.
This method is not efficient during iteration of each block of memory.
Grouping
This approach stores the address of the free blocks in the first free block. The first free block
stores the address of some, say n free blocks. Out of these n blocks, the first n-1 blocks are
actually free and the last block contains the address of next free n blocks. An advantage of this
approach is that the addresses of a group of free disk blocks can be found easily.
Advantage:
Finding free blocks in massive amount can be done easily using this method.
26
Disadvantage:
The only disadvantage is, we need to alter the entire list, if any of the block of the list is
occupied.
Counting
This approach stores the address of the first free disk block and a number n of free contiguous
disk blocks that follow the first block. Every entry in the list would contain:
Address of first free disk block.
A number n.
Advantages:
Using this method, a group of entire free blocks can take place easily and Fastly.
The list formed in this method is especially smaller in size.
Disadvantage:
The first free block in this method, keeps account of other free blocks. Thus, due to that one
block the space requirement is more.
Advantages of Free Space Management Techniques
Efficient Use of Storage Space: Free space management techniques help to optimize the use
of storage space on the hard disk or other secondary storage devices.
Easy to Implement: Some techniques, such as linked allocation, are simple to implement
and require less overhead in terms of processing and memory resources.
Faster Access to Files: Techniques such as contiguous allocation can help to reduce disk
fragmentation and improve access time to files.
Disadvantages of Free Space Management Techniques
Fragmentation: Techniques such as linked allocation can lead to fragmentation of disk
space, which can decrease the efficiency of storage devices.
Overhead: Some techniques, such as indexed allocation, require additional overhead in
terms of memory and processing resources to maintain index blocks.
Limited scalability: Some techniques, such as FAT, have limited scalability in terms of the
number of files that can be stored on the disk.
Risk of data loss: In some cases, such as with contiguous allocation, if a file becomes
corrupted or damaged, it may be difficult to recover the data.
27
Overall, the choice of free space management technique depends on the specific
requirements of the operating system and the storage devices being used. While some
techniques may offer advantages in terms of efficiency and speed, they may also have
limitations and drawbacks that need to be considered.
Mounting is the process by which the operating system adds directories and files from a storage
device to the user's computer file system. This is done by attaching the file system to an empty
directory, known as the mount point. Once mounted, the data on the storage device can be
accessed through the system file manager1.
Terminologies Used in File System Mounting
File System: The method used by the operating system to manage data storage on a storage
device, allowing users to access and organize directories and files efficiently1.
Device Name: An identifier given to a storage partition, such as "D:" in Windows1.
Mount Point: An empty directory where the file system is added during the mounting
process1.
Mounting in Different Operating Systems
Linux/Unix-based OS
In Linux/Unix-based systems, mounting is done using the mount command. For example, to
28
This ensures that the file system is properly detached from the directory1.
Windows OS
In Windows, mounting is typically automatic. When an external storage device is connected,
Windows detects the file system and assigns it a drive letter, such as "E:". Users can then access
the drive through File Explorer1.
Mac OS
Similar to Windows, Mac OS automatically mounts external storage devices, making them
accessible via Finder. Advanced users can also use the diskutil command in Terminal to
The primary purpose of file system mounting is to make files and directories accessible to users.
It allows the operating system to integrate various storage devices seamlessly, providing a
unified view of all available data1.
In Linux, the /etc/fstab file contains information about file systems that should be automatically
mounted at boot time. This file helps in managing persistent mounts across reboots
29
File Sharing in OS
File Sharing in an Operating System(OS) denotes how information and files are shared
between different users, computers, or devices on a network; and files are units of data that are
stored in a computer in the form of documents/images/videos or any others types of information
needed.
For Example: Suppose letting your computer talk to another computer and exchange pictures,
documents, or any useful data. This is generally useful when one wants to work on a project with
others, send files to friends, or simply shift stuff to another device. Our OS provides ways to do
this like email attachments, cloud services, etc. to make the sharing process easier and more
secure.
Now, file sharing is nothing like a magical bridge between Computer A to Computer B allowing
them to swap some files with each other.
30
Primary Terminology Related to File Sharing
Let's see what are the various ways to achieve this, but there are some important terminologies
one should know beforehand. Let's discuss those primary terminologies first:
Folder/Directory: It is basically like a container for all of our files on a computer. The
folder can contain files and even other folders maintaining like hierarchical structure for
organizing data.
Networking: It is involved in connecting computers or devices where we need to share the
resources. Networks can be local (LAN) or global (Internet).
IP Address: It is numerical data given to every connected device on the network
Protocol: It is given as the set of rules which drives the communication between devices on a
network. In the context of file sharing, protocols define how files are transferred between
computers.
File Transfer Protocol (FTP): FTP is a standard network protocol used to transfer files
between a client and a server on a computer network.
Various Ways to Achieve File Sharing
Let's see the various ways through which we can achieve file sharing in an OS.
1. Server Message Block (SMB)
SMB is like a network based file sharing protocol mainly used in windows operating systems. It
allows our computer to share files/printer on a network. SMB is now the standard way for
seamless file transfer method and printer sharing.
Example: Imagine in a company where the employees have to share the files on a particular
project . Here SMB is employed to share files among all the windows based operating
system.orate on projects. SMB/CIFS is employed to share files between Windows-based
computers. Users can access shared folders on a server, create, modify, and delete files.
31
SMB and it's implementation
It is the most common standard protocol for transferring of the files between a client and a server
on a computer network. FTPs supports both uploading and downloading of the files, here we can
download,upload and transfer of files from Computer A to Computer B over the internet or
between computer systems.
Example: Suppose the developer makes changes on the server. Using the FTP protocol, the
developer connects to the server they can update the server with new website content and
updates the existing file over there.
32
Read more about FTP: FTP and it's implementation
These all file sharing methods serves different purpose and needs according to the requirements
and flexibility of the users based on the operating system.
Protection in File System
In computer systems, alot of user’s information is stored, the objective of the operating system
is to keep safe the data of the user from the improper access to the system. Protection can be
provided in number of ways. For a single laptop system, we might provide protection by
locking the computer in a desk drawer or file cabinet. For multi-user systems, different
mechanisms are used for the protection.
33
Types of Access :
The files which have direct access of the any user have the need of protection. The files which
are not accessible to other users doesn’t require any kind of protection. The mechanism of the
protection provide the facility of the controlled access by just limiting the types of access to the
file. Access can be given or not given to any user depends on several factors, one of which is
the type of access required. Several different types of operations can be controlled:
Access Control :
There are different methods used by different users to access any file. The general way of
protection is to associate identity-dependent access with all the files and directories an list
called access-control list (ACL) which specify the names of the users and the types of access
associate with each of the user. The main problem with the access list is their length. If we
want to allow everyone to read a file, we must list all the users with the read access. This
technique has two undesirable consequences:
Constructing such a list may be tedious and unrewarding task, especially if we do not know in
advance the list of the users in the system.
Previously, the entry of the any directory is of the fixed size but now it changes to the variable
size which results in the complicates space management. These problems can be resolved by
use of a condensed version of the access list. To condense the length of the access-control list,
many systems recognize three classification of users in connection with each file:
34
Group – A group is a set of members who has similar needs and they are sharing the same
file.
Universe – In the system, all other users are under the category called universe.
The most common recent approach is to combine access-control lists with the normal general
owner, group, and universe access control scheme. For example: Solaris uses the three
categories of access by default but allows access-control lists to be added to specific files and
directories when more fine-grained access control is desired.
The number of passwords are very large so it is difficult to remember the large passwords.
If one password is used for all the files, then once it is discovered, all files are accessible;
protection is on all-or-none basis.
One of the primary methods of file system protection is through access control. This mechanism
restricts the types of operations that can be performed on files by different users. Access control
can be implemented using an access-control list (ACL), which specifies user names and the
corresponding types of access allowed for each user1.
The types of access that can be controlled include:
Read: Allows reading from a file.
Write: Permits writing or rewriting the file.
Execute: Enables loading and execution of a file.
Append: Allows writing new information at the end of an existing file.
35
Delete: Permits deletion of a file.
List: Enables listing the names and attributes of files.
Additional operations like renaming, editing, and copying can also be controlled through access
control mechanisms.
User Classifications
To streamline the access-control process, systems often recognize three classifications of users in
relation to each file:
Owner: The user who created the file.
Group: A set of users sharing the same file.
Universe: All other users in the system.
This approach is commonly used in conjunction with ACLs to provide a balance between
detailed access control and manageability. For instance, Solaris uses the three categories by
default but allows ACLs to be added to specific files and directories for more granular control1.
Passwords and Protection
Another layer of protection is the use of passwords. Passwords can limit access to files
effectively if they are changed regularly and are not easily guessable. However, this method has
drawbacks, such as the difficulty in remembering multiple complex passwords and the risk of all
files becoming accessible if a single password is compromised1.
Advantages and Disadvantages
The advantages of system protection include ensuring data security, preventing unauthorized
access, and maintaining system integrity. However, implementing system protection can be
complex, potentially slow down system performance, and may lead to compatibility issues with
some applications or hardware2
36
locking the computer in a desk drawer or file cabinet. For multi-user systems, different
mechanisms are used for the protection.
Types of Access :
The files which have direct access of the any user have the need of protection. The files which
are not accessible to other users doesn’t require any kind of protection. The mechanism of the
protection provide the facility of the controlled access by just limiting the types of access to the
file. Access can be given or not given to any user depends on several factors, one of which is
the type of access required. Several different types of operations can be controlled:
Access Control :
There are different methods used by different users to access any file. The general way of
protection is to associate identity-dependent access with all the files and directories an list
called access-control list (ACL) which specify the names of the users and the types of access
associate with each of the user. The main problem with the access list is their length. If we
want to allow everyone to read a file, we must list all the users with the read access. This
technique has two undesirable consequences:
Constructing such a list may be tedious and unrewarding task, especially if we do not know in
advance the list of the users in the system.
Previously, the entry of the any directory is of the fixed size but now it changes to the variable
size which results in the complicates space management. These problems can be resolved by
37
use of a condensed version of the access list. To condense the length of the access-control list,
many systems recognize three classification of users in connection with each file:
The number of passwords are very large so it is difficult to remember the large passwords.
If one password is used for all the files, then once it is discovered, all files are accessible;
protection is on all-or-none basis.
The domain of protection refers to the set of resources that are controlled by a particular
protection mechanism. In an OS, a domain can be defined as a set of objects (resources like files,
memory, and I/O devices) that are accessed by a set of subjects (entities like processes, users,
and groups). Each domain has specific rules that govern access to its objects by its subjects1.
38
Protection is essential in a multiuser environment where multiple users share computer resources
such as CPU and memory. It ensures that each process can only access the resources necessary to
fulfill its task, thereby preventing unauthorized access and potential security breaches2.
Components of Domain of Protection
1. Objects and Operations: Each domain consists of a set of objects and the operations that can
be performed on them. For example, a domain element can be described as <object, {set of
domains1.
2. Process and Procedure Association: A domain can consist of a process, procedure, or user.
If a domain corresponds to a procedure, changing the domain would mean changing the
procedure ID. Processes can switch from one domain to another if they have the necessary
access rights1.
3. Fixed and Dynamic Association: Fixed Association: All access rights are given to processes
at the beginning, but this can lead to excessive access rights for domain switching. Therefore,
dynamic methods are often used to change the contents of the domain^2^. Dynamic
Association: Processes can switch dynamically, creating new domains as needed^2^.
Examples of Domains of Protection
39
1. Complexity of Modern Operating Systems: As OSes become more complex, identifying
and securing all potential vulnerabilities becomes more challenging. Continuous monitoring
and updating of security measures are required to stay ahead of emerging threats3.
2. Trade-off Between Security and Usability: Protection mechanisms can make it more
difficult for users to access the resources they need, creating a balance between security and
usability3.
3. Overhead and Complexity: Protection mechanisms can introduce additional overhead and
complexity, impacting system performance and resource utilization3.
In conclusion, the domain of protection is a fundamental concept in OS protection, ensuring that
resources are accessed according to defined policies and preventing unauthorized access. It
involves various mechanisms like memory protection, process isolation, and privilege levels,
each playing a crucial role in maintaining system security and reliability
40
F1 F2 F3 Printer
D1 read read
D2 print
D3 read execute
41
F1 F2 F3 Printer D1 D2 D3 D4
D3 read execute
According to the above matrix, a process executing in domain D2 can switch to domain D3 and
D4. A process executing in domain D4 can switch to domain D1 and process executing in
domain D1 can switch to domain D2.
Implementations
There are various methods of implementing the access matrix in the operating system such as.
1. Global Table
2. Access Lists for Objects
3. Capability Lists for Domains
Global Table:
A single table with rows and columns, where rows represents subjects and columns represents
objects. Each cell of the global table contains the access for the subject-object pair.
Example
class AccessMatrix:
def __init__(self, subjects, objects):
self.subjects = subjects
self.objects = objects
self.matrix = {subject: {obj: set() for obj in objects} for subject in subjects}
42
self.matrix[subject][obj].add(right)
# Example usage
subjects = ['user1', 'user2']
objects = ['file1', 'file2']
am = AccessMatrix(subjects, objects)
am.set_permission('user1', 'file1', 'read')
print(am.check_permission('user1', 'file1', 'read')) # Output: True
print(am.check_permission('user2', 'file1', 'read')) # Output: False
43
def check_permission(self, obj, subject, right):
return right in self.acl.get(obj, {}).get(subject, set())
# Example usage
acl = ACL()
acl.add_object('file1')
acl.set_permission('file1', 'user1', 'read')
print(acl.check_permission('file1', 'user1', 'read')) # Output: True
print(acl.check_permission('file1', 'user2', 'read')) # Output: False
44
# Example usage
cap = Capability()
cap.add_subject('user1')
cap.add_capability('user1', 'file1', 'read')
print(cap.check_capability('user1', 'file1', 'read')) # Output: True
print(cap.check_capability('user2', 'file1', 'read')) # Output: False
45