Ext2fs Overview 0.1

download Ext2fs Overview 0.1

of 17

Transcript of Ext2fs Overview 0.1

  • 8/14/2019 Ext2fs Overview 0.1

    1/17

    T h e e x t e n d e d - 2 l e s y s t e m o v e r v i e w

    G a d i O x m a n , t g u d @ t o c h n a p c 2 . t e c h n i o n . a c . i l v 0 . 1 , A u g u s t 3 1 9 9 5

    C o n t e n t s

    1 P r e f a c e 2

    2 I n t r o d u c t i o n 3

    3 A l e s y s t e m - W h y d o w e n e e d i t ? 3

    4 T h e L i n u x V F S l a y e r 3

    5 A b o u t b l o c k s a n d b l o c k g r o u p s 4

    6 T h e v i e w o f i n o d e s f r o m t h e p o i n t o f v i e w o f a b l o c k s g r o u p 4

    7 T h e g r o u p d e s c r i p t o r s 4

    8 T h e b l o c k b i t m a p a l l o c a t i o n b l o c k 5

    9 T h e i n o d e a l l o c a t i o n b i t m a p 6

    1 0 O n t h e i n o d e a n d t h e i n o d e t a b l e s 6

    1 0 . 1 T h e a l l o c a t e d b l o c k s : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 7

    1 0 . 2 T h e i m o d e v a r i a b l e : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 8

    1 0 . 2 . 1 T h e r i g h t m o s t 4 o c t a l d i g i t s : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 8

    1 0 . 2 . 2 T h e l e f t m o s t t w o o c t a l d i g i t s : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 8

    1 0 . 3 T i m e a n d d a t e : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 9

    1 0 . 4 i s i z e : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 9

    1 0 . 5 U s e r a n d g r o u p i d : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 9

    1 0 . 6 H a r d l i n k s : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 1 0

    1 0 . 7 T h e E x t 2 f s e x t e n d e d a g s : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 1 0

    1 0 . 8 S y m b o l i c l i n k s : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 1 1

  • 8/14/2019 Ext2fs Overview 0.1

    2/17

    1 . P r e f a c e 2

    1 0 . 8 . 1 F a s t s y m b o l i c l i n k s : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 1 1

    1 0 . 8 . 2 S l o w s y m b o l i c l i n k s : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 1 1

    1 0 . 9 i v e r s i o n : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 1 1

    1 0 . 1 0 R e s e r v e d v a r i a b l e s : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 1 2

    1 0 . 1 1 S p e c i a l r e s e r v e d i n o d e s : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 1 2

    1 1 D i r e c t o r i e s 1 2

    1 2 T h e s u p e r b l o c k 1 3

    1 2 . 1 s u p e r b l o c k i d e n t i c a t i o n : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 1 4

    1 2 . 2 F i l e s y s t e m x e d p a r a m e t e r s : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 1 4

    1 2 . 3 E x t 2 f s e r r o r h a n d l i n g : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 1 5

    1 2 . 4 A d d i t i o n a l p a r a m e t e r s u s e d b y e 2 f s c k : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 1 5

    1 2 . 5 A d d i t i o n a l u s e r t u n a b l e p a r a m e t e r s : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 1 6

    1 2 . 6 F i l e s y s t e m c u r r e n t s t a t e : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 1 6

    1 3 C o p y r i g h t 1 6

    1 4 A c k n o w l e d g m e n t s 1 6

    1 P r e f a c e

    T h i s d o c u m e n t a t t e m p t s t o p r e s e n t a n o v e r v i e w o f t h e i n t e r n a l s t r u c t u r e o f t h e e x t 2 l e s y s t e m . I t w a s w r i t t e n

    i n s u m m e r 9 5 , w h i l e I w a s w o r k i n g o n t h e e x t 2 f i l e s y s t e m e d i t o r p r o j e c t E X T 2 E D

    I n t h e p r o c e s s o f c o n s t r u c t i n g E X T 2 E D , I a c q u i r e d k n o w l e d g e o f t h e v a r i o u s d e s i g n a s p e c t s o f t h e t h e e x t 2

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

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

    i t p r o v i d e s a s t a r t i n g p o i n t .

    I n t h e p r o c e s s o f l e a r n i n g t h e s u b j e c t , I h a v e u s e d t h e f o l l o w i n g s o u r c e s t o o l s :

    E x p e r i m e n t i n g w i t h E X T 2 E D , a s i t w a s d e v e l o p e d .

    T h e e x t 2 k e r n e l s o u r c e s :

    T h e m a i n e x t 2 i n c l u d e l e , u s r i n c l u d e l i n u x e x t 2 f s . h

    T h e c o n t e n t s o f t h e d i r e c t o r y u s r s r c l i n u x f s e x t 2

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

    T h e s l i d e s : T h e S e c o n d E x t e n d e d F i l e S y s t e m , C u r r e n t S t a t e , F u t u r e D e v e l o p m e n t , b y R e m y C a r d

  • 8/14/2019 Ext2fs Overview 0.1

    3/17

    2 . I n t r o d u c t i o n 3

    T h e s l i d e s : O p t i m i s a t i o n i n F i l e S y s t e m s , b y S t e p h e n T w e e d i e

    T h e v a r i o u s e x t 2 u t i l i t i e s .

    2 I n t r o d u c t i o n

    T h e S e c o n d E x t e n d e d F i l e S y s t e m E x t 2 f s i s v e r y p o p u l a r a m o n g L i n u x u s e r s . I f y o u u s e L i n u x , c h a n c e s

    a r e t h a t y o u a r e u s i n g t h e e x t 2 l e s y s t e m .

    E x t 2 f s w a s d e s i g n e d b y R e m y C a r d a n d W a y n e D a v i s o n . I t w a s i m p l e m e n t e d b y R e m y C a r d a n d w a s f u r t h e r

    e n h a n c e d b y S t e p h e n T w e e d i e a n d T h e o d o r e T s ' o

    T h e e x t 2 l e s y s t e m i s s t i l l u n d e r d e v e l o p m e n t . I w i l l d o c u m e n t h e r e v e r s i o n 0 . 5 a , w h i c h i s d i s t r i b u t e d a l o n g

    w i t h L i n u x 1 . 2 . x . A t t h i s t i m e o f w r i t i n g , t h e m o s t r e c e n t v e r s i o n o f L i n u x i s 1 . 3 . 1 3 , a n d t h e v e r s i o n o f t h e

    e x t 2 k e r n e l s o u r c e i s 0 . 5 b . A l o t o f f a n c y e n h a n c e m e n t s a r e p l a n n e d f o r t h e e x t 2 l e s y s t e m i n L i n u x 1 . 3 , s o

    s t a y t u n e d .

    3 A l e s y s t e m - W h y d o w e n e e d i t ?

    I t h o u g h t t h a t b e f o r e w e d i v e i n t o t h e v a r i o u s s m a l l d e t a i l s , I ' l l r e s e r v e a f e w m i n u t e s f o r t h e d i s c u s s i o n o f

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

    A f i l e s y s t e m c o n s i s t s o f t w o w o r d - f i l e a n d s y s t e m

    E v e r y o n e k n o w s t h e m e a n i n g o f t h e w o r d f i l e - A b u n c h o f d a t a p u t s o m e w h e r e . w h e r e ? T h i s i s a n i m p o r t a n t

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

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

    T h i s i s w h e r e t h e s y s t e m c o m e s i n - I n s t e a d o f j u s t t h r o w i n g t h e d a t a t o t h e d e v i c e , w e g e n e r a l i z e a n d

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

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

    i t , i s t o m a k e i t e a s y f o r u s t o u p d a t e a n d m a i n t a i n o u r d a t a .

    N o r m a l l y , b y m o u n t i n g l e s y s t e m s , w e j u s t u s e t h e n i c e a n d l o g i c a l v i r t u a l s t r u c t u r e . H o w e v e r , t h e d i s k k n o w s

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

    w h e r e v e r w e w i s h . I t i s t h e t a s k o f t h e l e s y s t e m m a n a g e m e n t c o d e t o s t o r e b o o k k e e p i n g i n f o r m a t i o n w h i c h

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

    I n t h i s d o c u m e n t , w e c o n s i d e r o n e p a r t i c u l a r a d m i n i s t r a t i v e s t r u c t u r e - T h e S e c o n d E x t e n d e d F i l e s y s t e m .

    4 T h e L i n u x V F S l a y e r

    W h e n L i n u x w a s r s t d e v e l o p e d , i t s u p p o r t e d o n l y o n e l e s y s t e m - T h e M i n i x l e s y s t e m . T o d a y , L i n u x h a s

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

    b e t w e e n t h e k e r n e l a n d t h e l e s y s t e m c o d e - T h e V i r t u a l F i l e S y s t e m V F S .

  • 8/14/2019 Ext2fs Overview 0.1

    4/17

    5 . A b o u t b l o c k s a n d b l o c k g r o u p s 4

    T h e k e r n e l " s p e a k s " w i t h t h e V F S l a y e r . T h e V F S l a y e r p a s s e s t h e k e r n e l ' s r e q u e s t t o t h e p r o p e r l e s y s t e m

    m a n a g e m e n t c o d e . I h a v e n ' t l e a r n e d m u c h o f t h e V F S l a y e r a s I d i d n ' t n e e d i t f o r t h e c o n s t r u c t i o n o f E X T 2 E D

    s o t h a t I c a n ' t e l a b o r a t e o n i t . J u s t b e a w a r e t h a t i t e x i s t s .

    5 A b o u t b l o c k s a n d b l o c k g r o u p s

    I n o r d e r t o e a s e m a n a g e m e n t , t h e e x t 2 l e s y s t e m l o g i c a l l y d i v i d e s t h e d i s k i n t o s m a l l u n i t s c a l l e d b l o c k s A

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

    1

    T h e b l o c k s i z e c a n b e s e l e c t e d t o b e 1 0 2 4 , 2 0 4 8 o r 4 0 9 6 b y t e s w h e n c r e a t i n g t h e l e s y s t e m .

    E x t 2 f s g r o u p s t o g e t h e r a x e d n u m b e r o f s e q u e n t i a l b l o c k s i n t o a g r o u p b l o c k . T h e r e s u l t i n g s i t u a t i o n i s

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

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

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

    6 T h e v i e w o f i n o d e s f r o m t h e p o i n t o f v i e w o f a b l o c k s g r o u p

    E a c h l e i n t h e l e s y s t e m i s r e s e r v e d a s p e c i a l i n o d e . I d o n ' t w a n t t o e x p l a i n i n o d e s n o w . R a t h e r , I w o u l d

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

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

    7 T h e g r o u p d e s c r i p t o r s

    E a c h b l o c k s g r o u p i s a c c o m p a n i e d b y a g r o u p d e s c r i p t o r . T h e g r o u p d e s c r i p t o r s u m m a r i z e s s o m e n e c e s s a r y

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

    u s r i n c l u d e l i n u x e x t 2 f s . h :

    s t r u c t e x t 2 _ g r o u p _ d e s c

    _ _ u 3 2 b g _ b l o c k _ b i t m a p ; * B l o c k s b i t m a p b l o c k *

    _ _ u 3 2 b g _ i n o d e _ b i t m a p ; * I n o d e s b i t m a p b l o c k *

    _ _ u 3 2 b g _ i n o d e _ t a b l e ; * I n o d e s t a b l e b l o c k *

    _ _ u 1 6 b g _ f r e e _ b l o c k s _ c o u n t ; * F r e e b l o c k s c o u n t *

    _ _ u 1 6 b g _ f r e e _ i n o d e s _ c o u n t ; * F r e e i n o d e s c o u n t *

    _ _ u 1 6 b g _ u s e d _ d i r s _ c o u n t ; * D i r e c t o r i e s c o u n t *

    _ _ u 1 6 b g _ p a d ;

    _ _ u 3 2 b g _ r e s e r v e d 3 ;

    ;

    1

    T h e E x t 2 f s s o u r c e c o d e r e f e r s t o t h e c o n c e p t o f f r a g m e n t s , w h i c h I b e l i e v e a r e s u p p o s e d t o b e s u b - b l o c k a l l o c a t i o n s .

    A s f a r a s I k n o w , f r a g m e n t s a r e c u r r e n t l y u n s u p p o r t e d i n E x t 2 f s .

  • 8/14/2019 Ext2fs Overview 0.1

    5/17

    8 . T h e b l o c k b i t m a p a l l o c a t i o n b l o c k 5

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

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

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

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

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

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

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

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

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

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

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

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

    H o w e v e r , o n l y t h e r s t c o p y i n g r o u p 0 i s a c t u a l l y u s e d b y t h e k e r n e l . T h e o t h e r c o p i e s a r e t h e r e f o r b a c k u p

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

    8 T h e b l o c k b i t m a p a l l o c a t i o n b l o c k

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

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

    g r o u p i s u s e d o r f r e e .

    T h e f o r m a t i s a c t u a l l y q u i t e s i m p l e - J u s t v i e w t h e e n t i r e b l o c k a s a s e r i e s o f b i t s . F o r e x a m p l e ,

    S u p p o s e t h e b l o c k s i z e i s 1 0 2 4 b y t e s . A s s u c h , t h e r e i s a p l a c e f o r 1 0 2 4 * 8 = 8 1 9 2 b l o c k s i n a g r o u p b l o c k . T h i s

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

    B l o c k 0 i n t h e b l o c k s g r o u p i s m a n a g e d b y b i t 0 o f b y t e 0 i n t h e b i t m a p b l o c k .

    B l o c k 7 i n t h e b l o c k s g r o u p i s m a n a g e d b y b i t 7 o f b y t e 0 i n t h e b i t m a p b l o c k .

    B l o c k 8 i n t h e b l o c k s g r o u p i s m a n a g e d b y b i t 0 o f b y t e 1 i n t h e b i t m a p b l o c k .

    B l o c k 8 1 9 1 i n t h e b l o c k s g r o u p i s m a n a g e d b y b i t 7 o f b y t e 1 0 2 3 i n t h e b i t m a p b l o c k .

    A v a l u e o f " 1 " i n t h e a p p r o p r i a t e b i t s i g n a l s t h a t t h e b l o c k i s a l l o c a t e d , w h i l e a v a l u e o f " 0 " s i g n a l s t h a t t h e

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

    Y o u w i l l p r o b a b l y n o t i c e t h a t t y p i c a l l y , a l l t h e b i t s i n a b y t e c o n t a i n t h e s a m e v a l u e , m a k i n g t h e b y t e ' s v a l u e

    0 o r 0 f f h . T h i s i s d o n e b y t h e k e r n e l o n p u r p o s e i n o r d e r t o g r o u p r e l a t e d d a t a i n p h y s i c a l l y c l o s e b l o c k s ,

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

  • 8/14/2019 Ext2fs Overview 0.1

    6/17

    9 . T h e i n o d e a l l o c a t i o n b i t m a p 6

    9 T h e i n o d e a l l o c a t i o n b i t m a p

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

    b l o c k . T h e e x p l a n a t i o n a b o v e i s v a l i d h e r e , w i t h t h e w o r k b l o c k r e p l a c e d b y i n o d e . T y p i c a l l y , t h e r e a r e

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

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

    1 0 O n t h e i n o d e a n d t h e i n o d e t a b l e s

    A n i n o d e i s a m a i n r e s o u r c e i n t h e e x t 2 l e s y s t e m . I t i s u s e d f o r v a r i o u s p u r p o s e s , b u t t h e m a i n t w o a r e :

    S u p p o r t o f l e s

    S u p p o r t o f d i r e c t o r i e s

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

    A n e x t 2 l e s y s t e m h a s a t o t a l n u m b e r o f a v a i l a b l e i n o d e s w h i c h i s d e t e r m i n e d w h i l e c r e a t i n g t h e l e s y s t e m .

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

    w i l l s t i l l b e f r e e b l o c k s o n t h e l e s y s t e m .

    E a c h i n o d e t a k e s u p 1 2 8 b y t e s i n t h e l e s y s t e m . B y d e f a u l t , m k e 2 f s r e s e r v e s a n i n o d e f o r e a c h 4 0 9 6 b y t e s

    o f t h e l e s y s t e m s p a c e .

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

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

    o f l o c a l i t y a r g u m e n t s .

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

    e x a m p l e , i f t h e r e a r e 2 0 0 0 i n o d e s p e r g r o u p , g r o u p 0 w i l l c o n t a i n t h e i n o d e s 1 - 2 0 0 0 , g r o u p 2 w i l l c o n t a i n t h e

    i n o d e s 2 0 0 1 - 4 0 0 0 , a n d s o o n .

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

    F o l l o w s t h e s t r u c t u r e o f a n i n o d e i n E x t 2 f s :

    s t r u c t e x t 2 _ i n o d e

    _ _ u 1 6 i _ m o d e ; * F i l e m o d e *

    _ _ u 1 6 i _ u i d ; * O w n e r U i d *

    _ _ u 3 2 i _ s i z e ; * S i z e i n b y t e s *

    _ _ u 3 2 i _ a t i m e ; * A c c e s s t i m e *

    _ _ u 3 2 i _ c t i m e ; * C r e a t i o n t i m e *

    _ _ u 3 2 i _ m t i m e ; * M o d i f i c a t i o n t i m e *

    _ _ u 3 2 i _ d t i m e ; * D e l e t i o n T i m e *

    _ _ u 1 6 i _ g i d ; * G r o u p I d *

    _ _ u 1 6 i _ l i n k s _ c o u n t ; * L i n k s c o u n t *

    _ _ u 3 2 i _ b l o c k s ; * B l o c k s c o u n t *

    _ _ u 3 2 i _ f l a g s ; * F i l e f l a g s *

    u n i o n

  • 8/14/2019 Ext2fs Overview 0.1

    7/17

    1 0 . O n t h e i n o d e a n d t h e i n o d e t a b l e s 7

    s t r u c t

    _ _ u 3 2 l _ i _ r e s e r v e d 1 ;

    l i n u x 1 ;

    s t r u c t

    _ _ u 3 2 h _ i _ t r a n s l a t o r ;

    h u r d 1 ;

    s t r u c t

    _ _ u 3 2 m _ i _ r e s e r v e d 1 ;

    m a s i x 1 ;

    o s d 1 ; * O S d e p e n d e n t 1 *

    _ _ u 3 2 i _ b l o c k E X T 2 _ N _ B L O C K S ; * P o i n t e r s t o b l o c k s *

    _ _ u 3 2 i _ v e r s i o n ; * F i l e v e r s i o n f o r N F S *

    _ _ u 3 2 i _ f i l e _ a c l ; * F i l e A C L *

    _ _ u 3 2 i _ d i r _ a c l ; * D i r e c t o r y A C L *

    _ _ u 3 2 i _ f a d d r ; * F r a g m e n t a d d r e s s *

    u n i o n

    s t r u c t

    _ _ u 8 l _ i _ f r a g ; * F r a g m e n t n u m b e r *

    _ _ u 8 l _ i _ f s i z e ; * F r a g m e n t s i z e *

    _ _ u 1 6 i _ p a d 1 ;

    _ _ u 3 2 l _ i _ r e s e r v e d 2 2 ;

    l i n u x 2 ;

    s t r u c t

    _ _ u 8 h _ i _ f r a g ; * F r a g m e n t n u m b e r *

    _ _ u 8 h _ i _ f s i z e ; * F r a g m e n t s i z e *

    _ _ u 1 6 h _ i _ m o d e _ h i g h ;

    _ _ u 1 6 h _ i _ u i d _ h i g h ;

    _ _ u 1 6 h _ i _ g i d _ h i g h ;

    _ _ u 3 2 h _ i _ a u t h o r ;

    h u r d 2 ;

    s t r u c t

    _ _ u 8 m _ i _ f r a g ; * F r a g m e n t n u m b e r *

    _ _ u 8 m _ i _ f s i z e ; * F r a g m e n t s i z e *

    _ _ u 1 6 m _ p a d 1 ;

    _ _ u 3 2 m _ i _ r e s e r v e d 2 2 ;

    m a s i x 2 ;

    o s d 2 ; * O S d e p e n d e n t 2 *

    ;

    1 0 . 1 T h e a l l o c a t e d b l o c k s

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

    t h e a l l o c a t e d b l o c k s - E a c h b l o c k c a n b e a l l o c a t e d t o e a c h i n o d e . N e v e r t h e l e s s , b l o c k a l l o c a t i o n w i l l u s u a l l y

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

    T h e i n o d e i s n o t a l w a y s u s e d i n t h a t w a y . I w i l l n o w e x p l a i n t h e a l l o c a t i o n o f b l o c k s , a s s u m i n g t h a t t h e

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

  • 8/14/2019 Ext2fs Overview 0.1

    8/17

    1 0 . O n t h e i n o d e a n d t h e i n o d e t a b l e s 8

    I t w a s f o u n d e x p e r i m e n t l y t h a t m a n y o f t h e l e s i n t h e l e s y s t e m a r e a c t u a l l y q u i t e s m a l l . T o t a k e a d v a n t a g e

    o f t h i s e e c t , t h e k e r n e l p r o v i d e s s t o r a g e o f u p t o 1 2 b l o c k n u m b e r s i n t h e i n o d e i t s e l f . T h o s e b l o c k s a r e

    c a l l e d d i r e c t b l o c k s . T h e a d v a n t a g e i s t h a t o n c e t h e k e r n e l h a s t h e i n o d e , i t c a n d i r e c t l y a c c e s s t h e l e ' s

    b l o c k s , w i t h o u t a n a d d i t i o n a l d i s k a c c e s s . T h o s e 1 2 b l o c k s a r e d i r e c t l y s p e c i e d i n t h e v a r i a b l e s i b l o c k 0

    t o i b l o c k 1 1

    i b l o c k 1 2 i s t h e i n d i r e c t b l o c k - T h e b l o c k p o i n t e d b y i b l o c k 1 2 w i l l n o t b e a d a t a b l o c k . R a t h e r , i t

    w i l l j u s t c o n t a i n a l i s t o f d i r e c t b l o c k s . F o r e x a m p l e , i f t h e b l o c k s i z e i s 1 0 2 4 b y t e s , s i n c e e a c h b l o c k n u m b e r

    i s 4 b y t e s l o n g , t h e r e w i l l b e p l a c e f o r 2 5 6 i n d i r e c t b l o c k s . T h a t i s , b l o c k 1 3 t i l l b l o c k 2 6 8 i n t h e l e w i l l b e

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

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

    I n m u c h t h e s a m e w a y , i b l o c k 1 3 i s t h e d o u b l e i n d i r e c t b l o c k a n d i b l o c k 1 4 i s t h e t r i p l e

    i n d i r e c t b l o c k

    i b l o c k 1 3 p o i n t s t o a b l o c k w h i c h c o n t a i n s p o i n t e r s t o i n d i r e c t b l o c k s . E a c h o n e o f t h e m i s h a n d l e d i n

    t h e w a y d e s c r i b e d a b o v e .

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

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

    1 0 . 2 T h e i m o d e v a r i a b l e

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

    d e s c r i b e d b y r e p r e s e n t i n g i t a s a n o c t a l n u m b e r . S i n c e i t i s a 1 6 b i t v a r i a b l e , t h e r e w i l l b e 6 o c t a l d i g i t s .

    T h o s e a r e d i v i d e d i n t o t w o p a r t s - T h e r i g h t m o s t 4 d i g i t s a n d t h e l e f t m o s t 2 d i g i t s .

    1 0 . 2 . 1 T h e r i g h t m o s t 4 o c t a l d i g i t s

    T h e r i g h t m o s t 4 d i g i t s a r e b i t o p t i o n s - E a c h b i t h a s i t s o w n p u r p o s e .

    T h e l a s t 3 d i g i t s O c t a l d i g i t s 0 , 1 a n d 2 a r e j u s t t h e u s u a l p e r m i s s i o n s , i n t h e k n o w n f o r m r w x r w x r w x . D i g i t

    2 r e f e r s t o t h e u s e r , d i g i t 1 t o t h e g r o u p a n d d i g i t 2 t o e v e r y o n e e l s e . T h e y a r e u s e d b y t h e k e r n e l t o g r a n t

    o r d e n y a c c e s s t o t h e o b j e c t p r e s e n t e d b y t h i s i n o d e .

    2

    B i t n u m b e r 9 s i g n a l s t h a t t h e l e I ' l l r e f e r t o t h e o b j e c t p r e s e n t e d b y t h e i n o d e a s l e e v e n t h o u g h i t c a n b e

    a s p e c i a l d e v i c e , f o r e x a m p l e i s s e t V T X . I s t i l l d o n ' t k n o w w h a t i s t h e m e a n i n g o f " V T X " .

    B i t n u m b e r 1 0 s i g n a l s t h a t t h e l e i s s e t g r o u p i d - I d o n ' t k n o w e x a c t l y t h e m e a n i n g o f t h e a b o v e e i t h e r .

    B i t n u m b e r 1 1 s i g n a l s t h a t t h e l e i s s e t u s e r i d , w h i c h m e a n s t h a t t h e l e w i l l r u n w i t h a n e e c t i v e u s e r

    i d r o o t .

    1 0 . 2 . 2 T h e l e f t m o s t t w o o c t a l d i g i t s

    N o t e t h e t h e l e f t m o s t o c t a l d i g i t c a n o n l y b e 0 o r 1 , s i n c e t h e t o t a l n u m b e r o f b i t s i s 1 6 .

    2

    A s m a r t e r p e r m i s s i o n s c o n t r o l i s o n e o f t h e e n h a n c e m e n t s p l a n n e d f o r L i n u x 1 . 3 - T h e A C L A c c e s s C o n t r o l

    L i s t s . A c t u a l l y , f r o m b r o w s i n g o f t h e k e r n e l s o u r c e , s o m e o f t h e A C L h a n d l i n g i s a l r e a d y d o n e .

  • 8/14/2019 Ext2fs Overview 0.1

    9/17

    1 0 . O n t h e i n o d e a n d t h e i n o d e t a b l e s 9

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

    t h e " l e " t o w h i c h t h e i n o d e b e l o n g s :

    0 1 - T h e l e i s a F I F O

    0 2 - T h e l e i s a c h a r a c t e r d e v i c e

    0 4 - T h e l e i s a d i r e c t o r y

    0 6 - T h e l e i s a b l o c k d e v i c e

    1 0 - T h e l e i s a r e g u l a r f i l e

    1 2 - T h e l e i s a s y m b o l i c l i n k

    1 4 - T h e l e i s a s o c k e t

    1 0 . 3 T i m e a n d d a t e

    L i n u x r e c o r d s t h e l a s t t i m e i n w h i c h v a r i o u s o p e r a t i o n s o c c u r e d w i t h t h e l e . T h e t i m e a n d d a t e a r e s a v e d i n

    t h e s t a n d a r d C l i b r a r y f o r m a t - T h e n u m b e r o f s e c o n d s w h i c h p a s s e d s i n c e 0 0 : 0 0 : 0 0 G M T , J a n u a r y 1 , 1 9 7 0 .

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

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

    w a s c r e a t e d .

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

    i a t i m e - T h e t i m e i n w h i c h t h e l e w a s l a s t a c c e s s e d .

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

    d e l e t e d .

    1 0 . 4 i s i z e

    i s i z e c o n t a i n s i n f o r m a t i o n a b o u t t h e s i z e o f t h e o b j e c t p r e s e n t e d b y t h e i n o d e . I f t h e i n o d e c o r r e s p o n d s

    t o a r e g u l a r l e , t h i s i s j u s t t h e s i z e o f t h e l e i n b y t e s . I n o t h e r c a s e s , t h e i n t e r p r e t a t i o n o f t h e v a r i a b l e i s

    d i e r e n t .

    1 0 . 5 U s e r a n d g r o u p i d

    T h e u s e r a n d g r o u p i d o f t h e l e a r e j u s t s a v e d i n t h e v a r i a b l e s i u i d a n d i g i d

  • 8/14/2019 Ext2fs Overview 0.1

    10/17

    1 0 . O n t h e i n o d e a n d t h e i n o d e t a b l e s 1 0

    1 0 . 6 H a r d l i n k s

    L a t e r , w h e n w e ' l l d i s c u s s t h e i m p l e m e n t a t i o n o f d i r e c t o r i e s , i t w i l l b e e x p l a i n e d t h a t e a c h d i r e c t o r y e n t r y

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

    t h a t c a s e , w e s a y t h a t t h e r e e x i s t h a r d l i n k s t o t h e l e - T h e l e c a n b e a c c e s s e d f r o m e a c h o f t h e d i r e c t o r i e s .

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

    w h e n r s t a l l o c a t i n g t h e i n o d e , a n d i s i n c r e m e n t e d w i t h e a c h a d d i t i o n a l l i n k . D e l e t i o n o f a l e w i l l d e l e t e

    t h e c u r r e n t d i r e c t o r y e n t r y a n d w i l l d e c r e m e n t t h e n u m b e r o f l i n k s . O n l y w h e n t h i s n u m b e r r e a c h e s z e r o , t h e

    i n o d e w i l l b e a c t u a l l y d e a l l o c a t e d .

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

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

    1 0 . 7 T h e E x t 2 f s e x t e n d e d a g s

    T h e e x t 2 l e s y s t e m a s s o c i a t e s a d d i t i o n a l a g s w i t h a n i n o d e . T h e e x t e n d e d a t t r i b u t e s a r e s t o r e d i n t h e

    v a r i a b l e i f l a g s i f l a g s i s a 3 2 b i t v a r i a b l e . O n l y t h e 7 r i g h t m o s t b i t s a r e d e n e d . O f t h e m , o n l y 5

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

    i m p l e m e n t e d , a n d a r e t o b e i n t r o d u c e d i n L i n u x 1 . 3 d e v e l o p m e n t .

    T h e c u r r e n t l y a v a i l a b l e a g s a r e :

    b i t 0 - S e c u r e d e l e t i o n .

    W h e n t h i s b i t i s o n , t h e l e ' s b l o c k s a r e z e r o e d w h e n t h e l e i s d e l e t e d . W i t h t h i s b i t o , t h e y w i l l j u s t

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

    b i t 1 - U n d e l e t e .

    T h i s b i t i s n o t s u p p o r t e d y e t . I t w i l l b e u s e d t o p r o v i d e a n u n d e l e t e f e a t u r e i n f u t u r e E x t 2 f s d e v e l o p -

    m e n t s .

    b i t 2 - C o m p r e s s l e .

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

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

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

    m o u n t e d w i t h t h e " s y n c " m o u n t o p t i o n .

    b i t 4 - I m m u t a b l e l e .

    W h e n t h i s b i t i s o n , t h e l e w i l l s t a y a s i t i s - C a n n o t b e c h a n g e d , d e l e t e d , r e n a m e d , n o h a r d l i n k s ,

    e t c , b e f o r e t h e b i t i s c l e a r e d .

    b i t 5 - A p p e n d o n l y l e .

    W i t h t h i s o p t i o n a c t i v e , d a t a w i l l o n l y b e a p p e n d e d t o t h e l e .

    b i t 6 - D o n o t d u m p t h i s l e .

    I t h i n k t h a t t h i s b i t i s u s e d b y t h e p o r t o f d u m p t o l i n u x p o r t e d b y R e m y C a r d t o c h e c k i f t h e l e

    s h o u l d n o t b e d u m p e d .

  • 8/14/2019 Ext2fs Overview 0.1

    11/17

    1 0 . O n t h e i n o d e a n d t h e i n o d e t a b l e s 1 1

    1 0 . 8 S y m b o l i c l i n k s

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

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

    l e s y s t e m a r e v i s i b l e t o t h e u s e r - I n a p u r e a b s t r a c t u s a g e o f t h e l e s y s t e m , t h e u s e r s h o u l d n o t c a r e a b o u t

    i n o d e s .

    T h e a b o v e c a u s e s s e v e r a l l i m i t a t i o n s :

    H a r d l i n k s c a n b e d o n e o n l y i n t h e s a m e l e s y s t e m . T h i s i s o b v i o u s , s i n c e a h a r d l i n k i s j u s t a n i n o d e

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

    Y o u c a n n o t " r e p l a c e " t h e l e w h i c h i s p o i n t e d t o b y t h e h a r d l i n k a f t e r t h e l i n k c r e a t i o n . " R e p l a c i n g "

    t h e l e i n o n e d i r e c t o r y w i l l s t i l l l e a v e t h e o r i g i n a l l e i n t h e o t h e r d i r e c t o r y - T h e " r e p l a c e m e n t " w i l l n o t

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

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

    S y m b o l i c l i n k , o n t h e o t h e r h a n d , i s a n a l y z e d a t r u n t i m e . A s y m b o l i c l i n k i s j u s t a p a t h n a m e w h i c h i s

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

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

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

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

    T h e d i s a d v a n t a g e i s t h a t h a r d l i n k d o e s n ' t c o n s u m e s p a c e e x c e p t t o a s m a l l d i r e c t o r y e n t r y . S y m b o l i c l i n k ,

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

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

    1 0 . 8 . 1 F a s t s y m b o l i c l i n k s

    W h e n t h e p a t h n a m e c o n t a i n s u p t o 6 4 b y t e s , i t c a n b e s a v e d d i r e c t l y i n t h e i n o d e , o n t h e i b l o c k 0 -

    i b l o c k 1 5 v a r i a b l e s , s i n c e t h o s e a r e n o t n e e d e d i n t h a t c a s e . T h i s i s c a l l e d f a s t s y m b o l i c l i n k . I t i s f a s t

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

    a l s o e c o n o m i c a l , s i n c e i t a l l o c a t e s o n l y a n i n o d e . T h e l e n g t h o f t h e p a t h n a m e i s s t o r e d i n t h e i s i z e v a r i a b l e .

    1 0 . 8 . 2 S l o w s y m b o l i c l i n k s

    S t a r t i n g f r o m 6 5 b y t e s , a d d i t i o n a l b l o c k i s a l l o c a t e d b y t h e u s e o f i b l o c k 0 a n d t h e p a t h n a m e i s s t o r e d

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

    i s a g a i n s a v e d i n i s i z e

    1 0 . 9 i v e r s i o n

    i v e r s i o n i s u s e d w i t h r e g a r d t o N e t w o r k F i l e S y s t e m . I d o n ' t k n o w i t s e x a c t u s e .

  • 8/14/2019 Ext2fs Overview 0.1

    12/17

    1 1 . D i r e c t o r i e s 1 2

    1 0 . 1 0 R e s e r v e d v a r i a b l e s

    A s f a r a s I k n o w , t h e v a r i a b l e s w h i c h a r e c o n n e c t e d t o A C L a n d f r a g m e n t s a r e n o t c u r r e n t l y u s e d . T h e y w i l l

    b e s u p p o r t e d i n f u t u r e v e r s i o n s .

    E x t 2 f s i s b e i n g p o r t e d t o o t h e r o p e r a t i n g s y s t e m s . A s f a r a s I k n o w , a t l e a s t i n l i n u x , t h e o s d e p e n d e n t

    v a r i a b l e s a r e a l s o n o t u s e d .

    1 0 . 1 1 S p e c i a l r e s e r v e d i n o d e s

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

    I n o d e 1 i s t h e b a d b l o c k s i n o d e - I b e l i e v e t h a t i t s d a t a b l o c k s c o n t a i n a l i s t o f t h e b a d b l o c k s i n t h e

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

    I n o d e 2 i s t h e r o o t i n o d e - 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 . I t i s t h e s t a r t i n g p o i n t f o r r e a c h i n g a

    k n o w n p a t h i n t h e l e s y s t e m .

    I n o d e 3 i s t h e a c l i n d e x i n o d e . A c c e s s c o n t r o l l i s t s a r e c u r r e n t l y n o t s u p p o r t e d b y t h e e x t 2 l e s y s t e m ,

    s o I b e l i e v e t h i s i n o d e i s n o t u s e d .

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

    I n o d e 5 i s t h e b o o t l o a d e r i n o d e . I d o n ' t k n o w i t s u s a g e .

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

    c u r r e n t l y n o t u s e d .

    I n o d e s 7 - 1 0 a r e r e s e r v e d a n d c u r r e n t l y n o t u s e d .

    1 1 D i r e c t o r i e s

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

    e t c - I t i s j u s t a l e w h i c h i s f o r m a t t e d w i t h a s p e c i a l f o r m a t - A l i s t o f d i r e c t o r y e n t r i e s .

    F o l l o w s t h e d e n i t i o n o f a d i r e c t o r y e n t r y :

    s t r u c t e x t 2 _ d i r _ e n t r y

    _ _ u 3 2 i n o d e ; * I n o d e n u m b e r *

    _ _ u 1 6 r e c _ l e n ; * D i r e c t o r y e n t r y l e n g t h *

    _ _ u 1 6 n a m e _ l e n ; * N a m e l e n g t h *

    c h a r n a m e E X T 2 _ N A M E _ L E N ; * F i l e n a m e *

    ;

    E x t 2 f s s u p p o r t s l e n a m e s o f v a r y i n g l e n g t h s , u p t o 2 5 5 b y t e s . T h e n a m e e l d a b o v e j u s t c o n t a i n s t h e l e

    n a m e . N o t e t h a t i t i s n o t z e r o t e r m i n a t e d ; I n s t e a d , t h e v a r i a b l e n a m e l e n c o n t a i n s t h e l e n g t h o f t h e l e

    n a m e .

  • 8/14/2019 Ext2fs Overview 0.1

    13/17

    1 2 . T h e s u p e r b l o c k 1 3

    T h e v a r i a b l e r e c l e n i s p r o v i d e d b e c a u s e t h e d i r e c t o r y e n t r i e s a r e p a d d e d w i t h z e r o e s s o t h a t t h e n e x t e n t r y

    w i l l b e i n a n o s e t w h i c h i s a m u l t i p l i t i o n o f 4 . T h e r e s u l t i n g d i r e c t o r y e n t r y s i z e i s s t o r e d i n r e c l e n I f

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

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

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

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

    n o t s u r e e n t r y .

    1 2 T h e s u p e r b l o c k

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

    T h e s u p e r b l o c k i s l o c a t e d a t t h e f i x e d o f f s e t 1 0 2 4 i n t h e d e v i c e . I t s l e n g t h i s 1 0 2 4 b y t e s a l s o .

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

    H o w e v e r , o n l y t h e m a i n c o p y i s u s e d b y t h e k e r n e l .

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

    F i l e s y s t e m p a r a m e t e r s w h i c h a r e x e d a n d w h i c h w e r e d e t e r m i n e d w h e n t h i s s p e c i c l e s y s t e m w a s

    c r e a t e d . S o m e o f t h o s e p a r a m e t e r s c a n b e d i e r e n t i n d i e r e n t i n s t a l l a t i o n s o f t h e e x t 2 l e s y s t e m , b u t

    c a n n o t b e c h a n g e d o n c e t h e l e s y s t e m w a s c r e a t e d .

    F i l e s y s t e m p a r a m e t e r s w h i c h a r e t u n a b l e - C a n a l w a y s b e c h a n g e d .

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

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

    s t r u c t e x t 2 _ s u p e r _ b l o c k

    _ _ u 3 2 s _ i n o d e s _ c o u n t ; * I n o d e s c o u n t *

    _ _ u 3 2 s _ b l o c k s _ c o u n t ; * B l o c k s c o u n t *

    _ _ u 3 2 s _ r _ b l o c k s _ c o u n t ; * R e s e r v e d b l o c k s c o u n t *

    _ _ u 3 2 s _ f r e e _ b l o c k s _ c o u n t ; * F r e e b l o c k s c o u n t *

    _ _ u 3 2 s _ f r e e _ i n o d e s _ c o u n t ; * F r e e i n o d e s c o u n t *

    _ _ u 3 2 s _ f i r s t _ d a t a _ b l o c k ; * F i r s t D a t a B l o c k *

    _ _ u 3 2 s _ l o g _ b l o c k _ s i z e ; * B l o c k s i z e *

    _ _ s 3 2 s _ l o g _ f r a g _ s i z e ; * F r a g m e n t s i z e *

    _ _ u 3 2 s _ b l o c k s _ p e r _ g r o u p ; * B l o c k s p e r g r o u p *

    _ _ u 3 2 s _ f r a g s _ p e r _ g r o u p ; * F r a g m e n t s p e r g r o u p *

    _ _ u 3 2 s _ i n o d e s _ p e r _ g r o u p ; * I n o d e s p e r g r o u p *

    _ _ u 3 2 s _ m t i m e ; * M o u n t t i m e *

    _ _ u 3 2 s _ w t i m e ; * W r i t e t i m e *

    _ _ u 1 6 s _ m n t _ c o u n t ; * M o u n t c o u n t *

    _ _ s 1 6 s _ m a x _ m n t _ c o u n t ; * M a x i m a l m o u n t c o u n t *

    _ _ u 1 6 s _ m a g i c ; * M a g i c s i g n a t u r e *

    _ _ u 1 6 s _ s t a t e ; * F i l e s y s t e m s t a t e *

  • 8/14/2019 Ext2fs Overview 0.1

    14/17

    1 2 . T h e s u p e r b l o c k 1 4

    _ _ u 1 6 s _ e r r o r s ; * B e h a v i o u r w h e n d e t e c t i n g e r r o r s *

    _ _ u 1 6 s _ p a d ;

    _ _ u 3 2 s _ l a s t c h e c k ; * t i m e o f l a s t c h e c k *

    _ _ u 3 2 s _ c h e c k i n t e r v a l ; * m a x . t i m e b e t w e e n c h e c k s *

    _ _ u 3 2 s _ c r e a t o r _ o s ; * O S *

    _ _ u 3 2 s _ r e v _ l e v e l ; * R e v i s i o n l e v e l *

    _ _ u 1 6 s _ d e f _ r e s u i d ; * D e f a u l t u i d f o r r e s e r v e d b l o c k s *

    _ _ u 1 6 s _ d e f _ r e s g i d ; * D e f a u l t g i d f o r r e s e r v e d b l o c k s *

    _ _ u 3 2 s _ r e s e r v e d 2 3 5 ; * P a d d i n g t o t h e e n d o f t h e b l o c k *

    ;

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

    T h e e x t 2 l e s y s t e m ' s s u p e r b l o c k i s i d e n t i e d b y t h e s m a g i c e l d . T h e c u r r e n t e x t 2 m a g i c n u m b e r i s 0 x E F 5 3 .

    I p r e s u m e t h a t " E F " m e a n s " E x t e n d e d F i l e s y s t e m " . I n v e r s i o n s o f t h e e x t 2 l e s y s t e m p r i o r t o 0 . 2 B , t h e m a g i c

    n u m b e r w a s 0 x E F 5 1 . T h o s e l e s y s t e m s a r e n o t c o m p a t i b l e w i t h t h e c u r r e n t v e r s i o n s ; S p e c i c a l l y , t h e g r o u p

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

    1 2 . 2 F i l e s y s t e m x e d p a r a m e t e r s

    B y u s i n g t h e w o r d f i x e d , I m e a n x e d w i t h r e s p e c t t o a p a r t i c u l a r i n s t a l l a t i o n . T h o s e v a r i a b l e s a r e u s u a l l y

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

    T h e b l o c k s i z e i s d e t e r m i n e d b y u s i n g t h e s l o g b l o c k s i z e v a r i a b l e . T h e b l o c k s i z e i s 1 0 2 4 * p o w

    2 , s l o g b l o c k s i z e a n d s h o u l d b e b e t w e e n 1 0 2 4 a n d 4 0 9 6 . T h e a v a i l a b l e o p t i o n s a r e 1 0 2 4 , 2 0 4 8 a n d 4 0 9 6 .

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

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

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

    a l w a y s p r e s e n t a t t h e x e d o s e t 1 0 2 4 , b u t t h e d e v i c e b l o c k n u m b e r i n g c a n d i e r . F o r e x a m p l e , i f t h e b l o c k

    s i z e i s 1 0 2 4 , t h e s u p e r b l o c k w i l l b e a t b l o c k 1 w i t h r e s p e c t t o t h e d e v i c e . H o w e v e r , i f t h e b l o c k s i z e i s 4 0 9 6 ,

    o s e t 1 0 2 4 i s i n c l u d e d i n b l o c k 0 o f t h e d e v i c e , a n d i n t h a t c a s e s f i r s t d a t a b l o c k w i l l c o n t a i n 0 . A t

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

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

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

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

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

    t e m :

    L i n u x : - i s s p e c i e d b y t h e v a l u e 0

    H u r d i s s p e c i e d b y t h e v a l u e 1

    M a s i x i s s p e c i e d b y t h e v a l u e 2

  • 8/14/2019 Ext2fs Overview 0.1

    15/17

    1 2 . T h e s u p e r b l o c k 1 5

    s r e v l e v e l c o n t a i n s t h e m a j o r v e r s i o n o f t h e e x t 2 l e s y s t e m . C u r r e n t l y t h i s i s a l w a y s 0 , a s t h e m o s t r e c e n t

    v e r s i o n i s 0 . 5 B . I t w i l l p r o b a b l y t a k e s o m e t i m e u n t i l w e r e a c h v e r s i o n 1 . 0 .

    A s f a r a s I k n o w , f r a g m e n t s s u b - b l o c k a l l o c a t i o n s a r e c u r r e n t l y n o t s u p p o r t e d a n d h e n c e a b l o c k i s e q u a l

    t o a f r a g m e n t . A s a r e s u l t , s l o g f r a g s i z e a n d s f r a g s p e r g r o u p a r e a l w a y s e q u a l t o s l o g b l o c k s i z e

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

    1 2 . 3 E x t 2 f s e r r o r h a n d l i n g

    T h e e x t 2 l e s y s t e m e r r o r h a n d l i n g i s b a s e d o n t h e f o l l o w i n g p h i l o s o p h y :

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

    2 . T h e c o r r e c t i o n t a s k i s l e f t t o a n e x t e r n a l u t i l i t y , s u c h a s e 2 f s c k b y T h e o d o r e T s ' o f o r a u t o m a t i c

    a n a l y s i s a n d c o r r e c t i o n , o r p e r h a p s d e b u g f s b y T h e o d o r e T s ' o a n d E X T 2 E D b y m y s e l f , f o r h a n d

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

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

    b i t 0 o f s s t a t e i s r e s e t w h e n t h e p a r t i t i o n i s m o u n t e d a n d s e t w h e n t h e p a r t i t i o n i s u n m o u n t e d . T h u s ,

    a v a l u e o f 0 o n a n u n m o u n t e d l e s y s t e m m e a n s t h a t t h e l e s y s t e m w a s n o t u n m o u n t e d p r o p e r l y - T h e

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

    b i t 1 o f s s t a t e i s s e t b y t h e k e r n e l w h e n i t d e t e c t s a n e r r o r i n t h e l e s y s t e m . A v a l u e o f 0 d o e s n ' t

    m e a n t h a t t h e r e i s n ' t a n e r r o r i n t h e l e s y s t e m , j u s t t h a t t h e k e r n e l d i d n ' t n d a n y .

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

    T h e k e r n e l w i l l i g n o r e t h e e r r o r a n d c o n t i n u e i f s e r r o r s = 1

    T h e k e r n e l w i l l r e m o u n t t h e l e s y s t e m i n r e a d - o n l y m o d e i f s e r r o r s = 2

    A k e r n e l p a n i c w i l l b e i s s u e d i f s e r r o r s = 3

    T h e d e f a u l t b e h a v i o r i s t o i g n o r e t h e e r r o r .

    1 2 . 4 A d d i t i o n a l p a r a m e t e r s u s e d b y e 2 f s c k

    O f - c o u r s e , e 2 f s c k w i l l c h e c k t h e l e s y s t e m i f e r r o r s w e r e d e t e c t e d o r i f t h e l e s y s t e m i s n o t c l e a n .

    I n a d d i t i o n , e a c h t i m e t h e l e s y s t e m i s m o u n t e d , s m n t c o u n t i s i n c r e m e n t e d . W h e n s m n t c o u n t r e a c h e s

    s m a x m n t c o u n t e 2 f s c k w i l l f o r c e a c h e c k o n t h e l e s y s t e m e v e n t h o u g h i t m a y b e c l e a n . I t w i l l t h e n z e r o

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

    E 2 f s c k a l s o r e c o r d s t h e l a s t t i m e i n w h i c h t h e l e s y s t e m w a s c h e c k e d i n t h e s l a s t c h e c k v a r i a b l e . T h e

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

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

  • 8/14/2019 Ext2fs Overview 0.1

    16/17

  • 8/14/2019 Ext2fs Overview 0.1

    17/17

    1 4 . A c k n o w l e d g m e n t s 1 7

    R e m y C a r d

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

    R e m y C a r d i s a l s o t h e a u t h o r o f s e v e r a l h e l p f u l s l i d e s c o n c e r n i n g t h e e x t 2 l e s y s t e m . S p e c i c a l l y , h e i s

    t h e a u t h o r o f F i l e M a n a g e m e n t i n t h e L i n u x K e r n e l a n d o f T h e S e c o n d E x t e n d e d F i l e S y s t e m

    - C u r r e n t S t a t e , F u t u r e D e v e l o p m e n t

    W a y n e D a v i s o n

    W h o d e s i g n e d t h e e x t 2 l e s y s t e m .

    S t e p h e n T w e e d i e

    W h o h e l p e d d e s i g n i n g t h e e x t 2 l e s y s t e m k e r n e l c o d e a n d w r o t e t h e s l i d e s O p t i m i z a t i o n s i n F i l e

    S y s t e m s

    T h e o d o r e T s ' o

    W h o i s t h e a u t h o r o f s e v e r a l e x t 2 u t i l i t i e s a n d o f t h e e x t 2 l i b r a r y l i b e x t 2 f s w h i c h I d i d n ' t u s e , s i m p l y

    b e c a u s e I d i d n ' t k n o w i t e x i s t s w h e n I s t a r t e d t o w o r k o n m y p r o j e c t .

    L a s t l y , I w o u l d l i k e t o t h a n k , o f - c o u r s e , L i n u s T o r v a l d s a n d t h e L i n u x c o m m u n i t y f o r p r o v i d i n g a l l o f u s

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

    P l e a s e c o n t a c t m e i n a c a s e o f a n e r r o r r e p o r t , s u g g e s t i o n s , o r j u s t a b o u t a n y t h i n g c o n c e r n i n g t h i s d o c u m e n t .

    E n j o y ,

    G a d i O x m a n t g u d @ t o c h n a p c 2 . t e c h n i o n . a c . i l

    H a i f a , A u g u s t 9 5