:




            2,     UNIX  -
 .   ,     
,    , ,    , 
   ,         -
.    ,     -
      ,      
    .        ,
         .
             
  UNIX,        
,    .  4.1    
  ,  4.2 -       -
,        .   4.3
   -  ,   -
      ,  4.4  
     .   4.5  
 ,    4.6  4.7   -
       . ,   4.8 
      ,       .
    ,    ,       -
     ,     (
4.1).  iget         
    ,   ,   iput
  .  bmap   ,  
  .  namei      -
    ,   iget, iput 

              
    +--------------------+------------------+-----------------+
    |       namei        |                  |                 |
    +--------------------+  alloc    free   |  ialloc  ifree  |
    | iget   iput   bmap |                  |                 |
    +--------------------+------------------+-----------------+
    +---------------------------------------------------------+
    |                                 |
    +---------------------------------------------------------+
    |    getblk     brelse     bread     breada     bwrite    |
    +---------------------------------------------------------+

              4.1.   


bmap.   alloc  free       -
,  ialloc  ifree      .







                  

                                     59

  ,     .     
 :
  *   .     -
       ""      
    ,      .    
          .
  *   .      , , 
    ,   -    ,
          (   
     , "  -  ").
  *    .        
       :   , 
       ;      
       ,    ,   -
    .        ,  -
              -
          .
  *  ,     :    
          ,     , 
        .
  *    ,   ,    
        .     -
       5.
  *    ,     . 
               ,
           .  -
     ,   ,   .
  *   .          -
      ,   ,  0,   
         1   . ,  -
          1     
     1000   ,    1001 .    -
            ,   
      .

            +---------------------------------------+
            |              mjb              |
            |               os                |
            |           -             |
            |          rwxr-xr-x        |
            |   23  1984 13:45 |
            |   22  1984 10:30 |
            |    23  1984 13:30  |
            |            6030             |
            |                         |
            +---------------------------------------+

               4.2.   


      4.2       .    
    ,    - "mjb"    -
6030 .    "mjb"  ,  
 ;   "os"     -
     ,      .  -
      23  1984   13:45,  
  22  1984   10:30.     
 23  1984   13:30,        
 .       . -

                                     60

           
.     ,     -
.        ,  
     ,     . 
     ,  
      .
       ,    ,    
 :
  *    , 
    -   ,
    -       - ,
    -           
         ,
    -           
         ,
    -       (.  5.15).
  *     ,  .
  *  .          (.
     2.2.1),        -
      .       .
  *      .      --
              ,  -
        -        -
    .  -      
       .         
          ,     -
       -,      .
  *  ,      (,
     ).
         ,       ,  -
     ,      
.    ,      -
   ;           
,      ,       
 ,      .    
           -
.           ,  -
           .
              -
      ,   -
  .  ,    , -
,   .      , -
       0,   ,     
       .  -
,          -
.       ,      -
   ,         
      .   ,    
;          ,  
 .



              
         . 
iget          (  4.3);    
   getblk       . 
        -    
  -    .    ,  

                                     61

    +------------------------------------------------------------+
    |  iget                                              |
    |  :            |
    |  :                  |
    | {                                                          |
    |                                                   |
    |   {                                                        |
    |      (   )                         |
    |     {                                                      |
    |        ( )                           |
    |       {                                                    |
    |          (  );         |
    |         ;    /*     */   |
    |       }                                                    |
    |       /*           |
    |          ( 5) */                                      |
    |        (    )            |
    |             ;               |
    |           ;                |
    |        ();                                 |
    |     }                                                      |
    |     /*      */              |
    |      (   )                  |
    |        ();                                 |
    |           ;      |
    |          ;             |
    |         -,   ;|
    |         ( bread);               |
    |       (,     |
    |        1);                                          |
    |      ();                                   |
    |   }                                                        |
    | }                                                          |
    +------------------------------------------------------------+

           4.3.     



       .        
       ,    .   
          
 ,  ,   ,    -
    .    

      = ((  - 1) /    ) +
                  +     
      . , ,
  2           -
  8  ,      8    2,   
 9 -   3.       16 , -
    8  9         2,  
   17       3.
              ,   ,
  bread ( 2),       -
    :

    ((  - 1)  (   )) *
    *   

                                     62

,      64     
8  ,       8     448  
  .         -
,     -    
   1.        -
,   ,    ,    
           
.
               
   .  -  ,     -
            -
          (    -
).        : -
        .  -
          .
,   5.1  ,      -
    ,       .   
   ,    ,  ,
    .  ,    -
    .      
     ,    
    ;     
     ,   
    .  ,     
       . -
           open 
