1/****************************************************************************
2 ****************************************************************************
3 ***
4 ***   This header was automatically generated from a Linux kernel header
5 ***   of the same name, to make information necessary for userspace to
6 ***   call into the kernel available to libc.  It contains only constants,
7 ***   structures, and macros generated from the original header, and thus,
8 ***   contains no copyrightable information.
9 ***
10 ****************************************************************************
11 ****************************************************************************/
12#ifndef _LINUX_EXT2_FS_H
13#define _LINUX_EXT2_FS_H
14
15#include <linux/types.h>
16
17#undef EXT2FS_DEBUG
18
19#define EXT2_PREALLOCATE
20#define EXT2_DEFAULT_PREALLOC_BLOCKS 8
21
22#define EXT2FS_DATE "95/08/09"
23#define EXT2FS_VERSION "0.5b"
24
25#ifdef EXT2FS_DEBUG
26#define ext2_debug(f, a...) {   printk ("EXT2-fs DEBUG (%s, %d): %s:",   __FILE__, __LINE__, __FUNCTION__);   printk (f, ## a);   }
27#else
28#define ext2_debug(f, a...)
29#endif
30
31#define EXT2_BAD_INO 1
32#define EXT2_ROOT_INO 2
33#define EXT2_BOOT_LOADER_INO 5
34#define EXT2_UNDEL_DIR_INO 6
35
36#define EXT2_GOOD_OLD_FIRST_INO 11
37
38#define EXT2_SUPER_MAGIC 0xEF53
39
40#define EXT2_SB(sb) (sb)
41
42#define EXT2_LINK_MAX 32000
43
44#define EXT2_MIN_BLOCK_SIZE 1024
45#define EXT2_MAX_BLOCK_SIZE 4096
46#define EXT2_MIN_BLOCK_LOG_SIZE 10
47#define EXT2_BLOCK_SIZE(s) (EXT2_MIN_BLOCK_SIZE << (s)->s_log_block_size)
48#define EXT2_ADDR_PER_BLOCK(s) (EXT2_BLOCK_SIZE(s) / sizeof (__u32))
49#define EXT2_BLOCK_SIZE_BITS(s) ((s)->s_log_block_size + 10)
50#define EXT2_INODE_SIZE(s) (((s)->s_rev_level == EXT2_GOOD_OLD_REV) ?   EXT2_GOOD_OLD_INODE_SIZE :   (s)->s_inode_size)
51#define EXT2_FIRST_INO(s) (((s)->s_rev_level == EXT2_GOOD_OLD_REV) ?   EXT2_GOOD_OLD_FIRST_INO :   (s)->s_first_ino)
52
53#define EXT2_MIN_FRAG_SIZE 1024
54#define EXT2_MAX_FRAG_SIZE 4096
55#define EXT2_MIN_FRAG_LOG_SIZE 10
56#define EXT2_FRAG_SIZE(s) (EXT2_MIN_FRAG_SIZE << (s)->s_log_frag_size)
57#define EXT2_FRAGS_PER_BLOCK(s) (EXT2_BLOCK_SIZE(s) / EXT2_FRAG_SIZE(s))
58
59struct ext2_group_desc
60{
61 __le32 bg_block_bitmap;
62 __le32 bg_inode_bitmap;
63 __le32 bg_inode_table;
64 __le16 bg_free_blocks_count;
65 __le16 bg_free_inodes_count;
66 __le16 bg_used_dirs_count;
67 __le16 bg_pad;
68 __le32 bg_reserved[3];
69};
70
71#define EXT2_BLOCKS_PER_GROUP(s) ((s)->s_blocks_per_group)
72#define EXT2_DESC_PER_BLOCK(s) (EXT2_BLOCK_SIZE(s) / sizeof (struct ext2_group_desc))
73#define EXT2_INODES_PER_GROUP(s) ((s)->s_inodes_per_group)
74
75#define EXT2_NDIR_BLOCKS 12
76#define EXT2_IND_BLOCK EXT2_NDIR_BLOCKS
77#define EXT2_DIND_BLOCK (EXT2_IND_BLOCK + 1)
78#define EXT2_TIND_BLOCK (EXT2_DIND_BLOCK + 1)
79#define EXT2_N_BLOCKS (EXT2_TIND_BLOCK + 1)
80
81#define EXT2_SECRM_FL 0x00000001
82#define EXT2_UNRM_FL 0x00000002
83#define EXT2_COMPR_FL 0x00000004
84#define EXT2_SYNC_FL 0x00000008
85#define EXT2_IMMUTABLE_FL 0x00000010
86#define EXT2_APPEND_FL 0x00000020
87#define EXT2_NODUMP_FL 0x00000040
88#define EXT2_NOATIME_FL 0x00000080
89
90#define EXT2_DIRTY_FL 0x00000100
91#define EXT2_COMPRBLK_FL 0x00000200
92#define EXT2_NOCOMP_FL 0x00000400
93#define EXT2_ECOMPR_FL 0x00000800
94
95#define EXT2_BTREE_FL 0x00001000
96#define EXT2_INDEX_FL 0x00001000
97#define EXT2_IMAGIC_FL 0x00002000
98#define EXT2_JOURNAL_DATA_FL 0x00004000
99#define EXT2_NOTAIL_FL 0x00008000
100#define EXT2_DIRSYNC_FL 0x00010000
101#define EXT2_TOPDIR_FL 0x00020000
102#define EXT2_RESERVED_FL 0x80000000
103
104#define EXT2_FL_USER_VISIBLE 0x0003DFFF
105#define EXT2_FL_USER_MODIFIABLE 0x000380FF
106
107#define EXT2_IOC_GETFLAGS _IOR('f', 1, long)
108#define EXT2_IOC_SETFLAGS _IOW('f', 2, long)
109#define EXT2_IOC_GETVERSION _IOR('v', 1, long)
110#define EXT2_IOC_SETVERSION _IOW('v', 2, long)
111
112struct ext2_inode {
113 __le16 i_mode;
114 __le16 i_uid;
115 __le32 i_size;
116 __le32 i_atime;
117 __le32 i_ctime;
118 __le32 i_mtime;
119 __le32 i_dtime;
120 __le16 i_gid;
121 __le16 i_links_count;
122 __le32 i_blocks;
123 __le32 i_flags;
124 union {
125 struct {
126 __le32 l_i_reserved1;
127 } linux1;
128 struct {
129 __le32 h_i_translator;
130 } hurd1;
131 struct {
132 __le32 m_i_reserved1;
133 } masix1;
134 } osd1;
135 __le32 i_block[EXT2_N_BLOCKS];
136 __le32 i_generation;
137 __le32 i_file_acl;
138 __le32 i_dir_acl;
139 __le32 i_faddr;
140 union {
141 struct {
142 __u8 l_i_frag;
143 __u8 l_i_fsize;
144 __u16 i_pad1;
145 __le16 l_i_uid_high;
146 __le16 l_i_gid_high;
147 __u32 l_i_reserved2;
148 } linux2;
149 struct {
150 __u8 h_i_frag;
151 __u8 h_i_fsize;
152 __le16 h_i_mode_high;
153 __le16 h_i_uid_high;
154 __le16 h_i_gid_high;
155 __le32 h_i_author;
156 } hurd2;
157 struct {
158 __u8 m_i_frag;
159 __u8 m_i_fsize;
160 __u16 m_pad1;
161 __u32 m_i_reserved2[2];
162 } masix2;
163 } osd2;
164};
165
166#define i_size_high i_dir_acl
167
168#ifdef __linux__
169#define i_reserved1 osd1.linux1.l_i_reserved1
170#define i_frag osd2.linux2.l_i_frag
171#define i_fsize osd2.linux2.l_i_fsize
172#define i_uid_low i_uid
173#define i_gid_low i_gid
174#define i_uid_high osd2.linux2.l_i_uid_high
175#define i_gid_high osd2.linux2.l_i_gid_high
176#define i_reserved2 osd2.linux2.l_i_reserved2
177#endif
178
179#ifdef __hurd__
180#define i_translator osd1.hurd1.h_i_translator
181#define i_frag osd2.hurd2.h_i_frag;
182#define i_fsize osd2.hurd2.h_i_fsize;
183#define i_uid_high osd2.hurd2.h_i_uid_high
184#define i_gid_high osd2.hurd2.h_i_gid_high
185#define i_author osd2.hurd2.h_i_author
186#endif
187
188#ifdef __masix__
189#define i_reserved1 osd1.masix1.m_i_reserved1
190#define i_frag osd2.masix2.m_i_frag
191#define i_fsize osd2.masix2.m_i_fsize
192#define i_reserved2 osd2.masix2.m_i_reserved2
193#endif
194
195#define EXT2_VALID_FS 0x0001
196#define EXT2_ERROR_FS 0x0002
197
198#define EXT2_MOUNT_CHECK 0x000001
199#define EXT2_MOUNT_OLDALLOC 0x000002
200#define EXT2_MOUNT_GRPID 0x000004
201#define EXT2_MOUNT_DEBUG 0x000008
202#define EXT2_MOUNT_ERRORS_CONT 0x000010
203#define EXT2_MOUNT_ERRORS_RO 0x000020
204#define EXT2_MOUNT_ERRORS_PANIC 0x000040
205#define EXT2_MOUNT_MINIX_DF 0x000080
206#define EXT2_MOUNT_NOBH 0x000100
207#define EXT2_MOUNT_NO_UID32 0x000200
208#define EXT2_MOUNT_XATTR_USER 0x004000
209#define EXT2_MOUNT_POSIX_ACL 0x008000
210#define EXT2_MOUNT_XIP 0x010000
211#define EXT2_MOUNT_USRQUOTA 0x020000
212#define EXT2_MOUNT_GRPQUOTA 0x040000
213
214#define clear_opt(o, opt) o &= ~EXT2_MOUNT_##opt
215#define set_opt(o, opt) o |= EXT2_MOUNT_##opt
216#define test_opt(sb, opt) (EXT2_SB(sb)->s_mount_opt &   EXT2_MOUNT_##opt)
217
218#define EXT2_DFL_MAX_MNT_COUNT 20
219#define EXT2_DFL_CHECKINTERVAL 0
220
221#define EXT2_ERRORS_CONTINUE 1
222#define EXT2_ERRORS_RO 2
223#define EXT2_ERRORS_PANIC 3
224#define EXT2_ERRORS_DEFAULT EXT2_ERRORS_CONTINUE
225
226struct ext2_super_block {
227 __le32 s_inodes_count;
228 __le32 s_blocks_count;
229 __le32 s_r_blocks_count;
230 __le32 s_free_blocks_count;
231 __le32 s_free_inodes_count;
232 __le32 s_first_data_block;
233 __le32 s_log_block_size;
234 __le32 s_log_frag_size;
235 __le32 s_blocks_per_group;
236 __le32 s_frags_per_group;
237 __le32 s_inodes_per_group;
238 __le32 s_mtime;
239 __le32 s_wtime;
240 __le16 s_mnt_count;
241 __le16 s_max_mnt_count;
242 __le16 s_magic;
243 __le16 s_state;
244 __le16 s_errors;
245 __le16 s_minor_rev_level;
246 __le32 s_lastcheck;
247 __le32 s_checkinterval;
248 __le32 s_creator_os;
249 __le32 s_rev_level;
250 __le16 s_def_resuid;
251 __le16 s_def_resgid;
252
253 __le32 s_first_ino;
254 __le16 s_inode_size;
255 __le16 s_block_group_nr;
256 __le32 s_feature_compat;
257 __le32 s_feature_incompat;
258 __le32 s_feature_ro_compat;
259 __u8 s_uuid[16];
260 char s_volume_name[16];
261 char s_last_mounted[64];
262 __le32 s_algorithm_usage_bitmap;
263
264 __u8 s_prealloc_blocks;
265 __u8 s_prealloc_dir_blocks;
266 __u16 s_padding1;
267
268 __u8 s_journal_uuid[16];
269 __u32 s_journal_inum;
270 __u32 s_journal_dev;
271 __u32 s_last_orphan;
272 __u32 s_hash_seed[4];
273 __u8 s_def_hash_version;
274 __u8 s_reserved_char_pad;
275 __u16 s_reserved_word_pad;
276 __le32 s_default_mount_opts;
277 __le32 s_first_meta_bg;
278 __u32 s_reserved[190];
279};
280
281#define EXT2_OS_LINUX 0
282#define EXT2_OS_HURD 1
283#define EXT2_OS_MASIX 2
284#define EXT2_OS_FREEBSD 3
285#define EXT2_OS_LITES 4
286
287#define EXT2_GOOD_OLD_REV 0
288#define EXT2_DYNAMIC_REV 1
289
290#define EXT2_CURRENT_REV EXT2_GOOD_OLD_REV
291#define EXT2_MAX_SUPP_REV EXT2_DYNAMIC_REV
292
293#define EXT2_GOOD_OLD_INODE_SIZE 128
294
295#define EXT2_HAS_COMPAT_FEATURE(sb,mask)   ( EXT2_SB(sb)->s_es->s_feature_compat & cpu_to_le32(mask) )
296#define EXT2_HAS_RO_COMPAT_FEATURE(sb,mask)   ( EXT2_SB(sb)->s_es->s_feature_ro_compat & cpu_to_le32(mask) )
297#define EXT2_HAS_INCOMPAT_FEATURE(sb,mask)   ( EXT2_SB(sb)->s_es->s_feature_incompat & cpu_to_le32(mask) )
298#define EXT2_SET_COMPAT_FEATURE(sb,mask)   EXT2_SB(sb)->s_es->s_feature_compat |= cpu_to_le32(mask)
299#define EXT2_SET_RO_COMPAT_FEATURE(sb,mask)   EXT2_SB(sb)->s_es->s_feature_ro_compat |= cpu_to_le32(mask)
300#define EXT2_SET_INCOMPAT_FEATURE(sb,mask)   EXT2_SB(sb)->s_es->s_feature_incompat |= cpu_to_le32(mask)
301#define EXT2_CLEAR_COMPAT_FEATURE(sb,mask)   EXT2_SB(sb)->s_es->s_feature_compat &= ~cpu_to_le32(mask)
302#define EXT2_CLEAR_RO_COMPAT_FEATURE(sb,mask)   EXT2_SB(sb)->s_es->s_feature_ro_compat &= ~cpu_to_le32(mask)
303#define EXT2_CLEAR_INCOMPAT_FEATURE(sb,mask)   EXT2_SB(sb)->s_es->s_feature_incompat &= ~cpu_to_le32(mask)
304
305#define EXT2_FEATURE_COMPAT_DIR_PREALLOC 0x0001
306#define EXT2_FEATURE_COMPAT_IMAGIC_INODES 0x0002
307#define EXT3_FEATURE_COMPAT_HAS_JOURNAL 0x0004
308#define EXT2_FEATURE_COMPAT_EXT_ATTR 0x0008
309#define EXT2_FEATURE_COMPAT_RESIZE_INO 0x0010
310#define EXT2_FEATURE_COMPAT_DIR_INDEX 0x0020
311#define EXT2_FEATURE_COMPAT_ANY 0xffffffff
312
313#define EXT2_FEATURE_RO_COMPAT_SPARSE_SUPER 0x0001
314#define EXT2_FEATURE_RO_COMPAT_LARGE_FILE 0x0002
315#define EXT2_FEATURE_RO_COMPAT_BTREE_DIR 0x0004
316#define EXT2_FEATURE_RO_COMPAT_ANY 0xffffffff
317
318#define EXT2_FEATURE_INCOMPAT_COMPRESSION 0x0001
319#define EXT2_FEATURE_INCOMPAT_FILETYPE 0x0002
320#define EXT3_FEATURE_INCOMPAT_RECOVER 0x0004
321#define EXT3_FEATURE_INCOMPAT_JOURNAL_DEV 0x0008
322#define EXT2_FEATURE_INCOMPAT_META_BG 0x0010
323#define EXT2_FEATURE_INCOMPAT_ANY 0xffffffff
324
325#define EXT2_FEATURE_COMPAT_SUPP EXT2_FEATURE_COMPAT_EXT_ATTR
326#define EXT2_FEATURE_INCOMPAT_SUPP (EXT2_FEATURE_INCOMPAT_FILETYPE|   EXT2_FEATURE_INCOMPAT_META_BG)
327#define EXT2_FEATURE_RO_COMPAT_SUPP (EXT2_FEATURE_RO_COMPAT_SPARSE_SUPER|   EXT2_FEATURE_RO_COMPAT_LARGE_FILE|   EXT2_FEATURE_RO_COMPAT_BTREE_DIR)
328#define EXT2_FEATURE_RO_COMPAT_UNSUPPORTED ~EXT2_FEATURE_RO_COMPAT_SUPP
329#define EXT2_FEATURE_INCOMPAT_UNSUPPORTED ~EXT2_FEATURE_INCOMPAT_SUPP
330
331#define EXT2_DEF_RESUID 0
332#define EXT2_DEF_RESGID 0
333
334#define EXT2_DEFM_DEBUG 0x0001
335#define EXT2_DEFM_BSDGROUPS 0x0002
336#define EXT2_DEFM_XATTR_USER 0x0004
337#define EXT2_DEFM_ACL 0x0008
338#define EXT2_DEFM_UID16 0x0010
339
340#define EXT3_DEFM_JMODE 0x0060
341#define EXT3_DEFM_JMODE_DATA 0x0020
342#define EXT3_DEFM_JMODE_ORDERED 0x0040
343#define EXT3_DEFM_JMODE_WBACK 0x0060
344
345#define EXT2_NAME_LEN 255
346
347struct ext2_dir_entry {
348 __le32 inode;
349 __le16 rec_len;
350 __le16 name_len;
351 char name[EXT2_NAME_LEN];
352};
353
354struct ext2_dir_entry_2 {
355 __le32 inode;
356 __le16 rec_len;
357 __u8 name_len;
358 __u8 file_type;
359 char name[EXT2_NAME_LEN];
360};
361
362enum {
363 EXT2_FT_UNKNOWN,
364 EXT2_FT_REG_FILE,
365 EXT2_FT_DIR,
366 EXT2_FT_CHRDEV,
367 EXT2_FT_BLKDEV,
368 EXT2_FT_FIFO,
369 EXT2_FT_SOCK,
370 EXT2_FT_SYMLINK,
371 EXT2_FT_MAX
372};
373
374#define EXT2_DIR_PAD 4
375#define EXT2_DIR_ROUND (EXT2_DIR_PAD - 1)
376#define EXT2_DIR_REC_LEN(name_len) (((name_len) + 8 + EXT2_DIR_ROUND) &   ~EXT2_DIR_ROUND)
377
378#endif
379