16#ifndef _LINUX_EXT2_FS_H
17#define _LINUX_EXT2_FS_H
19#include <linux/types.h>
33#define EXT2_PREALLOCATE
34#define EXT2_DEFAULT_PREALLOC_BLOCKS 8
39#define EXT2FS_DATE "95/08/09"
40#define EXT2FS_VERSION "0.5b"
46# define ext2_debug(f, a...) { \
47 printk ("EXT2-fs DEBUG (%s, %d): %s:", \
48 __FILE__, __LINE__, __FUNCTION__); \
59#define EXT2_ROOT_INO 2
60#define EXT2_ACL_IDX_INO 3
61#define EXT2_ACL_DATA_INO 4
62#define EXT2_BOOT_LOADER_INO 5
63#define EXT2_UNDEL_DIR_INO 6
66#define EXT2_GOOD_OLD_FIRST_INO 11
71#define EXT2_SUPER_MAGIC 0xEF53
76#define EXT2_LINK_MAX 32000
81#define EXT2_MIN_BLOCK_SIZE 1024
82#define EXT2_MAX_BLOCK_SIZE 4096
83#define EXT2_MIN_BLOCK_LOG_SIZE 10
85# define EXT2_BLOCK_SIZE(s) ((s)->s_blocksize)
87# define EXT2_BLOCK_SIZE(s) (EXT2_MIN_BLOCK_SIZE << (s)->s_log_block_size)
89#define EXT2_ACLE_PER_BLOCK(s) (EXT2_BLOCK_SIZE(s) / sizeof (struct ext2_acl_entry))
90#define EXT2_ADDR_PER_BLOCK(s) (EXT2_BLOCK_SIZE(s) / sizeof (__u32))
92# define EXT2_BLOCK_SIZE_BITS(s) ((s)->s_blocksize_bits)
94# define EXT2_BLOCK_SIZE_BITS(s) ((s)->s_log_block_size + 10)
97#define EXT2_ADDR_PER_BLOCK_BITS(s) ((s)->u.ext2_sb.s_addr_per_block_bits)
98#define EXT2_INODE_SIZE(s) ((s)->u.ext2_sb.s_inode_size)
99#define EXT2_FIRST_INO(s) ((s)->u.ext2_sb.s_first_ino)
101#define EXT2_INODE_SIZE(s) (((s)->s_rev_level == EXT2_GOOD_OLD_REV) ? \
102 EXT2_GOOD_OLD_INODE_SIZE : \
104#define EXT2_FIRST_INO(s) (((s)->s_rev_level == EXT2_GOOD_OLD_REV) ? \
105 EXT2_GOOD_OLD_FIRST_INO : \
112#define EXT2_MIN_FRAG_SIZE 1024
113#define EXT2_MAX_FRAG_SIZE 4096
114#define EXT2_MIN_FRAG_LOG_SIZE 10
116# define EXT2_FRAG_SIZE(s) ((s)->u.ext2_sb.s_frag_size)
117# define EXT2_FRAGS_PER_BLOCK(s) ((s)->u.ext2_sb.s_frags_per_block)
119# define EXT2_FRAG_SIZE(s) (EXT2_MIN_FRAG_SIZE << (s)->s_log_frag_size)
120# define EXT2_FRAGS_PER_BLOCK(s) (EXT2_BLOCK_SIZE(s) / EXT2_FRAG_SIZE(s))
164# define EXT2_BLOCKS_PER_GROUP(s) ((s)->u.ext2_sb.s_blocks_per_group)
165# define EXT2_DESC_PER_BLOCK(s) ((s)->u.ext2_sb.s_desc_per_block)
166# define EXT2_INODES_PER_GROUP(s) ((s)->u.ext2_sb.s_inodes_per_group)
167# define EXT2_DESC_PER_BLOCK_BITS(s) ((s)->u.ext2_sb.s_desc_per_block_bits)
169# define EXT2_BLOCKS_PER_GROUP(s) ((s)->s_blocks_per_group)
170# define EXT2_DESC_PER_BLOCK(s) (EXT2_BLOCK_SIZE(s) / sizeof (struct ext2_group_desc))
171# define EXT2_INODES_PER_GROUP(s) ((s)->s_inodes_per_group)
177#define EXT2_NDIR_BLOCKS 12
178#define EXT2_IND_BLOCK EXT2_NDIR_BLOCKS
179#define EXT2_DIND_BLOCK (EXT2_IND_BLOCK + 1)
180#define EXT2_TIND_BLOCK (EXT2_DIND_BLOCK + 1)
181#define EXT2_N_BLOCKS (EXT2_TIND_BLOCK + 1)
186#define EXT2_SECRM_FL 0x00000001
187#define EXT2_UNRM_FL 0x00000002
188#define EXT2_COMPR_FL 0x00000004
189#define EXT2_SYNC_FL 0x00000008
190#define EXT2_IMMUTABLE_FL 0x00000010
191#define EXT2_APPEND_FL 0x00000020
192#define EXT2_NODUMP_FL 0x00000040
193#define EXT2_NOATIME_FL 0x00000080
195#define EXT2_DIRTY_FL 0x00000100
196#define EXT2_COMPRBLK_FL 0x00000200
197#define EXT2_NOCOMP_FL 0x00000400
198#define EXT2_ECOMPR_FL 0x00000800
200#define EXT2_BTREE_FL 0x00001000
201#define EXT2_IMAGIC_FL 0x00002000
202#define EXT2_JOURNAL_DATA_FL 0x00004000
203#define EXT2_NOTAIL_FL 0x00008000
204#define EXT2_DIRSYNC_FL 0x00010000
205#define EXT2_TOPDIR_FL 0x00020000
206#define EXT2_HUGE_FILE_FL 0x00040000
207#define EXT2_EXTENTS_FL 0x00080000
208#define EXT2_RESERVED_FL 0x80000000
210#define EXT2_FL_USER_VISIBLE 0x00001FFF
211#define EXT2_FL_USER_MODIFIABLE 0x000000FF
216#define EXT2_IOC_GETFLAGS _IOR('f', 1, long)
217#define EXT2_IOC_SETFLAGS _IOW('f', 2, long)
218#define EXT2_IOC_GETVERSION _IOR('v', 1, long)
219#define EXT2_IOC_SETVERSION _IOW('v', 2, long)
280#if defined(__KERNEL__) || defined(__linux__)
281#define i_reserved1 osd1.linux1.l_i_reserved1
282#define i_frag osd2.linux2.l_i_frag
283#define i_fsize osd2.linux2.l_i_fsize
284#define i_uid_low i_uid
285#define i_gid_low i_gid
286#define i_uid_high osd2.linux2.l_i_uid_high
287#define i_gid_high osd2.linux2.l_i_gid_high
288#define i_reserved2 osd2.linux2.l_i_reserved2
292#define i_translator osd1.hurd1.h_i_translator
293#define i_frag osd2.hurd2.h_i_frag;
294#define i_fsize osd2.hurd2.h_i_fsize;
295#define i_uid_high osd2.hurd2.h_i_uid_high
296#define i_gid_high osd2.hurd2.h_i_gid_high
297#define i_author osd2.hurd2.h_i_author
301#define i_reserved1 osd1.masix1.m_i_reserved1
302#define i_frag osd2.masix2.m_i_frag
303#define i_fsize osd2.masix2.m_i_fsize
304#define i_reserved2 osd2.masix2.m_i_reserved2
310#define EXT2_VALID_FS 0x0001
311#define EXT2_ERROR_FS 0x0002
316#define EXT2_MOUNT_CHECK 0x0001
317#define EXT2_MOUNT_GRPID 0x0004
318#define EXT2_MOUNT_DEBUG 0x0008
319#define EXT2_MOUNT_ERRORS_CONT 0x0010
320#define EXT2_MOUNT_ERRORS_RO 0x0020
321#define EXT2_MOUNT_ERRORS_PANIC 0x0040
322#define EXT2_MOUNT_MINIX_DF 0x0080
323#define EXT2_MOUNT_NO_UID32 0x0200
325#define clear_opt(o, opt) o &= ~EXT2_MOUNT_##opt
326#define set_opt(o, opt) o |= EXT2_MOUNT_##opt
327#define test_opt(sb, opt) ((sb)->u.ext2_sb.s_mount_opt & \
332#define EXT2_DFL_MAX_MNT_COUNT 20
333#define EXT2_DFL_CHECKINTERVAL 0
338#define EXT2_ERRORS_CONTINUE 1
339#define EXT2_ERRORS_RO 2
340#define EXT2_ERRORS_PANIC 3
341#define EXT2_ERRORS_DEFAULT EXT2_ERRORS_CONTINUE
406#define EXT2_SB(sb) (&((sb)->u.ext2_sb))
411#define EXT2_SB(sb) (sb)
417#define EXT2_OS_LINUX 0
418#define EXT2_OS_HURD 1
419#define EXT2_OS_MASIX 2
420#define EXT2_OS_FREEBSD 3
421#define EXT2_OS_LITES 4
426#define EXT2_GOOD_OLD_REV 0
427#define EXT2_DYNAMIC_REV 1
429#define EXT2_CURRENT_REV EXT2_GOOD_OLD_REV
430#define EXT2_MAX_SUPP_REV EXT2_DYNAMIC_REV
432#define EXT2_GOOD_OLD_INODE_SIZE 128
438#define EXT2_HAS_COMPAT_FEATURE(sb,mask) \
439 ( EXT2_SB(sb)->s_es->s_feature_compat & cpu_to_le32(mask) )
440#define EXT2_HAS_RO_COMPAT_FEATURE(sb,mask) \
441 ( EXT2_SB(sb)->s_es->s_feature_ro_compat & cpu_to_le32(mask) )
442#define EXT2_HAS_INCOMPAT_FEATURE(sb,mask) \
443 ( EXT2_SB(sb)->s_es->s_feature_incompat & cpu_to_le32(mask) )
444#define EXT2_SET_COMPAT_FEATURE(sb,mask) \
445 EXT2_SB(sb)->s_es->s_feature_compat |= cpu_to_le32(mask)
446#define EXT2_SET_RO_COMPAT_FEATURE(sb,mask) \
447 EXT2_SB(sb)->s_es->s_feature_ro_compat |= cpu_to_le32(mask)
448#define EXT2_SET_INCOMPAT_FEATURE(sb,mask) \
449 EXT2_SB(sb)->s_es->s_feature_incompat |= cpu_to_le32(mask)
450#define EXT2_CLEAR_COMPAT_FEATURE(sb,mask) \
451 EXT2_SB(sb)->s_es->s_feature_compat &= ~cpu_to_le32(mask)
452#define EXT2_CLEAR_RO_COMPAT_FEATURE(sb,mask) \
453 EXT2_SB(sb)->s_es->s_feature_ro_compat &= ~cpu_to_le32(mask)
454#define EXT2_CLEAR_INCOMPAT_FEATURE(sb,mask) \
455 EXT2_SB(sb)->s_es->s_feature_incompat &= ~cpu_to_le32(mask)
457#define EXT2_FEATURE_COMPAT_DIR_PREALLOC 0x0001
458#define EXT2_FEATURE_COMPAT_IMAGIC_INODES 0x0002
459#define EXT3_FEATURE_COMPAT_HAS_JOURNAL 0x0004
460#define EXT2_FEATURE_COMPAT_EXT_ATTR 0x0008
461#define EXT2_FEATURE_COMPAT_RESIZE_INO 0x0010
462#define EXT2_FEATURE_COMPAT_DIR_INDEX 0x0020
463#define EXT2_FEATURE_COMPAT_ANY 0xffffffff
465#define EXT2_FEATURE_RO_COMPAT_SPARSE_SUPER 0x0001
466#define EXT2_FEATURE_RO_COMPAT_LARGE_FILE 0x0002
467#define EXT2_FEATURE_RO_COMPAT_BTREE_DIR 0x0004
468#define EXT2_FEATURE_RO_COMPAT_ANY 0xffffffff
470#define EXT2_FEATURE_INCOMPAT_COMPRESSION 0x0001
471#define EXT2_FEATURE_INCOMPAT_FILETYPE 0x0002
473#define EXT2_FEATURE_COMPAT_SUPP 0
474#define EXT2_FEATURE_INCOMPAT_SUPP EXT2_FEATURE_INCOMPAT_FILETYPE
475#define EXT2_FEATURE_RO_COMPAT_SUPP (EXT2_FEATURE_RO_COMPAT_SPARSE_SUPER| \
476 EXT2_FEATURE_RO_COMPAT_LARGE_FILE| \
477 EXT2_FEATURE_RO_COMPAT_BTREE_DIR)
478#define EXT2_FEATURE_RO_COMPAT_UNSUPPORTED ~EXT2_FEATURE_RO_COMPAT_SUPP
479#define EXT2_FEATURE_INCOMPAT_UNSUPPORTED ~EXT2_FEATURE_INCOMPAT_SUPP
484#define EXT2_DEF_RESUID 0
485#define EXT2_DEF_RESGID 0
490#define EXT2_NAME_LEN 255
534#define EXT2_DIR_PAD 4
535#define EXT2_DIR_ROUND (EXT2_DIR_PAD - 1)
536#define EXT2_DIR_REC_LEN(name_len) (((name_len) + 8 + EXT2_DIR_ROUND) & \
549# define ATTRIB_NORET __attribute__((noreturn))
550# define NORET_AND noreturn,
557extern void ext2_free_blocks (
struct inode *,
unsigned long,
559extern unsigned long ext2_count_free_blocks (
struct super_block *);
560extern void ext2_check_blocks_bitmap (
struct super_block *);
562 unsigned int block_group,
566extern int ext2_add_link (
struct dentry *,
struct inode *);
568extern int ext2_make_empty(
struct inode *,
struct inode *);
571extern int ext2_empty_dir (
struct inode *);
576extern int ext2_sync_file (
struct file *,
struct dentry *,
int);
577extern int ext2_fsync_inode (
struct inode *,
int);
581extern void ext2_free_inode (
struct inode *);
582extern unsigned long ext2_count_free_inodes (
struct super_block *);
583extern void ext2_check_inodes_bitmap (
struct super_block *);
584extern unsigned long ext2_count_free (
struct buffer_head *,
unsigned);
589extern void ext2_put_inode (
struct inode *);
590extern void ext2_delete_inode (
struct inode *);
591extern int ext2_sync_inode (
struct inode *);
592extern void ext2_discard_prealloc (
struct inode *);
593extern void ext2_truncate (
struct inode *);
596extern int ext2_ioctl (
struct inode *,
struct file *,
unsigned int,
600extern void ext2_error (
struct super_block *,
const char *,
const char *, ...)
621extern struct file_operations ext2_dir_operations;
624extern struct inode_operations ext2_file_inode_operations;
625extern struct file_operations ext2_file_operations;
628extern struct address_space_operations ext2_aops;
631extern struct inode_operations ext2_dir_inode_operations;
634extern struct inode_operations ext2_fast_symlink_inode_operations;
bool ext2_bg_has_super(PEXT2_SUPER_BLOCK pExt2Sb, int group_block)
bool ext2_read_inode(PEXT2_FILESYS Ext2Sys, ULONG ino, ULONG offset, PVOID Buffer, ULONG size, PULONG dwReturn)
bool ext2_new_inode(PEXT2_FILESYS fs, ULONG dir, int mode, PEXT2_INODE_BITMAP map, ULONG *ret)
bool ext2_write_inode(PEXT2_FILESYS Ext2Sys, ULONG ino, ULONG offset, PVOID Buffer, ULONG size, PULONG dwReturn)
bool ext2_new_block(PEXT2_FILESYS fs, ULONG goal, PEXT2_BLOCK_BITMAP map, ULONG *ret)
void ext2_update_dynamic_rev(PEXT2_FILESYS fs)
int statfs(const char *name, struct statfs *info)
__u16 bg_free_blocks_count
__u16 bg_free_inodes_count
struct ext2_inode::@702::@704 linux1
struct ext2_inode::@703::@707 linux2
struct ext2_inode::@703::@709 masix2
struct ext2_inode::@703::@708 hurd2
struct ext2_inode::@702::@705 hurd1
struct ext2_inode::@702::@706 masix1
__u32 i_block[EXT2_N_BLOCKS]
__u8 s_prealloc_dir_blocks
__u32 s_algorithm_usage_bitmap
__u32 s_free_inodes_count
__u32 s_feature_ro_compat
__u32 s_free_blocks_count