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.2d, 93/03/30"
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 long i_faddr;
142 unsigned char i_frag;
143 unsigned char i_fsize;
144 unsigned short i_pad1;
145 unsigned long i_reserved2[2];
146 };
147
148
149
150
151 struct ext2_super_block {
152 unsigned long s_inodes_count;
153 unsigned long s_blocks_count;
154 unsigned long s_r_blocks_count;
155 unsigned long s_free_blocks_count;
156 unsigned long s_free_inodes_count;
157 unsigned long s_first_data_block;
158 unsigned long s_log_block_size;
159 long s_log_frag_size;
160 unsigned long s_blocks_per_group;
161 unsigned long s_frags_per_group;
162 unsigned long s_inodes_per_group;
163 unsigned long s_mtime;
164 unsigned long s_wtime;
165 unsigned long s_pad;
166
167
168 unsigned short s_magic;
169 unsigned short s_valid;
170 unsigned long s_reserved[243];
171 };
172
173
174
175
176 #define EXT2_NAME_LEN 255
177
178 struct ext2_dir_entry {
179 unsigned long inode;
180 unsigned short rec_len;
181 unsigned short name_len;
182 char name[EXT2_NAME_LEN];
183 };
184
185
186
187
188
189
190 #define EXT2_DIR_PAD 4
191 #define EXT2_DIR_ROUND (EXT2_DIR_PAD - 1)
192 #define EXT2_DIR_REC_LEN(name_len) (((name_len) + 8 + EXT2_DIR_ROUND) & \
193 ~EXT2_DIR_ROUND)
194
195
196
197
198
199
200 extern int ext2_new_block (struct super_block *, unsigned long);
201 extern void ext2_free_block (struct super_block *, unsigned long);
202 extern unsigned long ext2_count_free_blocks (struct super_block *);
203
204
205 extern unsigned long ext2_count_free (struct buffer_head *, unsigned);
206
207
208 extern void ext2_dcache_invalidate (unsigned short);
209 extern unsigned long ext2_dcache_lookup (unsigned short, unsigned long,
210 const char *, int);
211 extern void ext2_dcache_add (unsigned short, unsigned long, const char *,
212 int, int);
213 extern void ext2_dcache_remove (unsigned short, unsigned long, const char *,
214 int);
215
216
217 extern int ext2_check_dir_entry (char *, struct inode *,
218 struct ext2_dir_entry *, struct buffer_head *,
219 unsigned int);
220
221
222 extern int ext2_read (struct inode *, struct file *, char *, int);
223 extern int ext2_write (struct inode *, struct file *, char *, int);
224
225
226 extern struct inode * ext2_new_inode (const struct inode *, int);
227 extern void ext2_free_inode (struct inode *);
228 extern unsigned long ext2_count_free_inodes (struct super_block *);
229
230
231 extern int ext2_bmap (struct inode *, int);
232
233 extern struct buffer_head * ext2_getblk (struct inode *, int, int);
234 extern struct buffer_head * ext2_bread (struct inode *, int, int);
235
236 extern void ext2_truncate (struct inode *);
237 extern void ext2_put_super (struct super_block *);
238 extern void ext2_write_super (struct super_block *);
239 extern struct super_block * ext2_read_super (struct super_block *,void *,int);
240 extern void ext2_read_inode (struct inode *);
241 extern void ext2_write_inode (struct inode *);
242 extern void ext2_put_inode (struct inode *);
243 extern void ext2_statfs (struct super_block *, struct statfs *);
244
245
246 extern int ext2_open (struct inode *, struct file *);
247 extern void ext2_release (struct inode *, struct file *);
248 extern int ext2_lookup (struct inode *,const char *, int, struct inode **);
249 extern int ext2_create (struct inode *,const char *, int, int,
250 struct inode **);
251 extern int ext2_mkdir (struct inode *, const char *, int, int);
252 extern int ext2_rmdir (struct inode *, const char *, int);
253 extern int ext2_unlink (struct inode *, const char *, int);
254 extern int ext2_symlink (struct inode *, const char *, int, const char *);
255 extern int ext2_link (struct inode *, struct inode *, const char *, int);
256 extern int ext2_mknod (struct inode *, const char *, int, int, int);
257 extern int ext2_rename (struct inode *, const char *, int,
258 struct inode *, const char *, int);
259
260
261
262
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_file_inode_operations;
270 extern struct file_operations ext2_file_operations;
271
272
273 extern struct inode_operations ext2_symlink_inode_operations;
274
275 #endif