1. File Concepts
A file is a collection of related information stored on secondary storage. It has attributes such as:
 Name: Human-readable identifier.
 Type: Format (e.g., .txt, .exe, .jpg).
 Location: Address on storage.
 Size: Current file size in bytes.
 Protection: Permissions (read/write/execute).
 Time, date, and user information: Metadata for security and tracking.
File Types
 Regular Files: User data (text, binary, multimedia, etc.).
 Directories: Contain file and directory entries.
 Special Files: System-related files (device drivers, pipes, etc.).
2. Access Methods
Different ways to read/write files:
1. Sequential Access
o Data is read in order.
o Common in text files.
2. Direct (Random) Access
o Jump to any part of the file.
o Used in databases and executable files.
3. Indexed Access
o Index table stores pointers to file blocks.
o Efficient for large files with random access needs.
3. Directory and Disk Structure
The directory structure organizes files on disk.
Directory Structures
1. Single-Level Directory
o Simple but all files are in one directory, leading to name conflicts.
2. Two-Level Directory
o Separate directories for each user.
3. Tree-Structured Directory
o Hierarchical structure with subdirectories.
4. Acyclic Graph Directory
o Allows shared directories.
5. General Graph Directory
o Allows cycles (must handle links carefully).
Disk Structure
 Boot Block: Contains boot loader.
 Superblock: Holds file system metadata.
 File Control Block (FCB): Stores file details.
 Data Blocks: Hold file content.
4. File System Mounting
 A file system must be mounted before use.
 Mount Point: Directory where another file system is attached.
 Ensures proper access permissions and consistency.
5. File Sharing
Types of File Sharing
 Local Sharing: Among users on the same system.
 Remote Sharing: Across networks (NFS, SMB).
 Access Control: Permissions define who can read/write.
File Locking
 Shared Lock: Multiple processes can read.
 Exclusive Lock: Only one process can write.
6. Protection
Prevents unauthorized access to files.
Access Control Methods
1. Access Control Lists (ACLs)
o Lists users/groups with specific permissions.
2. Unix-style Protection Bits
o Owner-Group-World permissions (rwxr-x--x).
3. Role-Based Access Control (RBAC)
o Access based on user roles.
7. Directory Implementation
Data Structures for Directories
1. Linear List
o Simple but slow searching.
2. Hash Table
o Faster lookup but more complex management.
8. Allocation Methods
Determines how files are stored on disk.
1. Contiguous Allocation
o Files occupy consecutive blocks.
o Fast but causes fragmentation.
2. Linked Allocation
o Each file block points to the next.
o No fragmentation, but slow access.
3. Indexed Allocation
o Index block holds pointers to file blocks.
o Fast random access.
9. Free-Space Management
Manages available disk space.
1. Bit Vector
o Bitmap indicating free/used blocks.
2. Linked List
o Free blocks linked together.
3. Grouping
o Lists free blocks in groups for efficiency.
4. Counting
o Stores contiguous free block count.

File Management in Operating System.docx

  • 1.
    1. File Concepts Afile is a collection of related information stored on secondary storage. It has attributes such as:  Name: Human-readable identifier.  Type: Format (e.g., .txt, .exe, .jpg).  Location: Address on storage.  Size: Current file size in bytes.  Protection: Permissions (read/write/execute).  Time, date, and user information: Metadata for security and tracking. File Types  Regular Files: User data (text, binary, multimedia, etc.).  Directories: Contain file and directory entries.  Special Files: System-related files (device drivers, pipes, etc.). 2. Access Methods Different ways to read/write files: 1. Sequential Access o Data is read in order. o Common in text files. 2. Direct (Random) Access o Jump to any part of the file. o Used in databases and executable files. 3. Indexed Access o Index table stores pointers to file blocks. o Efficient for large files with random access needs.
  • 2.
    3. Directory andDisk Structure The directory structure organizes files on disk. Directory Structures 1. Single-Level Directory o Simple but all files are in one directory, leading to name conflicts. 2. Two-Level Directory o Separate directories for each user. 3. Tree-Structured Directory o Hierarchical structure with subdirectories. 4. Acyclic Graph Directory o Allows shared directories. 5. General Graph Directory o Allows cycles (must handle links carefully). Disk Structure  Boot Block: Contains boot loader.  Superblock: Holds file system metadata.  File Control Block (FCB): Stores file details.  Data Blocks: Hold file content. 4. File System Mounting  A file system must be mounted before use.  Mount Point: Directory where another file system is attached.  Ensures proper access permissions and consistency.
  • 3.
    5. File Sharing Typesof File Sharing  Local Sharing: Among users on the same system.  Remote Sharing: Across networks (NFS, SMB).  Access Control: Permissions define who can read/write. File Locking  Shared Lock: Multiple processes can read.  Exclusive Lock: Only one process can write. 6. Protection Prevents unauthorized access to files. Access Control Methods 1. Access Control Lists (ACLs) o Lists users/groups with specific permissions. 2. Unix-style Protection Bits o Owner-Group-World permissions (rwxr-x--x). 3. Role-Based Access Control (RBAC) o Access based on user roles. 7. Directory Implementation
  • 4.
    Data Structures forDirectories 1. Linear List o Simple but slow searching. 2. Hash Table o Faster lookup but more complex management. 8. Allocation Methods Determines how files are stored on disk. 1. Contiguous Allocation o Files occupy consecutive blocks. o Fast but causes fragmentation. 2. Linked Allocation o Each file block points to the next. o No fragmentation, but slow access. 3. Indexed Allocation o Index block holds pointers to file blocks. o Fast random access. 9. Free-Space Management Manages available disk space. 1. Bit Vector o Bitmap indicating free/used blocks. 2. Linked List o Free blocks linked together.
  • 5.
    3. Grouping o Listsfree blocks in groups for efficiency. 4. Counting o Stores contiguous free block count.