1
2
3
4
5
6
7
8
9
10
11
12
13 #ifndef _LINUX_EXT2_FS_H
14 #define _LINUX_EXT2_FS_H
15
16
17
18
19
20
21
22
23 #undef EXT2FS_DEBUG
24
25
26
27
28 #undef EXT2FS_DEBUG_CACHE
29
30
31
32
33 #undef EXT2FS_CHECK_CACHE
34
35
36
37
38 #undef EXT2FS_PRE_02B_COMPAT
39
40
41
42
43 #define EXT2_PRE_04_COMPAT
44
45
46
47
48 #define DONT_USE_DCACHE
49
50
51
52
53 #define EXT2FS_DATE "93/11/19"
54 #define EXT2FS_VERSION "0.4a"
55
56
57
58
59 #ifdef EXT2FS_DEBUG
60 # define ext2_debug(f, a...) { \
61 printk ("EXT2-fs DEBUG (%s, %d): %s:", \
62 __FILE__, __LINE__, __FUNCTION__); \
63 printk (f, ## a); \
64 }
65 #else
66 # define ext2_debug(f, a...)
67 #endif
68
69
70
71
72 #define EXT2_BAD_INO 1
73 #define EXT2_ROOT_INO 2
74 #define EXT2_ACL_IDX_INO 3
75 #define EXT2_ACL_DATA_INO 4
76 #define EXT2_BOOT_LOADER_INO 5
77 #define EXT2_UNDEL_DIR_INO 6
78 #define EXT2_FIRST_INO 11
79
80
81
82
83 #define EXT2_PRE_02B_MAGIC 0xEF51
84 #define EXT2_SUPER_MAGIC 0xEF53
85
86
87
88
89 #define EXT2_LINK_MAX 32000
90
91
92
93
94 #define EXT2_MIN_BLOCK_SIZE 1024
95 #define EXT2_MAX_BLOCK_SIZE 4096
96 #define EXT2_MIN_BLOCK_LOG_SIZE 10
97 #ifdef __KERNEL__
98 # define EXT2_BLOCK_SIZE(s) ((s)->s_blocksize)
99 #else
100 # define EXT2_BLOCK_SIZE(s) (EXT2_MIN_BLOCK_SIZE << (s)->s_log_block_size)
101 #endif
102 #define EXT2_ACLE_PER_BLOCK(s) (EXT2_BLOCK_SIZE(s) / sizeof (struct ext2_acl_entry))
103 #define EXT2_ADDR_PER_BLOCK(s) (EXT2_BLOCK_SIZE(s) / sizeof (unsigned long))
104 #ifdef __KERNEL__
105 # define EXT2_BLOCK_SIZE_BITS(s) ((s)->u.ext2_sb.s_es->s_log_block_size + 10)
106 #else
107 # define EXT2_BLOCK_SIZE_BITS(s) ((s)->s_log_block_size + 10)
108 #endif
109 #define EXT2_INODES_PER_BLOCK(s) (EXT2_BLOCK_SIZE(s) / sizeof (struct ext2_inode))
110
111
112
113
114 #define EXT2_MIN_FRAG_SIZE 1024
115 #define EXT2_MAX_FRAG_SIZE 4096
116 #define EXT2_MIN_FRAG_LOG_SIZE 10
117 #ifdef __KERNEL__
118 # define EXT2_FRAG_SIZE(s) ((s)->u.ext2_sb.s_frag_size)
119 # define EXT2_FRAGS_PER_BLOCK(s) ((s)->u.ext2_sb.s_frags_per_block)
120 #else
121 # define EXT2_FRAG_SIZE(s) (EXT2_MIN_FRAG_SIZE << (s)->s_log_frag_size)
122 # define EXT2_FRAGS_PER_BLOCK(s) (EXT2_BLOCK_SIZE(s) / EXT2_FRAG_SIZE(s))
123 #endif
124
125
126
127
128 struct ext2_acl_header
129 {
130 unsigned long aclh_size;
131 unsigned long aclh_file_count;
132 unsigned long aclh_acle_count;
133 unsigned long aclh_first_acle;
134 };
135
136 struct ext2_acl_entry
137 {
138 unsigned long acle_size;
139 unsigned short acle_perms;
140 unsigned short acle_type;
141 unsigned short acle_tag;
142 unsigned short acle_pad1;
143 unsigned long acle_next;
144
145 };
146
147
148
149
150 struct ext2_old_group_desc
151 {
152 unsigned long bg_block_bitmap;
153 unsigned long bg_inode_bitmap;
154 unsigned long bg_inode_table;
155 unsigned short bg_free_blocks_count;
156 unsigned short bg_free_inodes_count;
157 };
158
159 struct ext2_group_desc
160 {
161 unsigned long bg_block_bitmap;
162 unsigned long bg_inode_bitmap;
163 unsigned long bg_inode_table;
164 unsigned short bg_free_blocks_count;
165 unsigned short bg_free_inodes_count;
166 unsigned short bg_used_dirs_count;
167 unsigned short bg_pad;
168 unsigned long bg_reserved[3];
169 };
170
171
172
173
174 #ifdef __KERNEL__
175 # define EXT2_BLOCKS_PER_GROUP(s) ((s)->u.ext2_sb.s_blocks_per_group)
176 # define EXT2_DESC_PER_BLOCK(s) ((s)->u.ext2_sb.s_desc_per_block)
177 # define EXT2_INODES_PER_GROUP(s) ((s)->u.ext2_sb.s_inodes_per_group)
178 #else
179 # define EXT2_BLOCKS_PER_GROUP(s) ((s)->s_blocks_per_group)
180 # define EXT2_DESC_PER_BLOCK(s) (EXT2_BLOCK_SIZE(s) / sizeof (struct ext2_group_desc))
181 # define EXT2_INODES_PER_GROUP(s) ((s)->s_inodes_per_group)
182 #endif
183
184
185
186
187 #define EXT2_NDIR_BLOCKS 12
188 #define EXT2_IND_BLOCK EXT2_NDIR_BLOCKS
189 #define EXT2_DIND_BLOCK (EXT2_IND_BLOCK + 1)
190 #define EXT2_TIND_BLOCK (EXT2_DIND_BLOCK + 1)
191 #define EXT2_N_BLOCKS (EXT2_TIND_BLOCK + 1)
192
193
194
195
196 #define EXT2_SECRM_FL 0x0001
197 #define EXT2_UNRM_FL 0x0002
198 #define EXT2_COMPR_FL 0x0004
199 #define EXT2_SYNC_FL 0x0008
200
201
202
203
204 #define EXT2_IOC_GETFLAGS _IOR('f', 1, long)
205 #define EXT2_IOC_SETFLAGS _IOW('f', 2, long)
206 #define EXT2_IOC_GETVERSION _IOR('v', 1, long)
207 #define EXT2_IOC_SETVERSION _IOW('v', 2, long)
208
209
210
211
212 struct ext2_inode {
213 unsigned short i_mode;
214 unsigned short i_uid;
215 unsigned long i_size;
216 unsigned long i_atime;
217 unsigned long i_ctime;
218 unsigned long i_mtime;
219 unsigned long i_dtime;
220 unsigned short i_gid;
221 unsigned short i_links_count;
222 unsigned long i_blocks;
223 unsigned long i_flags;
224 unsigned long i_reserved1;
225 unsigned long i_block[EXT2_N_BLOCKS];
226 unsigned long i_version;
227 unsigned long i_file_acl;
228 unsigned long i_dir_acl;
229 unsigned long i_faddr;
230 unsigned char i_frag;
231 unsigned char i_fsize;
232 unsigned short i_pad1;
233 unsigned long i_reserved2[2];
234 };
235
236
237
238
239 #define EXT2_VALID_FS 0x0001
240 #define EXT2_ERROR_FS 0x0002
241
242
243
244
245 #define EXT2_MOUNT_CHECK 0x0001
246
247
248
249
250 #define EXT2_DFL_MAX_MNT_COUNT 20
251
252
253
254
255 struct ext2_super_block {
256 unsigned long s_inodes_count;
257 unsigned long s_blocks_count;
258 unsigned long s_r_blocks_count;
259 unsigned long s_free_blocks_count;
260 unsigned long s_free_inodes_count;
261 unsigned long s_first_data_block;
262 unsigned long s_log_block_size;
263 long s_log_frag_size;
264 unsigned long s_blocks_per_group;
265 unsigned long s_frags_per_group;
266 unsigned long s_inodes_per_group;
267 unsigned long s_mtime;
268 unsigned long s_wtime;
269 unsigned short s_mnt_count;
270 unsigned short s_max_mnt_count;
271 unsigned short s_magic;
272 unsigned short s_state;
273 unsigned long s_reserved[241];
274 };
275
276
277
278
279 #define EXT2_NAME_LEN 255
280
281 struct ext2_dir_entry {
282 unsigned long inode;
283 unsigned short rec_len;
284 unsigned short name_len;
285 char name[EXT2_NAME_LEN];
286 };
287
288
289
290
291
292
293 #define EXT2_DIR_PAD 4
294 #define EXT2_DIR_ROUND (EXT2_DIR_PAD - 1)
295 #define EXT2_DIR_REC_LEN(name_len) (((name_len) + 8 + EXT2_DIR_ROUND) & \
296 ~EXT2_DIR_ROUND)
297
298 #ifdef __KERNEL__
299
300
301
302
303
304 extern int ext2_permission (struct inode *, int);
305
306
307 extern int ext2_new_block (struct super_block *, unsigned long);
308 extern void ext2_free_block (struct super_block *, unsigned long);
309 extern unsigned long ext2_count_free_blocks (struct super_block *);
310 extern void ext2_check_blocks_bitmap (struct super_block *);
311
312
313 extern unsigned long ext2_count_free (struct buffer_head *, unsigned);
314
315 #ifndef DONT_USE_DCACHE
316
317 extern void ext2_dcache_invalidate (unsigned short);
318 extern unsigned long ext2_dcache_lookup (unsigned short, unsigned long,
319 const char *, int);
320 extern void ext2_dcache_add (unsigned short, unsigned long, const char *,
321 int, unsigned long);
322 extern void ext2_dcache_remove (unsigned short, unsigned long, const char *,
323 int);
324 #endif
325
326
327 extern int ext2_check_dir_entry (char *, struct inode *,
328 struct ext2_dir_entry *, struct buffer_head *,
329 unsigned long);
330
331
332 extern int ext2_read (struct inode *, struct file *, char *, int);
333 extern int ext2_write (struct inode *, struct file *, char *, int);
334
335
336 extern int ext2_sync_file (struct inode *, struct file *);
337
338
339 extern struct inode * ext2_new_inode (const struct inode *, int);
340 extern void ext2_free_inode (struct inode *);
341 extern unsigned long ext2_count_free_inodes (struct super_block *);
342 extern void ext2_check_inodes_bitmap (struct super_block *);
343
344
345 extern int ext2_bmap (struct inode *, int);
346
347 extern struct buffer_head * ext2_getblk (struct inode *, long, int, int *);
348 extern struct buffer_head * ext2_bread (struct inode *, int, int, int *);
349
350 extern void ext2_read_inode (struct inode *);
351 extern void ext2_write_inode (struct inode *);
352 extern void ext2_put_inode (struct inode *);
353 extern int ext2_sync_inode (struct inode *);
354
355
356 extern int ext2_ioctl (struct inode *, struct file *, unsigned int,
357 unsigned long);
358
359
360 extern int ext2_open (struct inode *, struct file *);
361 extern void ext2_release (struct inode *, struct file *);
362 extern int ext2_lookup (struct inode *,const char *, int, struct inode **);
363 extern int ext2_create (struct inode *,const char *, int, int,
364 struct inode **);
365 extern int ext2_mkdir (struct inode *, const char *, int, int);
366 extern int ext2_rmdir (struct inode *, const char *, int);
367 extern int ext2_unlink (struct inode *, const char *, int);
368 extern int ext2_symlink (struct inode *, const char *, int, const char *);
369 extern int ext2_link (struct inode *, struct inode *, const char *, int);
370 extern int ext2_mknod (struct inode *, const char *, int, int, int);
371 extern int ext2_rename (struct inode *, const char *, int,
372 struct inode *, const char *, int);
373
374
375 extern void ext2_error (struct super_block *, const char *, const char *, ...)
376 __attribute__ ((format (printf, 3, 4)));
377 extern volatile void ext2_panic (struct super_block *, const char *,
378 const char *, ...)
379 __attribute__ ((format (printf, 3, 4)));
380 extern void ext2_warning (struct super_block *, const char *, const char *, ...)
381 __attribute__ ((format (printf, 3, 4)));
382 extern void ext2_put_super (struct super_block *);
383 extern void ext2_write_super (struct super_block *);
384 extern int ext2_remount (struct super_block *, int *);
385 extern struct super_block * ext2_read_super (struct super_block *,void *,int);
386 extern void ext2_statfs (struct super_block *, struct statfs *);
387
388
389 extern void ext2_truncate (struct inode *);
390
391
392
393
394
395
396 extern struct inode_operations ext2_dir_inode_operations;
397
398
399 extern struct inode_operations ext2_file_inode_operations;
400
401
402 extern struct inode_operations ext2_symlink_inode_operations;
403
404 #endif
405
406 #endif