4.3  1 , , ; - . - , - , , . - , - ("/") . - , , , - , . V UNIX 14 ; , 2 , , - 16 . +-----------------------------------------------+ | | | (2 ) | +--------------------+---------------+----------+ | 0 | 83 | . | | 16 | 2 | .. | | 32 | 1798 | init | | 48 | 1276 | fsck | | 64 | 85 | clri | | 80 | 1268 | motd | | 96 | 1799 | mount | | 112 | 88 | mknod | | 128 | 2114 | passwd | | 144 | 1717 | umount | | 160 | 1851 | checklist| | 176 | 92 | fsdbld | | 192 | 84 | config | | 208 | 1432 | getty | | 224 | 0 | crash | | 240 | 95 | mkfs | | 256 | 188 | inittab | +--------------------+---------------+----------+ 4.10. /etc 4.10 "etc". , ("." "..") - - , . "." "/etc" 0 83. ".." 16 2. , 0. , - 224 "/etc" , , - - "crash". mkfs - , "." ".." - . , - , . , 70 , - , - . : ; - ( - creat, mknod, link unlink), ; ( "" ). 4.6 . 4.4 ( )   ( ), open, chdir ( ) link. - , - , , - . namei - , ( 4.11). 2 , ( ); , - , . - , , . , (. - 5.10). , - chdir ( ). , , , . , - . , (**). namei - ; . , , . - . , , , , . ( ). - - , . , . , - , - . ( 0), - bmap , bread. - --------------------------------------- (**) , - chroot. - . 71 +------------------------------------------------------------+ | namei /* */| | : | | : | | { | | ( ) | | = ( iget); | | | | = | | ( iget); | | | | ( ) | | { | | ; | | | | ; | | ( - | | "..") | | ; /* */| | ( ), - | | bmap, bread brelse; | | ( | | ( )) | | { | | -| | ; | | ( iput); | | = | | ( iget); | | } | | /* | | */ | | ( ); | | } | | ( ); | | } | +------------------------------------------------------------+ 4.11. , - . , ( brelse) ( iput), - ( iget). . , , - , ( bmap) . , , , - . , , "/etc/ passwd". , ("/") . , "etc". ("/") - , "etc". , 72 "etc". , - , ( iput), "etc" ( iget) - . , "etc" , , , "etc" , "passwd". 4.10, , "passwd" - . , , - "etc", "passwd", - - - . , . (. [Ritchie 78b], .1968), , - . , UNIX , - , . - , , , . 4.5  , - , - , . - , . , . : * , * , * , , * , * , * , * , * , * , * , , . , , . , , , - , . 4.6  , , - ( ), - iget. namei, , , . , ialloc, . 2, . , - . , . , , 73 (, ) . - . 4.12 ialloc . , , , - - - +------------------------------------------------------------+ | ialloc /* */ | | : | | : | | { | | | | { | | ( ) | | { | | ( ); | | ; /* */ | | } | | ( ) | | { | | ; | | | | ; | | , | | , - | | ( bread | | brelse); | | ; | | ( -| | ); | | ( ) | | ( ); | | - | | - | | ; | | } | | /* */ | | - | | ; | | ( iget); | | ( ) /* !!! */| | { | | ; | | ( iput); | | ; /* */ | | } | | /* */ | | ; | | ; | | - | | ; | | (); | | } | | } | +------------------------------------------------------------+ 4.12. 74 . , , , iget ( , ), , . - , , . , . , - , . , , - , - , - . , , . - , 2, : - , . , . - , , . ""; , . , , , , , - . - . , , - , . ( 4.13). - 4.13() , - 18 48. 4.13(), , , , 470, - . - +---------------------+------+------+-------------------+ | | | | | |<>| 83 | 48 |<>| +---------------------+------+------+-------------------+ 18 19 20 1 ^ | +---------------------+------+------+-------------------+ | | | | | |<>| 83 | <|>| +---------------------+------+------+-------------------+ 18 19 20 1 ^ | () 75 +------+------------------------------------------------+ | 470 | | |<|>| +------+------------------------------------------------+ 0  1 ^  | ( )   +------+------------------------------+-----+-----+-----+ | 535 | | 476 | 475 | 471 | |<||||>| +------+------------------------------+-----+-----+-----+ 0 48 49 50 ^ | () , - 4.13. , . ( 471 ) - . +------------------------------------------------------------+ | ifree /* */ | | : | | : | | { | | 1 | | ; | | ( ) | | ; | | ( ) | | { | | ( , - | | ) | | | | ; | | } | | | | ; | | ; | | } | +------------------------------------------------------------+ 4.14. . , - . , , - , : - , - 76 . , , , - . , - . - . , , . , , . - , , , . , - +------+------------------------------+-----+-----+-----+ | 535 | | 476 | 475 | 471 | |<||||>| +------+------------------------------+-----+-----+-----+ 0 ^ 48 49 50 | ^ | () - +------+------------------------------+-----+-----+-----+ | 499 | | 476 | 475 | 471 | |<||||>| +------+------------------------------+-----+-----+-----+ 0 ^ 48 49 50 | ^ | () 499 +------+------------------------------+-----+-----+-----+ | 499 | | 476 | 475 | 471 | |<||||>| +------+------------------------------+-----+-----+-----+ 0 ^ 48 49 50 | ^ | () 601 4.15. - , , . . ( 4.13()), , . ( 4.15), - , - . , 4.15(), 499, 535 . 601, . - 77 , , , 499, 535 601. A B C +------------------------------------------------------------ | I - - | - - | - - | - - | - - | () - - | - - - | - - | - - | - - | - () - | - - | - - | - - - | - , - - | - I - | - () - | - - - | I - - | - - | - - | - - - | - , - | - - | - () - | - - - | - - I | - - | - - | - - I - | - - ! | - - | - - | - - () | - - v 4.16. . - , . , , . , - ( 4.16 4.17). , A, B C, , A (***), I, , - . iget ( --------------------------------------- (***) , "" ", ". 78 | | +---+---+---+--------------------------------+ | () | | | | | | | | | I | ------------------------------ | | | | | | | | +---+---+---+--------------------------------+ | +--------------------------------------------+ | () | | | | ----------------------------- | | | | | +--------------------------------------------+ | +---+---+---+--------------------+---+---+---+ | () | | | | | | | | | | | | | | J | I | K | | | --|---|---|--------------------|---|---|-- | | +---+---+---+--------------------+---+---+---+ | +---+---+---+--------------------+---+---+---+ | () | | | | | | | | | | | | | | J | I | | | | --|---|---|--------------------|---|---| | | +---+---+---+--------------------+---+---+---+ | +---+---+---+----------------+---+---+---+---+ | () | | | | | | | | | | | | | | | L | | | | | | --|---|---|----------------|---| | | | | +---+---+---+----------------+---+---+---+---+ v 4.17. () ialloc) bread ( iget) A - . , A , B , , . B , , , A. , B I , A , , - . B, , , - () , . , I - . A , I. , C I . - , , . , , , . ialloc , , . . , , , , -. , - , . . , - . , , , 79 . , , , , - , . - . , , . - . 4.7  , . , - . mkfs ("make file system" - - ) - , , - , . ( alloc, - 4.19), , - . , , . , , , . , - . (- ). . , . , , - +-----+-----+-----+-----+---------------------+ | 109 | 106 | 103 | 100 | ------------------- | +--+--+-----+-----+-----+---------------------+ +-----+ | 109 | +-----+-----+-----+-----+---------------+-----+ +->| 211 | 208 | 205 | 202 | ------------- | 112 | +--+--+-----+-----+-----+---------------+-----+ +-----+ | 211 | +-----+-----+-----+-----+---------------+-----+ +->| 310 | 307 | 304 | 301 | ------------- | 214 | +--+--+-----+-----+-----+---------------+-----+ +-----+ | 310 | +-----+-----+-----+-----+---------------+-----+ +->| 409 | 406 | 403 | 400 | | 313 | +--+--+-----+-----+-----+---------------+-----+ | v 4.18. 80 . mkfs - , - , , . - , . 4.18 , . , , , . - . free - . , - . , , , ; . . - . 4.20 alloc free , - . 949 . . , 109 . - , , 109, . +------------------------------------------------------------+ | alloc /* */ | | : | | : | | { | | ( ) | | ( , | | ); | |