Unit6 - File System Interface
Unit6 - File System Interface
Information management :
•Files Concept and Systems
– Linked Allocation
– Indexed Allocation
•Free-Space Management
•Directory structures
•Directory implementation
– linear list
– hash table
Information management
4. Delete
5. Truncate
File Types – Name, Extension
Criteria for File Organization
1. Economy of Storage
2. Simple
3. Maintenance
4. Reliability
File System
• It is a part of OS, responsible for controlling secondary
storage space.
read next: reads a portion of the file (read record) and automatically
updates pointer. (move pointer to next location)
write next: Append to end of the file (write and update the pointer)
read n
write n
position to n (jump to record n)
read next
write next
• To find the record in the file, search the index and then use the
pointer to access the file directly and to find the desired record.
13
File Management
Allocation methods
Contiguous Allocation
Linked Allocation
Indexed Allocation
Free-Space Management
Allocation Methods
• It is the mechanism of keeping track of which disk blocks
go which files
• It is easy to implement
Drawback
• It is efficient for sequential access files
• To find ith block of a file, we must start at the beginning of
that file and follow the pointers until we go to ith block.
• Requires extra space for pointers
• Bring all the pointers together into one location : Index Block
• Each ith entry in index block points to ith block of the file
• Disadvantages:
– If index block is small, it will not be able to hold enough
pointers
– Entire index will have to be kept in main memory to
make it work
Indexed Allocation
Approaches to implement Index Block
• For large files several indexes can be combined and
maintained.
• Multi-Level Index -
• (number of bits per word) x (number of 0-value words) + offset of first 1 bit.
Linked List
Linked List
• Linked list of all the free blocks is maintained
• First free block in the list can be pointed by the head
pointer
– Linked Allocation
– Indexed Allocation
•Free-Space Management
•Directory structures
•Directory implementation
– linear list
Directory Structure
• A collection of nodes containing information about all files.
Directory
Files
F1 F2 F4
F3
Fn
Operations:
• Search for a file
• Create a file
• Delete a file
• List a directory
• Rename a file
• Traverse the file system : Search all directories/ sub directories
and files
Directory Schemes
1. Single Level Directory
One directory many files
Single-Level Directory
• UFDs have the similar structure, but each lists files of a single user.
Tree Structure
• Users can create their sub directories to manage the files.
• Three has Root directory and files have unique file names
Acyclic-Graph Directories
• Multiple users can Have shared subdirectories and files
• Users have their own working directory and may have
one shared directory
• Shared subdirectory created by one user in one directory is
automatically visible to all users sharing that directory.
• Shared directory or file may exist at multiple places
simultaneously
• Because of sharing, a file may have multiple absolute
paths
• So different names can refer to same file
Acyclic-Graph Directories
• These kind of directory graphs can be made using links.
• Links can either be symbolic (logical) or hard link
(physical).
• If a file gets deleted then,
– In case of soft link , the file just gets deleted, and we are left with a
dangling pointers.
– In case of hard link, the actual file will be deleted only if all the
references to it gets deleted.
Acyclic-Graph Directories
General Graph Directories
• Disadvantages:
• It is more costly than others.
• It needs garbage collection.
General Graph Directories
• There can be cycle in the directory arrangement
• Two methods
1. Linear List
2. Hash Table
Directory Implementation
1. Linear List
•This approach uses hash table along with the linked lists.
•This approach uses hash table along with the linked lists.
•Only hash table entries are checked using the key and if an
entry found then the corresponding file will be fetched using
the value.