,        5.
       iget, ,       -
        ,  
  .       ,      
 ,        ,
   .      -
      open    close  
       ,    .
, ,       -
 ,    .    -
    ,      "" .
,       .   
        -
 ,        ,  
      ,    -
.
        ,     
,      .     , -
 (A)    -  ,      
  (B).   ,  A 
         , ,    
.    B  ,  ""  -
 (  A),   .    
  A   ,   ,   -
     .         
,   0,       , -
    :     .   -
       .
          ,  ,   iget
      ,    
    .         
    ,  1 ,      .
         .  

                                     63

         ,    
      ,  .   5 -
    .

    +------------------------------------------------------------+
    |  iput   /*       */|
    |  :                |
    |  :                            |
    | {                                                          |
    |          ;       |
    |      1    ;              |
    |     (   == 0)                    |
    |    {                                                       |
    |        (   == 0)                 |
    |       {                                                    |
    |               (     |
    |           free,  4.7);                               |
    |              0;                    |
    |            ( ifree,  4.6);   |
    |       }                                                    |
    |        (          |
    |          )                        |
    |            ;                  |
    |            ;        |
    |    }                                                       |
    |       ;                             |
    | }                                                          |
    +------------------------------------------------------------+

                  4.4.  





      ,        (  iput,  
4.4),           .   
  0,          ,  
       .  , -
   ,       -
          .   -
    ,        
    ,     .    -
        ,   
   0.




      ,        
   .         
,          . 
        (    
    ),      
             
. ,         
          
     .  ,    -
           -

                                     64

 ,      .

   -------------+----------+----------+----------+-------------
     ---------- |   A  |   B  |   C  | -----------
   -------------+----------+----------+----------+-------------
               40         50         60         70
    

   -------------+----------+----------+----------+---------+---
     ---------- |   A  |  |   C  |   B | --
   -------------+----------+----------+----------+---------+---
               40         50         60         70        81
    

     4.5.         
                   


    ,  ,        , A, B  C,
    10  ,      
        .   
  5      , B,    
  B      ,    
15 .          -
  ,      B,  , 
        10  (  4.5).
       , 
   ,   ,    -
       .
                 ,
        .  -
      .    -
   ,    , 
    ,       
 .     1 ,  , -
  10 ,     10  ,  , -
  100 ,     100  .   
             , 
        .
     ,        -
 ,            
,     4.6.  V  UNIX  
13      ,     -
    . ,   " " 
,    ,       -
.  ,      "  ",  
,      .    
       ,     ,
       ,    -
,  . ,   "  -
",       ,   ,
   "  ",    -
   .
     ,           -
   ,      
,        . -
,        1        
  32  (4 ).       256 -
  .   ( 4.7),    

                                     65

 16 ,     10    
1   , 1      1  
 .   ,    " "  
