CONTENTS xxi
Homework (Simulation) . . . . . . . . . . . . . . . . . . . . . . . 466
39 Interlude: Files and Directories 467
39.1 Files And Directories . . . . . . . . . . . . . . . . . . . . . . 467
39.2 The File System Interface . . . . . . . . . . . . . . . . . . . 469
39.3 Creating Files . . . . . . . . . . . . . . . . . . . . . . . . . . 469
39.4 Reading And Writing Files . . . . . . . . . . . . . . . . . . 470
39.5 Reading And Writing, But Not Sequentially . . . . . . . . . 472
39.6 Shared File Table Entries: fork() And dup() .......475
39.7 Writing Immediately With fsync() .............477
39.8 Renaming Files . . . . . . . . . . . . . . . . . . . . . . . . . 478
39.9 Getting Information About Files . . . . . . . . . . . . . . . 479
39.10 Removing Files . . . . . . . . . . . . . . . . . . . . . . . . . 480
39.11 Making Directories . . . . . . . . . . . . . . . . . . . . . . . 480
39.12 Reading Directories . . . . . . . . . . . . . . . . . . . . . . 481
39.13 Deleting Directories . . . . . . . . . . . . . . . . . . . . . . 482
39.14 Hard Links . . . . . . . . . . . . . . . . . . . . . . . . . . . 482
39.15 Symbolic Links . . . . . . . . . . . . . . . . . . . . . . . . . 484
39.16 Permission Bits And Access Control Lists . . . . . . . . . . 485
39.17 Making And Mounting A File System . . . . . . . . . . . . 488
39.18 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . 490
References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 491
Homework (Code) . . . . . . . . . . . . . . . . . . . . . . . . . . . 492
40 File System Implementation 493
40.1 The Way To Think . . . . . . . . . . . . . . . . . . . . . . . 493
40.2 Overall Organization . . . . . . . . . . . . . . . . . . . . . . 494
40.3 File Organization: The Inode . . . . . . . . . . . . . . . . . 496
40.4 Directory Organization . . . . . . . . . . . . . . . . . . . . 501
40.5 Free Space Management . . . . . . . . . . . . . . . . . . . . 501
40.6 Access Paths: Reading and Writing . . . . . . . . . . . . . . 502
40.7 Caching and Buffering . . . . . . . . . . . . . . . . . . . . . 506
40.8 Summar y . . . . . . . . . . . . . . . . . . . . . . . . . . . . 508
References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 509
Homework (Simulation) . . . . . . . . . . . . . . . . . . . . . . . 510
41 Locality and The Fast File System 511
41.1 The Problem: Poor Performance . . . . . . . . . . . . . . . 511
41.2 FFS: Disk Awareness Is The Solution . . . . . . . . . . . . . 513
41.3 Organizing Structure: T he Cylinder Group . . . . . . . . . 513
41.4 Policies: How To Allocate Files and Directories . . . . . . . 515
41.5 Measuring File Locality . . . . . . . . . . . . . . . . . . . . 517
41.6 The Large-File Exception . . . . . . . . . . . . . . . . . . . 518
41.7 A Few Other Things About FFS . . . . . . . . . . . . . . . . 520
41.8 Summar y . . . . . . . . . . . . . . . . . . . . . . . . . . . . 522
References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 523
Homework (Simulation) . . . . . . . . . . . . . . . . . . . . . . . 524
c
2008–18, ARPACI-DUSSEAU
THREE
EASY
PIECES