Download pdf - Minix File System

Transcript
  • 8/10/2019 Minix File System

    1/38

    M i n i x F i l e S y s t e m

    C S C 3 1 5 0

    D r . J o h n C . S . L u i

    A b s t r a c t

    I n t r o d u c t i o n t o M i n i x F i l e S y s t e m

    C S C 3 1 5 0 : I n t r o d u c t i o n t o O p e r a t i n g S y s t e m s . P r e p a r e d b y D r . J o h n C . S . L u i

  • 8/10/2019 Minix File System

    2/38

    S u p p l e m e n t a r y N o t e : T h e M i n i x F S

    O v e r v i e w o f M i n i x F S

    M i n i x F S i s j u s t a b i g C p r o g r a m r u n s i n a u s e r

    s p a c e .

    u s e r p r o c e s s e s s e n d m e s s a g e s t o t h e F S t e l l i n g w h a t

    t h e y w a n t d o n e . T h e F S d o e s t h e w o r k a n d s e n d s

    b a c k a r e p l y . I t c a n b e u s e d a s a n e t w o r k l e s e r v e r !

    O v e r v i e w o f M i n i x F S 1 ) m e s s a g e s , 2 ) F S l a y o u t , 3 )

    i - n o d e s , 4 ) b l o c k c a c h e , 5 ) b i t m a p s , 6 ) d i r e c t o r i e s

    a n d p a t h n a m e s , 7 ) t h e p r o c e s s t a b l e , 8 ) p i p e l e s ,

    9 ) i n t e g r a t i o n .

    C S C 3 1 5 0 : I n t r o d u c t i o n t o O p e r a t i n g S y s t e m s . P r e p a r e d b y D r . J o h n C . S . L u i 1

  • 8/10/2019 Minix File System

    3/38

  • 8/10/2019 Minix File System

    4/38

    F S h a s a m a i n l o o p t h a t w a i t s f o r a m e s s a g e t o

    a r r i v e , m e s s a g e t y p e w i l l b e e x t r a c t e d a n d u s e d a s a n

    i n d e x i n t o a t a b l e c o n t a i n i n g p o i n t e r s t o p r o c e d u r e s

    w i t h i n t h e F S t h a t h a n d l e t h e r e q u e s t . W h e n d o n e ,

    r e t u r n s t a t u s .

    C S C 3 1 5 0 : I n t r o d u c t i o n t o O p e r a t i n g S y s t e m s . P r e p a r e d b y D r . J o h n C . S . L u i 3

  • 8/10/2019 Minix File System

    5/38

    F S l a y o u t

    T h e M i n i x F S i s a l o g i c a l , s e l f - c o n t a i n e d e n t i t y w i t h

    i - n o d e s , d i r e c t o r i e s a n d d a t a b l o c k s . E x a m p l e o f a

    3 6 0 K l a y o u t w i t h 1 2 7 i - n o d e s a n d 1 K b l o c k s i z e .

    F i g u r e 5 . 3 0 .

    ~~

    ~~

    Bootblock

    Superblock I-nodes one disk block

    I-nodebit map

    Zonebit map Data

    Figure 5.30: Minix FS Layout

    B o o t b l o c k . W h e n a c o m p u t e r i s t u r n e d o n , t h e

    h a r d w a r e r e a d s t h e b o o t b l o c k i n t o m e m o r y a n d

    j u m p t o i t .

    C S C 3 1 5 0 : I n t r o d u c t i o n t o O p e r a t i n g S y s t e m s . P r e p a r e d b y D r . J o h n C . S . L u i 4

  • 8/10/2019 Minix File System

    6/38

    s u p e r - b l o c k c o n t a i n s i n f o r m a t i o n a b o u t l e s y s t e m

    l a y o u t . F i g u r e 5 . 3 1 .

    Numer of nodesNumber of zones

    Number of i-node bit map blocksNumber of zone bit map blocks

    First data zoneLog 2(zone size/block size)

    Maximum file sizeMagic numberPointer to i-node bit map block

    Super-blocks device number

    I-node of mounted file system

    I-node mounted onTime of last update

    Read-only flag/Dirty flag

    . . . .

    Pointer to zone bit map block . . . .

    Presenton disk and inmemory

    Presentin memory

    but noton disk

    11011011101101110011011011101111

    . . . . . . .

    01011011101101110011011011101110

    . . . . . . .

    I-node bit map

    Zone bit map

    Figure 5.31: The MINIX super-block

    G i v e n b l o c k s i z e a n d n u m b e r o f i - n o d e s . I t i s e a s y

    t o c o m p u t e t h e s i z e o f i - n o d e b i t m a p a n d n u m b e r

    o f b l o c k s f o r i - n o d e s . F o r e x a m p l e , w i t h 1 K b l o c k

    s i z e , e a c h b l o c k o f b i t m a p s c a n i n d i c a t e s t a t u s o f

    8 1 9 1 i - n o d e s . I f i - n o d e s a r e o f 3 2 - b y t e s , e a c h b l o c k

    h o l d s 3 2 i - n o d e s , t h e r e f o r e , 1 2 7 i - n o d e s n e e d 4 d i s k

    b l o c k s .

    C S C 3 1 5 0 : I n t r o d u c t i o n t o O p e r a t i n g S y s t e m s . P r e p a r e d b y D r . J o h n C . S . L u i 5

  • 8/10/2019 Minix File System

    7/38

    d i s k s t o r a g e i s a l l o c a t e d i n u n i t s ( z o n e s ) o f 1 , 2 , 4 , 8

    o r i n g e n e r a l , 2

    n

    b l o c k s .

    m a p p i n g f r o m z o n e t o b l o c k o r v i c e v e r s a c a n b e

    d o n e b y a l g o r i t h m . F o r e x a m p l e , w i t h 8 b l o c k s p e r

    z o n e , t o n d z o n e c o n t a i n i n g b l o c k 1 2 8 , j u s t s h i f t

    1 2 8 r i g h t b y 3 b i t s .

    w h e n M i n i x i s b o o t e d , t h e s u p e r - b l o c k f o r t h e r o o t

    d e v i c e i s r e a d i n t o a t a b l e c a l l e d s u p e r - b l o c k s t a b l e .

    N e w p a r a m e t e r s a r e t h e n d e r i v e d a n d s t o r e d i n t h i s

    t a b l e l i k e w h e t h e r i t h a s b e e n m o u n t e d r e a d - o n l y ,

    m o d i e d s t a t u s e l d .

    T o e n f o r c e a k n o w n s t r u c t u r e , t h e u t i l i t y p r o g r a m

    m k f s i s p r o v i d e d t o b u i l d a l e s y s t e m .

    C S C 3 1 5 0 : I n t r o d u c t i o n t o O p e r a t i n g S y s t e m s . P r e p a r e d b y D r . J o h n C . S . L u i 6

  • 8/10/2019 Minix File System

    8/38

    B i t M a p s

    i - n o d e s a n d z o n e b i t m a p s k e e p t r a c k o f s t a t u s .

    u p o n b o o t u p , s u p e r - b l o c k a n d b i t m a p s f o r t h e

    r o o t d e v i c e a r e l o a d e d i n t o m e m o r y .

    t o r e m o v e a l e , b a s e d o n t h e i - n o d e n u m b e r , w e

    w i l l k n o w w h i c h p o i n t e r i n i n t h e s u p e r - b l o c k t o g o

    t o a n d a c c e s s t h e i - n o d e b i t m a p a n d t h e n c l e a r t h e

    c o r r e s p o n d i n g b i t .

    t o c r e a t e a l e , s e q u e n t i a l l y s e a r c h t h r o u g h t h e b i t

    m a p b l o c k s u n t i l i t n d s a f r e e i - n o d e . T h i s i - n o d e

    i s t h e n a l l o c a t e d f o r t h e n e w l e . I f n o a v a i l a b l e

    i - n o d e , r e t u r n 0 .

    R a t i o n a l f o r z o n e i s t o i m p r o v e p e r f o r m a n c e s o t h a t

    d i s k b l o c k s t h a t b e l o n g t o t h e s a m e l e a r e l o c a t e d

    o n t h e s a m e c y l i n d e r a s m u c h a s p o s s i b l e .

    C S C 3 1 5 0 : I n t r o d u c t i o n t o O p e r a t i n g S y s t e m s . P r e p a r e d b y D r . J o h n C . S . L u i 7

  • 8/10/2019 Minix File System

    9/38

    I - n o d e s

    i n M i n i x , i - n o d e i s a 3 2 - b y t e s s t r u c t u r e . F i g u r e

    5 . 3 2 .

    Mode

    Uid

    File Size

    Time of lastmodification

    Link

    Zone 0 number

    Zone 1 number

    Zone 5 number

    Zone 6 number

    Indirect

    Double Indirect

    Zone 2 number

    Zone 3 number

    Gid

    Zone 4 number

    3 2 b y

    t e s

    File type and RWX bitIdentifies the user who owns the file

    Number of bytes in the file

    In seconds, since Jan. 1, 1970

    Directories listing this i-node/owners group

    Zone numbers forthe first 7 datasones in the file

    Only used for files larger than 7 zones

    Figure 5.32: The MINIX i-node

    m o d e i n d i c a t e s t h e t y p e o f l e ( r e g u l a r , d i r e c t o r y ,

    b l o c k s p e c i a l , c h a r a c t e r s p e c i a l o r p i p e ) , p r o t e c t i o n

    b i t s .

    I t i s d i e r e n t f r o m t r a d i t i o n a l u n i x 1 ) n u m b e r o f

    t i m e e l d , 2 ) l i n k a n d g i d s i z e s , 3 ) f e w e r d i s k b l o c k

    p o i n t e r s .

    C S C 3 1 5 0 : I n t r o d u c t i o n t o O p e r a t i n g S y s t e m s . P r e p a r e d b y D r . J o h n C . S . L u i 8

  • 8/10/2019 Minix File System

    10/38

    W h e n a l e i s o p e n e d , i t s i - n o d e i s l o c a t e d a n d

    b r o u g h t i n t o t h e i n o d e t a b l e i n m e m o r y . I t r e m a i n s

    t h e r e u n t i l t h e l e i s c l o s e d .

    t h e i n o d e t a b l e h a s s e v e r a l p a r a m e t e r s w h i c h i s n o t

    i n d i s k , 1 ) i - n o d e ' s d e v i c e n u m b e r s o s y s t e m k n o w s

    w h e r e t o w r i t e b a c k t h e i - n o d e , 2 ) a c o u n t e r f o r e a c h

    i - n o d e t o i n d i c a t e t h e n u m b e r o f p r o c e s s o p e n i n g

    t h e l e . W h e n t h e c o u n t e r i s z e r o , t h e i - n o d e i s

    r e m o v e d f r o m t h e t a b l e a n d w r i t t e n t o d i s k i f i t h a s

    b e e n m o d i e d .

    C S C 3 1 5 0 : I n t r o d u c t i o n t o O p e r a t i n g S y s t e m s . P r e p a r e d b y D r . J o h n C . S . L u i 9

  • 8/10/2019 Minix File System

    11/38

    B l o c k C a c h e

    b l o c k c a c h e i s u s e d t o i m p r o v e F S p e r f o r m a n c e .

    E a c h b l o c k b u e r i s i m p l e m e n t e d a s a n o d e w i t h

    1 ) p o i n t e r s 2 ) c o u n t e r s , 3 ) a g s , 4 ) r o o m f o r a d i s k

    b l o c k .

    b u e r s a r e c h a i n e d t o g e t h e r i n a d o u b l e - l i n k l i s t

    w i t h m o s t r e c e n t l y u s e d ( M R U ) t o l e a s t r e c e n t l y

    u s e d ( L R U ) . F i g u r e 5 . 3 3 .

    Hash table Rear (MRU) Front (LRU)

    Figure 5.33: The linked lists used by the block cache

    H o w c a n w e q u i c k l y a c c e s s e d a g i v e n b l o c k ? T a k e

    a d v a n t a g e o f h a s h i n g t e c h n i q u e b y h a s h i n g t h e l o w -

    o r d e r n b i t s o f t h e b l o c k n u m b e r . A l l b l o c k s t h a t

    C S C 3 1 5 0 : I n t r o d u c t i o n t o O p e r a t i n g S y s t e m s . P r e p a r e d b y D r . J o h n C . S . L u i 1 0

  • 8/10/2019 Minix File System

    12/38

    h a v e t h e s a m e l o w e r - o r d e r b i t s a r e l i n k e d t o g e t h e r

    o n a s i n g l e - l i n k e d l i s t .

    W h e n t h e F S n e e d s a b l o c k , i t c a l l s a p r o c e d u r e

    g e t b l o c k . B a s e o n h a s h i n g a n d s e a r c h e s t h e

    a p p r o p r i a t e l i s t . I f t h e b l o c k i s f o u n d , a c o u n t e r

    i n t h e b l o c k ' s h e a d e r i s i n c r e m e n t e d a n d a p o i n t e r

    i s r e t u r n e d . I f b l o c k i s n o t f o u n d , t h e L R U l i s t i s

    s e a r c h e d t o n d a b l o c k t o e v i c t ( a s s u m i n g t h e r e i s a

    x e d b l o c k c a c h e ) . I f t h e b l o c k a t f r o n t h a s c o u n t e r

    v a l u e o f z e r o . T h a t b l o c k i s c h o s e n f o r e v i c t i o n ,

    o t h e r w i s e , n e x t b l o c k i s i n s p e c t e d ( w h a t h a p p e n i f

    y o u c a n n o t n d a n y b l o c k t o e v i c t ? ) . W h e n a b l o c k

    i s c h o s e n f o r e v i c t i o n , t h e s y s t e m c h e c k s h a s t h e

    b l o c k b e e n m o d i e d ( t h e m o d i c a t i o n a g i s s t o r e d

    i n t h e h e a d e r ) . F o r m o d i e d b l o c k , w r i t e i t o u t t o

    d i s k . A t t h i s p o i n t , s y s t e m c a n b r i n g i n a n o t h e r

    b l o c k b y s e n d i n g a m e s s a g e t o t h e d i s k t a s k . F S

    i s s u s p e n d e d u n t i l t h e b l o c k a r r i v e s , t h e n i t r e t u r n s

    t h e b l o c k p o i n t e r t o t h e c a l l e r .

    C S C 3 1 5 0 : I n t r o d u c t i o n t o O p e r a t i n g S y s t e m s . P r e p a r e d b y D r . J o h n C . S . L u i 1 1

  • 8/10/2019 Minix File System

    13/38

    A n o t h e r p r o c e d u r e p u t b l o c k i s t o d e c i d e w h e r e

    t o p u t t h e b l o c k . B l o c k s t h a t a r e n o t l i k e l y t o b e

    n e e d e d a g a i n ( e x : d o u b l e i n d i r e c t b l o c k s ) g o t o t h e

    f r o n t o f t h e l i s t . B l o c k s t h a t a r e l i k e l y t o b e n e e d e d

    g o t o t h e r e a r o f t h e l i s t . D a t a b l o c k t h a t h a s b e e n

    m o d i e d i s n o t r e w r i t t e n b a c k t o d i s k u n l e s s 1 ) i t

    r e a c h e s t h e f r o n t o f t h e l i s t , 2 ) a S Y N C s y s t e m

    c a l l i s m a d e . F o r a l l t h o s e o p e r a t i o n s , r e m e m b e r t o

    c h a i n b a c k t h e h a s h e d s i n g l e d l i n k l i s t .

    C S C 3 1 5 0 : I n t r o d u c t i o n t o O p e r a t i n g S y s t e m s . P r e p a r e d b y D r . J o h n C . S . L u i 1 2

  • 8/10/2019 Minix File System

    14/38

    D i r e c t o r i e s a n d P a t h

    a s m e n t i o n e d b e f o r e , w h e n t h e s y s t e m w a n t s t o

    o p e n a l e , i t i s a c t u a l l y a c c e s s i n g a n i - n o d e .

    l e n a m e l o o k u p i s t h e s a m e a s w e d e s c r i b e d

    b e f o r e . T h e i m p o r t a n t t h i n g i s t o n d t h e r o o t

    d i r e c t o r y i - n o d e , w h i c h i s l o c a t e d i n t h e x e d

    p o s i t i o n o f t h e d i s k .

    W h e n u s e r t y p e s i n c o m m a n d

    % m o u n t / d e f / f d 1 / u s e r

    t h i s i m p l i e s t o m o u n t t h e l e s y s t e m o n t o p o f / u s e r .

    F i g u r e 5 . 3 4

    Root file system /

    /lib /bin /user

    Unmounted FS /

    /bal /jim /ast

    After mounting /

    /lib /bin /user

    /ast/f1 /ast/f2

    /user/bal /user/ast

    /user/ast/f2

    . . . . .

    (a) (b) (c)

    Figure 5.34: (a) Root file system. (b) An unmounted file system. (c) The result of mounting the file system of (b) on /user

    C S C 3 1 5 0 : I n t r o d u c t i o n t o O p e r a t i n g S y s t e m s . P r e p a r e d b y D r . J o h n C . S . L u i 1 3

  • 8/10/2019 Minix File System

    15/38

    W h a t d o e s i t r e a l l y m e a n f o r m o u n t i n g ? T h a t i s ,

    d u r i n g l e n a m e l o o k u p , h o w d o e s t h e s y s t e m k n o w

    w h e n a n d w h e r e t o s w i t c h ?

    O S h a s t o 1 ) s e t a a g i n " / u s e r " t o i n d i c a t e

    a s u c c e s s f u l m o u n t , 2 ) l o a d t h e s u p e r - b l o c k

    a n d i - n o d e o f t h e n e w l y m o u n t e d l e s y s t e m

    i n t o s u p e r - b l o c k t a b l e a n d i - n o d e t a b l e ( t h i s

    i s a c c o m p l i s h e d b y M O U N T c a l l ) , 3 ) s e t t h e

    i - n o d e - o f - t h e - m o u n t e d - l e - s y s t e m t o p o i n t t o t h e

    r o o t i - n o d e o f t h e n e w l y m o u n t e d s y s t e m , 4 ) s e t

    t h e i - n o d e - m o u n t e d - o n t o p o i n t t o t h e i - n o d e o f

    " / u s e r " .

    t o a n s w e r t h e p r e v i o u s q u e s t i o n , i t i s s t r a i g h t

    f o r w a r d .

    C S C 3 1 5 0 : I n t r o d u c t i o n t o O p e r a t i n g S y s t e m s . P r e p a r e d b y D r . J o h n C . S . L u i 1 4

  • 8/10/2019 Minix File System

    16/38

    F i l e D e s c r i p t o r s

    w h e n a l e h a s b e e n o p e n , a l e d e s c r i p t o r i s

    r e t u r n e d t o u s e r . T h i s i m p l i e s t h e O S h a s t o

    m a n a g e l e d e s c r i p t o r .

    F S m a i n t a i n s p a r t o f t h e p r o c e s s t a b l e w i t h i n i t s

    a d d r e s s s p a c e . T h e r e a r e 3 i n t e r e s t i n g e l d s i n

    t h e p r o c e s s t a b l e , 1 ) p o i n t e r t o t h e i - n o d e o f t h e

    r o o t d i r e c t o r y , 2 ) p o i n t e r t o t h e c u r r e n t w o r k i n g

    d i r e c t o r y f o r t h a t p r o c e s s , 3 ) i s a n a r r a y " i n d e x e d "

    b y t h e l e d e s c r i p t o r . I t i s u s e d t o l o c a t e t h e p r o p e r

    l e w h e n a l e d e s c r i p t o r i s u s e d b y t h e p r o c e s s .

    T h e i n t e r e s t i n g q u e s t i o n i s c a n w e j u s t p u t a p o i n t e r

    o f t h e l e ' s i - n o d e i n t h e a r r a y ?

    T o a n s w e r t h a t , w e r s t h a v e t o u n d e r s t a n d i n U n i x ,

    l e s c a n b e s h a r e d . F o r e a c h l e , t h e r e i s a 3 2 - b i t s

    n u m b e r i n d i c a t e s t h e l e p o s i t i o n ( s o p r o c e s s k n o w

    w h e r e t o r e a d o r w r i t e t h e n e x t t i m e ) . w h e r e c a n

    w e p u t t h i s n u m b e r ?

    C S C 3 1 5 0 : I n t r o d u c t i o n t o O p e r a t i n g S y s t e m s . P r e p a r e d b y D r . J o h n C . S . L u i 1 5

  • 8/10/2019 Minix File System

    17/38

    I f w e p u t i t a s p a r t o f t h e i - n o d e e l d , t h e n d i e r e n t

    p r o c e s s e s m i g h t o p e n t h e s a m e l e a n d t h e y m i g h t

    h a v e d i e r e n t l e p o s i t i o n s . S o w e C A N N O T p u t

    t h e l e p o s i t i o n a s p a r t o f t h e i - n o d e .

    T h e n c a n w e p u t t h e l e - p o s i t i o n i n t h e p r o c e s s

    t a b l e ? I n t h i s w a y , e a c h p r o c e s s c a n h a v e d i e r e n t

    l e - p o s i t i o n e v e n t h e y a r e a c c e s s i n g t h e s a m e l e .

    P r o b l e m d u r i n g f o r k i n g ! S o w e c a n n o t p u t t h e

    l e - p o s i t i o n i n t h e p r o c e s s t a b l e .

    S o l u t i o n : i s t o i n t r o d u c e a s h a r e d t a b l e , l p . F i g u r e

    5 . 3 5 .

    ~~ ~~

    Parent

    Child

    Process table

    File positioni-node pointer

    ~~ ~~~~ ~~

    I-node table

    Figure 5.35: How file positions are shared between a parent and a child

    C S C 3 1 5 0 : I n t r o d u c t i o n t o O p e r a t i n g S y s t e m s . P r e p a r e d b y D r . J o h n C . S . L u i 1 6

  • 8/10/2019 Minix File System

    18/38

    I n t h i s w a y , p a r e n t - c h i l d p r o c e s s e s c a n b e s h a r e d

    u s i n g t h e s a m e l p e n t r y w h i l e d i e r e n t p r o c e s s e s

    p o i n t t o d i e r e n t l p e n t r y f o r s h a r i n g s a m e l e .

    T h e l p e n t r y h a s a c o u n t e r t o c h e c k n u m b e r o f

    p r o c e s s e s u s i n g i t . I t c a n b e d e a l l o c a t e d w h e n i t

    r e a c h e s z e r o .

    C S C 3 1 5 0 : I n t r o d u c t i o n t o O p e r a t i n g S y s t e m s . P r e p a r e d b y D r . J o h n C . S . L u i 1 7

  • 8/10/2019 Minix File System

    19/38

    P i p e s a n d s p e c i a l l e s

    I f p r o c e s s t r i e s t o r e a d o r w r i t e f r o m a d i s k , i t i s

    c e r t a i n t h a t , a t w o r s t , i t t a k e s s e v e r a l d i s k a c c e s s

    t o g e t t h e i n f o r m a t i o n . B u t w h e n r e a d i n g a p i p e ,

    i t i s q u i t e d i e r e n t b e c a u s e t h e r e a d e r o f t h e p i p e

    m a y h a v e t o w a i t f o r t h e o t h e r p r o c e s s t o p u t d a t a

    i n t h e p i p e .

    w h e n p r o c e s s t r i e s t o r e a d o r w r i t e f r o m a p i p e ,

    t h e F S c a n c h e c k t h e s t a t e o f t h e p i p e r s t t o s e e

    i f t h e o p e r a t i o n i s p o s s i b l e . I f y e s , p r o c e e d . E l s e ,

    F S r e c o r d s t h e p a r a m e t e r s o f t h e s y s t e m c a l l i n t h e

    p r o c e s s t a b l e f o r l a t e r r e s t a r t o f p r o c e s s a n d t h e n

    s u s p e n d t h e p r o c e s s .

    I n s u s p e n d i n g p r o c e s s , F S j u s t h a v e t o r e f r a i n f r o m

    s e n d i n g a r e p l y b a c k t o t h e c a l l i n g p r o c e s s a n d t h e n

    t h e F S g o e s b a c k t o t h e m a i n l o o p . E v e n t u a l l y ,

    o t h e r p r o c e s s w i l l m o d i f y t h e s t a t e o f t h e p i p e s o

    t h e s u s p e n d e d p r o c e s s c a n p r o c e e d w h e n t h e F S

    s e r v i c e t h e p r o c e s s .

    C S C 3 1 5 0 : I n t r o d u c t i o n t o O p e r a t i n g S y s t e m s . P r e p a r e d b y D r . J o h n C . S . L u i 1 8

  • 8/10/2019 Minix File System

    20/38

    F o r o t h e r s p e c i a l l e s l i k e t e r m i n a l s a n d o t h e r

    c h a r a c t e r s p e c i a l l e s . T h e i - n o d e o f t h i s s p e c i a l

    l e h a s t w o n u m b e r s , t h e m a j o r a n d m i n o r d e v i c e

    n u m b e r . T h e m a j o r d e v i c e n u m b e r i s t o i n d i c a t e

    w h i c h c l a s s o f d e v i c e ( e . g . , R A M d i s k , o p p y d i s k ,

    h a r d d i s k , t e r m i n a l ) . I t i s a l s o u s e d t o i n d e x i n t o

    a l e s y s t e m t a b l e s o t h e p r o p e r I / O d r i v e r c a n b e

    c a l l e d . M i n o r d e v i c e n u m b e r i s u s e d t o s p e c i f y t h e

    s p e c i c d e v i c e , f o r e x a m p l e , y o u m i g h t h a v e s e v e r a l

    o p p y d i s k d r i v e .

    O n c e w e k n o w t h e I / O d r i v e r t a s k n u m b e r , t h e l e

    s y s t e m s e n d s t h e t a s k a m e s s a g e i n c l u d i n g 1 ) m i n o r

    d e v i c e n u m b e r , 2 ) o p e r a t i o n t o b e p e r f o r m e d , 3 )

    c a l l e r ' s p r o c e s s n u m b e r , 4 ) c a l l e r ' s b u e r a d d r e s s ,

    5 ) n u m b e r o f b y t e s t o b e t r a n s f e r r e d .

    I f t h e d r i v e r c a n c a r r y o u t t h e w o r k i m m e d i a t e l y ,

    i t c o p i e s d a t a f r o m i t s i n t e r n a l b u e r t o t h e u s e r ' s

    b u e r s p a c e , s e n d s t h e F S a r e p l y s a y i n g w o r k i s

    d o n e , t h e n t h e F S c a n r e p l y b a c k t o t h e c a l l i n g

    p r o c e s s .

    C S C 3 1 5 0 : I n t r o d u c t i o n t o O p e r a t i n g S y s t e m s . P r e p a r e d b y D r . J o h n C . S . L u i 1 9

  • 8/10/2019 Minix File System

    21/38

    I f d r i v e r i s n o t a b l e t o c a r r y o u t w o r k , i t r e c o r d s t h e

    m e s s a g e p a r a m e t e r s i n i t s i n t e r n a l t a b l e s , r e p l y t o

    t h e F S s a y i n g t h a t t h e c a l l c o u l d n o t b e c o m p l e t e d .

    T h e n F S r e c o r d s t h e f a c t t h a t t h e p r o c e s s i s

    s u s p e n d e d a n d w a i t s f o r n e x t m e s s a g e . E v e n t u a l l y

    t h e d r i v e r c a n n i s h t h e w o r k , i t s e n d s m e s s a g e b a c k

    t o F S , t h e F S c a n r e p l y b a c k t o t h e c a l l i n g p r o c e s s .

    C S C 3 1 5 0 : I n t r o d u c t i o n t o O p e r a t i n g S y s t e m s . P r e p a r e d b y D r . J o h n C . S . L u i 2 0

  • 8/10/2019 Minix File System

    22/38

    R E A D s y s t e m c a l l

    % n = r e a d ( f d , b u e r , n b y t e s )

    s e n d r e a d m e s s a g e t o F S .

    F S d e c o d e s m e s s a g e a n d j u m p s t o t h e a p p r o p r i a t e

    f u n c t i o n .

    p r o c e d u r e e x t r a c t s l e d e s c r i p t o r a n d t h e n l o c a t e

    t h e l p e n t r y a n d t h e n t h e i - n o d e f o r t h e l e t o

    r e a d .

    r e q u e s t i s t h e n b r o k e n i n t o p i e c e s s u c h t h a t e a c h

    p i e c e t s w i t h i n a b l o c k . F o r e x a m p l e , i f t h e l e

    p o s i t i o n i s a t 6 0 0 a n d 1 K b y t e s h e a v e r e q u e s t e d .

    R e q u e s t i s s p l i t i n t o t w o p a r t s , f o r 6 0 0 t o 1 0 2 3 , a n d

    1 0 2 4 t o 1 6 2 3 .

    f o r e a c h p i e c e , c h e c k t o s e e i f t h e r e l e v a n t b l o c k i s

    i n c a c h e . I f i t i s n o t , F S p i c k s t h e l e a s t r e c e n t l y u s e d

    b u e r n o t c u r r e n t l y i n u s e d a n d c l a i m s i t . S e n d i n g

    a m e s s a g e t o t h e d i s k t a s k t o r e w r i t e i f t h e b l o c k i s

    C S C 3 1 5 0 : I n t r o d u c t i o n t o O p e r a t i n g S y s t e m s . P r e p a r e d b y D r . J o h n C . S . L u i 2 1

  • 8/10/2019 Minix File System

    23/38

    d i r t y . T h e n t h e d i s k t a s k i s a s k e d t o f e t c h t h e b l o c k

    t o b e r e a d .

    o n c e a b l o c k i s i n c a c h e , t h e F S s e n d s a m e s s a g e

    t o t h e s y s t e m t a s k a s k i n g i t t o c o p y t h e d a t a t o t h e

    a p p r o p r i a t e p l a c e i n u s e r ' s b u e r .

    A f t e r t h e c o p y h a s b e e n d o n e , t h e F S s e n d s a r e p l y

    m e s s a g e t o t h e u s e r s p e c i f y i n g h o w m a n y b y t e s h a v e

    b e e n c o p i e d .

    t h e l i b r a r y f u n c t i o n r e a d e x t r a c t s t h e r e p l y c o d e

    a n d r e t u r n s i t a s t h e f u n c t i o n v a l u e t o t h e c a l l e r .

    C S C 3 1 5 0 : I n t r o d u c t i o n t o O p e r a t i n g S y s t e m s . P r e p a r e d b y D r . J o h n C . S . L u i 2 2

  • 8/10/2019 Minix File System

    24/38

    M i n i x h e a d e r l e s

    l e " f s / c o n s t . h " d e n e s f s c o n s t a n t s .

    N R B U F S ( n u m b e r o f b l o c k s i n b u e r c a c h e ) ,

    N R B U F H A S H ( s i z e o f b u e r h a s h t a b l e ) ,

    N R F D S ( m a x l e d e s c r i p t o r s p e r p r o c e s s ) ,

    N R F I L P S ( m a x i m u m n u m b e r o f s l o t s i n l p t a b l e ) ,

    c a n b e c h a n g e d t o t u n e t h e s y s t e m ' s p e r f o r m a n c e .

    A l s o d e n e s p o s i t i o n l i k e B O O T B L O C K a n d

    S U P E R B L O C K .

    b u f . h d e n e s t h e d i s k b l o c k b u e r c a c h e . t h e

    " b c o u n t s " h o l d s t h e n u m b e r o f u s e r s o f t h i s b u e r

    a n d " t h e r e a r e v a r i o u s p o i n t e r s f o r L R U d o u b l e l i n k

    l i s t a n d h a s h e d l i n k .

    b u f . h a l s o d e n e d t h e t y p e o f b l o c k w h e n F S c a l l s

    t h e p u t b l o c k ( ) . S o m e b l o c k s h a v e t o b e w r i t t e n

    o u t t o d i s k i m m e d i a t e l y ( e . g . , i - n o d e b l o c k , d i r e c t o r y

    b l o c k ) .

    C S C 3 1 5 0 : I n t r o d u c t i o n t o O p e r a t i n g S y s t e m s . P r e p a r e d b y D r . J o h n C . S . L u i 2 3

  • 8/10/2019 Minix File System

    25/38

    l e . h c o n t a i n s t h e i n t e r m e d i a t e t a b l e t o h o l d

    c u r r e n t l e p o s i t i o n , i - n o d e p o i n t e r , h o w m a n y l e

    d e s c r i p t o r s a r e c u r r e n t l y p o i n t i n g t o t h i s e n t r y .

    f p r o c . h i s t h e F S ' s p a r t o f t h e p r o c e s s t a b l e . A g a i n ,

    i t h a s i - n o d e p o i n t e r s t o w o r k i n g d i r e c t o r y a n d r o o t

    d i r e c t o r y a s w e l l a s l p p o i n t e r . I t a l s o h a s t w o

    e l d s f p s u s p e n d e d a n d f p r e v i v e d t o s u s p e n d a n d

    r e v i v e a p r o c e s s .

    i n o d e . h d e n e s t h e i - n o d e t a b l e . R e m e m b e r , w h e n

    a l e i s o p e n e d , i t s i - n o d e i s r e a d i n t o m e m o r y a n d

    k e p t i n t h e i n o d e t a b l e . I t h a s e l d " i d i r t " ( i s i t

    d i r t y ) , " i p i p e " ( i f i n o d e i s a p i p e ) , " i m o u n t " ( s e t

    i f o t h e r l e s y s t e m c a n b e m o u n t e d o n t h i s i n o d e ,

    " i s e e k " i s f o r p e r f o r m a n c e f o r p r e - f e t c h i n g . I t i s

    s e t t o i n h i b i t r e a d a h e a d .

    s u p e r . h d e n e s t h e s u p e r b l o c k t a b l e . N o t e t h a t

    t h e s e c o n d h a l f o f t h e s u p e r - b l o c k i s d e r i v e d o n c e i t

    i s i n t h e m e m o r y .

    C S C 3 1 5 0 : I n t r o d u c t i o n t o O p e r a t i n g S y s t e m s . P r e p a r e d b y D r . J o h n C . S . L u i 2 4

  • 8/10/2019 Minix File System

    26/38

    B l o c k M a n a g e m e n t

    c a c h e . c m a n a g e s t h e b l o c k c a c h e . I t h a s s i x

    p r o c e d u r e s . F i g u r e 5 . 3 6 .

    get_block Fetch a block for reading or writingput_block Return a block previously requested with get_block alloc_zone Allocate a new zone (to make a file longer)free_zone Release a zone (when a file is removed)rw_block Transfer a block between disk and cacheinvalidate Purge all the cache blocks for some device

    Figure 5.36: Procedures used for block management

    w h e n y o u n e e d a d a t a b l o c k , u s e g e t b l o c k ( ) w i t h

    d e v i c e a n d b l o c k n u m b e r . B u e r c h o s e n f o r e v i c t i o n

    i s r e m o v e d f r o m h a s h c h a i n a n d i f i t i s d i r t y , w r i t e

    i t o u t o n d i s k .

    t h e p r o c e d u r e p u t b l o c k t a k e s c a r e s o f p u t t i n g t h e

    n e w l y r e t u r n e d b l o c k o n t h e L R U l i s t , a n d i n s o m e

    c a s e s , r e w r i t i n g i t b a c k t o t h e d i s k ( e . g . , d i r e c t o r y

    b l o c k ) .

    C S C 3 1 5 0 : I n t r o d u c t i o n t o O p e r a t i n g S y s t e m s . P r e p a r e d b y D r . J o h n C . S . L u i 2 5

  • 8/10/2019 Minix File System

    27/38

    i n v a l i d a t e ( ) i s c a l l e d w h e n a d i s k i s u n m o u n t e d s o

    t h a t a l l b l o c k s i n t h e c a c h e b e l o n g i n g t o t h a t l e

    s y s t e m w i l l b e r e m o v e d ( a s p o s s i b l e w r i t t e n o u t ) .

    C S C 3 1 5 0 : I n t r o d u c t i o n t o O p e r a t i n g S y s t e m s . P r e p a r e d b y D r . J o h n C . S . L u i 2 6

  • 8/10/2019 Minix File System

    28/38

    I - n o d e m a n a g e m e n t

    i n o d e . c m a n a g e s i - n o d e t a b l e . I t h a s t h e f o l l o w i n g

    s u p p o r t i n g p r o c e d u r e s . F i g u r e 5 . 3 7 .

    get_inode Fetch an i-node into memoryput_inode Return an i-node that is no longer neededalloc_inode Allocate a new i-node (for a new file)wipe_inode Clear some fields in an i-node

    free_inode Release an i-node (when a file is removed)rw_inode Transfer an i-node between memory and disk

    Figure 5.37: Procedures used for i-node management

    dup_inode Indicate that someone else is using an i-node

    g e t i n o d e ( ) s e a r c h e s t h e i n o d e t a b l e t o s e e i f

    t h e i n o d e i s a l r e a d y p r e s e n t ( w e n e e d b o t h d e v i c e

    n u m b e r a n d i n o d e n u m b e r s p e c i f y a s y s t e m i n o d e ) .

    I f s o , i n c r e m e n t t h e u s a g e c o u n t e r a n d r e t u r n s a

    p o i n t e r , e l s e , c a l l e d r w i n o d e ( ) .

    i n o d e i s r e t u r n e d b y c a l l i n g p u t i n o d e , w h i c h

    d e c r e m e n t s t h e u s a g e i c o u t . I f t h e c o u n t i s z e r o ,

    i - n o d e i s r e m o v e d f r o m i - n o d e t a b l e . I f i t i s d i r t y ,

    w r i t e i t o u t t o d i s k .

    C S C 3 1 5 0 : I n t r o d u c t i o n t o O p e r a t i n g S y s t e m s . P r e p a r e d b y D r . J o h n C . S . L u i 2 7

  • 8/10/2019 Minix File System

    29/38

    a l l o c i n o d e ( ) w i l l a l l o c a t e a f r e e i - n o d e o n a g i v e n

    d e v i c e .

    f r e e i n o d e ( ) , c o r r e s p o n d i n g i - n o d e b i t - m a p i s s e t

    t o z e r o .

    d u p i n o d e ( ) i n c r e m e n t t h e u s a g e c o u n t o f t h e i -

    n o d e .

    C S C 3 1 5 0 : I n t r o d u c t i o n t o O p e r a t i n g S y s t e m s . P r e p a r e d b y D r . J o h n C . S . L u i 2 8

  • 8/10/2019 Minix File System

    30/38

    S u p e r - b l o c k m a n a g e m e n t

    s u p e r . c c o n t a i n s p r o c e d u r e s t o m a n a g e s u p e r - b l o c k

    t a b l e a n d b i t m a p s . F i g u r e 5 . 3 8 .

    get_inode Fetch an i-node into memoryput_inode Return an i-node that is no longer neededalloc_inode Allocate a new i-node (for a new file)wipe_inode Clear some fields in an i-nodefree_inode Release an i-node (when a file is removed)rw_inode Transfer an i-node between memory and disk

    Figure 5.37: Procedures used for i-node management

    dup_inode Indicate that someone else is using an i-node

    l o a d b i t m a p s ( ) l o a d s a l l b i t m a p b l o c k s , s e t u p

    s u p e r - b l o c k t o p o i n t t o t h e m .

    u n l o a d b i t m a p s ( ) i s c a l l e d w h e n t h e l e s y s t e m i s

    u n m o u n t e d a n d b i t m a p s a r e c o p i e d b a c k t o d i s k .

    g e t s u p e r ( ) i s u s e d t o s e a r c h t h e s u p e r - b l o c k t a b l e

    f o r a s p e c i c d e v i c e . F o r e x a m p l e , w h e n a l e

    C S C 3 1 5 0 : I n t r o d u c t i o n t o O p e r a t i n g S y s t e m s . P r e p a r e d b y D r . J o h n C . S . L u i 2 9

  • 8/10/2019 Minix File System

    31/38

    s y s t e m i s m o u n t e d , y o u n e e d t o c h e c k t h a t i t i s n o t

    a l r e a d y m o u n t e d .

    s c a l e f a c t o r ( ) l o o k s u p t h e z o n e - t o - b l o c k

    c o n v e r s i o n f a c t o r . I t i s d i e r e n t f o r e a c h l e s y s t e m .

    C S C 3 1 5 0 : I n t r o d u c t i o n t o O p e r a t i n g S y s t e m s . P r e p a r e d b y D r . J o h n C . S . L u i 3 0

  • 8/10/2019 Minix File System

    32/38

    F i l e d e s c r i p t o r m a n a g e m e n t

    l e d e s . c m a n a g e s t h e l e d e s c r i p t o r s a n d l p t a b l e .

    g e t f d ( ) l o o k s f o r f r e e l e d e s c r i p t o r a n d f r e e l p

    s l o t s .

    g e t l p ( ) l o o k s u p t h e l p e n t r y f o r a g i v e n l e

    d e s c r i p t o r .

    n d l p ( ) n d s a l p s l o t t h a t p o i n t s t o a g i v e n

    i n o d e . W e n e e d t h i s f u n c t i o n , f o r e x a m p l e , w h e n a

    p r o c e s s i s w r i t i n g o n a b r o k e n p i p e . I t u s e s a b r u t e

    f o r c e s e a r c h o f t h e l p t a b l e .

    C S C 3 1 5 0 : I n t r o d u c t i o n t o O p e r a t i n g S y s t e m s . P r e p a r e d b y D r . J o h n C . S . L u i 3 1

  • 8/10/2019 Minix File System

    33/38

    F S m a i n p r o g r a m

    F S i s a l w a y s i n a n i n n i t e l o o p .

    t h e c a l l t o g e t w o r k ( ) w a i t s f o r t h e n e x t r e q u e s t

    m e s s a g e t o a r r i v e . I t s e t g l o b a l v a r i a b l e , w h o ( t h e

    c a l l e r ' s p r o c e s s t a b l e s l o t n u m b e r ) a n d f s c a l l ( t h e

    n u m b e r o f s y s t e m c a l l t o b e c a r r i e d o u t ) .

    T h r e e a g s i s s e t : f p p o i n t s t o t h e c a l l e r ' s p r o c e s s

    t a b l e s l o t , s u p e r u s e r t e l l s w h e t h e r t h e c a l l e r i s t h e

    s u p e r - u s e r a n d d o n t r e p l y i s s e t t o F A L S E . T h e n

    c a l l t h e a p p r o p r i a t e s y s t e m c a l l r o u t i n e .

    W h e n c o n t r o l c o m e s b a c k t o t h e m a i n l o o p . I f

    d o n t r e p l y i s s e t , r e p l y i s i n h i b i t e d ( e . g , p r o c e s s

    h a s b e e n b l o c k e d t o r e a d f r o m a n e m p t y p i p e ) .

    O t h e r w i s e , r e p l y i s s e n t .

    A t t h e e n d o f t h e l o o p , t r y t o s e e i f t h e l e i s b e i n g

    r e a d s e q u e n t i a l l y a n d t o l o a d t h e n e x t b l o c k i n t o

    t h e c a c h e b e f o r e i t i s r e q u e s t e d .

    C S C 3 1 5 0 : I n t r o d u c t i o n t o O p e r a t i n g S y s t e m s . P r e p a r e d b y D r . J o h n C . S . L u i 3 2

  • 8/10/2019 Minix File System

    34/38

    g e t w o r k ( ) c h e c k s t o s e e i f a n y p r e v i o u s l y b l o c k e d

    p r o c e d u r e s h a v e n o w b e e n r e v i v e d . T h e y h a v e

    H I G H E R P R I O R I T Y o v e r n e w m e s s a g e s . I f n o

    i n t e r n a l w o r k t o p e r f o r m , t h e F S c a l l t h e k e r n e l t o

    g e t a m e s s a g e .

    r e p l y ( ) i s b a s i c a l l y a r e p l y b a c k t o a u s e r p r o c e s s .

    f s i n i t ( ) i s c a l l e d f o r i n i t i a l i z a t i o n b e f o r e t h e F S

    i n n i t e l o o p . I t b u i l d s t h e b l o c k c a c h e , i n i t i a l i z e s

    t h e s u p e r - b l o c k t a b l e s , r e a d i n r o o t i - n o d e f o r t h e

    r o o t d e v i c e , l o a d i - n o d e a n d z o n e b i t m a p s .

    t a b l e . c c o n t a i n s t h e p o i n t e r a r r a y u s e d i n t h e F S

    m a i n l o o p f o r d e t e r m i n i n g w h i c h p r o c e d u r e h a n d l e s

    t o c a l l .

    C S C 3 1 5 0 : I n t r o d u c t i o n t o O p e r a t i n g S y s t e m s . P r e p a r e d b y D r . J o h n C . S . L u i 3 3

  • 8/10/2019 Minix File System

    35/38

    C r e a t i n g , o p e n i n g , a n d c l o s i n g l e s

    c r e a t i n g a l e i n v o l v e s 1 ) a l l o c a t i n g a n d i n i t i a l i z i n g

    a n i - n o d e f o r t h e n e w l e , 2 ) e n t e r i n g t h e n e w l e

    i n t h e p r o p e r d i r e c t o r y , 3 ) s e t t i n g u p a n d r e t u r n i n g

    a l e d e s c r i p t o r f o r t h e n e w l e .

    l e c r e a t i o n i s h a n d l e d b y p r o c e d u r e d o c r e a t ( ) .

    I t s t a r t s o u t b y f e t c h i n g t h e l e n a m e , m a k e s s u r e

    t h e l e d e s c r i p t o r a n d l p t a b l e s l o t s a r e a v a i l a b l e .

    I t t h e s e a r e o . k , c a l l n e w n o d e ( ) t o a l l o c a t e n e w

    i - n o d e . T h e n c l a i m s t h e l e d e s c r i p t o r a n d l p

    e n t r y .

    M K N O D s y s t e m c a l l i s h a n d l e d b y d o m k n o d . I t i s

    s i m i l a r t o d o c r e a t e e x c e p t t h a t i t c r e a t e s t h e i - n o d e

    a n d m a k e s a d i r e c t o r y e n t r y f o r i t . I f i - n o d e a l r e a d y

    e x i t s , t h e c a l l t e r m i n a t e s w i t h a n e r r o r .

    p r o c e d u r e n e w n o d e ( ) h a n d l e s i - n o d e a l l o c a t i o n

    a n d e n t e r i n g t h e p a t h n a m e i n t o t h e l e s y s t e m .

    C S C 3 1 5 0 : I n t r o d u c t i o n t o O p e r a t i n g S y s t e m s . P r e p a r e d b y D r . J o h n C . S . L u i 3 4

  • 8/10/2019 Minix File System

    36/38

    A f t e r i n o d e a l l o c a t i o n , m a k e s u r e t o w r i t e i t b a c k

    t o d i s k f o r c o n s i s t e n c y .

    d o o p e n ( ) i s t o o p e n a l e . I t p a r s e s t h e g i v e n

    l e n a m e a n d m a k e a l l n e c e s s a r y c h e c k ( e . g . , i s i t

    r e a d a b l e ) T h e n i t l o a d s i n t h e l e i n o d e i n t o t h e

    m e m o r y a n d l e d e s c r i p t o r i s r e t u r n e d .

    c l o s i n g a l e i s p e r f o r m e d b y d o c l o s e ( ) . I f i t i s

    a r e g u l a r l e , d e c r e m e n t t h e l p c o u n t e r . I f i t i s

    z e r o , r e t u r n t h e i - n o d e b y c a l l i n g p u t i n o d e ( ) , w h i c h

    i m p l i e s d e c r e m e n t i n g t h e t h e c o u n t e r i n t h e i n o d e

    t a b l e .

    r e a d i n g a n d w r i t i n g a l e i s d o n e b y c a l l i n g

    d o r e a d ( ) a n d d o w r i t e ( ) . B o t h o f t h e s e r o u t i n e s

    c a l l r e a d w r i t e ( ) w i t h a p p r o p r i a t e p a r a m e t e r .

    I n s i d e r e a d w r i t e ( ) r o u t i n e , t h e r e i s a s p e c i a l c o d e

    f o r t h e m e m o r y m a n a g e r t o R E A D t h e e n t i r e F S i n t o

    m e m o r y . T h e l o g i c a l s t r u c t u r e i s i n F i g u r e 5 . 4 0 .

    C S C 3 1 5 0 : I n t r o d u c t i o n t o O p e r a t i n g S y s t e m s . P r e p a r e d b y D r . J o h n C . S . L u i 3 5

  • 8/10/2019 Minix File System

    37/38

    do_read do_write

    read_write

    dev_io pipe_check rw_chunk

    read_map get_block rw_user put_block

    rw_block

    dev_io

    rw_dev

    sendrec

    Entry point

    Main procedure for reading/writing

    Read or Write one block Specialfiles

    Look updisk address

    User-FStransfer

    Return block to cache

    Search the cache

    List in dmap table

    Sends message to the kernel

    Figure 5.40: Some of the procedures involved in reading a file

    w r i t i n g a l e i s s i m i l a r t o r e a d i n g o n e e x c e p t

    t h a t w r i t i n g r e q u i r e s a l l o c a t i n g n e w d i s k b l o c k .

    P r o c e d u r e w r i t e m a p , w h i c h i s s i m i l a r t o r e a d m a p ,

    i n s t e a d l o o k i n g u p a p h y s i c a l b l o c k i n t h e i - n o d e

    a n d i t s i n d i r e c t b l o c k s , i t e n t e r s n e w b l o c k i n i n o d e

    o r i n t h e i n d i r e c t b l o c k s .

    p a t h n a m e l o o k u p i s d o n e i n l e p a t h . c , w h i c h

    C S C 3 1 5 0 : I n t r o d u c t i o n t o O p e r a t i n g S y s t e m s . P r e p a r e d b y D r . J o h n C . S . L u i 3 6

  • 8/10/2019 Minix File System

    38/38

    h a s s e v e r a l c o m p o n e n t s . N o t e t h a t p a t h n a m e s m a y

    b e a b s o l u t e o r r e l a t i v e , t h i s c a n b e d e t e c t e d b y

    e x a m i n i n g t h e r s t c o m p o n e n t o f t h e p a t h n a m e

    a r g u m e n t . F o r a b s o l u t e a d d r e s s , p o i n t t o t h e r o o t

    i - n o d e , f o r r e l a t i v e a d d r e s s , p o i n t t o t h e w o r k i n g

    d i r e c t o r y i n o d e . F i g u r e 5 . 4 2 .

    dev_io

    dev_io dev_io

    dev_io dev_io dev_io

    dev_io dev_io dev_io

    Convert path to i-node

    Get finaldirectory

    Process one component

    Loadi-node

    Look updisk address

    Find block in cache

    Return blockto cache

    Figure 5.42: Some of the procedures used in looking up path names

    m o u n t i n g a n d u n m o u n t i n g i s h a n d l e d i n

    l e m o u n t . c b y t w o r o u t i n e s , d o m o u n t a n d

    d o u n m o u n t . A g a i n , t h e r e a r e m a n y e r r o r c h e c k i n g

    c o d e s ( e . g . , c h e c k i n g i f t h e F S t o b e m o u n t e d i s a

    b l o c k d e v i c e o r n o t ) .

    C S C 3 1 5 0 : I n t r o d u c t i o n t o O p e r a t i n g S y s t e m s . P r e p a r e d b y D r . J o h n C . S . L u i 3 7


Recommended