1 #ifndef _LINUX_EXT2_FS_H
2 #define _LINUX_EXT2_FS_H
3
4
5
6
7
8
9
10
11 #undef EXT2FS_DEBUG
12
13
14
15
16 #undef EXT2FS_PRE_02B_COMPAT
17
18
19
20
21 #undef DONT_USE_DCACHE
22
23
24
25
26 #undef EXT2FS_DEBUG_CACHE
27
28
29
30
31 #define EXT2FS_DATE "93/06/06"
32 #define EXT2FS_VERSION "0.3a"
33
34
35
36
37 #define EXT2_BAD_INO 1
38 #define EXT2_ROOT_INO 2
39 #define EXT2_ACL_IDX_INO 3
40 #define EXT2_ACL_DATA_INO 4
41 #define EXT2_FIRST_INO 11
42
43
44
45
46 #define EXT2_OLD_SUPER_MAGIC 0xEF51
47 #define EXT2_SUPER_MAGIC 0xEF53
48
49
50
51
52 #define EXT2_LINK_MAX 32000
53
54
55
56
57 #define EXT2_MIN_BLOCK_SIZE 1024
58 #define EXT2_MAX_BLOCK_SIZE 4096
59 #define EXT2_MIN_BLOCK_LOG_SIZE 10
60 #ifdef __KERNEL__
61 # define EXT2_BLOCK_SIZE(s) ((s)->s_blocksize)
62 #else
63 # define EXT2_BLOCK_SIZE(s) (EXT2_MIN_BLOCK_SIZE << (s)->s_log_block_size)
64 #endif
65 #define EXT2_ACLE_PER_BLOCK(s) (EXT2_BLOCK_SIZE(s) / sizeof (struct ext2_acl_entry))
66 #define EXT2_ADDR_PER_BLOCK(s) (EXT2_BLOCK_SIZE(s) / sizeof (unsigned long))
67 #ifdef __KERNEL__
68 # define EXT2_BLOCK_SIZE_BITS(s) ((s)->u.ext2_sb.s_log_block_size + 10)
69 #else
70 # define EXT2_BLOCK_SIZE_BITS(s) ((s)->s_log_block_size + 10)
71 #endif
72 #define EXT2_INODES_PER_BLOCK(s) (EXT2_BLOCK_SIZE(s) / sizeof (struct ext2_inode))
73
74
75
76
77 #define EXT2_MIN_FRAG_SIZE 1024
78 #define EXT2_MAX_FRAG_SIZE 4096
79 #define EXT2_MIN_FRAG_LOG_SIZE 10
80 #ifdef __KERNEL__
81 # define EXT2_FRAG_SIZE(s) ((s)->u.ext2_sb.s_frag_size)
82 # define EXT2_FRAGS_PER_BLOCK(s) ((s)->u.ext2_sb.s_frags_per_block)
83 #else
84 # define EXT2_FRAG_SIZE(s) (EXT2_MIN_FRAG_SIZE << (s)->s_log_frag_size)
85 # define EXT2_FRAGS_PER_BLOCK(s) (EXT2_BLOCK_SIZE(s) / EXT2_FRAG_SIZE(s))
86 #endif
87
88
89
90
91 struct ext2_acl_header
92 {
93 unsigned long aclh_size;
94 unsigned long aclh_file_count;
95 unsigned long aclh_acle_count;
96 unsigned long aclh_first_acle;
97 };
98
99 struct ext2_acl_entry
100 {
101 unsigned long acle_size;
102 unsigned short acle_perms;
103 unsigned short acle_type;
104 unsigned short acle_tag;
105 unsigned short acle_pad1;
106 unsigned long acle_next;
107
108 };
109
110
111
112
113 struct ext2_old_group_desc
114 {
115 unsigned long bg_block_bitmap;
116 unsigned long bg_inode_bitmap;
117 unsigned long bg_inode_table;
118 unsigned short bg_free_blocks_count;
119 unsigned short bg_free_inodes_count;
120 };
121
122 struct ext2_group_desc
123 {
124 unsigned long bg_block_bitmap;
125 unsigned long bg_inode_bitmap;
126 unsigned long bg_inode_table;
127 unsigned short bg_free_blocks_count;
128 unsigned short bg_free_inodes_count;
129 unsigned short bg_used_dirs_count;
130 unsigned short bg_pad;
131 unsigned long bg_reserved[3];
132 };
133
134
135
136
137 #ifdef __KERNEL__
138 # define EXT2_BLOCKS_PER_GROUP(s) ((s)->u.ext2_sb.s_blocks_per_group)
139 # define EXT2_DESC_PER_BLOCK(s) ((s)->u.ext2_sb.s_desc_per_block)
140 # define EXT2_INODES_PER_GROUP(s) ((s)->u.ext2_sb.s_inodes_per_group)
141 #else
142 # define EXT2_BLOCKS_PER_GROUP(s) ((s)->s_blocks_per_group)
143 # define EXT2_DESC_PER_BLOCK(s) (EXT2_BLOCK_SIZE(s) / sizeof (struct ext2_group_desc))
144 # define EXT2_INODES_PER_GROUP(s) ((s)->s_inodes_per_group)
145 #endif
146
147
148
149
150 #define EXT2_NDIR_BLOCKS 12
151 #define EXT2_IND_BLOCK EXT2_NDIR_BLOCKS
152 #define EXT2_DIND_BLOCK (EXT2_IND_BLOCK + 1)
153 #define EXT2_TIND_BLOCK (EXT2_DIND_BLOCK + 1)
154 #define EXT2_N_BLOCKS (EXT2_TIND_BLOCK + 1)
155
156
157
158
159 struct ext2_inode {
160 unsigned short i_mode;
161 unsigned short i_uid;
162 unsigned long i_size;
163 unsigned long i_atime;
164 unsigned long i_ctime;
165 unsigned long i_mtime;
166 unsigned long i_dtime;
167 unsigned short i_gid;
168 unsigned short i_links_count;
169 unsigned long i_blocks;
170 unsigned long i_flags;
171 unsigned long i_reserved1;
172 unsigned long i_block[EXT2_N_BLOCKS];
173 unsigned long i_version;
174 unsigned long i_file_acl;
175 unsigned long i_dir_acl;
176 unsigned long i_faddr;
177 unsigned char i_frag;
178 unsigned char i_fsize;
179 unsigned short i_pad1;
180 unsigned long i_reserved2[2];
181 };
182
183
184
185
186 struct ext2_super_block {
187 unsigned long s_inodes_count;
188 unsigned long s_blocks_count;
189 unsigned long s_r_blocks_count;
190 unsigned long s_free_blocks_count;
191 unsigned long s_free_inodes_count;
192 unsigned long s_first_data_block;
193 unsigned long s_log_block_size;
194 long s_log_frag_size;
195 unsigned long s_blocks_per_group;
196 unsigned long s_frags_per_group;
197 unsigned long s_inodes_per_group;
198 unsigned long s_mtime;
199 unsigned long s_wtime;
200 unsigned long s_pad;
201
202
203 unsigned short s_magic;
204 unsigned short s_valid;
205 unsigned long s_reserved[243];
206 };
207
208
209
210
211 #define EXT2_NAME_LEN 255
212
213 struct ext2_dir_entry {
214 unsigned long inode;
215 unsigned short rec_len;
216 unsigned short name_len;
217 char name[EXT2_NAME_LEN];
218 };
219
220
221
222
223
224
225 #define EXT2_DIR_PAD 4
226 #define EXT2_DIR_ROUND (EXT2_DIR_PAD - 1)
227 #define EXT2_DIR_REC_LEN(name_len) (((name_len) + 8 + EXT2_DIR_ROUND) & \
228 ~EXT2_DIR_ROUND)
229
230
231
232
233
234
235 extern int ext2_permission (struct inode *, int);
236
237
238 extern int ext2_new_block (struct super_block *, unsigned long);
239 extern void ext2_free_block (struct super_block *, unsigned long);
240 extern unsigned long ext2_count_free_blocks (struct super_block *);
241
242
243 extern unsigned long ext2_count_free (struct buffer_head *, unsigned);
244
245
246 extern void ext2_dcache_invalidate (unsigned short);
247 extern unsigned long ext2_dcache_lookup (unsigned short, unsigned long,
248 const char *, int);
249 extern void ext2_dcache_add (unsigned short, unsigned long, const char *,
250 int, int);
251 extern void ext2_dcache_remove (unsigned short, unsigned long, const char *,
252 int);
253
254
255 extern int ext2_check_dir_entry (char *, struct inode *,
256 struct ext2_dir_entry *, struct buffer_head *,
257 unsigned int);
258
259
260 extern int ext2_read (struct inode *, struct file *, char *, int);
261 extern int ext2_write (struct inode *, struct file *, char *, int);
262
263
264 extern int ext2_sync_file(struct inode *, struct file *);
265
266
267 extern struct inode * ext2_new_inode (const struct inode *, int);
268 extern void ext2_free_inode (struct inode *);
269 extern unsigned long ext2_count_free_inodes (struct super_block *);
270
271
272 extern int ext2_bmap (struct inode *, int);
273
274 extern struct buffer_head * ext2_getblk (struct inode *, int, int, int *);
275 extern struct buffer_head * ext2_bread (struct inode *, int, int, int *);
276
277 extern void ext2_put_super (struct super_block *);
278 extern void ext2_write_super (struct super_block *);
279 extern int ext2_remount (struct super_block *, int *);
280 extern struct super_block * ext2_read_super (struct super_block *,void *,int);
281 extern void ext2_read_inode (struct inode *);
282 extern void ext2_write_inode (struct inode *);
283 extern void ext2_put_inode (struct inode *);
284 extern void ext2_statfs (struct super_block *, struct statfs *);
285 extern int ext2_sync_inode(struct inode *);
286
287
288 extern int ext2_ioctl (struct inode *, struct file *, unsigned int,
289 unsigned long);
290
291
292 extern int ext2_open (struct inode *, struct file *);
293 extern void ext2_release (struct inode *, struct file *);
294 extern int ext2_lookup (struct inode *,const char *, int, struct inode **);
295 extern int ext2_create (struct inode *,const char *, int, int,
296 struct inode **);
297 extern int ext2_mkdir (struct inode *, const char *, int, int);
298 extern int ext2_rmdir (struct inode *, const char *, int);
299 extern int ext2_unlink (struct inode *, const char *, int);
300 extern int ext2_symlink (struct inode *, const char *, int, const char *);
301 extern int ext2_link (struct inode *, struct inode *, const char *, int);
302 extern int ext2_mknod (struct inode *, const char *, int, int, int);
303 extern int ext2_rename (struct inode *, const char *, int,
304 struct inode *, const char *, int);
305
306
307 extern void ext2_truncate (struct inode *);
308
309
310
311
312
313
314 extern struct inode_operations ext2_dir_inode_operations;
315
316
317 extern struct inode_operations ext2_file_inode_operations;
318
319
320 extern struct inode_operations ext2_symlink_inode_operations;
321
322 #endif