File: ext2fs.tex

package info (click to toggle)
lde 2.6.0-6
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 1,508 kB
  • ctags: 1,197
  • sloc: ansic: 7,780; yacc: 477; makefile: 227; sh: 205
file content (266 lines) | stat: -rw-r--r-- 9,289 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
\documentstyle[]{article}

% Maps for Second Extended File System
% (c) 1994 Scott D. Heavner (sdh@po.cwru.edu)
% 
% One day it might even make it to the LDP.
%
\parindent 0pt
\parskip 5pt
\topmargin 0pt
\textheight 9in
\textwidth 6.5in
\oddsidemargin 0pt
\evensidemargin 0pt
\pagestyle{myheadings}
\markboth{Maps for Second Extended File System}
	{Maps for Second Extended File System}

\begin{document}

These are some ``maps'' for the second extended file system which 
were compiled by 
Scott D. Heavner \linebreak[4]
({\bf sdh@po.cwru.edu}).  Sorry there is no real descriptions for
anything, but read the docs/man pages that came with e2fsprogs and 
the ``Introduction to the Minix Fs'' included in the lde distribution
and you should get a pretty good idea of what is going on.  You don't
need to know everything to hack a FS, but it helps.  These tables just
make it easier to figure out what you are actually editing. 
Please direct any comments or
corrections back to the author.  You are free to distribute this
document to anyone in any medium as long as this notice remains intact.

\section*{BLOCK 0: UNUSED}

This block is reserved for OS boot code.

\section*{BLOCK 1: SUPERBLOCK}

From $<$linux/ext2\_fs.h$>$

\begin{verbatim}
/*
 * Structure of the super block
 */
struct ext2_super_block {
        unsigned long  s_inodes_count;  /* Inodes count */
        unsigned long  s_blocks_count;  /* Blocks count */
        unsigned long  s_r_blocks_count;/* Reserved blocks count */
        unsigned long  s_free_blocks_count;/* Free blocks count */
        unsigned long  s_free_inodes_count;/* Free inodes count */
        unsigned long  s_first_data_block;/* First Data Block */
        unsigned long  s_log_block_size;/* Block size */
        long           s_log_frag_size; /* Fragment size */
        unsigned long  s_blocks_per_group;/* # Blocks per group */
        unsigned long  s_frags_per_group;/* # Fragments per group */
        unsigned long  s_inodes_per_group;/* # Inodes per group */
        unsigned long  s_mtime;         /* Mount time */
        unsigned long  s_wtime;         /* Write time */
        unsigned short s_mnt_count;     /* Mount count */
        short          s_max_mnt_count; /* Maximal mount count */
        unsigned short s_magic;         /* Magic signature */
        unsigned short s_state;         /* File system state */
        unsigned short s_errors;        /* Behaviour when detecting errors */
        unsigned short s_pad;
        unsigned long  s_lastcheck;     /* time of last check */
        unsigned long  s_checkinterval; /* max. time between checks */
        unsigned long  s_reserved[238]; /* Padding to the end of the block */
};
\end{verbatim}

\scriptsize
\begin{tabular}{|r||c|c|c|c|c|c|c|c||c|c|c|c|c|c|c|c|}
\hline
\multicolumn{17}{|c|}{Ext2 Super Block Entry}
  \\ \hline\hline
 & 00 & 01 & 02 & 03 & 04 & 05 & 06 & 07 & 08 &
   09 & 0A & 0B & 0C & 0D & 0E & 0F \\ \hline
0x00 & \multicolumn{4}{c|}{Inodes count} & \multicolumn{4}{c||}{Blocks count} &
   \multicolumn{4}{c|}{Reserved blocks count} &
   \multicolumn{4}{c|}{Free blocks count} \\ \hline
0x10 & \multicolumn{4}{c|}{Free inodes count} &
   \multicolumn{4}{c||}{First data block} &
   \multicolumn{4}{c|}{Log block size} &
   \multicolumn{4}{c|}{Log fragment size} \\ \hline