- 32 ,       4  (2  -
 32).
         ,    . 
         ,   -
    ,   .      
  :        -
 ,       .  -
      ,  ,  -

                                                       -
                                                   
      +-------------+                                    +-----+
      |  . +----------------------------------->|     |
      |            0|                                    |     |
      +-------------+                                    +-----+
      |  . +-----------------+                  +-----+
      |            1|                 +----------------->|     |
      +-------------+                                    |     |
      |  . +-----------------+                  +-----+
      |            2|                 |                  +-----+
      +-------------+                 +----------------->|     |
      |  . +-----------------+                  |     |
      |            3|                 |                  +-----+
      +-------------+                 |                  +-----+
      |  . |                 +----------------->|     |
      |            4|                                    |     |
      +-------------+                                    +-----+
      |  . |                                       -
      |            5|                                       -
      +-------------+                                       -
      |  . |                                       -
      |            6|                                       -
      +-------------+                                    +-----+
      |  . |                 +----------------->|     |
      |            7|                 |                  |     |
      +-------------+  +--------------+                  +-----+
      |  . |  |                                 +-----+
      |            8|  |              +----------------->|     |
      +-------------+  |              |                  |     |
      |  . +--+  +------+    |                  +-----+
      |            9|     +------+----+                  +-----+
      +-------------+  +->+------+               +------>|     |
      |    +--+  +------+               |       |     |
      | |     +------+               |       +-----+
      +-------------+  +->+------+ +->+------+   |       +-----+
      |      +--+  +------+ |  +------+   |    +->|     |
      | |     +------+ |  +------+   |    |  |     |
      +-------------+     +------+-+  +------+---+    |  +-----+
      |      +--+  +------+    +------+        +---+
      | |  +->+------+ +->+------+ +>+------+-+
      +-------------+     +------+ |  +------+ | +------+
                          +------+-+  +------+ | +------+
                          +------+    +------+-+ +------+
                          +------+    +------+   +------+

       4.6.       

                                     66


     +----------------------------------------------------------+
     | 10     1   = 10  |
     | 1     256            |
     |                                   =   256  |
     | 1      256          |
     |                          =    64 |
     | 1      256          |
     |                   =    16  |
     +----------------------------------------------------------+

       4.7.        1 


    +------------------------------------------------------------+
    |  bmap  /*        |
    |                          |
    |                      */                    |
    |  :  (1)                             |
    |                      (2)                    |
    |  : (1)         |
    |                      (2)         |
    |                      (3)   -      |
    |                      (4)            |
    | {                                                          |
    |                |
    |          ;                         |
    |            -    |
    |       ;                 /*   2 */  |
    |          -    |
    |       ;                   /*   3 */  |
    |         ,   |
    |       ;                 /*   4 */  |
    |       ;                        |
    |      (   )            |
    |     {                                                      |
    |                 |
    |                    |
    |            ;                                          |
    |                   |
    |              ;                      |
    |             ,   -  |
    |                     |
    |             ( brelse);                        |
    |           (   )        |
    |                 ( );                   |
    |               (-  |
    |             bread);                                    |
    |                 |
    |              ;                          |
    |     }                                                      |
    | }                                                          |
    +------------------------------------------------------------+

     4.8.         
                   




                                     67

    .   4.8   bmap 
           .
         ( 4.9)  ,  -
   1024 .      ,  -
        ,  9000,    
  ,            
  8 (  0).        367; 808-
  
 (    0)   9000-   .  -
    ,   350000      
,       ,   -
      9156.         256
 ,  ,        
-

    +-------------+
    |    4096     |
    +-------------+
    |     228     |
    +-------------+
    |    45423    |
    +-------------+
    |      0      |
    +-------------+
    |      0      |
    +-------------+                      +----------->+------+
    |    11111    |                      |            |      |
    +-------------+                      |            |      |
    |      0      |                      |            |      |
    +-------------+                      |            +------+
    |     101     |                      |               367
    +-------------+                      |            -
    |     367     +----------------------+              
    +-------------+                                     
    |      0      |                  +->+------+
    +-------------+  +---->+------+  |  |      |  +-->+------+
    |     428     |  |     | 331  +--+  |      |  |   |      |
    +-------------+  |    0+------+   75+------+  |   |      |
    |    9156     +--+     |      |     | 3333 +--+   |      |
    +-------------+        +------+     +------+      +------+
    |     824     |          9156       |      |        3333
    +-------------+              +------+      -
                                 331           
                                               
                                       

        4.9.       


     ,     272384 (256 +
10);   ,    350000      -
   77616.       -
        256 ,    350000 
          -
  ,     331.      
         1 ,  
 77616   75-         
  ,     3333. ,     
350000    3333  816.

                                     68

         4.9  ,    
       0   ,    -
        .   ,  
             
           . 
      .   -
    ,     lseek  
write  (.  ).     ,  -
      read,      
   .
         ,    -
    ,   , -
               
  .        , -
  ,       
          
  .        ?   
,   ,    ,    
      ,         
 , ,   .  ,        
[Mullender 84],     UNIX  ,  -
  10    1  ! (*)  10    
  ,    ,   , 
      .    
  ,       .
             -
     .   
      BSD  4.2 [McKusick 84]   ,  
  ,          
 ,      .    
      ,    BSD -
     4   8  .  ,  
        ,  -
         .
,     8  ,        12
   1      .   -
  (4 )  ;       -
    .    ,   , -
      ,    , 
           ;
          -
   4  45% [McKusick 84].     
   BSD       ()  -
   .        
,    .    -
       5.
          -
       (. [Mullender 84]).   -
    ,      , -
         , 
  -              
    .      
,             
 ,      .
---------------------------------------
(*)      19978     ,  -
     85%     8   48%  -    1  .
      ,         
    ,     UNIX  .

                                     69






       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        .



                     


              (
 ),    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   
       ,     -
   ,     .   -
     ,  ,  ,
            
  .




            ,    -
,           -
   ,  .    -
,        .    
,   .
        :
    *   ,
    *      ,
    *   ,    ,
    *        ,
    *   ,
    *      ,
    *      ,
    *       ,
    *         ,
    * , ,      .

            ,   ,
   .      
  ,      ,  ,  -
   ,    .




       ,   ,    -
       (   ),  -
  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

   .  ,    ,  
