1 1. Introduction .....................................................................................................1 2. Hard Disk Structure ........................................................................................3 2.1 Physical Disk Access: Cylinders, Heads and Sectors .................................3 2.2 Hard Disk Partitions and Logical Sectors ....................................................4 3. The Second Extended File System................................................................6 3.1 A Brief History of Linux Filesystems ............................................................6 3.2 Common File System Concepts ..................................................................7 3.2.1 Blocks ...................................................................................................7 3.2.2 Inodes ...................................................................................................8 3.2.3 Directories.............................................................................................8 3.3 The Structure of the Second Extended File System....................................9 3.3.1 Block Groups: The Building Blocks of the Filesystem.........................10 3.3.2 The Superblock...................................................................................12 3.3.3 The Group Descriptors........................................................................14 3.3.4 The Block and Inode Bitmaps .............................................................15 3.3.5 Inodes .................................................................................................16 3.3.6 Directories...........................................................................................19 3.3.7 How the Second Extended Filesystem Works: A Mini Case Study.....20 4. Ext2lib Design ...............................................................................................21 4.1 The Multi-layer Design of Ext2lib ...............................................................21 4.2 Layer 0 - The Hardware Access Layer ......................................................21 4.3 Layer 1 - The Ext2 Translation Layer ........................................................23 4.3.1 A Mini-case study: Obtaining a Directory Listing.................................24 4.4 Layer 2 - The Application Interface Layer..................................................26 4.4.1 The part command..............................................................................26 4.4.2 The mount command..........................................................................26 4.4.3 The ls command .................................................................................27 4.4.4 The cd command ................................................................................27 4.4.5 The cp command ................................................................................27 4.4.6 The get inode command .....................................................................28 5. Ext2lib Implementation.................................................................................29 5.1 The Structure of the Source Code.............................................................29 5.2 The implementation of layer 0: The Hardware access layer......................30 5.3 Non-DOS Hard Disk Access Under MS-DOS: BIOS Disk Functions.........30 5.4 Using Interrupt 0x13 Under MS Windows 95: DPMI..................................31 5.5 Layer 0: The SimulateRMInt Function .......................................................32 5.6 Layer 0: The ReadPhysicalSector Function ..............................................33 5.7 Layer 0: The GetDiskParams Function......................................................34 5.8 Layer 0: The ReadPartInfo Function .........................................................35 5.9 Layer 0: The GetPartTable Function .........................................................37 5.10 Layer 0: The ReadLogicalSector Function ..............................................38 5.11 Layer 1: The ReadBlock Function ...........................................................38 5.11.1 The Read-Ahead Cache ...................................................................39 5.11.2 The FIFO Cache ...............................................................................39 5.12 Layer 1: The ReadSuperBlock and GetSuperBlock Functions................40 5.13 Layer 1: The ReadGroupDesc and GetGroupDesc Functions ................41