. , setuid- ( mkdir) , . , - , - ; , - ( ) . 391 open , - , , -, . read write , , , . - , . , , , , : . , . - , , - , , , - . . , - , - , , . , , - (/), , - , . - - , . chroot , ; , , . fork, - . - -- . - fork, - ; - -, . fork - . , - , ( exit), , . exec exit - . Newcastle , "" ( ), . , . , - . - , - ; - . - - , - . - , - , . - , . , , - , ; - . - 392 , . 13.3 ""  " " , , , , , , , , - . , , , : - . , 13.10, "/usr/src", B, "" "/usr/src", A. - , , "/usr/src". , A, , - B, (- : "/usr/src/cmd/login.c"), , . , B, - ( , - A), , , - , A. , , , , - , . A B +-----------------------------+ +-----------------------------+ | / | | / | | | | | | | | +--------+--------+ | | +-----------+-----------+ | | | | | | | | | | | bin usr | | usr bin etc | | | | | | | | | +----+----+ +----+--+ | | +-------+ | | | | | | | | | | | |login mail bin src| +--->src bin | | | | | | | | | | +---+---+ | | | | +------+-----+ | | | | | | | | | | | | | troff vi | | | | lib cmd uts | | | | | | | | | | | | | +---+---+ | | | | | | | | | | | | | | login.c mail.c | +---------------------------|-+ | +-----------------------------+ +---+ 13.10. - mount . . mount, 393 , . , "..". - , - ".." , , - . 13.10, , , - A, "/usr/src/cmd", , cd ../../.. , A, - B. namei, , - "..", , - -, , - . : . - , , , , , - . , 5. , , - , - - . , , , .. - , - () - (. [Sandberg 85]). (/) +--------------------+ +----------------------------------------+ | | | | | +-------+ | | - | | +-----+ ||-| | +-----+ +-----+ - | | | | +-+-----+ |- | | | | | | | +-----+ | | - +-----+ +-----+ - +-------+| | | | | +------+- -+-+ | | +--+|| | +-----+ | | | | +-----+ | +-----+ | +-------+| | | | | | | | | | +-+- -++ +-----+ | | | +-----+ | | | | +-----+ +-----+| | | | | | | | | | | | | | | || +-----+ | | | +-----+ | | | | +-----+ +-----++-+- -+-+ | | | --+----+-----+ | | | | | | +-----+ | | +-----+ | | +-----+ +-----+ | | | | | | +-----+ | +--------------------+ +----------------------------------------+ 13.11. , "/usr/src/cmd/login.c", "src" - . - ( namei-iget), , , , , - . , - 394 , . - ( , - ), . open , 5, , . open 13.11. read, - , , , , - . , - ( ) . , , . - read "", - . - ( ), , , , . ( ) , , , . - . - , . , , "core" ( 7). , , , - . open , - , , - , , - . "/usr/src/cmd/login.c" "cmd/login.c". , - , - . , open, - , - . , - , , , - , ( 13.11). , (- ) , , , , . , - - . , ( ), - , , - . - 395 , - . , , . 13.4  (-) "- " , -- , . - (. [Sandberg 85] [Cole 85]). () - -, - . - . , . , - - , : , , .. - - . , . , , . , (, read) , , - , - : , - .. - -, , , - - . - , - , - . - . , , . , , , - , - . , . , , - , - , . , - . , - - . , - -. , - , - , , , . , (, - 396 ), , . , . , -. , - , 13.14. , - -, , - - -. +------------------------------+ | | | | +------------------------------+ | | Newcastle | v +------------------------------+ ^ +------------------------------+ | | - | | | | | +------------------------------+ + | | <----+ , | | | | - | +------------------------------+ + | | <------ - +------------------------------+ 13.12. - 13.5  , - . 13.12. - , , , . , . Newcastle ("- ") , - , -. , , , - . - , , , , . "" mount. - , , , - , . "" - : ( , , ) ( ). 397 , - . 13.6  *1. exit . , - ? - ? 2. SIGKILL; , , . *3. exec . *4. , ? *5. , - ? ? 6. , . execl("/../sftig/bin/sh","sh",0); , . , - . 7. - Newcastle , - ? *8. exec , , Newcastle . . . *9. 13.2, exit Newcastle -, . . , - , ? *10. Newcastle, , - , ".." ( ), ? 11. 7 , . - , ? , - Newcastle ? *12. - ? *13. , "" link, , exec, - . : . *14. - , . - , , - 398 . , - -, , - -. - , . +----------+ +----------+ +----------+ | A | | B | | C | +----------+ +----------+ +----------+ - - - - - - getty- - - - - - - - - - - - - - - - - - - +-------------------------------------------+ - | - - - - - - | +--+----+----------+----+-----------+----+--+ | | | | | | tty00 tty01 tty02 tty03 tty04 tty05 13.13. *15. , , , . , - "break", . , , - ( 13.13). - getty-. - -, , . open , - , . - , "break", , ? *16. - , . - , (- ) , . . *17. 9 . , ? *18. , ( ) . - , - . , - , . *19. , , . "/usr/src/uts/3b2/os", "/usr" - , - A, "/usr/src" - B, "/usr/src/uts/3b2" - C. "" (multihop). , A C - , B - . "" Newcastle "" . 399