,      ,     -
     ,      
    .     -
  .   ,         ,
  .       -
      .




         ,     
            
   .       ,
          -
.   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   /*     */    |
    |  :                    |
    |  :                    |
    | {                                                          |
    |     (  )                 |
    |         (  ,   |
    |           );                           |
    |           ;   |
    |     (    )                  |
    |    {                                                       |
    |         ;                            |
    |         ,      - |
    |          ( bread);                              |
    |          ,    - |
    |         ,  ;                                   |
    |           ( brelse);         |
    |           ;                      |
    |           (  - |
    |           );                             |
    |    }                                                       |
    |       ,    (-   |
    |      getblk);                                          |
    |      ;                             |
    |        ;                 |
    |       "";                    |
    |     ;                                       |
    | }                                                          |
    +------------------------------------------------------------+


            4.19.    


                                     81


4.20()            
 211.
             
 ,       ,   
  -     .   
      ,  ,      
      ,     -
     .    .
1.   ,     , :   
    ,  .       -
     .   ,    , 
      ,    .      
     ,  ,    ,  , 
     . ,     
     ,      -
        .
2.           -
     :        -
     .        
       .
3.       ,  -
   ,           -
         ,      
         .

            
         +-----+-----+-----+-----+---------------------+
         | 109 | 106 | 103 | 100 | ------------------- |
         +--+--+-----+-----+-----+---------------------+
      +-----+
      |  109
      |  +-----+-----+-----+-----+---------------+-----+
      +->| 211 | 208 | 205 | 202 | ------------- | 112 |
         +-----+-----+-----+-----+---------------+-----+

         ()  

            
         +-----+-----+---------------------------------+
         | 109 | 949 | ------------------------------- |
         +--+--+-----+---------------------------------+
      +-----+
      |  109
      |  +-----+-----+-----+-----+---------------+-----+
      +->| 211 | 208 | 205 | 202 | ------------- | 112 |
         +-----+-----+-----+-----+---------------+-----+
         ()      949

            
         +-----+-----+-----+-----+---------------------+
         | 109 | 106 | 103 | 100 | ------------------- |
         +--+--+-----+-----+-----+---------------------+
      +-----+
      |  109
      |  +-----+-----+-----+-----+---------------+-----+
      +->| 211 | 208 | 205 | 202 | ------------- | 112 |
         +-----+-----+-----+-----+---------------+-----+
         ()      949

                                     82


            
         +-----+-----+-----+-----+---------------+-----+
         | 211 | 208 | 205 | 202 | ------------- | 112 |
         +--+--+-----+-----+-----+---------------+-----+
      +-----+
      |  211
      |  +-----+-----+-----+-----+---------------+-----+
      +->| 344 | 341 | 338 | 335 | ------------- | 243 |
         +-----+-----+-----+-----+---------------+-----+

         ()      
                 109

     4.20.     




       UNIX      :   -
   .   ,           fifo    (    
"first-in-first-out" - "  -  " -  -
    ),     ,  -
    : ,    ,  
  .  ,     ,  -
     ,       
 .          
      ,   ,   -
   ,   , .   -
        .
          UNIX   ,  -
     -   -
    -.     -
,             .
      -     -
.      , ,   ,
    -   ,      
  .      -
   10.





         ,    -
 ,         .  
  :   ,     -
,     ,    ,   -
   .  ialloc  ifree   
        creat, mknod, pipe
 unlink (.  ),   iget  iput  
        .  bmap -
   ,  ,  -
       .    
 ,       -
   .  namei   ,  
  ,   ,    . -
,       ,  -
 alloc  free.

                                     83

     ,    ,    
, -   ,   ,  
    ,  .  
,   ,      
 ,         .
    ,         
   .
              
.        ( 2.1), -
,    ,       -
    .       
 ,     -
,        ,  -
     .

8.   V  UNIX     14   
        .  namei   -
     .         -
    ,       -
    ?
9. ,       UNIX,  
          ,      
    30 ;        -
     ,     ,   -
     ,        32   16. 
           -
     ,        namei,  -
       ?
*10.    namei      
    .       -
        .     
     (unlink)  ?      -
    ?        .
*11.   ,      
          .   :
     n- .
*12.        -
     ,     .
*13.           
    , ,   "" ,   -
    ialloc.  ,      ?
14.             
      ,     .    
            
   ,            
     .         
            ?













                                     84

Last-modified: Thu, 12 Feb 1998 07:18:58 GMT
: