Unit-5 Notes-Part-1
Unit-5 Notes-Part-1
Disk Management
n Disk Formatting
n Boot Block
n Bad Blocks
Swap-Space Management
File Concept
OS provides a uniform logical view (file) of various information storage devices by abstracting from
the physical properties of storage devices
A file is a collection of related information that is recorded on secondary storage
Types of file
Data
Numeric, alphabetic, alphanumeric, or binary
Program
Source, object, executable
File Structure
None - sequence of words, bytes such as text file
Simple record structure
Lines
Fixed length record
Variable length record
Complex structures
Formatted document (e.g. html)
Relocatable load file (e.g. object file)
Can simulate last two with first method by inserting appropriate control characters
File Attributes
� A file has several attributes: (vary from one OS to another)
Name – only information kept in human-readable form
Identifier – unique tag (number) identifies file within file system
Type – needed for systems that support different types
Location – pointer to file location on device
Size – current file size
� Protection – controls who can do reading, writing, executing
� Time, date, and user identification – data for protection, security,
and usage monitoring
Information about files are kept in the directory structure, which is maintained on the disk
File Operations
� OS provides various system calls for file operations
� For example:
Create
Write
Read
Reposition within file – file seek
Delete
Truncate
Open(Fi) – search the directory structure on disk for entry Fi, and
move the content of entry to memory
Close (Fi) – move the content of entry Fi in memory to directory
Access Methods
Sequential Access: information in the file is processed in order
o read next-reads the next portion of the file and�automatically�advances�a�file�pointer
o write next – appends to the end of the file and advances to the end of the newly written
material�(the�new�end�of�file).�
o reset- file can be reset to the beginning, and on some systems, a program may be able to
skip forward or backward n records
read next
write next
reset
skip forward or backward n records
Direct Access: allow arbitrary blocks to be read or written
read n (n = relative block number)
write n
position to n
read next
write next
rewrite n
Simulation of Sequential Access on a Direct-access File
Directory Structure
Information in a Directory
Name
Type
Address
Current length
Maximum length
Date last accessed
Date last updated
Owner ID
Protection information
Operations Performed on a Directory
Search for a file
Create a file
Delete a file
List a directory
Rename a file
Traverse the file system
How to Organize a Directory?
Issues
Efficiency – locating a file quickly
Naming – convenient to users
Two users can have same name for different files
The same file can have several different names
Grouping – logical grouping of files by properties (e.g. all Java programs,�all�games,�…)
Schemes for defining the logical structure of a directory:
Single level directory
Two level directory
Tree structured directory
Acyclic graph directory
General graph directory
Single-Level Directory
A single directory for all users; easy to support and understand
Problems
Naming problem: all files must have unique names
Grouping problem
Two-Level Directory
As, a single-level directory often leads to confusion of file names among different users.
The standard solution is to create a separate directory for each user.
In the two-level directory structure, each user has own user file directory (UFD).
The U F D s have similar structures, but each lists only the files of a single user. When a
user job starts or a user logs in, the system’s master file directory ( M F D ) is
searched.
When a user refers to a particular file, only his own U F D is searched.
Thus, different users may have files with the same name, as long as all the file names
within each U F D are unique.
To create a file for a user, the operating system searches only that user’s U F D to
ascertain whether another file of that name exists.
To delete a file, the operating system confines its search to the local U F D ; thus, it cannot
accidentally delete another user’s file that has the same name.
Acyclic-Graph Directories
Have shared subdirectories and files using acyclic graph
With a shared file only one actual file exists, so any changes made by one person are immediately
visible to the other
Deletion:
o The deletion of a link does not need to affect the original file; only the link is removed.
o Another approach to deletion is to preserve the file until all references to it are deleted.
o Another approach keep a count of the number of references.
o When count=0, file is deleted.
File Sharing
Sharing of files on multi-user systems is desirable
Sharing may be done through a protection scheme
On distributed systems, files may be shared across a network
Network File System (NFS) is a common distributed file-sharing method
File Protection
File owner/creator should be able to control:
what can be done
by whom
Types of access
Read
Write
Execute
Append
Delete
List
Access Control List
Various users may need different types of access to a file or directory
The most general scheme is to associate with each file and directory an access-control list (ACL)
specifying the user name and the types of access allowed for each user
Advantages
Enable complex access methodology
Disadvantages
Constructing such a list may be a tedious and unrewarding task, especially if we do
not know in advance the list of users in the system
The directory entry, previously of fixed size, now needs to be of variable size,
resulting in more complicated space management