File Systems in Operating Systems

File Systems का परिचय

File System Operating System का एक महत्वपूर्ण component है जो data को organize और manage करता है। यह users को files और directories के साथ work करने की सुविधा प्रदान करता है।

File System क्या है?

File System वह mechanism है जो:

  • Data को organize करता है
  • Files और directories को manage करता है
  • Data access और storage को control करता है
  • Data protection और security को ensure करता है
File System Structure Diagram

Figure 1: File System Structure

File Organization

Files को organize करने के विभिन्न तरीके हैं:

  • Sequential Organization: Data को sequential order में store करना
  • Indexed Organization: Index के through data access
  • Direct Organization: Random access to data
  • Linked Organization: Data blocks को link करना

File Organization Methods:

  • Single-level Directory: सभी files एक directory में
  • Two-level Directory: User-specific directories
  • Tree-structured Directory: Hierarchical organization
  • Acyclic Graph Directory: Shared subdirectories

File Operations

File System में basic operations:

// File Operations Example
FILE* file = fopen("example.txt", "r");  // Open file
if (file != NULL) {
    char buffer[100];
    fread(buffer, 1, 100, file);  // Read data
    fwrite(buffer, 1, 100, file); // Write data
    fclose(file);  // Close file
}
                    

Basic File Operations:

  • Create: नई file बनाना
  • Delete: File को delete करना
  • Open: File को access के लिए open करना
  • Close: File को close करना
  • Read: File से data read करना
  • Write: File में data write करना

File Protection

File Protection mechanisms files को unauthorized access से बचाते हैं:

Protection Methods:

  • Access Control Lists (ACL): User-specific permissions
  • Capability Lists: Process-specific permissions
  • Password Protection: File-level security
  • Encryption: Data security

File Access Rights:

  • Read (R): File को read करने का अधिकार
  • Write (W): File में changes करने का अधिकार
  • Execute (X): File को execute करने का अधिकार
  • Delete (D): File को delete करने का अधिकार

व्यावहारिक Examples

File System के कुछ practical examples:

// File System Operations in C
#include 

int main() {
    // Create a new file
    FILE* file = fopen("data.txt", "w");
    if (file != NULL) {
        // Write data to file
        fprintf(file, "Hello, File System!");
        fclose(file);
    }

    // Read from file
    file = fopen("data.txt", "r");
    if (file != NULL) {
        char buffer[100];
        fgets(buffer, 100, file);
        printf("Read: %s\n", buffer);
        fclose(file);
    }
    return 0;
}
                    

File System के महत्वपूर्ण concepts:

  • File Allocation: Contiguous, Linked, Indexed
  • Free Space Management: Bit Vector, Linked List
  • File Recovery: Backup और recovery mechanisms
  • File System Types: FAT, NTFS, ext4, etc.