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