0x20 & \multicolumn{4}{c|}{Blocks per group} & 
   \multicolumn{4}{c||}{Fragments per group} &
   \multicolumn{4}{c|}{Inodes per group} &
   \multicolumn{4}{c|}{Mount time} \\ \hline
0x30 & \multicolumn{4}{c|}{Write time} &
   \multicolumn{2}{c|}{Mount count} &
   \multicolumn{2}{c||}{Max mount count} &
   \multicolumn{2}{c|}{Magic signature} &
   \multicolumn{2}{c|}{File system state} &
   \multicolumn{2}{c|}{Error behaviour} &
   \multicolumn{2}{c|}{Padding} \\ \hline
0x40 & \multicolumn{4}{c|}{Time of last check} &
   \multicolumn{4}{c||}{Max time between checks} &
   \multicolumn{8}{c|}{Padding to end of block} \\ \hline
\end{tabular}
\normalsize

\vskip1eM

\section*{BLOCK 2: GROUP DESCRIPTORS}

From $<$linux/ext2\_fs.h$>$

\begin{verbatim}
struct ext2_group_desc
{
        unsigned long  bg_block_bitmap;         /* Blocks bitmap block */
        unsigned long  bg_inode_bitmap;         /* Inodes bitmap block */
        unsigned long  bg_inode_table;          /* Inodes table block */
        unsigned short bg_free_blocks_count;    /* Free blocks count */
        unsigned short bg_free_inodes_count;    /* Free inodes count */
        unsigned short bg_used_dirs_count;      /* Directories count */
        unsigned short bg_pad;
        unsigned long  bg_reserved[3];
};
\end{verbatim}

\scriptsize
\begin{tabular}{|r||c|c|c|c|c|c|c|c||c|c|c|c|c|c|c|c|}
\hline
\multicolumn{17}{|c|}{Ext2 Group Descriptor Entry}
  \\ \hline\hline
 & 00 & 01 & 02 & 03 & 04 & 05 & 06 & 07 & 08 &
   09 & 0A & 0B & 0C & 0D & 0E & 0F \\ \hline
0x00 & \multicolumn{4}{c|}{Blocks bitmap block} &
   \multicolumn{4}{c||}{Inode bitmap block} &
   \multicolumn{4}{c|}{Inodes table block} &
   \multicolumn{2}{c|}{Free blocks count} &
   \multicolumn{2}{c|}{Free inodes count} \\ \hline
0x10 & \multicolumn{2}{c|}{Directories count} &
   \multicolumn{2}{c|}{Padding} &
   \multicolumn{4}{c||}{Reserved} &
   \multicolumn{8}{c|}{Reserved} \\ \hline
\end{tabular}
\normalsize

\section*{INODES}

From $<$linux/ext2\_fs.h$>$

\begin{verbatim}
/*
 * Structure of an inode on the disk
 */
struct ext2_inode {
        unsigned short i_mode;          /* File mode */
        unsigned short i_uid;           /* Owner Uid */
        unsigned long  i_size;          /* Size in bytes */
        unsigned long  i_atime;         /* Access time */
        unsigned long  i_ctime;         /* Creation time */
        unsigned long  i_mtime;         /* Modification time */
        unsigned long  i_dtime;         /* Deletion Time */
        unsigned short i_gid;           /* Group Id */
        unsigned short i_links_count;   /* Links count */
        unsigned long  i_blocks;        /* Blocks count */
        unsigned long  i_flags;         /* File flags */
        unsigned long  i_reserved1;
        unsigned long  i_block[EXT2_N_BLOCKS];/* Pointers to blocks */
        unsigned long  i_version;       /* File version (for NFS) */
        unsigned long  i_file_acl;      /* File ACL */
        unsigned long  i_dir_acl;       /* Directory ACL */
        unsigned long  i_faddr;         /* Fragment address */
        unsigned char  i_frag;          /* Fragment number */
        unsigned char  i_fsize;         /* Fragment size */
        unsigned short i_pad1;
        unsigned long  i_reserved2[2];
};
\end{verbatim}

