xref: /aosp_15_r20/external/e2fsprogs/ext2ed/doc/ext2fs-overview.sgml (revision 6a54128f25917bfc36a8a6e9d722c04a0b4641b6)
1*6a54128fSAndroid Build Coastguard Worker<!DOCTYPE Article PUBLIC "-//Davenport//DTD DocBook V3.0//EN">
2*6a54128fSAndroid Build Coastguard Worker
3*6a54128fSAndroid Build Coastguard Worker<Article>
4*6a54128fSAndroid Build Coastguard Worker
5*6a54128fSAndroid Build Coastguard Worker<ArtHeader>
6*6a54128fSAndroid Build Coastguard Worker
7*6a54128fSAndroid Build Coastguard Worker<Title>The extended-2 filesystem overview</Title>
8*6a54128fSAndroid Build Coastguard Worker<AUTHOR
9*6a54128fSAndroid Build Coastguard Worker>
10*6a54128fSAndroid Build Coastguard Worker<FirstName>Gadi Oxman, [email protected]</FirstName>
11*6a54128fSAndroid Build Coastguard Worker</AUTHOR
12*6a54128fSAndroid Build Coastguard Worker>
13*6a54128fSAndroid Build Coastguard Worker<PubDate>v0.1, August 3 1995</PubDate>
14*6a54128fSAndroid Build Coastguard Worker
15*6a54128fSAndroid Build Coastguard Worker</ArtHeader>
16*6a54128fSAndroid Build Coastguard Worker
17*6a54128fSAndroid Build Coastguard Worker<Sect1>
18*6a54128fSAndroid Build Coastguard Worker<Title>Preface</Title>
19*6a54128fSAndroid Build Coastguard Worker
20*6a54128fSAndroid Build Coastguard Worker<Para>
21*6a54128fSAndroid Build Coastguard WorkerThis document attempts to present an overview of the internal structure of
22*6a54128fSAndroid Build Coastguard Workerthe ext2 filesystem. It was written in summer 95, while I was working on the
23*6a54128fSAndroid Build Coastguard Worker<Literal remap="tt">ext2 filesystem editor project (EXT2ED)</Literal>.
24*6a54128fSAndroid Build Coastguard Worker</Para>
25*6a54128fSAndroid Build Coastguard Worker
26*6a54128fSAndroid Build Coastguard Worker<Para>
27*6a54128fSAndroid Build Coastguard WorkerIn the process of constructing EXT2ED, I acquired knowledge of the various
28*6a54128fSAndroid Build Coastguard Workerdesign aspects of the the ext2 filesystem. This document is a result of an
29*6a54128fSAndroid Build Coastguard Workereffort to document this knowledge.
30*6a54128fSAndroid Build Coastguard Worker</Para>
31*6a54128fSAndroid Build Coastguard Worker
32*6a54128fSAndroid Build Coastguard Worker<Para>
33*6a54128fSAndroid Build Coastguard WorkerThis is only the initial version of this document. It is obviously neither
34*6a54128fSAndroid Build Coastguard Workererror-prone nor complete, but at least it provides a starting point.
35*6a54128fSAndroid Build Coastguard Worker</Para>
36*6a54128fSAndroid Build Coastguard Worker
37*6a54128fSAndroid Build Coastguard Worker<Para>
38*6a54128fSAndroid Build Coastguard WorkerIn the process of learning the subject, I have used the following sources /
39*6a54128fSAndroid Build Coastguard Workertools:
40*6a54128fSAndroid Build Coastguard Worker
41*6a54128fSAndroid Build Coastguard Worker<ItemizedList>
42*6a54128fSAndroid Build Coastguard Worker<ListItem>
43*6a54128fSAndroid Build Coastguard Worker
44*6a54128fSAndroid Build Coastguard Worker<Para>
45*6a54128fSAndroid Build Coastguard Worker	Experimenting with EXT2ED, as it was developed.
46*6a54128fSAndroid Build Coastguard Worker</Para>
47*6a54128fSAndroid Build Coastguard Worker</ListItem>
48*6a54128fSAndroid Build Coastguard Worker<ListItem>
49*6a54128fSAndroid Build Coastguard Worker
50*6a54128fSAndroid Build Coastguard Worker<Para>
51*6a54128fSAndroid Build Coastguard Worker	The ext2 kernel sources:
52*6a54128fSAndroid Build Coastguard Worker
53*6a54128fSAndroid Build Coastguard Worker<ItemizedList>
54*6a54128fSAndroid Build Coastguard Worker<ListItem>
55*6a54128fSAndroid Build Coastguard Worker
56*6a54128fSAndroid Build Coastguard Worker<Para>
57*6a54128fSAndroid Build Coastguard Worker	The main ext2 include file,
58*6a54128fSAndroid Build Coastguard Worker<FILENAME>/usr/include/linux/ext2&lowbar;fs.h</FILENAME>
59*6a54128fSAndroid Build Coastguard Worker</Para>
60*6a54128fSAndroid Build Coastguard Worker</ListItem>
61*6a54128fSAndroid Build Coastguard Worker<ListItem>
62*6a54128fSAndroid Build Coastguard Worker
63*6a54128fSAndroid Build Coastguard Worker<Para>
64*6a54128fSAndroid Build Coastguard Worker	The contents of the directory <FILENAME>/usr/src/linux/fs/ext2</FILENAME>.
65*6a54128fSAndroid Build Coastguard Worker</Para>
66*6a54128fSAndroid Build Coastguard Worker</ListItem>
67*6a54128fSAndroid Build Coastguard Worker<ListItem>
68*6a54128fSAndroid Build Coastguard Worker
69*6a54128fSAndroid Build Coastguard Worker<Para>
70*6a54128fSAndroid Build Coastguard Worker	The VFS layer sources (only a bit).
71*6a54128fSAndroid Build Coastguard Worker</Para>
72*6a54128fSAndroid Build Coastguard Worker</ListItem>
73*6a54128fSAndroid Build Coastguard Worker
74*6a54128fSAndroid Build Coastguard Worker</ItemizedList>
75*6a54128fSAndroid Build Coastguard Worker
76*6a54128fSAndroid Build Coastguard Worker</Para>
77*6a54128fSAndroid Build Coastguard Worker</ListItem>
78*6a54128fSAndroid Build Coastguard Worker<ListItem>
79*6a54128fSAndroid Build Coastguard Worker
80*6a54128fSAndroid Build Coastguard Worker<Para>
81*6a54128fSAndroid Build Coastguard Worker	The slides: The Second Extended File System, Current State, Future
82*6a54128fSAndroid Build Coastguard WorkerDevelopment, by <personname><firstname>Remy</firstname> <surname>Card</surname></personname>.
83*6a54128fSAndroid Build Coastguard Worker</Para>
84*6a54128fSAndroid Build Coastguard Worker</ListItem>
85*6a54128fSAndroid Build Coastguard Worker<ListItem>
86*6a54128fSAndroid Build Coastguard Worker
87*6a54128fSAndroid Build Coastguard Worker<Para>
88*6a54128fSAndroid Build Coastguard Worker	The slides: Optimisation in File Systems, by <personname><firstname>Stephen</firstname> <surname>Tweedie</surname></personname>.
89*6a54128fSAndroid Build Coastguard Worker</Para>
90*6a54128fSAndroid Build Coastguard Worker</ListItem>
91*6a54128fSAndroid Build Coastguard Worker<ListItem>
92*6a54128fSAndroid Build Coastguard Worker
93*6a54128fSAndroid Build Coastguard Worker<Para>
94*6a54128fSAndroid Build Coastguard Worker	The various ext2 utilities.
95*6a54128fSAndroid Build Coastguard Worker</Para>
96*6a54128fSAndroid Build Coastguard Worker</ListItem>
97*6a54128fSAndroid Build Coastguard Worker
98*6a54128fSAndroid Build Coastguard Worker</ItemizedList>
99*6a54128fSAndroid Build Coastguard Worker
100*6a54128fSAndroid Build Coastguard Worker</Para>
101*6a54128fSAndroid Build Coastguard Worker
102*6a54128fSAndroid Build Coastguard Worker</Sect1>
103*6a54128fSAndroid Build Coastguard Worker
104*6a54128fSAndroid Build Coastguard Worker<Sect1>
105*6a54128fSAndroid Build Coastguard Worker<Title>Introduction</Title>
106*6a54128fSAndroid Build Coastguard Worker
107*6a54128fSAndroid Build Coastguard Worker<Para>
108*6a54128fSAndroid Build Coastguard WorkerThe <Literal remap="tt">Second Extended File System (Ext2fs)</Literal> is very popular among Linux
109*6a54128fSAndroid Build Coastguard Workerusers. If you use Linux, chances are that you are using the ext2 filesystem.
110*6a54128fSAndroid Build Coastguard Worker</Para>
111*6a54128fSAndroid Build Coastguard Worker
112*6a54128fSAndroid Build Coastguard Worker<Para>
113*6a54128fSAndroid Build Coastguard WorkerExt2fs was designed by <personname><firstname>Remy</firstname> <surname>Card</surname></personname> and <personname><firstname>Wayne</firstname> <surname>Davison</surname></personname>. It was
114*6a54128fSAndroid Build Coastguard Workerimplemented by <personname><firstname>Remy</firstname> <surname>Card</surname></personname> and was further enhanced by <personname><firstname>Stephen</firstname>
115*6a54128fSAndroid Build Coastguard Worker<surname>Tweedie</surname></personname> and <personname><firstname>Theodore</firstname> <surname>Ts'o</surname></personname>.
116*6a54128fSAndroid Build Coastguard Worker</Para>
117*6a54128fSAndroid Build Coastguard Worker
118*6a54128fSAndroid Build Coastguard Worker<Para>
119*6a54128fSAndroid Build Coastguard WorkerThe ext2 filesystem is still under development. I will document here
120*6a54128fSAndroid Build Coastguard Workerversion 0.5a, which is distributed along with Linux 1.2.x. At this time of
121*6a54128fSAndroid Build Coastguard Workerwriting, the most recent version of Linux is 1.3.13, and the version of the
122*6a54128fSAndroid Build Coastguard Workerext2 kernel source is 0.5b. A lot of fancy enhancements are planned for the
123*6a54128fSAndroid Build Coastguard Workerext2 filesystem in Linux 1.3, so stay tuned.
124*6a54128fSAndroid Build Coastguard Worker</Para>
125*6a54128fSAndroid Build Coastguard Worker
126*6a54128fSAndroid Build Coastguard Worker</Sect1>
127*6a54128fSAndroid Build Coastguard Worker
128*6a54128fSAndroid Build Coastguard Worker<Sect1>
129*6a54128fSAndroid Build Coastguard Worker<Title>A filesystem - Why do we need it?</Title>
130*6a54128fSAndroid Build Coastguard Worker
131*6a54128fSAndroid Build Coastguard Worker<Para>
132*6a54128fSAndroid Build Coastguard WorkerI thought that before we dive into the various small details, I'll reserve a
133*6a54128fSAndroid Build Coastguard Workerfew minutes for the discussion of filesystems from a general point of view.
134*6a54128fSAndroid Build Coastguard Worker</Para>
135*6a54128fSAndroid Build Coastguard Worker
136*6a54128fSAndroid Build Coastguard Worker<Para>
137*6a54128fSAndroid Build Coastguard WorkerA <Literal remap="tt">filesystem</Literal> consists of two word - <Literal remap="tt">file</Literal> and <Literal remap="tt">system</Literal>.
138*6a54128fSAndroid Build Coastguard Worker</Para>
139*6a54128fSAndroid Build Coastguard Worker
140*6a54128fSAndroid Build Coastguard Worker<Para>
141*6a54128fSAndroid Build Coastguard WorkerEveryone knows the meaning of the word <Literal remap="tt">file</Literal> - A bunch of data put
142*6a54128fSAndroid Build Coastguard Workersomewhere. where? This is an important question. I, for example, usually
143*6a54128fSAndroid Build Coastguard Workerthrow almost everything into a single drawer, and have difficulties finding
144*6a54128fSAndroid Build Coastguard Workersomething later.
145*6a54128fSAndroid Build Coastguard Worker</Para>
146*6a54128fSAndroid Build Coastguard Worker
147*6a54128fSAndroid Build Coastguard Worker<Para>
148*6a54128fSAndroid Build Coastguard WorkerThis is where the <Literal remap="tt">system</Literal> comes in - Instead of just throwing the data
149*6a54128fSAndroid Build Coastguard Workerto the device, we generalize and construct a <Literal remap="tt">system</Literal> which will
150*6a54128fSAndroid Build Coastguard Workervirtualize for us a nice and ordered structure in which we could arrange our
151*6a54128fSAndroid Build Coastguard Workerdata in much the same way as books are arranged in a library. The purpose of
152*6a54128fSAndroid Build Coastguard Workerthe filesystem, as I understand it, is to make it easy for us to update and
153*6a54128fSAndroid Build Coastguard Workermaintain our data.
154*6a54128fSAndroid Build Coastguard Worker</Para>
155*6a54128fSAndroid Build Coastguard Worker
156*6a54128fSAndroid Build Coastguard Worker<Para>
157*6a54128fSAndroid Build Coastguard WorkerNormally, by <Literal remap="tt">mounting</Literal> filesystems, we just use the nice and logical
158*6a54128fSAndroid Build Coastguard Workervirtual structure. However, the disk knows nothing about that - The device
159*6a54128fSAndroid Build Coastguard Workerdriver views the disk as a large continuous paper in which we can write notes
160*6a54128fSAndroid Build Coastguard Workerwherever we wish. It is the task of the filesystem management code to store
161*6a54128fSAndroid Build Coastguard Workerbookkeeping information which will serve the kernel for showing us the nice
162*6a54128fSAndroid Build Coastguard Workerand ordered virtual structure.
163*6a54128fSAndroid Build Coastguard Worker</Para>
164*6a54128fSAndroid Build Coastguard Worker
165*6a54128fSAndroid Build Coastguard Worker<Para>
166*6a54128fSAndroid Build Coastguard WorkerIn this document, we consider one particular administrative structure - The
167*6a54128fSAndroid Build Coastguard WorkerSecond Extended Filesystem.
168*6a54128fSAndroid Build Coastguard Worker</Para>
169*6a54128fSAndroid Build Coastguard Worker
170*6a54128fSAndroid Build Coastguard Worker</Sect1>
171*6a54128fSAndroid Build Coastguard Worker
172*6a54128fSAndroid Build Coastguard Worker<Sect1>
173*6a54128fSAndroid Build Coastguard Worker<Title>The Linux VFS layer</Title>
174*6a54128fSAndroid Build Coastguard Worker
175*6a54128fSAndroid Build Coastguard Worker<Para>
176*6a54128fSAndroid Build Coastguard WorkerWhen Linux was first developed, it supported only one filesystem - The
177*6a54128fSAndroid Build Coastguard Worker<Literal remap="tt">Minix</Literal> filesystem. Today, Linux has the ability to support several
178*6a54128fSAndroid Build Coastguard Workerfilesystems concurrently. This was done by the introduction of another layer
179*6a54128fSAndroid Build Coastguard Workerbetween the kernel and the filesystem code - The Virtual File System (VFS).
180*6a54128fSAndroid Build Coastguard Worker</Para>
181*6a54128fSAndroid Build Coastguard Worker
182*6a54128fSAndroid Build Coastguard Worker<Para>
183*6a54128fSAndroid Build Coastguard WorkerThe kernel "speaks" with the VFS layer. The VFS layer passes the kernel's
184*6a54128fSAndroid Build Coastguard Workerrequest to the proper filesystem management code. I haven't learned much of
185*6a54128fSAndroid Build Coastguard Workerthe VFS layer as I didn't need it for the construction of EXT2ED so that I
186*6a54128fSAndroid Build Coastguard Workercan't elaborate on it. Just be aware that it exists.
187*6a54128fSAndroid Build Coastguard Worker</Para>
188*6a54128fSAndroid Build Coastguard Worker
189*6a54128fSAndroid Build Coastguard Worker</Sect1>
190*6a54128fSAndroid Build Coastguard Worker
191*6a54128fSAndroid Build Coastguard Worker<Sect1>
192*6a54128fSAndroid Build Coastguard Worker<Title>About blocks and block groups</Title>
193*6a54128fSAndroid Build Coastguard Worker
194*6a54128fSAndroid Build Coastguard Worker<Para>
195*6a54128fSAndroid Build Coastguard WorkerIn order to ease management, the ext2 filesystem logically divides the disk
196*6a54128fSAndroid Build Coastguard Workerinto small units called <Literal remap="tt">blocks</Literal>. A block is the smallest unit which
197*6a54128fSAndroid Build Coastguard Workercan be allocated. Each block in the filesystem can be <Literal remap="tt">allocated</Literal> or
198*6a54128fSAndroid Build Coastguard Worker<Literal remap="tt">free</Literal>.
199*6a54128fSAndroid Build Coastguard Worker<FOOTNOTE>
200*6a54128fSAndroid Build Coastguard Worker
201*6a54128fSAndroid Build Coastguard Worker<Para>
202*6a54128fSAndroid Build Coastguard WorkerThe Ext2fs source code refers to the concept of <Literal remap="tt">fragments</Literal>, which I
203*6a54128fSAndroid Build Coastguard Workerbelieve are supposed to be sub-block allocations. As far as I know,
204*6a54128fSAndroid Build Coastguard Workerfragments are currently unsupported in Ext2fs.
205*6a54128fSAndroid Build Coastguard Worker</Para>
206*6a54128fSAndroid Build Coastguard Worker
207*6a54128fSAndroid Build Coastguard Worker</FOOTNOTE>
208*6a54128fSAndroid Build Coastguard Worker
209*6a54128fSAndroid Build Coastguard WorkerThe block size can be selected to be 1024, 2048 or 4096 bytes when creating
210*6a54128fSAndroid Build Coastguard Workerthe filesystem.
211*6a54128fSAndroid Build Coastguard Worker</Para>
212*6a54128fSAndroid Build Coastguard Worker
213*6a54128fSAndroid Build Coastguard Worker<Para>
214*6a54128fSAndroid Build Coastguard WorkerExt2fs groups together a fixed number of sequential blocks into a <Literal remap="tt">group
215*6a54128fSAndroid Build Coastguard Workerblock</Literal>. The resulting situation is that the filesystem is managed as a
216*6a54128fSAndroid Build Coastguard Workerseries of group blocks. This is done in order to keep related information
217*6a54128fSAndroid Build Coastguard Workerphysically close on the disk and to ease the management task. As a result,
218*6a54128fSAndroid Build Coastguard Workermuch of the filesystem management reduces to management of a single blocks
219*6a54128fSAndroid Build Coastguard Workergroup.
220*6a54128fSAndroid Build Coastguard Worker</Para>
221*6a54128fSAndroid Build Coastguard Worker
222*6a54128fSAndroid Build Coastguard Worker</Sect1>
223*6a54128fSAndroid Build Coastguard Worker
224*6a54128fSAndroid Build Coastguard Worker<Sect1>
225*6a54128fSAndroid Build Coastguard Worker<Title>The view of inodes from the point of view of a blocks group</Title>
226*6a54128fSAndroid Build Coastguard Worker
227*6a54128fSAndroid Build Coastguard Worker<Para>
228*6a54128fSAndroid Build Coastguard WorkerEach file in the filesystem is reserved a special <Literal remap="tt">inode</Literal>. I don't want
229*6a54128fSAndroid Build Coastguard Workerto explain inodes now. Rather, I would like to treat it as another resource,
230*6a54128fSAndroid Build Coastguard Workermuch like a <Literal remap="tt">block</Literal> - Each blocks group contains a limited number of
231*6a54128fSAndroid Build Coastguard Workerinode, while any specific inode can be <Literal remap="tt">allocated</Literal> or
232*6a54128fSAndroid Build Coastguard Worker<Literal remap="tt">unallocated</Literal>.
233*6a54128fSAndroid Build Coastguard Worker</Para>
234*6a54128fSAndroid Build Coastguard Worker
235*6a54128fSAndroid Build Coastguard Worker</Sect1>
236*6a54128fSAndroid Build Coastguard Worker
237*6a54128fSAndroid Build Coastguard Worker<Sect1>
238*6a54128fSAndroid Build Coastguard Worker<Title>The group descriptors</Title>
239*6a54128fSAndroid Build Coastguard Worker
240*6a54128fSAndroid Build Coastguard Worker<Para>
241*6a54128fSAndroid Build Coastguard WorkerEach blocks group is accompanied by a <Literal remap="tt">group descriptor</Literal>. The group
242*6a54128fSAndroid Build Coastguard Workerdescriptor summarizes some necessary information about the specific group
243*6a54128fSAndroid Build Coastguard Workerblock. Follows the definition of the group descriptor, as defined in
244*6a54128fSAndroid Build Coastguard Worker<FILENAME>/usr/include/linux/ext2&lowbar;fs.h</FILENAME>:
245*6a54128fSAndroid Build Coastguard Worker</Para>
246*6a54128fSAndroid Build Coastguard Worker
247*6a54128fSAndroid Build Coastguard Worker<Para>
248*6a54128fSAndroid Build Coastguard Worker
249*6a54128fSAndroid Build Coastguard Worker<ProgramListing>
250*6a54128fSAndroid Build Coastguard Workerstruct ext2_group_desc
251*6a54128fSAndroid Build Coastguard Worker{
252*6a54128fSAndroid Build Coastguard Worker	__u32	bg_block_bitmap;	/* Blocks bitmap block */
253*6a54128fSAndroid Build Coastguard Worker	__u32	bg_inode_bitmap;	/* Inodes bitmap block */
254*6a54128fSAndroid Build Coastguard Worker	__u32	bg_inode_table;		/* Inodes table block */
255*6a54128fSAndroid Build Coastguard Worker	__u16	bg_free_blocks_count;	/* Free blocks count */
256*6a54128fSAndroid Build Coastguard Worker	__u16	bg_free_inodes_count;	/* Free inodes count */
257*6a54128fSAndroid Build Coastguard Worker	__u16	bg_used_dirs_count;	/* Directories count */
258*6a54128fSAndroid Build Coastguard Worker	__u16	bg_pad;
259*6a54128fSAndroid Build Coastguard Worker	__u32	bg_reserved[3];
260*6a54128fSAndroid Build Coastguard Worker};
261*6a54128fSAndroid Build Coastguard Worker</ProgramListing>
262*6a54128fSAndroid Build Coastguard Worker
263*6a54128fSAndroid Build Coastguard Worker</Para>
264*6a54128fSAndroid Build Coastguard Worker
265*6a54128fSAndroid Build Coastguard Worker<Para>
266*6a54128fSAndroid Build Coastguard WorkerThe last three variables: <Literal remap="tt">bg&lowbar;free&lowbar;blocks&lowbar;count, bg&lowbar;free&lowbar;inodes&lowbar;count and bg&lowbar;used&lowbar;dirs&lowbar;count</Literal> provide statistics about the use of the three
267*6a54128fSAndroid Build Coastguard Workerresources in a blocks group - The <Literal remap="tt">blocks</Literal>, the <Literal remap="tt">inodes</Literal> and the
268*6a54128fSAndroid Build Coastguard Worker<Literal remap="tt">directories</Literal>. I believe that they are used by the kernel for balancing
269*6a54128fSAndroid Build Coastguard Workerthe load between the various blocks groups.
270*6a54128fSAndroid Build Coastguard Worker</Para>
271*6a54128fSAndroid Build Coastguard Worker
272*6a54128fSAndroid Build Coastguard Worker<Para>
273*6a54128fSAndroid Build Coastguard Worker<Literal remap="tt">bg&lowbar;block&lowbar;bitmap</Literal> contains the block number of the <Literal remap="tt">block allocation
274*6a54128fSAndroid Build Coastguard Workerbitmap block</Literal>. This is used to allocate / deallocate each block in the
275*6a54128fSAndroid Build Coastguard Workerspecific blocks group.
276*6a54128fSAndroid Build Coastguard Worker</Para>
277*6a54128fSAndroid Build Coastguard Worker
278*6a54128fSAndroid Build Coastguard Worker<Para>
279*6a54128fSAndroid Build Coastguard Worker<Literal remap="tt">bg&lowbar;inode&lowbar;bitmap</Literal> is fully analogous to the previous variable - It
280*6a54128fSAndroid Build Coastguard Workercontains the block number of the <Literal remap="tt">inode allocation bitmap block</Literal>, which
281*6a54128fSAndroid Build Coastguard Workeris used to allocate / deallocate each specific inode in the filesystem.
282*6a54128fSAndroid Build Coastguard Worker</Para>
283*6a54128fSAndroid Build Coastguard Worker
284*6a54128fSAndroid Build Coastguard Worker<Para>
285*6a54128fSAndroid Build Coastguard Worker<Literal remap="tt">bg&lowbar;inode&lowbar;table</Literal> contains the block number of the start of the
286*6a54128fSAndroid Build Coastguard Worker<Literal remap="tt">inode table of the current blocks group</Literal>. The <Literal remap="tt">inode table</Literal> is
287*6a54128fSAndroid Build Coastguard Workerjust the actual inodes which are reserved for the current block.
288*6a54128fSAndroid Build Coastguard Worker</Para>
289*6a54128fSAndroid Build Coastguard Worker
290*6a54128fSAndroid Build Coastguard Worker<Para>
291*6a54128fSAndroid Build Coastguard WorkerThe block bitmap block, inode bitmap block and the inode table are created
292*6a54128fSAndroid Build Coastguard Workerwhen the filesystem is created.
293*6a54128fSAndroid Build Coastguard Worker</Para>
294*6a54128fSAndroid Build Coastguard Worker
295*6a54128fSAndroid Build Coastguard Worker<Para>
296*6a54128fSAndroid Build Coastguard WorkerThe group descriptors are placed one after the other. Together they make the
297*6a54128fSAndroid Build Coastguard Worker<Literal remap="tt">group descriptors table</Literal>.
298*6a54128fSAndroid Build Coastguard Worker</Para>
299*6a54128fSAndroid Build Coastguard Worker
300*6a54128fSAndroid Build Coastguard Worker<Para>
301*6a54128fSAndroid Build Coastguard WorkerEach blocks group contains the entire table of group descriptors in its
302*6a54128fSAndroid Build Coastguard Workersecond block, right after the superblock. However, only the first copy (in
303*6a54128fSAndroid Build Coastguard Workergroup 0) is actually used by the kernel. The other copies are there for
304*6a54128fSAndroid Build Coastguard Workerbackup purposes and can be of use if the main copy gets corrupted.
305*6a54128fSAndroid Build Coastguard Worker</Para>
306*6a54128fSAndroid Build Coastguard Worker
307*6a54128fSAndroid Build Coastguard Worker</Sect1>
308*6a54128fSAndroid Build Coastguard Worker
309*6a54128fSAndroid Build Coastguard Worker<Sect1>
310*6a54128fSAndroid Build Coastguard Worker<Title>The block bitmap allocation block</Title>
311*6a54128fSAndroid Build Coastguard Worker
312*6a54128fSAndroid Build Coastguard Worker<Para>
313*6a54128fSAndroid Build Coastguard WorkerEach blocks group contains one special block which is actually a map of the
314*6a54128fSAndroid Build Coastguard Workerentire blocks in the group, with respect to their allocation status. Each
315*6a54128fSAndroid Build Coastguard Worker<Literal remap="tt">bit</Literal> in the block bitmap indicated whether a specific block in the
316*6a54128fSAndroid Build Coastguard Workergroup is used or free.
317*6a54128fSAndroid Build Coastguard Worker</Para>
318*6a54128fSAndroid Build Coastguard Worker
319*6a54128fSAndroid Build Coastguard Worker<Para>
320*6a54128fSAndroid Build Coastguard WorkerThe format is actually quite simple - Just view the entire block as a series
321*6a54128fSAndroid Build Coastguard Workerof bits. For example,
322*6a54128fSAndroid Build Coastguard Worker</Para>
323*6a54128fSAndroid Build Coastguard Worker
324*6a54128fSAndroid Build Coastguard Worker<Para>
325*6a54128fSAndroid Build Coastguard WorkerSuppose the block size is 1024 bytes. As such, there is a place for
326*6a54128fSAndroid Build Coastguard Worker1024*8=8192 blocks in a group block. This number is one of the fields in the
327*6a54128fSAndroid Build Coastguard Workerfilesystem's <Literal remap="tt">superblock</Literal>, which will be explained later.
328*6a54128fSAndroid Build Coastguard Worker</Para>
329*6a54128fSAndroid Build Coastguard Worker
330*6a54128fSAndroid Build Coastguard Worker<Para>
331*6a54128fSAndroid Build Coastguard Worker
332*6a54128fSAndroid Build Coastguard Worker<ItemizedList>
333*6a54128fSAndroid Build Coastguard Worker<ListItem>
334*6a54128fSAndroid Build Coastguard Worker
335*6a54128fSAndroid Build Coastguard Worker<Para>
336*6a54128fSAndroid Build Coastguard Worker	Block 0 in the blocks group is managed by bit 0 of byte 0 in the bitmap
337*6a54128fSAndroid Build Coastguard Workerblock.
338*6a54128fSAndroid Build Coastguard Worker</Para>
339*6a54128fSAndroid Build Coastguard Worker</ListItem>
340*6a54128fSAndroid Build Coastguard Worker<ListItem>
341*6a54128fSAndroid Build Coastguard Worker
342*6a54128fSAndroid Build Coastguard Worker<Para>
343*6a54128fSAndroid Build Coastguard Worker	Block 7 in the blocks group is managed by bit 7 of byte 0 in the bitmap
344*6a54128fSAndroid Build Coastguard Workerblock.
345*6a54128fSAndroid Build Coastguard Worker</Para>
346*6a54128fSAndroid Build Coastguard Worker</ListItem>
347*6a54128fSAndroid Build Coastguard Worker<ListItem>
348*6a54128fSAndroid Build Coastguard Worker
349*6a54128fSAndroid Build Coastguard Worker<Para>
350*6a54128fSAndroid Build Coastguard Worker	Block 8 in the blocks group is managed by bit 0 of byte 1 in the bitmap
351*6a54128fSAndroid Build Coastguard Workerblock.
352*6a54128fSAndroid Build Coastguard Worker</Para>
353*6a54128fSAndroid Build Coastguard Worker</ListItem>
354*6a54128fSAndroid Build Coastguard Worker<ListItem>
355*6a54128fSAndroid Build Coastguard Worker
356*6a54128fSAndroid Build Coastguard Worker<Para>
357*6a54128fSAndroid Build Coastguard Worker	Block 8191 in the blocks group is managed by bit 7 of byte 1023 in the
358*6a54128fSAndroid Build Coastguard Workerbitmap 	block.
359*6a54128fSAndroid Build Coastguard Worker</Para>
360*6a54128fSAndroid Build Coastguard Worker</ListItem>
361*6a54128fSAndroid Build Coastguard Worker
362*6a54128fSAndroid Build Coastguard Worker</ItemizedList>
363*6a54128fSAndroid Build Coastguard Worker
364*6a54128fSAndroid Build Coastguard Worker</Para>
365*6a54128fSAndroid Build Coastguard Worker
366*6a54128fSAndroid Build Coastguard Worker<Para>
367*6a54128fSAndroid Build Coastguard WorkerA value of "<Literal remap="tt">1</Literal>" in the appropriate bit signals that the block is
368*6a54128fSAndroid Build Coastguard Workerallocated, while a value of "<Literal remap="tt">0</Literal>" signals that the block is
369*6a54128fSAndroid Build Coastguard Workerunallocated.
370*6a54128fSAndroid Build Coastguard Worker</Para>
371*6a54128fSAndroid Build Coastguard Worker
372*6a54128fSAndroid Build Coastguard Worker<Para>
373*6a54128fSAndroid Build Coastguard WorkerYou will probably notice that typically, all the bits in a byte contain the
374*6a54128fSAndroid Build Coastguard Workersame value, making the byte's value <Literal remap="tt">0</Literal> or <Literal remap="tt">0ffh</Literal>. This is done by
375*6a54128fSAndroid Build Coastguard Workerthe kernel on purpose in order to group related data in physically close
376*6a54128fSAndroid Build Coastguard Workerblocks, since the physical device is usually optimized to handle such a close
377*6a54128fSAndroid Build Coastguard Workerrelationship.
378*6a54128fSAndroid Build Coastguard Worker</Para>
379*6a54128fSAndroid Build Coastguard Worker
380*6a54128fSAndroid Build Coastguard Worker</Sect1>
381*6a54128fSAndroid Build Coastguard Worker
382*6a54128fSAndroid Build Coastguard Worker<Sect1>
383*6a54128fSAndroid Build Coastguard Worker<Title>The inode allocation bitmap</Title>
384*6a54128fSAndroid Build Coastguard Worker
385*6a54128fSAndroid Build Coastguard Worker<Para>
386*6a54128fSAndroid Build Coastguard WorkerThe format of the inode allocation bitmap block is exactly like the format of
387*6a54128fSAndroid Build Coastguard Workerthe block allocation bitmap block. The explanation above is valid here, with
388*6a54128fSAndroid Build Coastguard Workerthe work <Literal remap="tt">block</Literal> replaced by <Literal remap="tt">inode</Literal>. Typically, there are much less
389*6a54128fSAndroid Build Coastguard Workerinodes then blocks in a blocks group and thus only part of the inode bitmap
390*6a54128fSAndroid Build Coastguard Workerblock is used. The number of inodes in a blocks group is another variable
391*6a54128fSAndroid Build Coastguard Workerwhich is listed in the <Literal remap="tt">superblock</Literal>.
392*6a54128fSAndroid Build Coastguard Worker</Para>
393*6a54128fSAndroid Build Coastguard Worker
394*6a54128fSAndroid Build Coastguard Worker</Sect1>
395*6a54128fSAndroid Build Coastguard Worker
396*6a54128fSAndroid Build Coastguard Worker<Sect1>
397*6a54128fSAndroid Build Coastguard Worker<Title>On the inode and the inode tables</Title>
398*6a54128fSAndroid Build Coastguard Worker
399*6a54128fSAndroid Build Coastguard Worker<Para>
400*6a54128fSAndroid Build Coastguard WorkerAn inode is a main resource in the ext2 filesystem. It is used for various
401*6a54128fSAndroid Build Coastguard Workerpurposes, but the main two are:
402*6a54128fSAndroid Build Coastguard Worker
403*6a54128fSAndroid Build Coastguard Worker<ItemizedList>
404*6a54128fSAndroid Build Coastguard Worker<ListItem>
405*6a54128fSAndroid Build Coastguard Worker
406*6a54128fSAndroid Build Coastguard Worker<Para>
407*6a54128fSAndroid Build Coastguard Worker	Support of files
408*6a54128fSAndroid Build Coastguard Worker</Para>
409*6a54128fSAndroid Build Coastguard Worker</ListItem>
410*6a54128fSAndroid Build Coastguard Worker<ListItem>
411*6a54128fSAndroid Build Coastguard Worker
412*6a54128fSAndroid Build Coastguard Worker<Para>
413*6a54128fSAndroid Build Coastguard Worker	Support of directories
414*6a54128fSAndroid Build Coastguard Worker</Para>
415*6a54128fSAndroid Build Coastguard Worker</ListItem>
416*6a54128fSAndroid Build Coastguard Worker
417*6a54128fSAndroid Build Coastguard Worker</ItemizedList>
418*6a54128fSAndroid Build Coastguard Worker
419*6a54128fSAndroid Build Coastguard Worker</Para>
420*6a54128fSAndroid Build Coastguard Worker
421*6a54128fSAndroid Build Coastguard Worker<Para>
422*6a54128fSAndroid Build Coastguard WorkerEach file, for example, will allocate one inode from the filesystem
423*6a54128fSAndroid Build Coastguard Workerresources.
424*6a54128fSAndroid Build Coastguard Worker</Para>
425*6a54128fSAndroid Build Coastguard Worker
426*6a54128fSAndroid Build Coastguard Worker<Para>
427*6a54128fSAndroid Build Coastguard WorkerAn ext2 filesystem has a total number of available inodes which is determined
428*6a54128fSAndroid Build Coastguard Workerwhile creating the filesystem. When all the inodes are used, for example, you
429*6a54128fSAndroid Build Coastguard Workerwill not be able to create an additional file even though there will still
430*6a54128fSAndroid Build Coastguard Workerbe free blocks on the filesystem.
431*6a54128fSAndroid Build Coastguard Worker</Para>
432*6a54128fSAndroid Build Coastguard Worker
433*6a54128fSAndroid Build Coastguard Worker<Para>
434*6a54128fSAndroid Build Coastguard WorkerEach inode takes up 128 bytes in the filesystem. By default, <Literal remap="tt">mke2fs</Literal>
435*6a54128fSAndroid Build Coastguard Workerreserves an inode for each 4096 bytes of the filesystem space.
436*6a54128fSAndroid Build Coastguard Worker</Para>
437*6a54128fSAndroid Build Coastguard Worker
438*6a54128fSAndroid Build Coastguard Worker<Para>
439*6a54128fSAndroid Build Coastguard WorkerThe inodes are placed in several tables, each of which contains the same
440*6a54128fSAndroid Build Coastguard Workernumber of inodes and is placed at a different blocks group. The goal is to
441*6a54128fSAndroid Build Coastguard Workerplace inodes and their related files in the same blocks group because of
442*6a54128fSAndroid Build Coastguard Workerlocality arguments.
443*6a54128fSAndroid Build Coastguard Worker</Para>
444*6a54128fSAndroid Build Coastguard Worker
445*6a54128fSAndroid Build Coastguard Worker<Para>
446*6a54128fSAndroid Build Coastguard WorkerThe number of inodes in a blocks group is available in the superblock variable
447*6a54128fSAndroid Build Coastguard Worker<Literal remap="tt">s&lowbar;inodes&lowbar;per&lowbar;group</Literal>. For example, if there are 2000 inodes per group,
448*6a54128fSAndroid Build Coastguard Workergroup 0 will contain the inodes 1-2000, group 2 will contain the inodes
449*6a54128fSAndroid Build Coastguard Worker2001-4000, and so on.
450*6a54128fSAndroid Build Coastguard Worker</Para>
451*6a54128fSAndroid Build Coastguard Worker
452*6a54128fSAndroid Build Coastguard Worker<Para>
453*6a54128fSAndroid Build Coastguard WorkerEach inode table is accessed from the group descriptor of the specific
454*6a54128fSAndroid Build Coastguard Workerblocks group which contains the table.
455*6a54128fSAndroid Build Coastguard Worker</Para>
456*6a54128fSAndroid Build Coastguard Worker
457*6a54128fSAndroid Build Coastguard Worker<Para>
458*6a54128fSAndroid Build Coastguard WorkerFollows the structure of an inode in Ext2fs:
459*6a54128fSAndroid Build Coastguard Worker</Para>
460*6a54128fSAndroid Build Coastguard Worker
461*6a54128fSAndroid Build Coastguard Worker<Para>
462*6a54128fSAndroid Build Coastguard Worker
463*6a54128fSAndroid Build Coastguard Worker<ProgramListing>
464*6a54128fSAndroid Build Coastguard Workerstruct ext2_inode {
465*6a54128fSAndroid Build Coastguard Worker	__u16	i_mode;		/* File mode */
466*6a54128fSAndroid Build Coastguard Worker	__u16	i_uid;		/* Owner Uid */
467*6a54128fSAndroid Build Coastguard Worker	__u32	i_size;		/* Size in bytes */
468*6a54128fSAndroid Build Coastguard Worker	__u32	i_atime;	/* Access time */
469*6a54128fSAndroid Build Coastguard Worker	__u32	i_ctime;	/* Creation time */
470*6a54128fSAndroid Build Coastguard Worker	__u32	i_mtime;	/* Modification time */
471*6a54128fSAndroid Build Coastguard Worker	__u32	i_dtime;	/* Deletion Time */
472*6a54128fSAndroid Build Coastguard Worker	__u16	i_gid;		/* Group Id */
473*6a54128fSAndroid Build Coastguard Worker	__u16	i_links_count;	/* Links count */
474*6a54128fSAndroid Build Coastguard Worker	__u32	i_blocks;	/* Blocks count */
475*6a54128fSAndroid Build Coastguard Worker	__u32	i_flags;	/* File flags */
476*6a54128fSAndroid Build Coastguard Worker	union {
477*6a54128fSAndroid Build Coastguard Worker		struct {
478*6a54128fSAndroid Build Coastguard Worker			__u32  l_i_reserved1;
479*6a54128fSAndroid Build Coastguard Worker		} linux1;
480*6a54128fSAndroid Build Coastguard Worker		struct {
481*6a54128fSAndroid Build Coastguard Worker			__u32  h_i_translator;
482*6a54128fSAndroid Build Coastguard Worker		} hurd1;
483*6a54128fSAndroid Build Coastguard Worker		struct {
484*6a54128fSAndroid Build Coastguard Worker			__u32  m_i_reserved1;
485*6a54128fSAndroid Build Coastguard Worker		} masix1;
486*6a54128fSAndroid Build Coastguard Worker	} osd1;				/* OS dependent 1 */
487*6a54128fSAndroid Build Coastguard Worker	__u32	i_block[EXT2_N_BLOCKS];/* Pointers to blocks */
488*6a54128fSAndroid Build Coastguard Worker	__u32	i_version;	/* File version (for NFS) */
489*6a54128fSAndroid Build Coastguard Worker	__u32	i_file_acl;	/* File ACL */
490*6a54128fSAndroid Build Coastguard Worker	__u32	i_size_high;	/* High 32bits of size */
491*6a54128fSAndroid Build Coastguard Worker	__u32	i_faddr;	/* Fragment address */
492*6a54128fSAndroid Build Coastguard Worker	union {
493*6a54128fSAndroid Build Coastguard Worker		struct {
494*6a54128fSAndroid Build Coastguard Worker			__u8	l_i_frag;	/* Fragment number */
495*6a54128fSAndroid Build Coastguard Worker			__u8	l_i_fsize;	/* Fragment size */
496*6a54128fSAndroid Build Coastguard Worker			__u16	i_pad1;
497*6a54128fSAndroid Build Coastguard Worker			__u32	l_i_reserved2[2];
498*6a54128fSAndroid Build Coastguard Worker		} linux2;
499*6a54128fSAndroid Build Coastguard Worker		struct {
500*6a54128fSAndroid Build Coastguard Worker			__u8	h_i_frag;	/* Fragment number */
501*6a54128fSAndroid Build Coastguard Worker			__u8	h_i_fsize;	/* Fragment size */
502*6a54128fSAndroid Build Coastguard Worker			__u16	h_i_mode_high;
503*6a54128fSAndroid Build Coastguard Worker			__u16	h_i_uid_high;
504*6a54128fSAndroid Build Coastguard Worker			__u16	h_i_gid_high;
505*6a54128fSAndroid Build Coastguard Worker			__u32	h_i_author;
506*6a54128fSAndroid Build Coastguard Worker		} hurd2;
507*6a54128fSAndroid Build Coastguard Worker		struct {
508*6a54128fSAndroid Build Coastguard Worker			__u8	m_i_frag;	/* Fragment number */
509*6a54128fSAndroid Build Coastguard Worker			__u8	m_i_fsize;	/* Fragment size */
510*6a54128fSAndroid Build Coastguard Worker			__u16	m_pad1;
511*6a54128fSAndroid Build Coastguard Worker			__u32	m_i_reserved2[2];
512*6a54128fSAndroid Build Coastguard Worker		} masix2;
513*6a54128fSAndroid Build Coastguard Worker	} osd2;				/* OS dependent 2 */
514*6a54128fSAndroid Build Coastguard Worker};
515*6a54128fSAndroid Build Coastguard Worker</ProgramListing>
516*6a54128fSAndroid Build Coastguard Worker
517*6a54128fSAndroid Build Coastguard Worker</Para>
518*6a54128fSAndroid Build Coastguard Worker
519*6a54128fSAndroid Build Coastguard Worker<Sect2>
520*6a54128fSAndroid Build Coastguard Worker<Title>The allocated blocks</Title>
521*6a54128fSAndroid Build Coastguard Worker
522*6a54128fSAndroid Build Coastguard Worker<Para>
523*6a54128fSAndroid Build Coastguard WorkerThe basic functionality of an inode is to group together a series of
524*6a54128fSAndroid Build Coastguard Workerallocated blocks. There is no limitation on the allocated blocks - Each
525*6a54128fSAndroid Build Coastguard Workerblock can be allocated to each inode. Nevertheless, block allocation will
526*6a54128fSAndroid Build Coastguard Workerusually be done in series to take advantage of the locality principle.
527*6a54128fSAndroid Build Coastguard Worker</Para>
528*6a54128fSAndroid Build Coastguard Worker
529*6a54128fSAndroid Build Coastguard Worker<Para>
530*6a54128fSAndroid Build Coastguard WorkerThe inode is not always used in that way. I will now explain the allocation
531*6a54128fSAndroid Build Coastguard Workerof blocks, assuming that the current inode type indeed refers to a list of
532*6a54128fSAndroid Build Coastguard Workerallocated blocks.
533*6a54128fSAndroid Build Coastguard Worker</Para>
534*6a54128fSAndroid Build Coastguard Worker
535*6a54128fSAndroid Build Coastguard Worker<Para>
536*6a54128fSAndroid Build Coastguard WorkerIt was found experimentally that many of the files in the filesystem are
537*6a54128fSAndroid Build Coastguard Workeractually quite small. To take advantage of this effect, the kernel provides
538*6a54128fSAndroid Build Coastguard Workerstorage of up to 12 block numbers in the inode itself. Those blocks are
539*6a54128fSAndroid Build Coastguard Workercalled <Literal remap="tt">direct blocks</Literal>. The advantage is that once the kernel has the
540*6a54128fSAndroid Build Coastguard Workerinode, it can directly access the file's blocks, without an additional disk
541*6a54128fSAndroid Build Coastguard Workeraccess. Those 12 blocks are directly specified in the variables
542*6a54128fSAndroid Build Coastguard Worker<Literal remap="tt">i&lowbar;block[0] to i&lowbar;block[11]</Literal>.
543*6a54128fSAndroid Build Coastguard Worker</Para>
544*6a54128fSAndroid Build Coastguard Worker
545*6a54128fSAndroid Build Coastguard Worker<Para>
546*6a54128fSAndroid Build Coastguard Worker<Literal remap="tt">i&lowbar;block[12]</Literal> is the <Literal remap="tt">indirect block</Literal> - The block pointed by
547*6a54128fSAndroid Build Coastguard Workeri&lowbar;block&lsqb;12] will <Literal remap="tt">not</Literal> be a data block. Rather, it will just contain a
548*6a54128fSAndroid Build Coastguard Workerlist of direct blocks. For example, if the block size is 1024 bytes, since
549*6a54128fSAndroid Build Coastguard Workereach block number is 4 bytes long, there will be place for 256 indirect
550*6a54128fSAndroid Build Coastguard Workerblocks. That is, block 13 till block 268 in the file will be accessed by the
551*6a54128fSAndroid Build Coastguard Worker<Literal remap="tt">indirect block</Literal> method. The penalty in this case, compared to the
552*6a54128fSAndroid Build Coastguard Workerdirect blocks case, is that an additional access to the device is needed -
553*6a54128fSAndroid Build Coastguard WorkerWe need <Literal remap="tt">two</Literal> accesses to reach the required data block.
554*6a54128fSAndroid Build Coastguard Worker</Para>
555*6a54128fSAndroid Build Coastguard Worker
556*6a54128fSAndroid Build Coastguard Worker<Para>
557*6a54128fSAndroid Build Coastguard WorkerIn much the same way, <Literal remap="tt">i&lowbar;block[13]</Literal> is the <Literal remap="tt">double indirect block</Literal>
558*6a54128fSAndroid Build Coastguard Workerand <Literal remap="tt">i&lowbar;block[14]</Literal> is the <Literal remap="tt">triple indirect block</Literal>.
559*6a54128fSAndroid Build Coastguard Worker</Para>
560*6a54128fSAndroid Build Coastguard Worker
561*6a54128fSAndroid Build Coastguard Worker<Para>
562*6a54128fSAndroid Build Coastguard Worker<Literal remap="tt">i&lowbar;block[13]</Literal> points to a block which contains pointers to indirect
563*6a54128fSAndroid Build Coastguard Workerblocks. Each one of them is handled in the way described above.
564*6a54128fSAndroid Build Coastguard Worker</Para>
565*6a54128fSAndroid Build Coastguard Worker
566*6a54128fSAndroid Build Coastguard Worker<Para>
567*6a54128fSAndroid Build Coastguard WorkerIn much the same way, the triple indirect block is just an additional level
568*6a54128fSAndroid Build Coastguard Workerof indirection - It will point to a list of double indirect blocks.
569*6a54128fSAndroid Build Coastguard Worker</Para>
570*6a54128fSAndroid Build Coastguard Worker
571*6a54128fSAndroid Build Coastguard Worker</Sect2>
572*6a54128fSAndroid Build Coastguard Worker
573*6a54128fSAndroid Build Coastguard Worker<Sect2>
574*6a54128fSAndroid Build Coastguard Worker<Title>The i&lowbar;mode variable</Title>
575*6a54128fSAndroid Build Coastguard Worker
576*6a54128fSAndroid Build Coastguard Worker<Para>
577*6a54128fSAndroid Build Coastguard WorkerThe i&lowbar;mode variable is used to determine the <Literal remap="tt">inode type</Literal> and the
578*6a54128fSAndroid Build Coastguard Workerassociated <Literal remap="tt">permissions</Literal>. It is best described by representing it as an
579*6a54128fSAndroid Build Coastguard Workeroctal number. Since it is a 16 bit variable, there will be 6 octal digits.
580*6a54128fSAndroid Build Coastguard WorkerThose are divided into two parts - The rightmost 4 digits and the leftmost 2
581*6a54128fSAndroid Build Coastguard Workerdigits.
582*6a54128fSAndroid Build Coastguard Worker</Para>
583*6a54128fSAndroid Build Coastguard Worker
584*6a54128fSAndroid Build Coastguard Worker<Sect3>
585*6a54128fSAndroid Build Coastguard Worker<Title>The rightmost 4 octal digits</Title>
586*6a54128fSAndroid Build Coastguard Worker
587*6a54128fSAndroid Build Coastguard Worker<Para>
588*6a54128fSAndroid Build Coastguard WorkerThe rightmost 4 digits are <Literal remap="tt">bit options</Literal> - Each bit has its own
589*6a54128fSAndroid Build Coastguard Workerpurpose.
590*6a54128fSAndroid Build Coastguard Worker</Para>
591*6a54128fSAndroid Build Coastguard Worker
592*6a54128fSAndroid Build Coastguard Worker<Para>
593*6a54128fSAndroid Build Coastguard WorkerThe last 3 digits (Octal digits 0,1 and 2) are just the usual permissions,
594*6a54128fSAndroid Build Coastguard Workerin the known form <Literal remap="tt">rwxrwxrwx</Literal>. Digit 2 refers to the user, digit 1 to
595*6a54128fSAndroid Build Coastguard Workerthe group and digit 2 to everyone else. They are used by the kernel to grant
596*6a54128fSAndroid Build Coastguard Workeror deny access to the object presented by this inode.
597*6a54128fSAndroid Build Coastguard Worker<FOOTNOTE>
598*6a54128fSAndroid Build Coastguard Worker
599*6a54128fSAndroid Build Coastguard Worker<Para>
600*6a54128fSAndroid Build Coastguard WorkerA <Literal remap="tt">smarter</Literal> permissions control is one of the enhancements planned for
601*6a54128fSAndroid Build Coastguard WorkerLinux 1.3 - The ACL (Access Control Lists). Actually, from browsing of the
602*6a54128fSAndroid Build Coastguard Workerkernel source, some of the ACL handling is already done.
603*6a54128fSAndroid Build Coastguard Worker</Para>
604*6a54128fSAndroid Build Coastguard Worker
605*6a54128fSAndroid Build Coastguard Worker</FOOTNOTE>
606*6a54128fSAndroid Build Coastguard Worker
607*6a54128fSAndroid Build Coastguard Worker</Para>
608*6a54128fSAndroid Build Coastguard Worker
609*6a54128fSAndroid Build Coastguard Worker<Para>
610*6a54128fSAndroid Build Coastguard WorkerBit number 9 signals that the file (I'll refer to the object presented by
611*6a54128fSAndroid Build Coastguard Workerthe inode as file even though it can be a special device, for example) is
612*6a54128fSAndroid Build Coastguard Worker<Literal remap="tt">set VTX</Literal>. I still don't know what is the meaning of "VTX".
613*6a54128fSAndroid Build Coastguard Worker</Para>
614*6a54128fSAndroid Build Coastguard Worker
615*6a54128fSAndroid Build Coastguard Worker<Para>
616*6a54128fSAndroid Build Coastguard WorkerBit number 10 signals that the file is <Literal remap="tt">set group id</Literal> - I don't know
617*6a54128fSAndroid Build Coastguard Workerexactly the meaning of the above either.
618*6a54128fSAndroid Build Coastguard Worker</Para>
619*6a54128fSAndroid Build Coastguard Worker
620*6a54128fSAndroid Build Coastguard Worker<Para>
621*6a54128fSAndroid Build Coastguard WorkerBit number 11 signals that the file is <Literal remap="tt">set user id</Literal>, which means that
622*6a54128fSAndroid Build Coastguard Workerthe file will run with an effective user id root.
623*6a54128fSAndroid Build Coastguard Worker</Para>
624*6a54128fSAndroid Build Coastguard Worker
625*6a54128fSAndroid Build Coastguard Worker</Sect3>
626*6a54128fSAndroid Build Coastguard Worker
627*6a54128fSAndroid Build Coastguard Worker<Sect3>
628*6a54128fSAndroid Build Coastguard Worker<Title>The leftmost two octal digits</Title>
629*6a54128fSAndroid Build Coastguard Worker
630*6a54128fSAndroid Build Coastguard Worker<Para>
631*6a54128fSAndroid Build Coastguard WorkerNote the the leftmost octal digit can only be 0 or 1, since the total number
632*6a54128fSAndroid Build Coastguard Workerof bits is 16.
633*6a54128fSAndroid Build Coastguard Worker</Para>
634*6a54128fSAndroid Build Coastguard Worker
635*6a54128fSAndroid Build Coastguard Worker<Para>
636*6a54128fSAndroid Build Coastguard WorkerThose digits, as opposed to the rightmost 4 digits, are not bit mapped
637*6a54128fSAndroid Build Coastguard Workeroptions. They determine the type of the "file" to which the inode belongs:
638*6a54128fSAndroid Build Coastguard Worker
639*6a54128fSAndroid Build Coastguard Worker<ItemizedList>
640*6a54128fSAndroid Build Coastguard Worker<ListItem>
641*6a54128fSAndroid Build Coastguard Worker
642*6a54128fSAndroid Build Coastguard Worker<Para>
643*6a54128fSAndroid Build Coastguard Worker	<Literal remap="tt">01</Literal> - The file is a <Literal remap="tt">FIFO</Literal>.
644*6a54128fSAndroid Build Coastguard Worker</Para>
645*6a54128fSAndroid Build Coastguard Worker</ListItem>
646*6a54128fSAndroid Build Coastguard Worker<ListItem>
647*6a54128fSAndroid Build Coastguard Worker
648*6a54128fSAndroid Build Coastguard Worker<Para>
649*6a54128fSAndroid Build Coastguard Worker	<Literal remap="tt">02</Literal> - The file is a <Literal remap="tt">character device</Literal>.
650*6a54128fSAndroid Build Coastguard Worker</Para>
651*6a54128fSAndroid Build Coastguard Worker</ListItem>
652*6a54128fSAndroid Build Coastguard Worker<ListItem>
653*6a54128fSAndroid Build Coastguard Worker
654*6a54128fSAndroid Build Coastguard Worker<Para>
655*6a54128fSAndroid Build Coastguard Worker	<Literal remap="tt">04</Literal> - The file is a <Literal remap="tt">directory</Literal>.
656*6a54128fSAndroid Build Coastguard Worker</Para>
657*6a54128fSAndroid Build Coastguard Worker</ListItem>
658*6a54128fSAndroid Build Coastguard Worker<ListItem>
659*6a54128fSAndroid Build Coastguard Worker
660*6a54128fSAndroid Build Coastguard Worker<Para>
661*6a54128fSAndroid Build Coastguard Worker	<Literal remap="tt">06</Literal> - The file is a <Literal remap="tt">block device</Literal>.
662*6a54128fSAndroid Build Coastguard Worker</Para>
663*6a54128fSAndroid Build Coastguard Worker</ListItem>
664*6a54128fSAndroid Build Coastguard Worker<ListItem>
665*6a54128fSAndroid Build Coastguard Worker
666*6a54128fSAndroid Build Coastguard Worker<Para>
667*6a54128fSAndroid Build Coastguard Worker	<Literal remap="tt">10</Literal> - The file is a <Literal remap="tt">regular file</Literal>.
668*6a54128fSAndroid Build Coastguard Worker</Para>
669*6a54128fSAndroid Build Coastguard Worker</ListItem>
670*6a54128fSAndroid Build Coastguard Worker<ListItem>
671*6a54128fSAndroid Build Coastguard Worker
672*6a54128fSAndroid Build Coastguard Worker<Para>
673*6a54128fSAndroid Build Coastguard Worker	<Literal remap="tt">12</Literal> - The file is a <Literal remap="tt">symbolic link</Literal>.
674*6a54128fSAndroid Build Coastguard Worker</Para>
675*6a54128fSAndroid Build Coastguard Worker</ListItem>
676*6a54128fSAndroid Build Coastguard Worker<ListItem>
677*6a54128fSAndroid Build Coastguard Worker
678*6a54128fSAndroid Build Coastguard Worker<Para>
679*6a54128fSAndroid Build Coastguard Worker	<Literal remap="tt">14</Literal> - The file is a <Literal remap="tt">socket</Literal>.
680*6a54128fSAndroid Build Coastguard Worker</Para>
681*6a54128fSAndroid Build Coastguard Worker</ListItem>
682*6a54128fSAndroid Build Coastguard Worker
683*6a54128fSAndroid Build Coastguard Worker</ItemizedList>
684*6a54128fSAndroid Build Coastguard Worker
685*6a54128fSAndroid Build Coastguard Worker</Para>
686*6a54128fSAndroid Build Coastguard Worker
687*6a54128fSAndroid Build Coastguard Worker</Sect3>
688*6a54128fSAndroid Build Coastguard Worker
689*6a54128fSAndroid Build Coastguard Worker</Sect2>
690*6a54128fSAndroid Build Coastguard Worker
691*6a54128fSAndroid Build Coastguard Worker<Sect2>
692*6a54128fSAndroid Build Coastguard Worker<Title>Time and date</Title>
693*6a54128fSAndroid Build Coastguard Worker
694*6a54128fSAndroid Build Coastguard Worker<Para>
695*6a54128fSAndroid Build Coastguard WorkerLinux records the last time in which various operations occurred with the
696*6a54128fSAndroid Build Coastguard Workerfile. The time and date are saved in the standard C library format - The
697*6a54128fSAndroid Build Coastguard Workernumber of seconds which passed since 00:00:00 GMT, January 1, 1970. The
698*6a54128fSAndroid Build Coastguard Workerfollowing times are recorded:
699*6a54128fSAndroid Build Coastguard Worker
700*6a54128fSAndroid Build Coastguard Worker<ItemizedList>
701*6a54128fSAndroid Build Coastguard Worker<ListItem>
702*6a54128fSAndroid Build Coastguard Worker
703*6a54128fSAndroid Build Coastguard Worker<Para>
704*6a54128fSAndroid Build Coastguard Worker	<Literal remap="tt">i&lowbar;ctime</Literal> - The time in which the inode was last allocated. In
705*6a54128fSAndroid Build Coastguard Workerother words, the time in which the file was created.
706*6a54128fSAndroid Build Coastguard Worker</Para>
707*6a54128fSAndroid Build Coastguard Worker</ListItem>
708*6a54128fSAndroid Build Coastguard Worker<ListItem>
709*6a54128fSAndroid Build Coastguard Worker
710*6a54128fSAndroid Build Coastguard Worker<Para>
711*6a54128fSAndroid Build Coastguard Worker	<Literal remap="tt">i&lowbar;mtime</Literal> - The time in which the file was last modified.
712*6a54128fSAndroid Build Coastguard Worker</Para>
713*6a54128fSAndroid Build Coastguard Worker</ListItem>
714*6a54128fSAndroid Build Coastguard Worker<ListItem>
715*6a54128fSAndroid Build Coastguard Worker
716*6a54128fSAndroid Build Coastguard Worker<Para>
717*6a54128fSAndroid Build Coastguard Worker	<Literal remap="tt">i&lowbar;atime</Literal> - The time in which the file was last accessed.
718*6a54128fSAndroid Build Coastguard Worker</Para>
719*6a54128fSAndroid Build Coastguard Worker</ListItem>
720*6a54128fSAndroid Build Coastguard Worker<ListItem>
721*6a54128fSAndroid Build Coastguard Worker
722*6a54128fSAndroid Build Coastguard Worker<Para>
723*6a54128fSAndroid Build Coastguard Worker	<Literal remap="tt">i&lowbar;dtime</Literal> - The time in which the inode was deallocated. In
724*6a54128fSAndroid Build Coastguard Workerother words, the time in which the file was deleted.
725*6a54128fSAndroid Build Coastguard Worker</Para>
726*6a54128fSAndroid Build Coastguard Worker</ListItem>
727*6a54128fSAndroid Build Coastguard Worker
728*6a54128fSAndroid Build Coastguard Worker</ItemizedList>
729*6a54128fSAndroid Build Coastguard Worker
730*6a54128fSAndroid Build Coastguard Worker</Para>
731*6a54128fSAndroid Build Coastguard Worker
732*6a54128fSAndroid Build Coastguard Worker</Sect2>
733*6a54128fSAndroid Build Coastguard Worker
734*6a54128fSAndroid Build Coastguard Worker<Sect2>
735*6a54128fSAndroid Build Coastguard Worker<Title>i&lowbar;size</Title>
736*6a54128fSAndroid Build Coastguard Worker
737*6a54128fSAndroid Build Coastguard Worker<Para>
738*6a54128fSAndroid Build Coastguard Worker<Literal remap="tt">i&lowbar;size</Literal> contains information about the size of the object presented by
739*6a54128fSAndroid Build Coastguard Workerthe inode. If the inode corresponds to a regular file, this is just the size
740*6a54128fSAndroid Build Coastguard Workerof the file in bytes. In other cases, the interpretation of the variable is
741*6a54128fSAndroid Build Coastguard Workerdifferent.
742*6a54128fSAndroid Build Coastguard Worker</Para>
743*6a54128fSAndroid Build Coastguard Worker
744*6a54128fSAndroid Build Coastguard Worker</Sect2>
745*6a54128fSAndroid Build Coastguard Worker
746*6a54128fSAndroid Build Coastguard Worker<Sect2>
747*6a54128fSAndroid Build Coastguard Worker<Title>User and group id</Title>
748*6a54128fSAndroid Build Coastguard Worker
749*6a54128fSAndroid Build Coastguard Worker<Para>
750*6a54128fSAndroid Build Coastguard WorkerThe user and group id of the file are just saved in the variables
751*6a54128fSAndroid Build Coastguard Worker<Literal remap="tt">i&lowbar;uid</Literal> and <Literal remap="tt">i&lowbar;gid</Literal>.
752*6a54128fSAndroid Build Coastguard Worker</Para>
753*6a54128fSAndroid Build Coastguard Worker
754*6a54128fSAndroid Build Coastguard Worker</Sect2>
755*6a54128fSAndroid Build Coastguard Worker
756*6a54128fSAndroid Build Coastguard Worker<Sect2>
757*6a54128fSAndroid Build Coastguard Worker<Title>Hard links</Title>
758*6a54128fSAndroid Build Coastguard Worker
759*6a54128fSAndroid Build Coastguard Worker<Para>
760*6a54128fSAndroid Build Coastguard WorkerLater, when we'll discuss the implementation of directories, it will be
761*6a54128fSAndroid Build Coastguard Workerexplained that each <Literal remap="tt">directory entry</Literal> points to an inode. It is quite
762*6a54128fSAndroid Build Coastguard Workerpossible that a <Literal remap="tt">single inode</Literal> will be pointed to from <Literal remap="tt">several</Literal>
763*6a54128fSAndroid Build Coastguard Workerdirectories. In that case, we say that there exist <Literal remap="tt">hard links</Literal> to the
764*6a54128fSAndroid Build Coastguard Workerfile - The file can be accessed from each of the directories.
765*6a54128fSAndroid Build Coastguard Worker</Para>
766*6a54128fSAndroid Build Coastguard Worker
767*6a54128fSAndroid Build Coastguard Worker<Para>
768*6a54128fSAndroid Build Coastguard WorkerThe kernel keeps track of the number of hard links in the variable
769*6a54128fSAndroid Build Coastguard Worker<Literal remap="tt">i&lowbar;links&lowbar;count</Literal>. The variable is set to "1" when first allocating the
770*6a54128fSAndroid Build Coastguard Workerinode, and is incremented with each additional link. Deletion of a file will
771*6a54128fSAndroid Build Coastguard Workerdelete the current directory entry and will decrement the number of links.
772*6a54128fSAndroid Build Coastguard WorkerOnly when this number reaches zero, the inode will be actually deallocated.
773*6a54128fSAndroid Build Coastguard Worker</Para>
774*6a54128fSAndroid Build Coastguard Worker
775*6a54128fSAndroid Build Coastguard Worker<Para>
776*6a54128fSAndroid Build Coastguard WorkerThe name <Literal remap="tt">hard link</Literal> is used to distinguish between the alias method
777*6a54128fSAndroid Build Coastguard Workerdescribed above, to another alias method called <Literal remap="tt">symbolic linking</Literal>,
778*6a54128fSAndroid Build Coastguard Workerwhich will be described later.
779*6a54128fSAndroid Build Coastguard Worker</Para>
780*6a54128fSAndroid Build Coastguard Worker
781*6a54128fSAndroid Build Coastguard Worker</Sect2>
782*6a54128fSAndroid Build Coastguard Worker
783*6a54128fSAndroid Build Coastguard Worker<Sect2>
784*6a54128fSAndroid Build Coastguard Worker<Title>The Ext2fs extended flags</Title>
785*6a54128fSAndroid Build Coastguard Worker
786*6a54128fSAndroid Build Coastguard Worker<Para>
787*6a54128fSAndroid Build Coastguard WorkerThe ext2 filesystem associates additional flags with an inode. The extended
788*6a54128fSAndroid Build Coastguard Workerattributes are stored in the variable <Literal remap="tt">i&lowbar;flags</Literal>. <Literal remap="tt">i&lowbar;flags</Literal> is a 32
789*6a54128fSAndroid Build Coastguard Workerbit variable. Only the 7 rightmost bits are defined. Of them, only 5 bits
790*6a54128fSAndroid Build Coastguard Workerare used in version 0.5a of the filesystem. Specifically, the
791*6a54128fSAndroid Build Coastguard Worker<Literal remap="tt">undelete</Literal> and the <Literal remap="tt">compress</Literal> features are not implemented, and
792*6a54128fSAndroid Build Coastguard Workerare to be introduced in Linux 1.3 development.
793*6a54128fSAndroid Build Coastguard Worker</Para>
794*6a54128fSAndroid Build Coastguard Worker
795*6a54128fSAndroid Build Coastguard Worker<Para>
796*6a54128fSAndroid Build Coastguard WorkerThe currently available flags are:
797*6a54128fSAndroid Build Coastguard Worker
798*6a54128fSAndroid Build Coastguard Worker<ItemizedList>
799*6a54128fSAndroid Build Coastguard Worker<ListItem>
800*6a54128fSAndroid Build Coastguard Worker
801*6a54128fSAndroid Build Coastguard Worker<Para>
802*6a54128fSAndroid Build Coastguard Worker	bit 0 - Secure deletion.
803*6a54128fSAndroid Build Coastguard Worker
804*6a54128fSAndroid Build Coastguard WorkerWhen this bit is on, the file's blocks are zeroed when the file is
805*6a54128fSAndroid Build Coastguard Workerdeleted. With this bit off, they will just be left with their
806*6a54128fSAndroid Build Coastguard Workeroriginal data when the inode is deallocated.
807*6a54128fSAndroid Build Coastguard Worker</Para>
808*6a54128fSAndroid Build Coastguard Worker</ListItem>
809*6a54128fSAndroid Build Coastguard Worker<ListItem>
810*6a54128fSAndroid Build Coastguard Worker
811*6a54128fSAndroid Build Coastguard Worker<Para>
812*6a54128fSAndroid Build Coastguard Worker	bit 1 - Undelete.
813*6a54128fSAndroid Build Coastguard Worker
814*6a54128fSAndroid Build Coastguard WorkerThis bit is not supported yet. It will be used to provide an
815*6a54128fSAndroid Build Coastguard Worker<Literal remap="tt">undelete</Literal> feature in future Ext2fs developments.
816*6a54128fSAndroid Build Coastguard Worker</Para>
817*6a54128fSAndroid Build Coastguard Worker</ListItem>
818*6a54128fSAndroid Build Coastguard Worker<ListItem>
819*6a54128fSAndroid Build Coastguard Worker
820*6a54128fSAndroid Build Coastguard Worker<Para>
821*6a54128fSAndroid Build Coastguard Worker	bit 2 - Compress file.
822*6a54128fSAndroid Build Coastguard Worker
823*6a54128fSAndroid Build Coastguard WorkerThis bit is also not supported. The plan is to offer "compression on
824*6a54128fSAndroid Build Coastguard Workerthe fly" in future releases.
825*6a54128fSAndroid Build Coastguard Worker</Para>
826*6a54128fSAndroid Build Coastguard Worker</ListItem>
827*6a54128fSAndroid Build Coastguard Worker<ListItem>
828*6a54128fSAndroid Build Coastguard Worker
829*6a54128fSAndroid Build Coastguard Worker<Para>
830*6a54128fSAndroid Build Coastguard Worker	bit 3 - Synchronous updates.
831*6a54128fSAndroid Build Coastguard Worker
832*6a54128fSAndroid Build Coastguard WorkerWith this bit on, the meta-data will be written synchronously to the
833*6a54128fSAndroid Build Coastguard Workerdisk, as if the filesystem was mounted with the "sync" mount option.
834*6a54128fSAndroid Build Coastguard Worker</Para>
835*6a54128fSAndroid Build Coastguard Worker</ListItem>
836*6a54128fSAndroid Build Coastguard Worker<ListItem>
837*6a54128fSAndroid Build Coastguard Worker
838*6a54128fSAndroid Build Coastguard Worker<Para>
839*6a54128fSAndroid Build Coastguard Worker	bit 4 - Immutable file.
840*6a54128fSAndroid Build Coastguard Worker
841*6a54128fSAndroid Build Coastguard WorkerWhen this bit is on, the file will stay as it is - Can not be
842*6a54128fSAndroid Build Coastguard Workerchanged, deleted, renamed, no hard links, etc, before the bit is
843*6a54128fSAndroid Build Coastguard Workercleared.
844*6a54128fSAndroid Build Coastguard Worker</Para>
845*6a54128fSAndroid Build Coastguard Worker</ListItem>
846*6a54128fSAndroid Build Coastguard Worker<ListItem>
847*6a54128fSAndroid Build Coastguard Worker
848*6a54128fSAndroid Build Coastguard Worker<Para>
849*6a54128fSAndroid Build Coastguard Worker	bit 5 - Append only file.
850*6a54128fSAndroid Build Coastguard Worker
851*6a54128fSAndroid Build Coastguard WorkerWith this option active, data will only be appended to the file.
852*6a54128fSAndroid Build Coastguard Worker</Para>
853*6a54128fSAndroid Build Coastguard Worker</ListItem>
854*6a54128fSAndroid Build Coastguard Worker<ListItem>
855*6a54128fSAndroid Build Coastguard Worker
856*6a54128fSAndroid Build Coastguard Worker<Para>
857*6a54128fSAndroid Build Coastguard Worker	bit 6 - Do not dump this file.
858*6a54128fSAndroid Build Coastguard Worker
859*6a54128fSAndroid Build Coastguard WorkerI think that this bit is used by the port of dump to linux (ported by
860*6a54128fSAndroid Build Coastguard Worker<Literal remap="tt">Remy Card</Literal>) to check if the file should not be dumped.
861*6a54128fSAndroid Build Coastguard Worker</Para>
862*6a54128fSAndroid Build Coastguard Worker</ListItem>
863*6a54128fSAndroid Build Coastguard Worker
864*6a54128fSAndroid Build Coastguard Worker</ItemizedList>
865*6a54128fSAndroid Build Coastguard Worker
866*6a54128fSAndroid Build Coastguard Worker</Para>
867*6a54128fSAndroid Build Coastguard Worker
868*6a54128fSAndroid Build Coastguard Worker</Sect2>
869*6a54128fSAndroid Build Coastguard Worker
870*6a54128fSAndroid Build Coastguard Worker<Sect2>
871*6a54128fSAndroid Build Coastguard Worker<Title>Symbolic links</Title>
872*6a54128fSAndroid Build Coastguard Worker
873*6a54128fSAndroid Build Coastguard Worker<Para>
874*6a54128fSAndroid Build Coastguard WorkerThe <Literal remap="tt">hard links</Literal> presented above are just another pointers to the same
875*6a54128fSAndroid Build Coastguard Workerinode. The important aspect is that the inode number is <Literal remap="tt">fixed</Literal> when
876*6a54128fSAndroid Build Coastguard Workerthe link is created. This means that the implementation details of the
877*6a54128fSAndroid Build Coastguard Workerfilesystem are visible to the user - In a pure abstract usage of the
878*6a54128fSAndroid Build Coastguard Workerfilesystem, the user should not care about inodes.
879*6a54128fSAndroid Build Coastguard Worker</Para>
880*6a54128fSAndroid Build Coastguard Worker
881*6a54128fSAndroid Build Coastguard Worker<Para>
882*6a54128fSAndroid Build Coastguard WorkerThe above causes several limitations:
883*6a54128fSAndroid Build Coastguard Worker
884*6a54128fSAndroid Build Coastguard Worker<ItemizedList>
885*6a54128fSAndroid Build Coastguard Worker<ListItem>
886*6a54128fSAndroid Build Coastguard Worker
887*6a54128fSAndroid Build Coastguard Worker<Para>
888*6a54128fSAndroid Build Coastguard Worker	Hard links can be done only in the same filesystem. This is obvious,
889*6a54128fSAndroid Build Coastguard Workersince a hard link is just an inode number in some directory entry,
890*6a54128fSAndroid Build Coastguard Workerand the above elements are filesystem specific.
891*6a54128fSAndroid Build Coastguard Worker</Para>
892*6a54128fSAndroid Build Coastguard Worker</ListItem>
893*6a54128fSAndroid Build Coastguard Worker<ListItem>
894*6a54128fSAndroid Build Coastguard Worker
895*6a54128fSAndroid Build Coastguard Worker<Para>
896*6a54128fSAndroid Build Coastguard Worker	You can not "replace" the file which is pointed to by the hard link
897*6a54128fSAndroid Build Coastguard Workerafter the link creation. "Replacing" the file in one directory will
898*6a54128fSAndroid Build Coastguard Workerstill leave the original file in the other directory - The
899*6a54128fSAndroid Build Coastguard Worker"replacement" will not deallocate the original inode, but rather
900*6a54128fSAndroid Build Coastguard Workerallocate another inode for the new version, and the directory entry
901*6a54128fSAndroid Build Coastguard Workerat the other place will just point to the old inode number.
902*6a54128fSAndroid Build Coastguard Worker</Para>
903*6a54128fSAndroid Build Coastguard Worker</ListItem>
904*6a54128fSAndroid Build Coastguard Worker
905*6a54128fSAndroid Build Coastguard Worker</ItemizedList>
906*6a54128fSAndroid Build Coastguard Worker
907*6a54128fSAndroid Build Coastguard Worker</Para>
908*6a54128fSAndroid Build Coastguard Worker
909*6a54128fSAndroid Build Coastguard Worker<Para>
910*6a54128fSAndroid Build Coastguard Worker<Literal remap="tt">Symbolic link</Literal>, on the other hand, is analyzed at <Literal remap="tt">run time</Literal>. A
911*6a54128fSAndroid Build Coastguard Workersymbolic link is just a <Literal remap="tt">pathname</Literal> which is accessible from an inode.
912*6a54128fSAndroid Build Coastguard WorkerAs such, it "speaks" in the language of the abstract filesystem. When the
913*6a54128fSAndroid Build Coastguard Workerkernel reaches a symbolic link, it will <Literal remap="tt">follow it in run time</Literal> using
914*6a54128fSAndroid Build Coastguard Workerits normal way of reaching directories.
915*6a54128fSAndroid Build Coastguard Worker</Para>
916*6a54128fSAndroid Build Coastguard Worker
917*6a54128fSAndroid Build Coastguard Worker<Para>
918*6a54128fSAndroid Build Coastguard WorkerAs such, symbolic link can be made <Literal remap="tt">across different filesystems</Literal> and a
919*6a54128fSAndroid Build Coastguard Workerreplacement of a file with a new version will automatically be active on all
920*6a54128fSAndroid Build Coastguard Workerits symbolic links.
921*6a54128fSAndroid Build Coastguard Worker</Para>
922*6a54128fSAndroid Build Coastguard Worker
923*6a54128fSAndroid Build Coastguard Worker<Para>
924*6a54128fSAndroid Build Coastguard WorkerThe disadvantage is that hard link doesn't consume space except to a small
925*6a54128fSAndroid Build Coastguard Workerdirectory entry. Symbolic link, on the other hand, consumes at least an
926*6a54128fSAndroid Build Coastguard Workerinode, and can also consume one block.
927*6a54128fSAndroid Build Coastguard Worker</Para>
928*6a54128fSAndroid Build Coastguard Worker
929*6a54128fSAndroid Build Coastguard Worker<Para>
930*6a54128fSAndroid Build Coastguard WorkerWhen the inode is identified as a symbolic link, the kernel needs to find
931*6a54128fSAndroid Build Coastguard Workerthe path to which it points.
932*6a54128fSAndroid Build Coastguard Worker</Para>
933*6a54128fSAndroid Build Coastguard Worker
934*6a54128fSAndroid Build Coastguard Worker<Sect3>
935*6a54128fSAndroid Build Coastguard Worker<Title>Fast symbolic links</Title>
936*6a54128fSAndroid Build Coastguard Worker
937*6a54128fSAndroid Build Coastguard Worker<Para>
938*6a54128fSAndroid Build Coastguard WorkerWhen the pathname contains up to 64 bytes, it can be saved directly in the
939*6a54128fSAndroid Build Coastguard Workerinode, on the <Literal remap="tt">i&lowbar;block[0] - i&lowbar;block[15]</Literal> variables, since those are not
940*6a54128fSAndroid Build Coastguard Workerneeded in that case. This is called <Literal remap="tt">fast</Literal> symbolic link. It is fast
941*6a54128fSAndroid Build Coastguard Workerbecause the pathname resolution can be done using the inode itself, without
942*6a54128fSAndroid Build Coastguard Workeraccessing additional blocks. It is also economical, since it allocates only
943*6a54128fSAndroid Build Coastguard Workeran inode. The length of the pathname is stored in the <Literal remap="tt">i&lowbar;size</Literal>
944*6a54128fSAndroid Build Coastguard Workervariable.
945*6a54128fSAndroid Build Coastguard Worker</Para>
946*6a54128fSAndroid Build Coastguard Worker
947*6a54128fSAndroid Build Coastguard Worker</Sect3>
948*6a54128fSAndroid Build Coastguard Worker
949*6a54128fSAndroid Build Coastguard Worker<Sect3>
950*6a54128fSAndroid Build Coastguard Worker<Title>Slow symbolic links</Title>
951*6a54128fSAndroid Build Coastguard Worker
952*6a54128fSAndroid Build Coastguard Worker<Para>
953*6a54128fSAndroid Build Coastguard WorkerStarting from 65 bytes, additional block is allocated (by the use of
954*6a54128fSAndroid Build Coastguard Worker<Literal remap="tt">i&lowbar;block[0]</Literal>) and the pathname is stored in it. It is called slow
955*6a54128fSAndroid Build Coastguard Workerbecause the kernel needs to read additional block to resolve the pathname.
956*6a54128fSAndroid Build Coastguard WorkerThe length is again saved in <Literal remap="tt">i&lowbar;size</Literal>.
957*6a54128fSAndroid Build Coastguard Worker</Para>
958*6a54128fSAndroid Build Coastguard Worker
959*6a54128fSAndroid Build Coastguard Worker</Sect3>
960*6a54128fSAndroid Build Coastguard Worker
961*6a54128fSAndroid Build Coastguard Worker</Sect2>
962*6a54128fSAndroid Build Coastguard Worker
963*6a54128fSAndroid Build Coastguard Worker<Sect2>
964*6a54128fSAndroid Build Coastguard Worker<Title>i&lowbar;version</Title>
965*6a54128fSAndroid Build Coastguard Worker
966*6a54128fSAndroid Build Coastguard Worker<Para>
967*6a54128fSAndroid Build Coastguard Worker<Literal remap="tt">i&lowbar;version</Literal> is used with regard to Network File System. I don't know
968*6a54128fSAndroid Build Coastguard Workerits exact use.
969*6a54128fSAndroid Build Coastguard Worker</Para>
970*6a54128fSAndroid Build Coastguard Worker
971*6a54128fSAndroid Build Coastguard Worker</Sect2>
972*6a54128fSAndroid Build Coastguard Worker
973*6a54128fSAndroid Build Coastguard Worker<Sect2>
974*6a54128fSAndroid Build Coastguard Worker<Title>Reserved variables</Title>
975*6a54128fSAndroid Build Coastguard Worker
976*6a54128fSAndroid Build Coastguard Worker<Para>
977*6a54128fSAndroid Build Coastguard WorkerAs far as I know, the variables which are connected to ACL and fragments
978*6a54128fSAndroid Build Coastguard Workerare not currently used. They will be supported in future versions.
979*6a54128fSAndroid Build Coastguard Worker</Para>
980*6a54128fSAndroid Build Coastguard Worker
981*6a54128fSAndroid Build Coastguard Worker<Para>
982*6a54128fSAndroid Build Coastguard WorkerExt2fs is being ported to other operating systems. As far as I know,
983*6a54128fSAndroid Build Coastguard Workerat least in linux, the os dependent variables are also not used.
984*6a54128fSAndroid Build Coastguard Worker</Para>
985*6a54128fSAndroid Build Coastguard Worker
986*6a54128fSAndroid Build Coastguard Worker</Sect2>
987*6a54128fSAndroid Build Coastguard Worker
988*6a54128fSAndroid Build Coastguard Worker<Sect2>
989*6a54128fSAndroid Build Coastguard Worker<Title>Special reserved inodes</Title>
990*6a54128fSAndroid Build Coastguard Worker
991*6a54128fSAndroid Build Coastguard Worker<Para>
992*6a54128fSAndroid Build Coastguard WorkerThe first ten inodes on the filesystem are special inodes:
993*6a54128fSAndroid Build Coastguard Worker
994*6a54128fSAndroid Build Coastguard Worker<ItemizedList>
995*6a54128fSAndroid Build Coastguard Worker<ListItem>
996*6a54128fSAndroid Build Coastguard Worker
997*6a54128fSAndroid Build Coastguard Worker<Para>
998*6a54128fSAndroid Build Coastguard Worker	Inode 1 is the <Literal remap="tt">bad blocks inode</Literal> - I believe that its data
999*6a54128fSAndroid Build Coastguard Workerblocks contain a list of the bad blocks in the filesystem, which
1000*6a54128fSAndroid Build Coastguard Workershould not be allocated.
1001*6a54128fSAndroid Build Coastguard Worker</Para>
1002*6a54128fSAndroid Build Coastguard Worker</ListItem>
1003*6a54128fSAndroid Build Coastguard Worker<ListItem>
1004*6a54128fSAndroid Build Coastguard Worker
1005*6a54128fSAndroid Build Coastguard Worker<Para>
1006*6a54128fSAndroid Build Coastguard Worker	Inode 2 is the <Literal remap="tt">root inode</Literal> - The inode of the root directory.
1007*6a54128fSAndroid Build Coastguard WorkerIt is the starting point for reaching a known path in the filesystem.
1008*6a54128fSAndroid Build Coastguard Worker</Para>
1009*6a54128fSAndroid Build Coastguard Worker</ListItem>
1010*6a54128fSAndroid Build Coastguard Worker<ListItem>
1011*6a54128fSAndroid Build Coastguard Worker
1012*6a54128fSAndroid Build Coastguard Worker<Para>
1013*6a54128fSAndroid Build Coastguard Worker	Inode 3 is the <Literal remap="tt">acl index inode</Literal>. Access control lists are
1014*6a54128fSAndroid Build Coastguard Workercurrently not supported by the ext2 filesystem, so I believe this
1015*6a54128fSAndroid Build Coastguard Workerinode is not used.
1016*6a54128fSAndroid Build Coastguard Worker</Para>
1017*6a54128fSAndroid Build Coastguard Worker</ListItem>
1018*6a54128fSAndroid Build Coastguard Worker<ListItem>
1019*6a54128fSAndroid Build Coastguard Worker
1020*6a54128fSAndroid Build Coastguard Worker<Para>
1021*6a54128fSAndroid Build Coastguard Worker	Inode 4 is the <Literal remap="tt">acl data inode</Literal>. Of course, the above applies
1022*6a54128fSAndroid Build Coastguard Workerhere too.
1023*6a54128fSAndroid Build Coastguard Worker</Para>
1024*6a54128fSAndroid Build Coastguard Worker</ListItem>
1025*6a54128fSAndroid Build Coastguard Worker<ListItem>
1026*6a54128fSAndroid Build Coastguard Worker
1027*6a54128fSAndroid Build Coastguard Worker<Para>
1028*6a54128fSAndroid Build Coastguard Worker	Inode 5 is the <Literal remap="tt">boot loader inode</Literal>. I don't know its
1029*6a54128fSAndroid Build Coastguard Workerusage.
1030*6a54128fSAndroid Build Coastguard Worker</Para>
1031*6a54128fSAndroid Build Coastguard Worker</ListItem>
1032*6a54128fSAndroid Build Coastguard Worker<ListItem>
1033*6a54128fSAndroid Build Coastguard Worker
1034*6a54128fSAndroid Build Coastguard Worker<Para>
1035*6a54128fSAndroid Build Coastguard Worker	Inode 6 is the <Literal remap="tt">undelete directory inode</Literal>. It is also a
1036*6a54128fSAndroid Build Coastguard Workerfoundation for future enhancements, and is currently not used.
1037*6a54128fSAndroid Build Coastguard Worker</Para>
1038*6a54128fSAndroid Build Coastguard Worker</ListItem>
1039*6a54128fSAndroid Build Coastguard Worker<ListItem>
1040*6a54128fSAndroid Build Coastguard Worker
1041*6a54128fSAndroid Build Coastguard Worker<Para>
1042*6a54128fSAndroid Build Coastguard Worker	Inodes 7-10 are <Literal remap="tt">reserved</Literal> and currently not used.
1043*6a54128fSAndroid Build Coastguard Worker</Para>
1044*6a54128fSAndroid Build Coastguard Worker</ListItem>
1045*6a54128fSAndroid Build Coastguard Worker
1046*6a54128fSAndroid Build Coastguard Worker</ItemizedList>
1047*6a54128fSAndroid Build Coastguard Worker
1048*6a54128fSAndroid Build Coastguard Worker</Para>
1049*6a54128fSAndroid Build Coastguard Worker
1050*6a54128fSAndroid Build Coastguard Worker</Sect2>
1051*6a54128fSAndroid Build Coastguard Worker
1052*6a54128fSAndroid Build Coastguard Worker</Sect1>
1053*6a54128fSAndroid Build Coastguard Worker
1054*6a54128fSAndroid Build Coastguard Worker<Sect1>
1055*6a54128fSAndroid Build Coastguard Worker<Title>Directories</Title>
1056*6a54128fSAndroid Build Coastguard Worker
1057*6a54128fSAndroid Build Coastguard Worker<Para>
1058*6a54128fSAndroid Build Coastguard WorkerA directory is implemented in the same way as files are implemented (with
1059*6a54128fSAndroid Build Coastguard Workerthe direct blocks, indirect blocks, etc) - It is just a file which is
1060*6a54128fSAndroid Build Coastguard Workerformatted with a special format - A list of directory entries.
1061*6a54128fSAndroid Build Coastguard Worker</Para>
1062*6a54128fSAndroid Build Coastguard Worker
1063*6a54128fSAndroid Build Coastguard Worker<Para>
1064*6a54128fSAndroid Build Coastguard WorkerFollows the definition of a directory entry:
1065*6a54128fSAndroid Build Coastguard Worker</Para>
1066*6a54128fSAndroid Build Coastguard Worker
1067*6a54128fSAndroid Build Coastguard Worker<Para>
1068*6a54128fSAndroid Build Coastguard Worker
1069*6a54128fSAndroid Build Coastguard Worker<ProgramListing>
1070*6a54128fSAndroid Build Coastguard Workerstruct ext2_dir_entry {
1071*6a54128fSAndroid Build Coastguard Worker	__u32	inode;			/* Inode number */
1072*6a54128fSAndroid Build Coastguard Worker	__u16	rec_len;		/* Directory entry length */
1073*6a54128fSAndroid Build Coastguard Worker	__u16	name_len;		/* Name length */
1074*6a54128fSAndroid Build Coastguard Worker	char	name[EXT2_NAME_LEN];	/* File name */
1075*6a54128fSAndroid Build Coastguard Worker};
1076*6a54128fSAndroid Build Coastguard Worker</ProgramListing>
1077*6a54128fSAndroid Build Coastguard Worker
1078*6a54128fSAndroid Build Coastguard Worker</Para>
1079*6a54128fSAndroid Build Coastguard Worker
1080*6a54128fSAndroid Build Coastguard Worker<Para>
1081*6a54128fSAndroid Build Coastguard WorkerExt2fs supports file names of varying lengths, up to 255 bytes. The
1082*6a54128fSAndroid Build Coastguard Worker<Literal remap="tt">name</Literal> field above just contains the file name. Note that it is
1083*6a54128fSAndroid Build Coastguard Worker<Literal remap="tt">not zero terminated</Literal>; Instead, the variable <Literal remap="tt">name&lowbar;len</Literal> contains
1084*6a54128fSAndroid Build Coastguard Workerthe length of the file name.
1085*6a54128fSAndroid Build Coastguard Worker</Para>
1086*6a54128fSAndroid Build Coastguard Worker
1087*6a54128fSAndroid Build Coastguard Worker<Para>
1088*6a54128fSAndroid Build Coastguard WorkerThe variable <Literal remap="tt">rec&lowbar;len</Literal> is provided because the directory entries are
1089*6a54128fSAndroid Build Coastguard Workerpadded with zeroes so that the next entry will be in an offset which is
1090*6a54128fSAndroid Build Coastguard Workera multiplication of 4. The resulting directory entry size is stored in
1091*6a54128fSAndroid Build Coastguard Worker<Literal remap="tt">rec&lowbar;len</Literal>. If the directory entry is the last in the block, it is
1092*6a54128fSAndroid Build Coastguard Workerpadded with zeroes till the end of the block, and rec&lowbar;len is updated
1093*6a54128fSAndroid Build Coastguard Workeraccordingly.
1094*6a54128fSAndroid Build Coastguard Worker</Para>
1095*6a54128fSAndroid Build Coastguard Worker
1096*6a54128fSAndroid Build Coastguard Worker<Para>
1097*6a54128fSAndroid Build Coastguard WorkerThe <Literal remap="tt">inode</Literal> variable points to the inode of the above file.
1098*6a54128fSAndroid Build Coastguard Worker</Para>
1099*6a54128fSAndroid Build Coastguard Worker
1100*6a54128fSAndroid Build Coastguard Worker<Para>
1101*6a54128fSAndroid Build Coastguard WorkerDeletion of directory entries is done by appending of the deleted entry
1102*6a54128fSAndroid Build Coastguard Workerspace to the previous (or next, I am not sure) entry.
1103*6a54128fSAndroid Build Coastguard Worker</Para>
1104*6a54128fSAndroid Build Coastguard Worker
1105*6a54128fSAndroid Build Coastguard Worker</Sect1>
1106*6a54128fSAndroid Build Coastguard Worker
1107*6a54128fSAndroid Build Coastguard Worker<Sect1>
1108*6a54128fSAndroid Build Coastguard Worker<Title>The superblock</Title>
1109*6a54128fSAndroid Build Coastguard Worker
1110*6a54128fSAndroid Build Coastguard Worker<Para>
1111*6a54128fSAndroid Build Coastguard WorkerThe <Literal remap="tt">superblock</Literal> is a block which contains information which describes
1112*6a54128fSAndroid Build Coastguard Workerthe state of the internal filesystem.
1113*6a54128fSAndroid Build Coastguard Worker</Para>
1114*6a54128fSAndroid Build Coastguard Worker
1115*6a54128fSAndroid Build Coastguard Worker<Para>
1116*6a54128fSAndroid Build Coastguard WorkerThe superblock is located at the <Literal remap="tt">fixed offset 1024</Literal> in the device. Its
1117*6a54128fSAndroid Build Coastguard Workerlength is 1024 bytes also.
1118*6a54128fSAndroid Build Coastguard Worker</Para>
1119*6a54128fSAndroid Build Coastguard Worker
1120*6a54128fSAndroid Build Coastguard Worker<Para>
1121*6a54128fSAndroid Build Coastguard WorkerThe superblock, like the group descriptors, is copied on each blocks group
1122*6a54128fSAndroid Build Coastguard Workerboundary for backup purposes. However, only the main copy is used by the
1123*6a54128fSAndroid Build Coastguard Workerkernel.
1124*6a54128fSAndroid Build Coastguard Worker</Para>
1125*6a54128fSAndroid Build Coastguard Worker
1126*6a54128fSAndroid Build Coastguard Worker<Para>
1127*6a54128fSAndroid Build Coastguard WorkerThe superblock contain three types of information:
1128*6a54128fSAndroid Build Coastguard Worker
1129*6a54128fSAndroid Build Coastguard Worker<ItemizedList>
1130*6a54128fSAndroid Build Coastguard Worker<ListItem>
1131*6a54128fSAndroid Build Coastguard Worker
1132*6a54128fSAndroid Build Coastguard Worker<Para>
1133*6a54128fSAndroid Build Coastguard Worker	Filesystem parameters which are fixed and which were determined when
1134*6a54128fSAndroid Build Coastguard Workerthis specific filesystem was created. Some of those parameters can
1135*6a54128fSAndroid Build Coastguard Workerbe different in different installations of the ext2 filesystem, but
1136*6a54128fSAndroid Build Coastguard Workercan not be changed once the filesystem was created.
1137*6a54128fSAndroid Build Coastguard Worker</Para>
1138*6a54128fSAndroid Build Coastguard Worker</ListItem>
1139*6a54128fSAndroid Build Coastguard Worker<ListItem>
1140*6a54128fSAndroid Build Coastguard Worker
1141*6a54128fSAndroid Build Coastguard Worker<Para>
1142*6a54128fSAndroid Build Coastguard Worker	Filesystem parameters which are tunable - Can always be changed.
1143*6a54128fSAndroid Build Coastguard Worker</Para>
1144*6a54128fSAndroid Build Coastguard Worker</ListItem>
1145*6a54128fSAndroid Build Coastguard Worker<ListItem>
1146*6a54128fSAndroid Build Coastguard Worker
1147*6a54128fSAndroid Build Coastguard Worker<Para>
1148*6a54128fSAndroid Build Coastguard Worker	Information about the current filesystem state.
1149*6a54128fSAndroid Build Coastguard Worker</Para>
1150*6a54128fSAndroid Build Coastguard Worker</ListItem>
1151*6a54128fSAndroid Build Coastguard Worker
1152*6a54128fSAndroid Build Coastguard Worker</ItemizedList>
1153*6a54128fSAndroid Build Coastguard Worker
1154*6a54128fSAndroid Build Coastguard Worker</Para>
1155*6a54128fSAndroid Build Coastguard Worker
1156*6a54128fSAndroid Build Coastguard Worker<Para>
1157*6a54128fSAndroid Build Coastguard WorkerFollows the superblock definition:
1158*6a54128fSAndroid Build Coastguard Worker</Para>
1159*6a54128fSAndroid Build Coastguard Worker
1160*6a54128fSAndroid Build Coastguard Worker<Para>
1161*6a54128fSAndroid Build Coastguard Worker
1162*6a54128fSAndroid Build Coastguard Worker<ProgramListing>
1163*6a54128fSAndroid Build Coastguard Workerstruct ext2_super_block {
1164*6a54128fSAndroid Build Coastguard Worker	__u32	s_inodes_count;		/* Inodes count */
1165*6a54128fSAndroid Build Coastguard Worker	__u32	s_blocks_count;		/* Blocks count */
1166*6a54128fSAndroid Build Coastguard Worker	__u32	s_r_blocks_count;	/* Reserved blocks count */
1167*6a54128fSAndroid Build Coastguard Worker	__u32	s_free_blocks_count;	/* Free blocks count */
1168*6a54128fSAndroid Build Coastguard Worker	__u32	s_free_inodes_count;	/* Free inodes count */
1169*6a54128fSAndroid Build Coastguard Worker	__u32	s_first_data_block;	/* First Data Block */
1170*6a54128fSAndroid Build Coastguard Worker	__u32	s_log_block_size;	/* Block size */
1171*6a54128fSAndroid Build Coastguard Worker	__s32	s_log_frag_size;	/* Fragment size */
1172*6a54128fSAndroid Build Coastguard Worker	__u32	s_blocks_per_group;	/* # Blocks per group */
1173*6a54128fSAndroid Build Coastguard Worker	__u32	s_frags_per_group;	/* # Fragments per group */
1174*6a54128fSAndroid Build Coastguard Worker	__u32	s_inodes_per_group;	/* # Inodes per group */
1175*6a54128fSAndroid Build Coastguard Worker	__u32	s_mtime;		/* Mount time */
1176*6a54128fSAndroid Build Coastguard Worker	__u32	s_wtime;		/* Write time */
1177*6a54128fSAndroid Build Coastguard Worker	__u16	s_mnt_count;		/* Mount count */
1178*6a54128fSAndroid Build Coastguard Worker	__s16	s_max_mnt_count;	/* Maximal mount count */
1179*6a54128fSAndroid Build Coastguard Worker	__u16	s_magic;		/* Magic signature */
1180*6a54128fSAndroid Build Coastguard Worker	__u16	s_state;		/* File system state */
1181*6a54128fSAndroid Build Coastguard Worker	__u16	s_errors;		/* Behaviour when detecting errors */
1182*6a54128fSAndroid Build Coastguard Worker	__u16	s_pad;
1183*6a54128fSAndroid Build Coastguard Worker	__u32	s_lastcheck;		/* time of last check */
1184*6a54128fSAndroid Build Coastguard Worker	__u32	s_checkinterval;	/* max. time between checks */
1185*6a54128fSAndroid Build Coastguard Worker	__u32	s_creator_os;		/* OS */
1186*6a54128fSAndroid Build Coastguard Worker	__u32	s_rev_level;		/* Revision level */
1187*6a54128fSAndroid Build Coastguard Worker	__u16	s_def_resuid;		/* Default uid for reserved blocks */
1188*6a54128fSAndroid Build Coastguard Worker	__u16	s_def_resgid;		/* Default gid for reserved blocks */
1189*6a54128fSAndroid Build Coastguard Worker	__u32	s_reserved[235];	/* Padding to the end of the block */
1190*6a54128fSAndroid Build Coastguard Worker};
1191*6a54128fSAndroid Build Coastguard Worker</ProgramListing>
1192*6a54128fSAndroid Build Coastguard Worker
1193*6a54128fSAndroid Build Coastguard Worker</Para>
1194*6a54128fSAndroid Build Coastguard Worker
1195*6a54128fSAndroid Build Coastguard Worker<Sect2>
1196*6a54128fSAndroid Build Coastguard Worker<Title>superblock identification</Title>
1197*6a54128fSAndroid Build Coastguard Worker
1198*6a54128fSAndroid Build Coastguard Worker<Para>
1199*6a54128fSAndroid Build Coastguard WorkerThe ext2 filesystem's superblock is identified by the <Literal remap="tt">s&lowbar;magic</Literal> field.
1200*6a54128fSAndroid Build Coastguard WorkerThe current ext2 magic number is 0xEF53. I presume that "EF" means "Extended
1201*6a54128fSAndroid Build Coastguard WorkerFilesystem". In versions of the ext2 filesystem prior to 0.2B, the magic
1202*6a54128fSAndroid Build Coastguard Workernumber was 0xEF51. Those filesystems are not compatible with the current
1203*6a54128fSAndroid Build Coastguard Workerversions; Specifically, the group descriptors definition is different. I
1204*6a54128fSAndroid Build Coastguard Workerdoubt if there still exists such a installation.
1205*6a54128fSAndroid Build Coastguard Worker</Para>
1206*6a54128fSAndroid Build Coastguard Worker
1207*6a54128fSAndroid Build Coastguard Worker</Sect2>
1208*6a54128fSAndroid Build Coastguard Worker
1209*6a54128fSAndroid Build Coastguard Worker<Sect2>
1210*6a54128fSAndroid Build Coastguard Worker<Title>Filesystem fixed parameters</Title>
1211*6a54128fSAndroid Build Coastguard Worker
1212*6a54128fSAndroid Build Coastguard Worker<Para>
1213*6a54128fSAndroid Build Coastguard WorkerBy using the word <Literal remap="tt">fixed</Literal>, I mean fixed with respect to a particular
1214*6a54128fSAndroid Build Coastguard Workerinstallation. Those variables are usually not fixed with respect to
1215*6a54128fSAndroid Build Coastguard Workerdifferent installations.
1216*6a54128fSAndroid Build Coastguard Worker</Para>
1217*6a54128fSAndroid Build Coastguard Worker
1218*6a54128fSAndroid Build Coastguard Worker<Para>
1219*6a54128fSAndroid Build Coastguard WorkerThe <Literal remap="tt">block size</Literal> is determined by using the <Literal remap="tt">s&lowbar;log&lowbar;block&lowbar;size</Literal>
1220*6a54128fSAndroid Build Coastguard Workervariable. The block size is 1024*pow (2,s&lowbar;log&lowbar;block&lowbar;size) and should be
1221*6a54128fSAndroid Build Coastguard Workerbetween 1024 and 4096. The available options are 1024, 2048 and 4096.
1222*6a54128fSAndroid Build Coastguard Worker</Para>
1223*6a54128fSAndroid Build Coastguard Worker
1224*6a54128fSAndroid Build Coastguard Worker<Para>
1225*6a54128fSAndroid Build Coastguard Worker<Literal remap="tt">s&lowbar;inodes&lowbar;count</Literal> contains the total number of available inodes.
1226*6a54128fSAndroid Build Coastguard Worker</Para>
1227*6a54128fSAndroid Build Coastguard Worker
1228*6a54128fSAndroid Build Coastguard Worker<Para>
1229*6a54128fSAndroid Build Coastguard Worker<Literal remap="tt">s&lowbar;blocks&lowbar;count</Literal> contains the total number of available blocks.
1230*6a54128fSAndroid Build Coastguard Worker</Para>
1231*6a54128fSAndroid Build Coastguard Worker
1232*6a54128fSAndroid Build Coastguard Worker<Para>
1233*6a54128fSAndroid Build Coastguard Worker<Literal remap="tt">s&lowbar;first&lowbar;data&lowbar;block</Literal> specifies in which of the <Literal remap="tt">device block</Literal> the
1234*6a54128fSAndroid Build Coastguard Worker<Literal remap="tt">superblock</Literal> is present. The superblock is always present at the fixed
1235*6a54128fSAndroid Build Coastguard Workeroffset 1024, but the device block numbering can differ. For example, if the
1236*6a54128fSAndroid Build Coastguard Workerblock size is 1024, the superblock will be at <Literal remap="tt">block 1</Literal> with respect to
1237*6a54128fSAndroid Build Coastguard Workerthe device. However, if the block size is 4096, offset 1024 is included in
1238*6a54128fSAndroid Build Coastguard Worker<Literal remap="tt">block 0</Literal> of the device, and in that case <Literal remap="tt">s&lowbar;first&lowbar;data&lowbar;block</Literal>
1239*6a54128fSAndroid Build Coastguard Workerwill contain 0. At least this is how I understood this variable.
1240*6a54128fSAndroid Build Coastguard Worker</Para>
1241*6a54128fSAndroid Build Coastguard Worker
1242*6a54128fSAndroid Build Coastguard Worker<Para>
1243*6a54128fSAndroid Build Coastguard Worker<Literal remap="tt">s&lowbar;blocks&lowbar;per&lowbar;group</Literal> contains the number of blocks which are grouped
1244*6a54128fSAndroid Build Coastguard Workertogether as a blocks group.
1245*6a54128fSAndroid Build Coastguard Worker</Para>
1246*6a54128fSAndroid Build Coastguard Worker
1247*6a54128fSAndroid Build Coastguard Worker<Para>
1248*6a54128fSAndroid Build Coastguard Worker<Literal remap="tt">s&lowbar;inodes&lowbar;per&lowbar;group</Literal> contains the number of inodes available in a group
1249*6a54128fSAndroid Build Coastguard Workerblock. I think that this is always the total number of inodes divided by the
1250*6a54128fSAndroid Build Coastguard Workernumber of blocks groups.
1251*6a54128fSAndroid Build Coastguard Worker</Para>
1252*6a54128fSAndroid Build Coastguard Worker
1253*6a54128fSAndroid Build Coastguard Worker<Para>
1254*6a54128fSAndroid Build Coastguard Worker<Literal remap="tt">s&lowbar;creator&lowbar;os</Literal> contains a code number which specifies the operating
1255*6a54128fSAndroid Build Coastguard Workersystem which created this specific filesystem:
1256*6a54128fSAndroid Build Coastguard Worker
1257*6a54128fSAndroid Build Coastguard Worker<ItemizedList>
1258*6a54128fSAndroid Build Coastguard Worker<ListItem>
1259*6a54128fSAndroid Build Coastguard Worker
1260*6a54128fSAndroid Build Coastguard Worker<Para>
1261*6a54128fSAndroid Build Coastguard Worker	<Literal remap="tt">Linux</Literal> :-) is specified by the value <Literal remap="tt">0</Literal>.
1262*6a54128fSAndroid Build Coastguard Worker</Para>
1263*6a54128fSAndroid Build Coastguard Worker</ListItem>
1264*6a54128fSAndroid Build Coastguard Worker<ListItem>
1265*6a54128fSAndroid Build Coastguard Worker
1266*6a54128fSAndroid Build Coastguard Worker<Para>
1267*6a54128fSAndroid Build Coastguard Worker	<Literal remap="tt">Hurd</Literal> is specified by the value <Literal remap="tt">1</Literal>.
1268*6a54128fSAndroid Build Coastguard Worker</Para>
1269*6a54128fSAndroid Build Coastguard Worker</ListItem>
1270*6a54128fSAndroid Build Coastguard Worker<ListItem>
1271*6a54128fSAndroid Build Coastguard Worker
1272*6a54128fSAndroid Build Coastguard Worker<Para>
1273*6a54128fSAndroid Build Coastguard Worker	<Literal remap="tt">Masix</Literal> is specified by the value <Literal remap="tt">2</Literal>.
1274*6a54128fSAndroid Build Coastguard Worker</Para>
1275*6a54128fSAndroid Build Coastguard Worker</ListItem>
1276*6a54128fSAndroid Build Coastguard Worker
1277*6a54128fSAndroid Build Coastguard Worker</ItemizedList>
1278*6a54128fSAndroid Build Coastguard Worker
1279*6a54128fSAndroid Build Coastguard Worker</Para>
1280*6a54128fSAndroid Build Coastguard Worker
1281*6a54128fSAndroid Build Coastguard Worker<Para>
1282*6a54128fSAndroid Build Coastguard Worker<Literal remap="tt">s&lowbar;rev&lowbar;level</Literal> contains the major version of the ext2 filesystem.
1283*6a54128fSAndroid Build Coastguard WorkerCurrently this is always <Literal remap="tt">0</Literal>, as the most recent version is 0.5B. It
1284*6a54128fSAndroid Build Coastguard Workerwill probably take some time until we reach version 1.0.
1285*6a54128fSAndroid Build Coastguard Worker</Para>
1286*6a54128fSAndroid Build Coastguard Worker
1287*6a54128fSAndroid Build Coastguard Worker<Para>
1288*6a54128fSAndroid Build Coastguard WorkerAs far as I know, fragments (sub-block allocations) are currently not
1289*6a54128fSAndroid Build Coastguard Workersupported and hence a block is equal to a fragment. As a result,
1290*6a54128fSAndroid Build Coastguard Worker<Literal remap="tt">s&lowbar;log&lowbar;frag&lowbar;size</Literal> and <Literal remap="tt">s&lowbar;frags&lowbar;per&lowbar;group</Literal> are always equal to
1291*6a54128fSAndroid Build Coastguard Worker<Literal remap="tt">s&lowbar;log&lowbar;block&lowbar;size</Literal> and <Literal remap="tt">s&lowbar;blocks&lowbar;per&lowbar;group</Literal>, respectively.
1292*6a54128fSAndroid Build Coastguard Worker</Para>
1293*6a54128fSAndroid Build Coastguard Worker
1294*6a54128fSAndroid Build Coastguard Worker</Sect2>
1295*6a54128fSAndroid Build Coastguard Worker
1296*6a54128fSAndroid Build Coastguard Worker<Sect2>
1297*6a54128fSAndroid Build Coastguard Worker<Title>Ext2fs error handling</Title>
1298*6a54128fSAndroid Build Coastguard Worker
1299*6a54128fSAndroid Build Coastguard Worker<Para>
1300*6a54128fSAndroid Build Coastguard WorkerThe ext2 filesystem error handling is based on the following philosophy:
1301*6a54128fSAndroid Build Coastguard Worker
1302*6a54128fSAndroid Build Coastguard Worker<OrderedList>
1303*6a54128fSAndroid Build Coastguard Worker<ListItem>
1304*6a54128fSAndroid Build Coastguard Worker
1305*6a54128fSAndroid Build Coastguard Worker<Para>
1306*6a54128fSAndroid Build Coastguard Worker	Identification of problems is done by the kernel code.
1307*6a54128fSAndroid Build Coastguard Worker</Para>
1308*6a54128fSAndroid Build Coastguard Worker</ListItem>
1309*6a54128fSAndroid Build Coastguard Worker<ListItem>
1310*6a54128fSAndroid Build Coastguard Worker
1311*6a54128fSAndroid Build Coastguard Worker<Para>
1312*6a54128fSAndroid Build Coastguard Worker	The correction task is left to an external utility, such as
1313*6a54128fSAndroid Build Coastguard Worker<Literal remap="tt">e2fsck by Theodore Ts'o</Literal> for <Literal remap="tt">automatic</Literal> analysis and
1314*6a54128fSAndroid Build Coastguard Workercorrection, or perhaps <Literal remap="tt">debugfs by Theodore Ts'o</Literal> and
1315*6a54128fSAndroid Build Coastguard Worker<Literal remap="tt">EXT2ED by myself</Literal>, for <Literal remap="tt">hand</Literal> analysis and correction.
1316*6a54128fSAndroid Build Coastguard Worker</Para>
1317*6a54128fSAndroid Build Coastguard Worker</ListItem>
1318*6a54128fSAndroid Build Coastguard Worker
1319*6a54128fSAndroid Build Coastguard Worker</OrderedList>
1320*6a54128fSAndroid Build Coastguard Worker
1321*6a54128fSAndroid Build Coastguard Worker</Para>
1322*6a54128fSAndroid Build Coastguard Worker
1323*6a54128fSAndroid Build Coastguard Worker<Para>
1324*6a54128fSAndroid Build Coastguard WorkerThe <Literal remap="tt">s&lowbar;state</Literal> variable is used by the kernel to pass the identification
1325*6a54128fSAndroid Build Coastguard Workerresult to third party utilities:
1326*6a54128fSAndroid Build Coastguard Worker
1327*6a54128fSAndroid Build Coastguard Worker<ItemizedList>
1328*6a54128fSAndroid Build Coastguard Worker<ListItem>
1329*6a54128fSAndroid Build Coastguard Worker
1330*6a54128fSAndroid Build Coastguard Worker<Para>
1331*6a54128fSAndroid Build Coastguard Worker	<Literal remap="tt">bit 0</Literal> of s&lowbar;state is reset when the partition is mounted and
1332*6a54128fSAndroid Build Coastguard Workerset when the partition is unmounted. Thus, a value of 0 on an
1333*6a54128fSAndroid Build Coastguard Workerunmounted filesystem means that the filesystem was not unmounted
1334*6a54128fSAndroid Build Coastguard Workerproperly - The filesystem is not "clean" and probably contains
1335*6a54128fSAndroid Build Coastguard Workererrors.
1336*6a54128fSAndroid Build Coastguard Worker</Para>
1337*6a54128fSAndroid Build Coastguard Worker</ListItem>
1338*6a54128fSAndroid Build Coastguard Worker<ListItem>
1339*6a54128fSAndroid Build Coastguard Worker
1340*6a54128fSAndroid Build Coastguard Worker<Para>
1341*6a54128fSAndroid Build Coastguard Worker	<Literal remap="tt">bit 1</Literal> of s&lowbar;state is set by the kernel when it detects an
1342*6a54128fSAndroid Build Coastguard Workererror in the filesystem. A value of 0 doesn't mean that there isn't
1343*6a54128fSAndroid Build Coastguard Workeran error in the filesystem, just that the kernel didn't find any.
1344*6a54128fSAndroid Build Coastguard Worker</Para>
1345*6a54128fSAndroid Build Coastguard Worker</ListItem>
1346*6a54128fSAndroid Build Coastguard Worker
1347*6a54128fSAndroid Build Coastguard Worker</ItemizedList>
1348*6a54128fSAndroid Build Coastguard Worker
1349*6a54128fSAndroid Build Coastguard Worker</Para>
1350*6a54128fSAndroid Build Coastguard Worker
1351*6a54128fSAndroid Build Coastguard Worker<Para>
1352*6a54128fSAndroid Build Coastguard WorkerThe kernel behavior when an error is found is determined by the user tunable
1353*6a54128fSAndroid Build Coastguard Workerparameter <Literal remap="tt">s&lowbar;errors</Literal>:
1354*6a54128fSAndroid Build Coastguard Worker
1355*6a54128fSAndroid Build Coastguard Worker<ItemizedList>
1356*6a54128fSAndroid Build Coastguard Worker<ListItem>
1357*6a54128fSAndroid Build Coastguard Worker
1358*6a54128fSAndroid Build Coastguard Worker<Para>
1359*6a54128fSAndroid Build Coastguard Worker	The kernel will ignore the error and continue if <Literal remap="tt">s&lowbar;errors=1</Literal>.
1360*6a54128fSAndroid Build Coastguard Worker</Para>
1361*6a54128fSAndroid Build Coastguard Worker</ListItem>
1362*6a54128fSAndroid Build Coastguard Worker<ListItem>
1363*6a54128fSAndroid Build Coastguard Worker
1364*6a54128fSAndroid Build Coastguard Worker<Para>
1365*6a54128fSAndroid Build Coastguard Worker	The kernel will remount the filesystem in read-only mode if
1366*6a54128fSAndroid Build Coastguard Worker<Literal remap="tt">s&lowbar;errors=2</Literal>.
1367*6a54128fSAndroid Build Coastguard Worker</Para>
1368*6a54128fSAndroid Build Coastguard Worker</ListItem>
1369*6a54128fSAndroid Build Coastguard Worker<ListItem>
1370*6a54128fSAndroid Build Coastguard Worker
1371*6a54128fSAndroid Build Coastguard Worker<Para>
1372*6a54128fSAndroid Build Coastguard Worker	A kernel panic will be issued if <Literal remap="tt">s&lowbar;errors=3</Literal>.
1373*6a54128fSAndroid Build Coastguard Worker</Para>
1374*6a54128fSAndroid Build Coastguard Worker</ListItem>
1375*6a54128fSAndroid Build Coastguard Worker
1376*6a54128fSAndroid Build Coastguard Worker</ItemizedList>
1377*6a54128fSAndroid Build Coastguard Worker
1378*6a54128fSAndroid Build Coastguard Worker</Para>
1379*6a54128fSAndroid Build Coastguard Worker
1380*6a54128fSAndroid Build Coastguard Worker<Para>
1381*6a54128fSAndroid Build Coastguard WorkerThe default behavior is to ignore the error.
1382*6a54128fSAndroid Build Coastguard Worker</Para>
1383*6a54128fSAndroid Build Coastguard Worker
1384*6a54128fSAndroid Build Coastguard Worker</Sect2>
1385*6a54128fSAndroid Build Coastguard Worker
1386*6a54128fSAndroid Build Coastguard Worker<Sect2>
1387*6a54128fSAndroid Build Coastguard Worker<Title>Additional parameters used by e2fsck</Title>
1388*6a54128fSAndroid Build Coastguard Worker
1389*6a54128fSAndroid Build Coastguard Worker<Para>
1390*6a54128fSAndroid Build Coastguard WorkerOf-course, <Literal remap="tt">e2fsck</Literal> will check the filesystem if errors were detected
1391*6a54128fSAndroid Build Coastguard Workeror if the filesystem is not clean.
1392*6a54128fSAndroid Build Coastguard Worker</Para>
1393*6a54128fSAndroid Build Coastguard Worker
1394*6a54128fSAndroid Build Coastguard Worker<Para>
1395*6a54128fSAndroid Build Coastguard WorkerIn addition, each time the filesystem is mounted, <Literal remap="tt">s&lowbar;mnt&lowbar;count</Literal> is
1396*6a54128fSAndroid Build Coastguard Workerincremented. When s&lowbar;mnt&lowbar;count reaches <Literal remap="tt">s&lowbar;max&lowbar;mnt&lowbar;count</Literal>, <Literal remap="tt">e2fsck</Literal>
1397*6a54128fSAndroid Build Coastguard Workerwill force a check on the filesystem even though it may be clean. It will
1398*6a54128fSAndroid Build Coastguard Workerthen zero s&lowbar;mnt&lowbar;count. <Literal remap="tt">s&lowbar;max&lowbar;mnt&lowbar;count</Literal> is a tunable parameter.
1399*6a54128fSAndroid Build Coastguard Worker</Para>
1400*6a54128fSAndroid Build Coastguard Worker
1401*6a54128fSAndroid Build Coastguard Worker<Para>
1402*6a54128fSAndroid Build Coastguard WorkerE2fsck also records the last time in which the file system was checked in
1403*6a54128fSAndroid Build Coastguard Workerthe <Literal remap="tt">s&lowbar;lastcheck</Literal> variable. The user tunable parameter
1404*6a54128fSAndroid Build Coastguard Worker<Literal remap="tt">s&lowbar;checkinterval</Literal> will contain the number of seconds which are allowed
1405*6a54128fSAndroid Build Coastguard Workerto pass since <Literal remap="tt">s&lowbar;lastcheck</Literal> until a check is forced. A value of
1406*6a54128fSAndroid Build Coastguard Worker<Literal remap="tt">0</Literal> disables time-based check.
1407*6a54128fSAndroid Build Coastguard Worker</Para>
1408*6a54128fSAndroid Build Coastguard Worker
1409*6a54128fSAndroid Build Coastguard Worker</Sect2>
1410*6a54128fSAndroid Build Coastguard Worker
1411*6a54128fSAndroid Build Coastguard Worker<Sect2>
1412*6a54128fSAndroid Build Coastguard Worker<Title>Additional user tunable parameters</Title>
1413*6a54128fSAndroid Build Coastguard Worker
1414*6a54128fSAndroid Build Coastguard Worker<Para>
1415*6a54128fSAndroid Build Coastguard Worker<Literal remap="tt">s&lowbar;r&lowbar;blocks&lowbar;count</Literal> contains the number of disk blocks which are
1416*6a54128fSAndroid Build Coastguard Workerreserved for root, the user whose id number is <Literal remap="tt">s&lowbar;def&lowbar;resuid</Literal> and the
1417*6a54128fSAndroid Build Coastguard Workergroup whose id number is <Literal remap="tt">s&lowbar;deg&lowbar;resgid</Literal>. The kernel will refuse to
1418*6a54128fSAndroid Build Coastguard Workerallocate those last <Literal remap="tt">s&lowbar;r&lowbar;blocks&lowbar;count</Literal> if the user is not one of the
1419*6a54128fSAndroid Build Coastguard Workerabove. This is done so that the filesystem will usually not be 100&percnt; full,
1420*6a54128fSAndroid Build Coastguard Workersince 100&percnt; full filesystems can affect various aspects of operation.
1421*6a54128fSAndroid Build Coastguard Worker</Para>
1422*6a54128fSAndroid Build Coastguard Worker
1423*6a54128fSAndroid Build Coastguard Worker<Para>
1424*6a54128fSAndroid Build Coastguard Worker<Literal remap="tt">s&lowbar;def&lowbar;resuid</Literal> and <Literal remap="tt">s&lowbar;def&lowbar;resgid</Literal> contain the id of the user and
1425*6a54128fSAndroid Build Coastguard Workerof the group who can use the reserved blocks in addition to root.
1426*6a54128fSAndroid Build Coastguard Worker</Para>
1427*6a54128fSAndroid Build Coastguard Worker
1428*6a54128fSAndroid Build Coastguard Worker</Sect2>
1429*6a54128fSAndroid Build Coastguard Worker
1430*6a54128fSAndroid Build Coastguard Worker<Sect2>
1431*6a54128fSAndroid Build Coastguard Worker<Title>Filesystem current state</Title>
1432*6a54128fSAndroid Build Coastguard Worker
1433*6a54128fSAndroid Build Coastguard Worker<Para>
1434*6a54128fSAndroid Build Coastguard Worker<Literal remap="tt">s&lowbar;free&lowbar;blocks&lowbar;count</Literal> contains the current number of free blocks
1435*6a54128fSAndroid Build Coastguard Workerin the filesystem.
1436*6a54128fSAndroid Build Coastguard Worker</Para>
1437*6a54128fSAndroid Build Coastguard Worker
1438*6a54128fSAndroid Build Coastguard Worker<Para>
1439*6a54128fSAndroid Build Coastguard Worker<Literal remap="tt">s&lowbar;free&lowbar;inodes&lowbar;count</Literal> contains the current number of free inodes in the
1440*6a54128fSAndroid Build Coastguard Workerfilesystem.
1441*6a54128fSAndroid Build Coastguard Worker</Para>
1442*6a54128fSAndroid Build Coastguard Worker
1443*6a54128fSAndroid Build Coastguard Worker<Para>
1444*6a54128fSAndroid Build Coastguard Worker<Literal remap="tt">s&lowbar;mtime</Literal> contains the time at which the system was last mounted.
1445*6a54128fSAndroid Build Coastguard Worker</Para>
1446*6a54128fSAndroid Build Coastguard Worker
1447*6a54128fSAndroid Build Coastguard Worker<Para>
1448*6a54128fSAndroid Build Coastguard Worker<Literal remap="tt">s&lowbar;wtime</Literal> contains the last time at which something was changed in the
1449*6a54128fSAndroid Build Coastguard Workerfilesystem.
1450*6a54128fSAndroid Build Coastguard Worker</Para>
1451*6a54128fSAndroid Build Coastguard Worker
1452*6a54128fSAndroid Build Coastguard Worker</Sect2>
1453*6a54128fSAndroid Build Coastguard Worker
1454*6a54128fSAndroid Build Coastguard Worker</Sect1>
1455*6a54128fSAndroid Build Coastguard Worker
1456*6a54128fSAndroid Build Coastguard Worker<Sect1>
1457*6a54128fSAndroid Build Coastguard Worker<Title>Copyright</Title>
1458*6a54128fSAndroid Build Coastguard Worker
1459*6a54128fSAndroid Build Coastguard Worker<Para>
1460*6a54128fSAndroid Build Coastguard WorkerThis document contains source code which was taken from the Linux ext2
1461*6a54128fSAndroid Build Coastguard Workerkernel source code, mainly from <FILENAME>/usr/include/linux/ext2&lowbar;fs.h</FILENAME>. Follows
1462*6a54128fSAndroid Build Coastguard Workerthe original copyright:
1463*6a54128fSAndroid Build Coastguard Worker</Para>
1464*6a54128fSAndroid Build Coastguard Worker
1465*6a54128fSAndroid Build Coastguard Worker<Para>
1466*6a54128fSAndroid Build Coastguard Worker
1467*6a54128fSAndroid Build Coastguard Worker<ProgramListing>
1468*6a54128fSAndroid Build Coastguard Worker/*
1469*6a54128fSAndroid Build Coastguard Worker *  linux/include/linux/ext2_fs.h
1470*6a54128fSAndroid Build Coastguard Worker *
1471*6a54128fSAndroid Build Coastguard Worker * Copyright (C) 1992, 1993, 1994, 1995
1472*6a54128fSAndroid Build Coastguard Worker * Remy Card ([email protected])
1473*6a54128fSAndroid Build Coastguard Worker * Laboratoire MASI - Institut Blaise Pascal
1474*6a54128fSAndroid Build Coastguard Worker * Universite Pierre et Marie Curie (Paris VI)
1475*6a54128fSAndroid Build Coastguard Worker *
1476*6a54128fSAndroid Build Coastguard Worker *  from
1477*6a54128fSAndroid Build Coastguard Worker *
1478*6a54128fSAndroid Build Coastguard Worker *  linux/include/linux/minix_fs.h
1479*6a54128fSAndroid Build Coastguard Worker *
1480*6a54128fSAndroid Build Coastguard Worker *  Copyright (C) 1991, 1992  Linus Torvalds
1481*6a54128fSAndroid Build Coastguard Worker */
1482*6a54128fSAndroid Build Coastguard Worker
1483*6a54128fSAndroid Build Coastguard Worker</ProgramListing>
1484*6a54128fSAndroid Build Coastguard Worker
1485*6a54128fSAndroid Build Coastguard Worker</Para>
1486*6a54128fSAndroid Build Coastguard Worker
1487*6a54128fSAndroid Build Coastguard Worker</Sect1>
1488*6a54128fSAndroid Build Coastguard Worker
1489*6a54128fSAndroid Build Coastguard Worker<Sect1>
1490*6a54128fSAndroid Build Coastguard Worker<Title>Acknowledgments</Title>
1491*6a54128fSAndroid Build Coastguard Worker
1492*6a54128fSAndroid Build Coastguard Worker<Para>
1493*6a54128fSAndroid Build Coastguard WorkerI would like to thank the following people, who were involved in the
1494*6a54128fSAndroid Build Coastguard Workerdesign and implementation of the ext2 filesystem kernel code and support
1495*6a54128fSAndroid Build Coastguard Workerutilities:
1496*6a54128fSAndroid Build Coastguard Worker
1497*6a54128fSAndroid Build Coastguard Worker<ItemizedList>
1498*6a54128fSAndroid Build Coastguard Worker<ListItem>
1499*6a54128fSAndroid Build Coastguard Worker
1500*6a54128fSAndroid Build Coastguard Worker<Para>
1501*6a54128fSAndroid Build Coastguard Worker	<Literal remap="tt">Remy Card</Literal>
1502*6a54128fSAndroid Build Coastguard Worker
1503*6a54128fSAndroid Build Coastguard WorkerWho designed, implemented and maintains the ext2 filesystem kernel
1504*6a54128fSAndroid Build Coastguard Workercode, and some of the ext2 utilities. <Literal remap="tt">Remy Card</Literal> is also the
1505*6a54128fSAndroid Build Coastguard Workerauthor 	of several helpful slides concerning the ext2 filesystem.
1506*6a54128fSAndroid Build Coastguard WorkerSpecifically, he is the author of <Literal remap="tt">File Management in the Linux
1507*6a54128fSAndroid Build Coastguard WorkerKernel</Literal> and of <Literal remap="tt">The Second Extended File System - Current
1508*6a54128fSAndroid Build Coastguard WorkerState, Future Development</Literal>.
1509*6a54128fSAndroid Build Coastguard Worker
1510*6a54128fSAndroid Build Coastguard Worker</Para>
1511*6a54128fSAndroid Build Coastguard Worker</ListItem>
1512*6a54128fSAndroid Build Coastguard Worker<ListItem>
1513*6a54128fSAndroid Build Coastguard Worker
1514*6a54128fSAndroid Build Coastguard Worker<Para>
1515*6a54128fSAndroid Build Coastguard Worker	<Literal remap="tt">Wayne Davison</Literal>
1516*6a54128fSAndroid Build Coastguard Worker
1517*6a54128fSAndroid Build Coastguard WorkerWho designed the ext2 filesystem.
1518*6a54128fSAndroid Build Coastguard Worker</Para>
1519*6a54128fSAndroid Build Coastguard Worker</ListItem>
1520*6a54128fSAndroid Build Coastguard Worker<ListItem>
1521*6a54128fSAndroid Build Coastguard Worker
1522*6a54128fSAndroid Build Coastguard Worker<Para>
1523*6a54128fSAndroid Build Coastguard Worker	<Literal remap="tt">Stephen Tweedie</Literal>
1524*6a54128fSAndroid Build Coastguard Worker
1525*6a54128fSAndroid Build Coastguard WorkerWho helped designing the ext2 filesystem kernel code and wrote the
1526*6a54128fSAndroid Build Coastguard Workerslides <Literal remap="tt">Optimizations in File Systems</Literal>.
1527*6a54128fSAndroid Build Coastguard Worker</Para>
1528*6a54128fSAndroid Build Coastguard Worker</ListItem>
1529*6a54128fSAndroid Build Coastguard Worker<ListItem>
1530*6a54128fSAndroid Build Coastguard Worker
1531*6a54128fSAndroid Build Coastguard Worker<Para>
1532*6a54128fSAndroid Build Coastguard Worker	<Literal remap="tt">Theodore Ts'o</Literal>
1533*6a54128fSAndroid Build Coastguard Worker
1534*6a54128fSAndroid Build Coastguard WorkerWho is the author of several ext2 utilities and of the ext2 library
1535*6a54128fSAndroid Build Coastguard Worker<Literal remap="tt">libext2fs</Literal> (which I didn't use, simply because I didn't know
1536*6a54128fSAndroid Build Coastguard Workerit exists when I started to work on my project).
1537*6a54128fSAndroid Build Coastguard Worker</Para>
1538*6a54128fSAndroid Build Coastguard Worker</ListItem>
1539*6a54128fSAndroid Build Coastguard Worker
1540*6a54128fSAndroid Build Coastguard Worker</ItemizedList>
1541*6a54128fSAndroid Build Coastguard Worker
1542*6a54128fSAndroid Build Coastguard Worker</Para>
1543*6a54128fSAndroid Build Coastguard Worker
1544*6a54128fSAndroid Build Coastguard Worker<Para>
1545*6a54128fSAndroid Build Coastguard WorkerLastly, I would like to thank, of-course, <Literal remap="tt">Linus Torvalds</Literal> and the
1546*6a54128fSAndroid Build Coastguard Worker<Literal remap="tt">Linux community</Literal> for providing all of us with such a great operating
1547*6a54128fSAndroid Build Coastguard Workersystem.
1548*6a54128fSAndroid Build Coastguard Worker</Para>
1549*6a54128fSAndroid Build Coastguard Worker
1550*6a54128fSAndroid Build Coastguard Worker<Para>
1551*6a54128fSAndroid Build Coastguard WorkerPlease contact me in a case of an error report, suggestions, or just about
1552*6a54128fSAndroid Build Coastguard Workeranything concerning this document.
1553*6a54128fSAndroid Build Coastguard Worker</Para>
1554*6a54128fSAndroid Build Coastguard Worker
1555*6a54128fSAndroid Build Coastguard Worker<Para>
1556*6a54128fSAndroid Build Coastguard WorkerEnjoy,
1557*6a54128fSAndroid Build Coastguard Worker</Para>
1558*6a54128fSAndroid Build Coastguard Worker
1559*6a54128fSAndroid Build Coastguard Worker<Para>
1560*6a54128fSAndroid Build Coastguard WorkerGadi Oxman &lt;[email protected]&gt;
1561*6a54128fSAndroid Build Coastguard Worker</Para>
1562*6a54128fSAndroid Build Coastguard Worker
1563*6a54128fSAndroid Build Coastguard Worker<Para>
1564*6a54128fSAndroid Build Coastguard WorkerHaifa, August 95
1565*6a54128fSAndroid Build Coastguard Worker</Para>
1566*6a54128fSAndroid Build Coastguard Worker
1567*6a54128fSAndroid Build Coastguard Worker</Sect1>
1568*6a54128fSAndroid Build Coastguard Worker
1569*6a54128fSAndroid Build Coastguard Worker</Article>
1570