* Copyright (C) 1993, 1994, 1995, 1996 Theodore Ts'o.
* This file may be redistributed under the terms of the GNU Library
* General Public License, version 2.
#define EXT2FS_ATTR(x) __attribute__(x)
#define EXT2FS_NO_TDB_UNUSED
#define EXT2FS_NO_TDB_UNUSED EXT2FS_ATTR((unused))
* Non-GNU C compilers won't necessarily understand inline
#if (!defined(__GNUC__) && !defined(__WATCOMC__))
* Where the master copy of the superblock is located, and how big
* superblocks are supposed to be. We define SUPERBLOCK_SIZE because
* the size of the superblock structure is not necessarily trustworthy
* (some versions have the padding set up so that the superblock is
#define SUPERBLOCK_OFFSET 1024
#define SUPERBLOCK_SIZE 1024
* The last ext2fs revision level that this version of the library is
#define EXT2_LIB_CURRENT_REV EXT2_DYNAMIC_REV
#include "ext3_extents.h"
#include <ext2fs/ext2_types.h>
#include <ext2fs/ext2_fs.h>
#include <ext2fs/ext3_extents.h>
#endif /* EXT2_FLAT_INCLUDES */
typedef __u32 __bitwise ext2_ino_t;
typedef __u32 __bitwise blk_t;
typedef __u64 __bitwise blk64_t;
typedef __u32 __bitwise dgrp_t;
typedef __s32 __bitwise ext2_off_t;
typedef __s64 __bitwise ext2_off64_t;
typedef __s64 __bitwise e2_blkcnt_t;
typedef __u32 __bitwise ext2_dirhash_t;
#include "ext2_ext_attr.h"
#include <ext2fs/ext2_io.h>
#include <ext2fs/ext2_err.h>
#include <ext2fs/ext2_ext_attr.h>
* Portability help for Microsoft Visual C++
#define EXT2_QSORT_TYPE int __cdecl
#define EXT2_QSORT_TYPE int
typedef struct struct_ext2_filsys *ext2_filsys;
#define EXT2FS_MARK_ERROR 0
#define EXT2FS_UNMARK_ERROR 1
#define EXT2FS_TEST_ERROR 2
typedef struct ext2fs_struct_generic_bitmap *ext2fs_generic_bitmap;
typedef struct ext2fs_struct_generic_bitmap *ext2fs_inode_bitmap;
typedef struct ext2fs_struct_generic_bitmap *ext2fs_block_bitmap;
#define EXT2_FIRST_INODE(s) EXT2_FIRST_INO(s)
* Badblocks list definitions
typedef struct ext2_struct_u32_list *ext2_badblocks_list;
typedef struct ext2_struct_u32_iterate *ext2_badblocks_iterate;
typedef struct ext2_struct_u32_list *ext2_u32_list;
typedef struct ext2_struct_u32_iterate *ext2_u32_iterate;
typedef struct ext2_struct_u32_list *badblocks_list;
typedef struct ext2_struct_u32_iterate *badblocks_iterate;
#define BADBLOCKS_FLAG_DIRTY 1
* ext2_dblist structure and abstractions (see dblist.c)
/* Ye Olde 32-bit version */
typedef struct ext2_struct_dblist *ext2_dblist;
* ext2_fileio definitions
#define EXT2_FILE_WRITE 0x0001
#define EXT2_FILE_CREATE 0x0002
#define EXT2_FILE_MASK 0x00FF
#define EXT2_FILE_BUF_DIRTY 0x4000
#define EXT2_FILE_BUF_VALID 0x2000
typedef struct ext2_file *ext2_file_t;
* Flags for the ext2_filsys structure and for ext2fs_open()
#define EXT2_FLAG_RW 0x01
#define EXT2_FLAG_CHANGED 0x02
#define EXT2_FLAG_DIRTY 0x04
#define EXT2_FLAG_VALID 0x08
#define EXT2_FLAG_IB_DIRTY 0x10
#define EXT2_FLAG_BB_DIRTY 0x20
#define EXT2_FLAG_SWAP_BYTES 0x40
#define EXT2_FLAG_SWAP_BYTES_READ 0x80
#define EXT2_FLAG_SWAP_BYTES_WRITE 0x100
#define EXT2_FLAG_MASTER_SB_ONLY 0x200
#define EXT2_FLAG_FORCE 0x400
#define EXT2_FLAG_SUPER_ONLY 0x800
#define EXT2_FLAG_JOURNAL_DEV_OK 0x1000
#define EXT2_FLAG_IMAGE_FILE 0x2000
#define EXT2_FLAG_EXCLUSIVE 0x4000
#define EXT2_FLAG_SOFTSUPP_FEATURES 0x8000
#define EXT2_FLAG_NOFREE_ON_ERROR 0x10000
#define EXT2_FLAG_64BITS 0x20000
#define EXT2_FLAG_PRINT_PROGRESS 0x40000
#define EXT2_FLAG_DIRECT_IO 0x80000
#define EXT2_FLAG_SKIP_MMP 0x100000
#define EXT2_FLAG_IGNORE_CSUM_ERRORS 0x200000
#define EXT2_FLAG_SHARE_DUP 0x400000
#define EXT2_FLAG_IGNORE_SB_ERRORS 0x800000
#define EXT2_FLAG_BBITMAP_TAIL_PROBLEM 0x1000000
#define EXT2_FLAG_IBITMAP_TAIL_PROBLEM 0x2000000
* Special flag in the ext2 inode i_flag field that means that this is
* a new inode. (So that ext2_write_inode() can clear extra fields.)
#define EXT2_NEW_INODE_FL 0x80000000
#define EXT2_MKJOURNAL_V1_SUPER 0x0000001 /* create V1 superblock (deprecated) */
#define EXT2_MKJOURNAL_LAZYINIT 0x0000002 /* don't zero journal inode before use*/
#define EXT2_MKJOURNAL_NO_MNT_CHECK 0x0000004 /* don't check mount status */
struct opaque_ext2_group_desc;
struct struct_ext2_filsys {
struct ext2_super_block * super;
unsigned long desc_blocks;
struct opaque_ext2_group_desc * group_desc;
unsigned int inode_blocks_per_group;
ext2fs_inode_bitmap inode_map;
ext2fs_block_bitmap block_map;
/* XXX FIXME-64: not 64-bit safe, but not used? */
errcode_t (*get_blocks)(ext2_filsys fs, ext2_ino_t ino, blk_t *blocks);
errcode_t (*check_directory)(ext2_filsys fs, ext2_ino_t ino);
errcode_t (*write_bitmaps)(ext2_filsys fs);
errcode_t (*read_inode)(ext2_filsys fs, ext2_ino_t ino,
struct ext2_inode *inode);
errcode_t (*write_inode)(ext2_filsys fs, ext2_ino_t ino,
struct ext2_inode *inode);
ext2_badblocks_list badblocks;
__u32 stride; /* for mke2fs */
struct ext2_super_block * orig_super;
struct ext2_image_hdr * image_header;
__u16 default_bitmap_type;
* RedHat specific change to prevent ABI change by using 8
const struct ext2fs_nls_table *encoding;
* Reserved for future expansion
__u32 reserved[5 - (sizeof(long int)/4)];
* Reserved for the use of the calling application.
struct ext2_inode_cache *icache;
* More callback functions
errcode_t (*get_alloc_block)(ext2_filsys fs, blk64_t goal,
errcode_t (*get_alloc_block2)(ext2_filsys fs, blk64_t goal,
blk64_t *ret, struct blk_alloc_ctx *ctx);
void (*block_alloc_stats)(ext2_filsys fs, blk64_t blk, int inuse);
* Buffers for Multiple mount protection(MMP) block.
* Time at which e2fsck last updated the MMP block.
/* progress operation functions */
struct ext2fs_progress_ops *progress_ops;
/* Precomputed FS UUID checksum for seeding other checksums */
/* New block range allocation hooks */
errcode_t (*new_range)(ext2_filsys fs, int flags, blk64_t goal,
blk64_t len, blk64_t *pblk, blk64_t *plen);
void (*block_alloc_stats_range)(ext2_filsys fs, blk64_t blk, blk_t num,
/* hashmap for SHA of data blocks */
struct ext2fs_hashmap* block_sha_map;
#include <ext2fs/bitops.h>
* 64-bit bitmap backend types
#define EXT2FS_BMAP64_BITARRAY 1
#define EXT2FS_BMAP64_RBTREE 2
#define EXT2FS_BMAP64_AUTODIR 3
* Return flags for the block iterator functions
#define BLOCK_INLINE_DATA_CHANGED 8
* BLOCK_FLAG_APPEND, or BLOCK_FLAG_HOLE, indicates that the interator
* function should be called on blocks where the block number is zero.
* This is used by ext2fs_expand_dir() to be able to add a new block
* to an inode. It can also be used for programs that want to be able
* to deal with files that contain "holes".
* BLOCK_FLAG_DEPTH_TRAVERSE indicates that the iterator function for
* the indirect, doubly indirect, etc. blocks should be called after
* all of the blocks contained in the indirect blocks are processed.
* This is useful if you are going to be deallocating blocks from an
* BLOCK_FLAG_DATA_ONLY indicates that the iterator function should be
* called for data blocks only.
* BLOCK_FLAG_READ_ONLY is a promise by the caller that it will not
* modify returned block number.
* BLOCK_FLAG_NO_LARGE is for internal use only. It informs
* ext2fs_block_iterate2 that large files won't be accepted.
#define BLOCK_FLAG_APPEND 1
#define BLOCK_FLAG_HOLE 1
#define BLOCK_FLAG_DEPTH_TRAVERSE 2
#define BLOCK_FLAG_DATA_ONLY 4
#define BLOCK_FLAG_READ_ONLY 8
#define BLOCK_FLAG_NO_LARGE 0x1000
* Magic "block count" return values for the block iterator function.
#define BLOCK_COUNT_IND (-1)
#define BLOCK_COUNT_DIND (-2)
#define BLOCK_COUNT_TIND (-3)
#define BLOCK_COUNT_TRANSLATOR (-4)
#define BLOCK_ALLOC_UNKNOWN 0
#define BLOCK_ALLOC_DATA 1
#define BLOCK_ALLOC_METADATA 2
struct ext2_inode *inode;
* Flags for ext2fs_move_blocks
#define EXT2_BMOVE_GET_DBLIST 0x0001
#define EXT2_BMOVE_DEBUG 0x0002
* Generic (non-filesystem layout specific) extents structure
#define EXT2_EXTENT_FLAGS_LEAF 0x0001
#define EXT2_EXTENT_FLAGS_UNINIT 0x0002
#define EXT2_EXTENT_FLAGS_SECOND_VISIT 0x0004
blk64_t e_pblk; /* first physical block */
blk64_t e_lblk; /* first logical block extent covers */
__u32 e_len; /* number of blocks covered by extent */
__u32 e_flags; /* extent flags */
typedef struct ext2_extent_handle *ext2_extent_handle_t;
typedef struct ext2_extent_path *ext2_extent_path_t;
* Flags used by ext2fs_extent_get()
#define EXT2_EXTENT_CURRENT 0x0000
#define EXT2_EXTENT_MOVE_MASK 0x000F
#define EXT2_EXTENT_ROOT 0x0001
#define EXT2_EXTENT_LAST_LEAF 0x0002
#define EXT2_EXTENT_FIRST_SIB 0x0003
#define EXT2_EXTENT_LAST_SIB 0x0004
#define EXT2_EXTENT_NEXT_SIB 0x0005
#define EXT2_EXTENT_PREV_SIB 0x0006
#define EXT2_EXTENT_NEXT_LEAF 0x0007
#define EXT2_EXTENT_PREV_LEAF 0x0008
#define EXT2_EXTENT_NEXT 0x0009
#define EXT2_EXTENT_PREV 0x000A
#define EXT2_EXTENT_UP 0x000B
#define EXT2_EXTENT_DOWN 0x000C
#define EXT2_EXTENT_DOWN_AND_LAST 0x000D
* Flags used by ext2fs_extent_insert()
#define EXT2_EXTENT_INSERT_AFTER 0x0001 /* insert after handle loc'n */
#define EXT2_EXTENT_INSERT_NOSPLIT 0x0002 /* insert may not cause split */
* Flags used by ext2fs_extent_delete()
#define EXT2_EXTENT_DELETE_KEEP_EMPTY 0x001 /* keep node if last extent gone */
* Flags used by ext2fs_extent_set_bmap()
#define EXT2_EXTENT_SET_BMAP_UNINIT 0x0001
* Data structure returned by ext2fs_extent_get_info()
struct ext2_extent_info {
* Flags for directory block reading and writing functions
#define EXT2_DIRBLOCK_V2_STRUCT 0x0001
* Return flags for the directory iterator functions
* Directory iterator flags
#define DIRENT_FLAG_INCLUDE_EMPTY 1
#define DIRENT_FLAG_INCLUDE_REMOVED 2
#define DIRENT_FLAG_INCLUDE_CSUM 4
#define DIRENT_FLAG_INCLUDE_INLINE_DATA 8
#define DIRENT_DOT_FILE 1
#define DIRENT_DOT_DOT_FILE 2
#define DIRENT_OTHER_FILE 3
#define DIRENT_DELETED_FILE 4
#define DIRENT_CHECKSUM 5
typedef struct ext2_struct_inode_scan *ext2_inode_scan;
#define EXT2_SF_CHK_BADBLOCKS 0x0001