\scriptsize
\begin{tabular}{|r||c|c|c|c|c|c|c|c||c|c|c|c|c|c|c|c|}
\hline
\multicolumn{17}{|c|}{Ext2 Inode Entry}
  \\ \hline\hline
 & 00 & 01 & 02 & 03 & 04 & 05 & 06 & 07 & 08 &
   09 & 0A & 0B & 0C & 0D & 0E & 0F \\ \hline
0x00 & \multicolumn{2}{c|}{File mode} &
   \multicolumn{2}{c|}{Owner UID} &
   \multicolumn{4}{c||}{Size (bytes)} &
   \multicolumn{4}{c|}{Access time} &
   \multicolumn{4}{c|}{Creation time} \\ \hline
0x10 & \multicolumn{4}{c|}{Modification time} &
   \multicolumn{4}{c||}{Deletion time} &
   \multicolumn{2}{c|}{Group id} &
   \multicolumn{2}{c|}{Links count} &
   \multicolumn{4}{c|}{Blocks count} \\ \hline
0x20 & \multicolumn{4}{c|}{File flags} &
   \multicolumn{4}{c||}{Reserved} &
   \multicolumn{4}{c|}{Zone \#0} &
   \multicolumn{4}{c|}{Zone \#1} \\ \hline
0x30 & \multicolumn{4}{c|}{Zone \#2} &
   \multicolumn{4}{c||}{Zone \#3} &
   \multicolumn{4}{c|}{Zone \#4} &
   \multicolumn{4}{c|}{Zone \#5} \\ \hline
0x40 & \multicolumn{4}{c|}{Zone \#6} &
   \multicolumn{4}{c||}{Zone \#7} &
   \multicolumn{4}{c|}{Zone \#8} &
   \multicolumn{4}{c|}{Zone \#9} \\ \hline
0x50 & \multicolumn{4}{c|}{Zone \#10} &
   \multicolumn{4}{c||}{Zone \#11} &
   \multicolumn{4}{c|}{Indirect Zone} &
   \multicolumn{4}{c|}{Double Indirect Zone} \\ \hline
0x60 & \multicolumn{4}{c|}{Triple Indirect Zone} &
   \multicolumn{4}{c||}{NFS File version} &
   \multicolumn{4}{c|}{File ACL} &
   \multicolumn{4}{c|}{Directory ACL} \\ \hline
0x70 & \multicolumn{4}{c|}{Fragment address} &
   \multicolumn{1}{c|}{Fragment number} &
   \multicolumn{1}{c|}{Fragment size} &
   \multicolumn{2}{c||}{Padding} &
   \multicolumn{8}{c|}{Reserved} \\ \hline
\end{tabular}
\normalsize

\section*{DIRECTORIES}

From $<$linux/ext2\_fs.h$>$

\begin{verbatim}
/*
 * Structure of a directory entry
 */
#define EXT2_NAME_LEN 255

struct ext2_dir_entry {
        unsigned long  inode;                   /* Inode number */
        unsigned short rec_len;                 /* Directory entry length */
        unsigned short name_len;                /* Name length */
        char           name[EXT2_NAME_LEN];     /* File name */
};
\end{verbatim}

\scriptsize
\begin{tabular}{|r||c|c|c|c|c|c|c|c||c|c|c|c|c|c|c|c|}
\hline
\multicolumn{17}{|c|}{Ext2 Directory Entry}
  \\ \hline\hline
 & 00 & 01 & 02 & 03 & 04 & 05 & 06 & 07 & 08 &
   09 & 0A & 0B & 0C & 0D & 0E & 0F \\ \hline
0x00 & \multicolumn{4}{c|}{Inode number} &
   \multicolumn{2}{c|}{Entry length} &
   \multicolumn{2}{c||}{Name length} &
   \multicolumn{8}{c|}{Filename (variable len)} \\ \hline
\end{tabular}
\normalsize

\end{document}

% Local Variables:
% TeX-parse-self: nil
% TeX-auto-save: nil
% End: