pmt: initial 2.9.1 update
This commit is contained in:
606
include/e2fsprogs/ext2fs/bitops.h
Executable file
606
include/e2fsprogs/ext2fs/bitops.h
Executable file
@@ -0,0 +1,606 @@
|
||||
/*
|
||||
* bitops.h --- Bitmap frobbing code. The byte swapping routines are
|
||||
* also included here.
|
||||
*
|
||||
* Copyright (C) 1993, 1994, 1995, 1996 Theodore Ts'o.
|
||||
*
|
||||
* %Begin-Header%
|
||||
* This file may be redistributed under the terms of the GNU Library
|
||||
* General Public License, version 2.
|
||||
* %End-Header%
|
||||
*/
|
||||
|
||||
#ifdef WORDS_BIGENDIAN
|
||||
#define ext2fs_cpu_to_le64(x) ((__force __le64)ext2fs_swab64((__u64)(x)))
|
||||
#define ext2fs_le64_to_cpu(x) ext2fs_swab64((__force __u64)(__le64)(x))
|
||||
#define ext2fs_cpu_to_le32(x) ((__force __le32)ext2fs_swab32((__u32)(x)))
|
||||
#define ext2fs_le32_to_cpu(x) ext2fs_swab32((__force __u32)(__le32)(x))
|
||||
#define ext2fs_cpu_to_le16(x) ((__force __le16)ext2fs_swab16((__u16)(x)))
|
||||
#define ext2fs_le16_to_cpu(x) ext2fs_swab16((__force __u16)(__le16)(x))
|
||||
|
||||
#define ext2fs_cpu_to_be64(x) ((__force __be64)(__u64)(x))
|
||||
#define ext2fs_be64_to_cpu(x) ((__force __u64)(__be64)(x))
|
||||
#define ext2fs_cpu_to_be32(x) ((__force __be32)(__u32)(x))
|
||||
#define ext2fs_be32_to_cpu(x) ((__force __u32)(__be32)(x))
|
||||
#define ext2fs_cpu_to_be16(x) ((__force __be16)(__u16)(x))
|
||||
#define ext2fs_be16_to_cpu(x) ((__force __u16)(__be16)(x))
|
||||
#else
|
||||
#define ext2fs_cpu_to_le64(x) ((__force __le64)(__u64)(x))
|
||||
#define ext2fs_le64_to_cpu(x) ((__force __u64)(__le64)(x))
|
||||
#define ext2fs_cpu_to_le32(x) ((__force __le32)(__u32)(x))
|
||||
#define ext2fs_le32_to_cpu(x) ((__force __u32)(__le32)(x))
|
||||
#define ext2fs_cpu_to_le16(x) ((__force __le16)(__u16)(x))
|
||||
#define ext2fs_le16_to_cpu(x) ((__force __u16)(__le16)(x))
|
||||
|
||||
#define ext2fs_cpu_to_be64(x) ((__force __be64)ext2fs_swab64((__u64)(x)))
|
||||
#define ext2fs_be64_to_cpu(x) ext2fs_swab64((__force __u64)(__be64)(x))
|
||||
#define ext2fs_cpu_to_be32(x) ((__force __be32)ext2fs_swab32((__u32)(x)))
|
||||
#define ext2fs_be32_to_cpu(x) ext2fs_swab32((__force __u32)(__be32)(x))
|
||||
#define ext2fs_cpu_to_be16(x) ((__force __be16)ext2fs_swab16((__u16)(x)))
|
||||
#define ext2fs_be16_to_cpu(x) ext2fs_swab16((__force __u16)(__be16)(x))
|
||||
#endif
|
||||
|
||||
/*
|
||||
* EXT2FS bitmap manipulation routines.
|
||||
*/
|
||||
|
||||
/* Support for sending warning messages from the inline subroutines */
|
||||
extern const char *ext2fs_block_string;
|
||||
extern const char *ext2fs_inode_string;
|
||||
extern const char *ext2fs_mark_string;
|
||||
extern const char *ext2fs_unmark_string;
|
||||
extern const char *ext2fs_test_string;
|
||||
extern void ext2fs_warn_bitmap(errcode_t errcode, unsigned long arg,
|
||||
const char *description);
|
||||
extern void ext2fs_warn_bitmap2(ext2fs_generic_bitmap bitmap,
|
||||
int code, unsigned long arg);
|
||||
|
||||
#ifdef NO_INLINE_FUNCS
|
||||
extern void ext2fs_fast_set_bit(unsigned int nr,void * addr);
|
||||
extern void ext2fs_fast_clear_bit(unsigned int nr, void * addr);
|
||||
extern void ext2fs_fast_set_bit64(__u64 nr,void * addr);
|
||||
extern void ext2fs_fast_clear_bit64(__u64 nr, void * addr);
|
||||
extern __u16 ext2fs_swab16(__u16 val);
|
||||
extern __u32 ext2fs_swab32(__u32 val);
|
||||
extern __u64 ext2fs_swab64(__u64 val);
|
||||
|
||||
extern int ext2fs_mark_block_bitmap(ext2fs_block_bitmap bitmap, blk_t block);
|
||||
extern int ext2fs_unmark_block_bitmap(ext2fs_block_bitmap bitmap,
|
||||
blk_t block);
|
||||
extern int ext2fs_test_block_bitmap(ext2fs_block_bitmap bitmap, blk_t block);
|
||||
|
||||
extern int ext2fs_mark_inode_bitmap(ext2fs_inode_bitmap bitmap, ext2_ino_t inode);
|
||||
extern int ext2fs_unmark_inode_bitmap(ext2fs_inode_bitmap bitmap,
|
||||
ext2_ino_t inode);
|
||||
extern int ext2fs_test_inode_bitmap(ext2fs_inode_bitmap bitmap, ext2_ino_t inode);
|
||||
|
||||
extern void ext2fs_fast_mark_block_bitmap(ext2fs_block_bitmap bitmap,
|
||||
blk_t block);
|
||||
extern void ext2fs_fast_unmark_block_bitmap(ext2fs_block_bitmap bitmap,
|
||||
blk_t block);
|
||||
extern int ext2fs_fast_test_block_bitmap(ext2fs_block_bitmap bitmap,
|
||||
blk_t block);
|
||||
|
||||
extern void ext2fs_fast_mark_inode_bitmap(ext2fs_inode_bitmap bitmap,
|
||||
ext2_ino_t inode);
|
||||
extern void ext2fs_fast_unmark_inode_bitmap(ext2fs_inode_bitmap bitmap,
|
||||
ext2_ino_t inode);
|
||||
extern int ext2fs_fast_test_inode_bitmap(ext2fs_inode_bitmap bitmap,
|
||||
ext2_ino_t inode);
|
||||
extern blk_t ext2fs_get_block_bitmap_start(ext2fs_block_bitmap bitmap);
|
||||
extern ext2_ino_t ext2fs_get_inode_bitmap_start(ext2fs_inode_bitmap bitmap);
|
||||
extern blk_t ext2fs_get_block_bitmap_end(ext2fs_block_bitmap bitmap);
|
||||
extern ext2_ino_t ext2fs_get_inode_bitmap_end(ext2fs_inode_bitmap bitmap);
|
||||
|
||||
extern void ext2fs_fast_mark_block_bitmap_range(ext2fs_block_bitmap bitmap,
|
||||
blk_t block, int num);
|
||||
extern void ext2fs_fast_unmark_block_bitmap_range(ext2fs_block_bitmap bitmap,
|
||||
blk_t block, int num);
|
||||
extern int ext2fs_fast_test_block_bitmap_range(ext2fs_block_bitmap bitmap,
|
||||
blk_t block, int num);
|
||||
#endif
|
||||
|
||||
/* These functions routines moved to gen_bitmap.c */
|
||||
extern void ext2fs_mark_block_bitmap_range(ext2fs_block_bitmap bitmap,
|
||||
blk_t block, int num);
|
||||
extern void ext2fs_unmark_block_bitmap_range(ext2fs_block_bitmap bitmap,
|
||||
blk_t block, int num);
|
||||
extern int ext2fs_test_block_bitmap_range(ext2fs_block_bitmap bitmap,
|
||||
blk_t block, int num);
|
||||
extern int ext2fs_test_inode_bitmap_range(ext2fs_inode_bitmap bitmap,
|
||||
ext2_ino_t inode, int num);
|
||||
extern int ext2fs_mark_generic_bitmap(ext2fs_generic_bitmap bitmap,
|
||||
__u32 bitno);
|
||||
extern int ext2fs_unmark_generic_bitmap(ext2fs_generic_bitmap bitmap,
|
||||
blk_t bitno);
|
||||
extern int ext2fs_test_generic_bitmap(ext2fs_generic_bitmap bitmap,
|
||||
blk_t bitno);
|
||||
extern int ext2fs_test_block_bitmap_range(ext2fs_block_bitmap bitmap,
|
||||
blk_t block, int num);
|
||||
extern void ext2fs_set_bitmap_padding(ext2fs_generic_bitmap map);
|
||||
extern __u32 ext2fs_get_generic_bitmap_start(ext2fs_generic_bitmap bitmap);
|
||||
extern __u32 ext2fs_get_generic_bitmap_end(ext2fs_generic_bitmap bitmap);
|
||||
|
||||
/* 64-bit versions */
|
||||
|
||||
#ifdef NO_INLINE_FUNCS
|
||||
extern int ext2fs_mark_block_bitmap2(ext2fs_block_bitmap bitmap,
|
||||
blk64_t block);
|
||||
extern int ext2fs_unmark_block_bitmap2(ext2fs_block_bitmap bitmap,
|
||||
blk64_t block);
|
||||
extern int ext2fs_test_block_bitmap2(ext2fs_block_bitmap bitmap,
|
||||
blk64_t block);
|
||||
|
||||
extern int ext2fs_mark_inode_bitmap2(ext2fs_inode_bitmap bitmap,
|
||||
ext2_ino_t inode);
|
||||
extern int ext2fs_unmark_inode_bitmap2(ext2fs_inode_bitmap bitmap,
|
||||
ext2_ino_t inode);
|
||||
extern int ext2fs_test_inode_bitmap2(ext2fs_inode_bitmap bitmap,
|
||||
ext2_ino_t inode);
|
||||
|
||||
extern void ext2fs_fast_mark_block_bitmap2(ext2fs_block_bitmap bitmap,
|
||||
blk64_t block);
|
||||
extern void ext2fs_fast_unmark_block_bitmap2(ext2fs_block_bitmap bitmap,
|
||||
blk64_t block);
|
||||
extern int ext2fs_fast_test_block_bitmap2(ext2fs_block_bitmap bitmap,
|
||||
blk64_t block);
|
||||
|
||||
extern void ext2fs_fast_mark_inode_bitmap2(ext2fs_inode_bitmap bitmap,
|
||||
ext2_ino_t inode);
|
||||
extern void ext2fs_fast_unmark_inode_bitmap2(ext2fs_inode_bitmap bitmap,
|
||||
ext2_ino_t inode);
|
||||
extern int ext2fs_fast_test_inode_bitmap2(ext2fs_inode_bitmap bitmap,
|
||||
ext2_ino_t inode);
|
||||
extern errcode_t ext2fs_find_first_zero_block_bitmap2(ext2fs_block_bitmap bitmap,
|
||||
blk64_t start,
|
||||
blk64_t end,
|
||||
blk64_t *out);
|
||||
extern errcode_t ext2fs_find_first_zero_inode_bitmap2(ext2fs_inode_bitmap bitmap,
|
||||
ext2_ino_t start,
|
||||
ext2_ino_t end,
|
||||
ext2_ino_t *out);
|
||||
extern errcode_t ext2fs_find_first_set_block_bitmap2(ext2fs_block_bitmap bitmap,
|
||||
blk64_t start,
|
||||
blk64_t end,
|
||||
blk64_t *out);
|
||||
extern errcode_t ext2fs_find_first_set_inode_bitmap2(ext2fs_inode_bitmap bitmap,
|
||||
ext2_ino_t start,
|
||||
ext2_ino_t end,
|
||||
ext2_ino_t *out);
|
||||
extern blk64_t ext2fs_get_block_bitmap_start2(ext2fs_block_bitmap bitmap);
|
||||
extern ext2_ino_t ext2fs_get_inode_bitmap_start2(ext2fs_inode_bitmap bitmap);
|
||||
extern blk64_t ext2fs_get_block_bitmap_end2(ext2fs_block_bitmap bitmap);
|
||||
extern ext2_ino_t ext2fs_get_inode_bitmap_end2(ext2fs_inode_bitmap bitmap);
|
||||
|
||||
extern int ext2fs_fast_test_block_bitmap_range2(ext2fs_block_bitmap bitmap,
|
||||
blk64_t block,
|
||||
unsigned int num);
|
||||
extern void ext2fs_fast_mark_block_bitmap_range2(ext2fs_block_bitmap bitmap,
|
||||
blk64_t block,
|
||||
unsigned int num);
|
||||
extern void ext2fs_fast_unmark_block_bitmap_range2(ext2fs_block_bitmap bitmap,
|
||||
blk64_t block,
|
||||
unsigned int num);
|
||||
#endif
|
||||
|
||||
/* These routines moved to gen_bitmap64.c */
|
||||
extern void ext2fs_clear_generic_bmap(ext2fs_generic_bitmap bitmap);
|
||||
extern errcode_t ext2fs_compare_generic_bmap(errcode_t neq,
|
||||
ext2fs_generic_bitmap bm1,
|
||||
ext2fs_generic_bitmap bm2);
|
||||
extern void ext2fs_set_generic_bmap_padding(ext2fs_generic_bitmap bmap);
|
||||
extern int ext2fs_mark_generic_bmap(ext2fs_generic_bitmap bitmap,
|
||||
blk64_t bitno);
|
||||
extern int ext2fs_unmark_generic_bmap(ext2fs_generic_bitmap bitmap,
|
||||
blk64_t bitno);
|
||||
extern int ext2fs_test_generic_bmap(ext2fs_generic_bitmap bitmap,
|
||||
blk64_t bitno);
|
||||
extern int ext2fs_test_block_bitmap_range2(ext2fs_block_bitmap bitmap,
|
||||
blk64_t block, unsigned int num);
|
||||
extern __u64 ext2fs_get_generic_bmap_start(ext2fs_generic_bitmap bitmap);
|
||||
extern __u64 ext2fs_get_generic_bmap_end(ext2fs_generic_bitmap bitmap);
|
||||
extern int ext2fs_test_block_bitmap_range2(ext2fs_block_bitmap bitmap,
|
||||
blk64_t block, unsigned int num);
|
||||
extern void ext2fs_mark_block_bitmap_range2(ext2fs_block_bitmap bitmap,
|
||||
blk64_t block, unsigned int num);
|
||||
extern void ext2fs_unmark_block_bitmap_range2(ext2fs_block_bitmap bitmap,
|
||||
blk64_t block, unsigned int num);
|
||||
extern errcode_t ext2fs_find_first_zero_generic_bmap(ext2fs_generic_bitmap bitmap,
|
||||
__u64 start, __u64 end,
|
||||
__u64 *out);
|
||||
extern errcode_t ext2fs_find_first_set_generic_bmap(ext2fs_generic_bitmap bitmap,
|
||||
__u64 start, __u64 end,
|
||||
__u64 *out);
|
||||
|
||||
/*
|
||||
* The inline routines themselves...
|
||||
*
|
||||
* If NO_INLINE_FUNCS is defined, then we won't try to do inline
|
||||
* functions at all; they will be included as normal functions in
|
||||
* inline.c
|
||||
*/
|
||||
|
||||
#if (defined(INCLUDE_INLINE_FUNCS) || !defined(NO_INLINE_FUNCS))
|
||||
#ifdef INCLUDE_INLINE_FUNCS
|
||||
#if (__STDC_VERSION__ >= 199901L)
|
||||
#define _INLINE_ extern inline
|
||||
#else
|
||||
#define _INLINE_ inline
|
||||
#endif
|
||||
#else /* !INCLUDE_INLINE FUNCS */
|
||||
#if (__STDC_VERSION__ >= 199901L)
|
||||
#define _INLINE_ inline
|
||||
#else /* not C99 */
|
||||
#ifdef __GNUC__
|
||||
#define _INLINE_ extern __inline__
|
||||
#else /* For Watcom C */
|
||||
#define _INLINE_ extern inline
|
||||
#endif /* __GNUC__ */
|
||||
#endif /* __STDC_VERSION__ >= 199901L */
|
||||
#endif /* INCLUDE_INLINE_FUNCS */
|
||||
|
||||
/*
|
||||
* Fast bit set/clear functions that doesn't need to return the
|
||||
* previous bit value.
|
||||
*/
|
||||
|
||||
_INLINE_ void ext2fs_fast_set_bit(unsigned int nr,void * addr)
|
||||
{
|
||||
unsigned char *ADDR = (unsigned char *) addr;
|
||||
|
||||
ADDR += nr >> 3;
|
||||
*ADDR |= (unsigned char) (1 << (nr & 0x07));
|
||||
}
|
||||
|
||||
_INLINE_ void ext2fs_fast_clear_bit(unsigned int nr, void * addr)
|
||||
{
|
||||
unsigned char *ADDR = (unsigned char *) addr;
|
||||
|
||||
ADDR += nr >> 3;
|
||||
*ADDR &= (unsigned char) ~(1 << (nr & 0x07));
|
||||
}
|
||||
|
||||
|
||||
_INLINE_ void ext2fs_fast_set_bit64(__u64 nr, void * addr)
|
||||
{
|
||||
unsigned char *ADDR = (unsigned char *) addr;
|
||||
|
||||
ADDR += nr >> 3;
|
||||
*ADDR |= (unsigned char) (1 << (nr & 0x07));
|
||||
}
|
||||
|
||||
_INLINE_ void ext2fs_fast_clear_bit64(__u64 nr, void * addr)
|
||||
{
|
||||
unsigned char *ADDR = (unsigned char *) addr;
|
||||
|
||||
ADDR += nr >> 3;
|
||||
*ADDR &= (unsigned char) ~(1 << (nr & 0x07));
|
||||
}
|
||||
|
||||
_INLINE_ __u16 ext2fs_swab16(__u16 val)
|
||||
{
|
||||
return (val >> 8) | (__u16) (val << 8);
|
||||
}
|
||||
|
||||
_INLINE_ __u32 ext2fs_swab32(__u32 val)
|
||||
{
|
||||
return ((val>>24) | ((val>>8)&0xFF00) |
|
||||
((val<<8)&0xFF0000) | (val<<24));
|
||||
}
|
||||
|
||||
_INLINE_ __u64 ext2fs_swab64(__u64 val)
|
||||
{
|
||||
return (ext2fs_swab32((__u32) (val >> 32)) |
|
||||
(((__u64)ext2fs_swab32(val & 0xFFFFFFFFUL)) << 32));
|
||||
}
|
||||
|
||||
_INLINE_ int ext2fs_mark_block_bitmap(ext2fs_block_bitmap bitmap,
|
||||
blk_t block)
|
||||
{
|
||||
return ext2fs_mark_generic_bitmap((ext2fs_generic_bitmap) bitmap,
|
||||
block);
|
||||
}
|
||||
|
||||
_INLINE_ int ext2fs_unmark_block_bitmap(ext2fs_block_bitmap bitmap,
|
||||
blk_t block)
|
||||
{
|
||||
return ext2fs_unmark_generic_bitmap((ext2fs_generic_bitmap) bitmap,
|
||||
block);
|
||||
}
|
||||
|
||||
_INLINE_ int ext2fs_test_block_bitmap(ext2fs_block_bitmap bitmap,
|
||||
blk_t block)
|
||||
{
|
||||
return ext2fs_test_generic_bitmap((ext2fs_generic_bitmap) bitmap,
|
||||
block);
|
||||
}
|
||||
|
||||
_INLINE_ int ext2fs_mark_inode_bitmap(ext2fs_inode_bitmap bitmap,
|
||||
ext2_ino_t inode)
|
||||
{
|
||||
return ext2fs_mark_generic_bitmap((ext2fs_generic_bitmap) bitmap,
|
||||
inode);
|
||||
}
|
||||
|
||||
_INLINE_ int ext2fs_unmark_inode_bitmap(ext2fs_inode_bitmap bitmap,
|
||||
ext2_ino_t inode)
|
||||
{
|
||||
return ext2fs_unmark_generic_bitmap((ext2fs_generic_bitmap) bitmap,
|
||||
inode);
|
||||
}
|
||||
|
||||
_INLINE_ int ext2fs_test_inode_bitmap(ext2fs_inode_bitmap bitmap,
|
||||
ext2_ino_t inode)
|
||||
{
|
||||
return ext2fs_test_generic_bitmap((ext2fs_generic_bitmap) bitmap,
|
||||
inode);
|
||||
}
|
||||
|
||||
_INLINE_ void ext2fs_fast_mark_block_bitmap(ext2fs_block_bitmap bitmap,
|
||||
blk_t block)
|
||||
{
|
||||
ext2fs_mark_generic_bitmap((ext2fs_generic_bitmap) bitmap, block);
|
||||
}
|
||||
|
||||
_INLINE_ void ext2fs_fast_unmark_block_bitmap(ext2fs_block_bitmap bitmap,
|
||||
blk_t block)
|
||||
{
|
||||
ext2fs_unmark_generic_bitmap((ext2fs_generic_bitmap) bitmap, block);
|
||||
}
|
||||
|
||||
_INLINE_ int ext2fs_fast_test_block_bitmap(ext2fs_block_bitmap bitmap,
|
||||
blk_t block)
|
||||
{
|
||||
return ext2fs_test_generic_bitmap((ext2fs_generic_bitmap) bitmap,
|
||||
block);
|
||||
}
|
||||
|
||||
_INLINE_ void ext2fs_fast_mark_inode_bitmap(ext2fs_inode_bitmap bitmap,
|
||||
ext2_ino_t inode)
|
||||
{
|
||||
ext2fs_mark_generic_bitmap((ext2fs_generic_bitmap) bitmap, inode);
|
||||
}
|
||||
|
||||
_INLINE_ void ext2fs_fast_unmark_inode_bitmap(ext2fs_inode_bitmap bitmap,
|
||||
ext2_ino_t inode)
|
||||
{
|
||||
ext2fs_unmark_generic_bitmap((ext2fs_generic_bitmap) bitmap, inode);
|
||||
}
|
||||
|
||||
_INLINE_ int ext2fs_fast_test_inode_bitmap(ext2fs_inode_bitmap bitmap,
|
||||
ext2_ino_t inode)
|
||||
{
|
||||
return ext2fs_test_generic_bitmap((ext2fs_generic_bitmap) bitmap,
|
||||
inode);
|
||||
}
|
||||
|
||||
_INLINE_ blk_t ext2fs_get_block_bitmap_start(ext2fs_block_bitmap bitmap)
|
||||
{
|
||||
return ext2fs_get_generic_bitmap_start((ext2fs_generic_bitmap) bitmap);
|
||||
}
|
||||
|
||||
_INLINE_ ext2_ino_t ext2fs_get_inode_bitmap_start(ext2fs_inode_bitmap bitmap)
|
||||
{
|
||||
return ext2fs_get_generic_bitmap_start((ext2fs_generic_bitmap) bitmap);
|
||||
}
|
||||
|
||||
_INLINE_ blk_t ext2fs_get_block_bitmap_end(ext2fs_block_bitmap bitmap)
|
||||
{
|
||||
return ext2fs_get_generic_bitmap_end((ext2fs_generic_bitmap) bitmap);
|
||||
}
|
||||
|
||||
_INLINE_ ext2_ino_t ext2fs_get_inode_bitmap_end(ext2fs_inode_bitmap bitmap)
|
||||
{
|
||||
return ext2fs_get_generic_bitmap_end((ext2fs_generic_bitmap) bitmap);
|
||||
}
|
||||
|
||||
_INLINE_ int ext2fs_fast_test_block_bitmap_range(ext2fs_block_bitmap bitmap,
|
||||
blk_t block, int num)
|
||||
{
|
||||
return ext2fs_test_block_bitmap_range(bitmap, block, num);
|
||||
}
|
||||
|
||||
_INLINE_ void ext2fs_fast_mark_block_bitmap_range(ext2fs_block_bitmap bitmap,
|
||||
blk_t block, int num)
|
||||
{
|
||||
ext2fs_mark_block_bitmap_range(bitmap, block, num);
|
||||
}
|
||||
|
||||
_INLINE_ void ext2fs_fast_unmark_block_bitmap_range(ext2fs_block_bitmap bitmap,
|
||||
blk_t block, int num)
|
||||
{
|
||||
ext2fs_unmark_block_bitmap_range(bitmap, block, num);
|
||||
}
|
||||
|
||||
/* 64-bit versions */
|
||||
|
||||
_INLINE_ int ext2fs_mark_block_bitmap2(ext2fs_block_bitmap bitmap,
|
||||
blk64_t block)
|
||||
{
|
||||
return ext2fs_mark_generic_bmap((ext2fs_generic_bitmap) bitmap,
|
||||
block);
|
||||
}
|
||||
|
||||
_INLINE_ int ext2fs_unmark_block_bitmap2(ext2fs_block_bitmap bitmap,
|
||||
blk64_t block)
|
||||
{
|
||||
return ext2fs_unmark_generic_bmap((ext2fs_generic_bitmap) bitmap, block);
|
||||
}
|
||||
|
||||
_INLINE_ int ext2fs_test_block_bitmap2(ext2fs_block_bitmap bitmap,
|
||||
blk64_t block)
|
||||
{
|
||||
return ext2fs_test_generic_bmap((ext2fs_generic_bitmap) bitmap,
|
||||
block);
|
||||
}
|
||||
|
||||
_INLINE_ int ext2fs_mark_inode_bitmap2(ext2fs_inode_bitmap bitmap,
|
||||
ext2_ino_t inode)
|
||||
{
|
||||
return ext2fs_mark_generic_bmap((ext2fs_generic_bitmap) bitmap,
|
||||
inode);
|
||||
}
|
||||
|
||||
_INLINE_ int ext2fs_unmark_inode_bitmap2(ext2fs_inode_bitmap bitmap,
|
||||
ext2_ino_t inode)
|
||||
{
|
||||
return ext2fs_unmark_generic_bmap((ext2fs_generic_bitmap) bitmap,
|
||||
inode);
|
||||
}
|
||||
|
||||
_INLINE_ int ext2fs_test_inode_bitmap2(ext2fs_inode_bitmap bitmap,
|
||||
ext2_ino_t inode)
|
||||
{
|
||||
return ext2fs_test_generic_bmap((ext2fs_generic_bitmap) bitmap,
|
||||
inode);
|
||||
}
|
||||
|
||||
_INLINE_ void ext2fs_fast_mark_block_bitmap2(ext2fs_block_bitmap bitmap,
|
||||
blk64_t block)
|
||||
{
|
||||
ext2fs_mark_generic_bmap((ext2fs_generic_bitmap) bitmap, block);
|
||||
}
|
||||
|
||||
_INLINE_ void ext2fs_fast_unmark_block_bitmap2(ext2fs_block_bitmap bitmap,
|
||||
blk64_t block)
|
||||
{
|
||||
ext2fs_unmark_generic_bmap((ext2fs_generic_bitmap) bitmap, block);
|
||||
}
|
||||
|
||||
_INLINE_ int ext2fs_fast_test_block_bitmap2(ext2fs_block_bitmap bitmap,
|
||||
blk64_t block)
|
||||
{
|
||||
return ext2fs_test_generic_bmap((ext2fs_generic_bitmap) bitmap,
|
||||
block);
|
||||
}
|
||||
|
||||
_INLINE_ void ext2fs_fast_mark_inode_bitmap2(ext2fs_inode_bitmap bitmap,
|
||||
ext2_ino_t inode)
|
||||
{
|
||||
ext2fs_mark_generic_bmap((ext2fs_generic_bitmap) bitmap, inode);
|
||||
}
|
||||
|
||||
_INLINE_ void ext2fs_fast_unmark_inode_bitmap2(ext2fs_inode_bitmap bitmap,
|
||||
ext2_ino_t inode)
|
||||
{
|
||||
ext2fs_unmark_generic_bmap((ext2fs_generic_bitmap) bitmap, inode);
|
||||
}
|
||||
|
||||
_INLINE_ int ext2fs_fast_test_inode_bitmap2(ext2fs_inode_bitmap bitmap,
|
||||
ext2_ino_t inode)
|
||||
{
|
||||
return ext2fs_test_generic_bmap((ext2fs_generic_bitmap) bitmap,
|
||||
inode);
|
||||
}
|
||||
|
||||
_INLINE_ errcode_t ext2fs_find_first_zero_block_bitmap2(ext2fs_block_bitmap bitmap,
|
||||
blk64_t start,
|
||||
blk64_t end,
|
||||
blk64_t *out)
|
||||
{
|
||||
__u64 o;
|
||||
errcode_t rv;
|
||||
|
||||
rv = ext2fs_find_first_zero_generic_bmap((ext2fs_generic_bitmap) bitmap,
|
||||
start, end, &o);
|
||||
if (!rv)
|
||||
*out = o;
|
||||
return rv;
|
||||
}
|
||||
|
||||
_INLINE_ errcode_t ext2fs_find_first_zero_inode_bitmap2(ext2fs_inode_bitmap bitmap,
|
||||
ext2_ino_t start,
|
||||
ext2_ino_t end,
|
||||
ext2_ino_t *out)
|
||||
{
|
||||
__u64 o;
|
||||
errcode_t rv;
|
||||
|
||||
rv = ext2fs_find_first_zero_generic_bmap((ext2fs_generic_bitmap) bitmap,
|
||||
start, end, &o);
|
||||
if (!rv)
|
||||
*out = (ext2_ino_t) o;
|
||||
return rv;
|
||||
}
|
||||
|
||||
_INLINE_ errcode_t ext2fs_find_first_set_block_bitmap2(ext2fs_block_bitmap bitmap,
|
||||
blk64_t start,
|
||||
blk64_t end,
|
||||
blk64_t *out)
|
||||
{
|
||||
__u64 o;
|
||||
errcode_t rv;
|
||||
|
||||
rv = ext2fs_find_first_set_generic_bmap((ext2fs_generic_bitmap) bitmap,
|
||||
start, end, &o);
|
||||
if (!rv)
|
||||
*out = o;
|
||||
return rv;
|
||||
}
|
||||
|
||||
_INLINE_ errcode_t ext2fs_find_first_set_inode_bitmap2(ext2fs_inode_bitmap bitmap,
|
||||
ext2_ino_t start,
|
||||
ext2_ino_t end,
|
||||
ext2_ino_t *out)
|
||||
{
|
||||
__u64 o;
|
||||
errcode_t rv;
|
||||
|
||||
rv = ext2fs_find_first_set_generic_bmap((ext2fs_generic_bitmap) bitmap,
|
||||
start, end, &o);
|
||||
if (!rv)
|
||||
*out = (ext2_ino_t) o;
|
||||
return rv;
|
||||
}
|
||||
|
||||
_INLINE_ blk64_t ext2fs_get_block_bitmap_start2(ext2fs_block_bitmap bitmap)
|
||||
{
|
||||
return ext2fs_get_generic_bmap_start((ext2fs_generic_bitmap) bitmap);
|
||||
}
|
||||
|
||||
_INLINE_ ext2_ino_t ext2fs_get_inode_bitmap_start2(ext2fs_inode_bitmap bitmap)
|
||||
{
|
||||
return (ext2_ino_t) ext2fs_get_generic_bmap_start((ext2fs_generic_bitmap) bitmap);
|
||||
}
|
||||
|
||||
_INLINE_ blk64_t ext2fs_get_block_bitmap_end2(ext2fs_block_bitmap bitmap)
|
||||
{
|
||||
return ext2fs_get_generic_bmap_end((ext2fs_generic_bitmap) bitmap);
|
||||
}
|
||||
|
||||
_INLINE_ ext2_ino_t ext2fs_get_inode_bitmap_end2(ext2fs_inode_bitmap bitmap)
|
||||
{
|
||||
return (ext2_ino_t) ext2fs_get_generic_bmap_end((ext2fs_generic_bitmap) bitmap);
|
||||
}
|
||||
|
||||
_INLINE_ int ext2fs_fast_test_block_bitmap_range2(ext2fs_block_bitmap bitmap,
|
||||
blk64_t block,
|
||||
unsigned int num)
|
||||
{
|
||||
return ext2fs_test_block_bitmap_range2(bitmap, block, num);
|
||||
}
|
||||
|
||||
_INLINE_ void ext2fs_fast_mark_block_bitmap_range2(ext2fs_block_bitmap bitmap,
|
||||
blk64_t block,
|
||||
unsigned int num)
|
||||
{
|
||||
ext2fs_mark_block_bitmap_range2(bitmap, block, num);
|
||||
}
|
||||
|
||||
_INLINE_ void ext2fs_fast_unmark_block_bitmap_range2(ext2fs_block_bitmap bitmap,
|
||||
blk64_t block,
|
||||
unsigned int num)
|
||||
{
|
||||
ext2fs_unmark_block_bitmap_range2(bitmap, block, num);
|
||||
}
|
||||
|
||||
#undef _INLINE_
|
||||
#endif
|
||||
|
||||
extern int ext2fs_set_bit(unsigned int nr,void * addr);
|
||||
extern int ext2fs_clear_bit(unsigned int nr, void * addr);
|
||||
extern int ext2fs_test_bit(unsigned int nr, const void * addr);
|
||||
extern int ext2fs_set_bit64(__u64 nr,void * addr);
|
||||
extern int ext2fs_clear_bit64(__u64 nr, void * addr);
|
||||
extern int ext2fs_test_bit64(__u64 nr, const void * addr);
|
||||
extern unsigned int ext2fs_bitcount(const void *addr, unsigned int nbytes);
|
||||
106
include/e2fsprogs/ext2fs/bmap64.h
Executable file
106
include/e2fsprogs/ext2fs/bmap64.h
Executable file
@@ -0,0 +1,106 @@
|
||||
/*
|
||||
* bmap64.h --- 64-bit bitmap structure
|
||||
*
|
||||
* Copyright (C) 2007, 2008 Theodore Ts'o.
|
||||
*
|
||||
* %Begin-Header%
|
||||
* This file may be redistributed under the terms of the GNU Public
|
||||
* License.
|
||||
* %End-Header%
|
||||
*/
|
||||
|
||||
struct ext2_bmap_statistics {
|
||||
int type;
|
||||
struct timeval created;
|
||||
|
||||
#ifdef ENABLE_BMAP_STATS_OPS
|
||||
unsigned long copy_count;
|
||||
unsigned long resize_count;
|
||||
unsigned long mark_count;
|
||||
unsigned long unmark_count;
|
||||
unsigned long test_count;
|
||||
unsigned long mark_ext_count;
|
||||
unsigned long unmark_ext_count;
|
||||
unsigned long test_ext_count;
|
||||
unsigned long set_range_count;
|
||||
unsigned long get_range_count;
|
||||
unsigned long clear_count;
|
||||
|
||||
blk64_t last_marked;
|
||||
blk64_t last_tested;
|
||||
blk64_t mark_back;
|
||||
blk64_t test_back;
|
||||
|
||||
unsigned long mark_seq;
|
||||
unsigned long test_seq;
|
||||
#endif /* ENABLE_BMAP_STATS_OPS */
|
||||
};
|
||||
|
||||
|
||||
struct ext2fs_struct_generic_bitmap_64 {
|
||||
errcode_t magic;
|
||||
ext2_filsys fs;
|
||||
struct ext2_bitmap_ops *bitmap_ops;
|
||||
int flags;
|
||||
__u64 start, end;
|
||||
__u64 real_end;
|
||||
int cluster_bits;
|
||||
char *description;
|
||||
void *private;
|
||||
errcode_t base_error_code;
|
||||
#ifdef ENABLE_BMAP_STATS
|
||||
struct ext2_bmap_statistics stats;
|
||||
#endif
|
||||
};
|
||||
|
||||
typedef struct ext2fs_struct_generic_bitmap_64 *ext2fs_generic_bitmap_64;
|
||||
|
||||
#define EXT2FS_IS_32_BITMAP(bmap) \
|
||||
(((bmap)->magic == EXT2_ET_MAGIC_GENERIC_BITMAP) || \
|
||||
((bmap)->magic == EXT2_ET_MAGIC_BLOCK_BITMAP) || \
|
||||
((bmap)->magic == EXT2_ET_MAGIC_INODE_BITMAP))
|
||||
|
||||
#define EXT2FS_IS_64_BITMAP(bmap) \
|
||||
(((bmap)->magic == EXT2_ET_MAGIC_GENERIC_BITMAP64) || \
|
||||
((bmap)->magic == EXT2_ET_MAGIC_BLOCK_BITMAP64) || \
|
||||
((bmap)->magic == EXT2_ET_MAGIC_INODE_BITMAP64))
|
||||
|
||||
struct ext2_bitmap_ops {
|
||||
int type;
|
||||
/* Generic bmap operators */
|
||||
errcode_t (*new_bmap)(ext2_filsys fs, ext2fs_generic_bitmap_64 bmap);
|
||||
void (*free_bmap)(ext2fs_generic_bitmap_64 bitmap);
|
||||
errcode_t (*copy_bmap)(ext2fs_generic_bitmap_64 src,
|
||||
ext2fs_generic_bitmap_64 dest);
|
||||
errcode_t (*resize_bmap)(ext2fs_generic_bitmap_64 bitmap,
|
||||
__u64 new_end,
|
||||
__u64 new_real_end);
|
||||
/* bit set/test operators */
|
||||
int (*mark_bmap)(ext2fs_generic_bitmap_64 bitmap, __u64 arg);
|
||||
int (*unmark_bmap)(ext2fs_generic_bitmap_64 bitmap, __u64 arg);
|
||||
int (*test_bmap)(ext2fs_generic_bitmap_64 bitmap, __u64 arg);
|
||||
void (*mark_bmap_extent)(ext2fs_generic_bitmap_64 bitmap, __u64 arg,
|
||||
unsigned int num);
|
||||
void (*unmark_bmap_extent)(ext2fs_generic_bitmap_64 bitmap, __u64 arg,
|
||||
unsigned int num);
|
||||
int (*test_clear_bmap_extent)(ext2fs_generic_bitmap_64 bitmap,
|
||||
__u64 arg, unsigned int num);
|
||||
errcode_t (*set_bmap_range)(ext2fs_generic_bitmap_64 bitmap,
|
||||
__u64 start, size_t num, void *in);
|
||||
errcode_t (*get_bmap_range)(ext2fs_generic_bitmap_64 bitmap,
|
||||
__u64 start, size_t num, void *out);
|
||||
void (*clear_bmap)(ext2fs_generic_bitmap_64 bitmap);
|
||||
void (*print_stats)(ext2fs_generic_bitmap_64);
|
||||
|
||||
/* Find the first zero bit between start and end, inclusive.
|
||||
* May be NULL, in which case a generic function is used. */
|
||||
errcode_t (*find_first_zero)(ext2fs_generic_bitmap_64 bitmap,
|
||||
__u64 start, __u64 end, __u64 *out);
|
||||
/* Find the first set bit between start and end, inclusive.
|
||||
* May be NULL, in which case a generic function is used. */
|
||||
errcode_t (*find_first_set)(ext2fs_generic_bitmap_64 bitmap,
|
||||
__u64 start, __u64 end, __u64 *out);
|
||||
};
|
||||
|
||||
extern struct ext2_bitmap_ops ext2fs_blkmap64_bitarray;
|
||||
extern struct ext2_bitmap_ops ext2fs_blkmap64_rbtree;
|
||||
86
include/e2fsprogs/ext2fs/brel.h
Executable file
86
include/e2fsprogs/ext2fs/brel.h
Executable file
@@ -0,0 +1,86 @@
|
||||
/*
|
||||
* brel.h
|
||||
*
|
||||
* Copyright (C) 1996, 1997 Theodore Ts'o.
|
||||
*
|
||||
* %Begin-Header%
|
||||
* This file may be redistributed under the terms of the GNU Library
|
||||
* General Public License, version 2.
|
||||
* %End-Header%
|
||||
*/
|
||||
|
||||
struct ext2_block_relocate_entry {
|
||||
blk64_t new;
|
||||
__s16 offset;
|
||||
__u16 flags;
|
||||
union {
|
||||
blk64_t block_ref;
|
||||
ext2_ino_t inode_ref;
|
||||
} owner;
|
||||
};
|
||||
|
||||
#define RELOCATE_TYPE_REF 0x0007
|
||||
#define RELOCATE_BLOCK_REF 0x0001
|
||||
#define RELOCATE_INODE_REF 0x0002
|
||||
|
||||
typedef struct ext2_block_relocation_table *ext2_brel;
|
||||
|
||||
struct ext2_block_relocation_table {
|
||||
__u32 magic;
|
||||
char *name;
|
||||
blk64_t current;
|
||||
void *priv_data;
|
||||
|
||||
/*
|
||||
* Add a block relocation entry.
|
||||
*/
|
||||
errcode_t (*put)(ext2_brel brel, blk64_t old,
|
||||
struct ext2_block_relocate_entry *ent);
|
||||
|
||||
/*
|
||||
* Get a block relocation entry.
|
||||
*/
|
||||
errcode_t (*get)(ext2_brel brel, blk64_t old,
|
||||
struct ext2_block_relocate_entry *ent);
|
||||
|
||||
/*
|
||||
* Initialize for iterating over the block relocation entries.
|
||||
*/
|
||||
errcode_t (*start_iter)(ext2_brel brel);
|
||||
|
||||
/*
|
||||
* The iterator function for the inode relocation entries.
|
||||
* Returns an inode number of 0 when out of entries.
|
||||
*/
|
||||
errcode_t (*next)(ext2_brel brel, blk64_t *old,
|
||||
struct ext2_block_relocate_entry *ent);
|
||||
|
||||
/*
|
||||
* Move the inode relocation table from one block number to
|
||||
* another.
|
||||
*/
|
||||
errcode_t (*move)(ext2_brel brel, blk64_t old, blk_t new);
|
||||
|
||||
/*
|
||||
* Remove a block relocation entry.
|
||||
*/
|
||||
errcode_t (*delete)(ext2_brel brel, blk64_t old);
|
||||
|
||||
|
||||
/*
|
||||
* Free the block relocation table.
|
||||
*/
|
||||
errcode_t (*free)(ext2_brel brel);
|
||||
};
|
||||
|
||||
errcode_t ext2fs_brel_memarray_create(char *name, blk64_t max_block,
|
||||
ext2_brel *brel);
|
||||
|
||||
#define ext2fs_brel_put(brel, old, ent) ((brel)->put((brel), old, ent))
|
||||
#define ext2fs_brel_get(brel, old, ent) ((brel)->get((brel), old, ent))
|
||||
#define ext2fs_brel_start_iter(brel) ((brel)->start_iter((brel)))
|
||||
#define ext2fs_brel_next(brel, old, ent) ((brel)->next((brel), old, ent))
|
||||
#define ext2fs_brel_move(brel, old, new) ((brel)->move((brel), old, new))
|
||||
#define ext2fs_brel_delete(brel, old) ((brel)->delete((brel), old))
|
||||
#define ext2fs_brel_free(brel) ((brel)->free((brel)))
|
||||
|
||||
26
include/e2fsprogs/ext2fs/compiler.h
Executable file
26
include/e2fsprogs/ext2fs/compiler.h
Executable file
@@ -0,0 +1,26 @@
|
||||
#ifndef _EXT2FS_COMPILER_H
|
||||
#define _EXT2FS_COMPILER_H
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
#ifdef __GNUC__
|
||||
|
||||
#ifndef __GNUC_PREREQ
|
||||
#if defined(__GNUC__) && defined(__GNUC_MINOR__)
|
||||
#define __GNUC_PREREQ(maj, min) \
|
||||
((__GNUC__ << 16) + __GNUC_MINOR__ >= ((maj) << 16) + (min))
|
||||
#else
|
||||
#define __GNUC_PREREQ(maj, min) 0
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#define container_of(ptr, type, member) ({ \
|
||||
__typeof__( ((type *)0)->member ) *__mptr = (ptr); \
|
||||
(type *)( (char *)__mptr - offsetof(type,member) );})
|
||||
#else
|
||||
#define container_of(ptr, type, member) \
|
||||
((type *)((char *)(ptr) - offsetof(type, member)))
|
||||
#endif
|
||||
|
||||
|
||||
#endif /* _EXT2FS_COMPILER_H */
|
||||
74
include/e2fsprogs/ext2fs/crc16.c
Executable file
74
include/e2fsprogs/ext2fs/crc16.c
Executable file
@@ -0,0 +1,74 @@
|
||||
/*
|
||||
* crc16.c
|
||||
*
|
||||
* This source code is licensed under the GNU General Public License,
|
||||
* Version 2. See the file COPYING for more details.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
#if HAVE_SYS_TYPES_H
|
||||
#include <sys/types.h>
|
||||
#endif
|
||||
#include <ext2fs/ext2_types.h>
|
||||
|
||||
#include "crc16.h"
|
||||
|
||||
/** CRC table for the CRC-16. The poly is 0x8005 (x16 + x15 + x2 + 1) */
|
||||
static __u16 const crc16_table[256] = {
|
||||
0x0000, 0xC0C1, 0xC181, 0x0140, 0xC301, 0x03C0, 0x0280, 0xC241,
|
||||
0xC601, 0x06C0, 0x0780, 0xC741, 0x0500, 0xC5C1, 0xC481, 0x0440,
|
||||
0xCC01, 0x0CC0, 0x0D80, 0xCD41, 0x0F00, 0xCFC1, 0xCE81, 0x0E40,
|
||||
0x0A00, 0xCAC1, 0xCB81, 0x0B40, 0xC901, 0x09C0, 0x0880, 0xC841,
|
||||
0xD801, 0x18C0, 0x1980, 0xD941, 0x1B00, 0xDBC1, 0xDA81, 0x1A40,
|
||||
0x1E00, 0xDEC1, 0xDF81, 0x1F40, 0xDD01, 0x1DC0, 0x1C80, 0xDC41,
|
||||
0x1400, 0xD4C1, 0xD581, 0x1540, 0xD701, 0x17C0, 0x1680, 0xD641,
|
||||
0xD201, 0x12C0, 0x1380, 0xD341, 0x1100, 0xD1C1, 0xD081, 0x1040,
|
||||
0xF001, 0x30C0, 0x3180, 0xF141, 0x3300, 0xF3C1, 0xF281, 0x3240,
|
||||
0x3600, 0xF6C1, 0xF781, 0x3740, 0xF501, 0x35C0, 0x3480, 0xF441,
|
||||
0x3C00, 0xFCC1, 0xFD81, 0x3D40, 0xFF01, 0x3FC0, 0x3E80, 0xFE41,
|
||||
0xFA01, 0x3AC0, 0x3B80, 0xFB41, 0x3900, 0xF9C1, 0xF881, 0x3840,
|
||||
0x2800, 0xE8C1, 0xE981, 0x2940, 0xEB01, 0x2BC0, 0x2A80, 0xEA41,
|
||||
0xEE01, 0x2EC0, 0x2F80, 0xEF41, 0x2D00, 0xEDC1, 0xEC81, 0x2C40,
|
||||
0xE401, 0x24C0, 0x2580, 0xE541, 0x2700, 0xE7C1, 0xE681, 0x2640,
|
||||
0x2200, 0xE2C1, 0xE381, 0x2340, 0xE101, 0x21C0, 0x2080, 0xE041,
|
||||
0xA001, 0x60C0, 0x6180, 0xA141, 0x6300, 0xA3C1, 0xA281, 0x6240,
|
||||
0x6600, 0xA6C1, 0xA781, 0x6740, 0xA501, 0x65C0, 0x6480, 0xA441,
|
||||
0x6C00, 0xACC1, 0xAD81, 0x6D40, 0xAF01, 0x6FC0, 0x6E80, 0xAE41,
|
||||
0xAA01, 0x6AC0, 0x6B80, 0xAB41, 0x6900, 0xA9C1, 0xA881, 0x6840,
|
||||
0x7800, 0xB8C1, 0xB981, 0x7940, 0xBB01, 0x7BC0, 0x7A80, 0xBA41,
|
||||
0xBE01, 0x7EC0, 0x7F80, 0xBF41, 0x7D00, 0xBDC1, 0xBC81, 0x7C40,
|
||||
0xB401, 0x74C0, 0x7580, 0xB541, 0x7700, 0xB7C1, 0xB681, 0x7640,
|
||||
0x7200, 0xB2C1, 0xB381, 0x7340, 0xB101, 0x71C0, 0x7080, 0xB041,
|
||||
0x5000, 0x90C1, 0x9181, 0x5140, 0x9301, 0x53C0, 0x5280, 0x9241,
|
||||
0x9601, 0x56C0, 0x5780, 0x9741, 0x5500, 0x95C1, 0x9481, 0x5440,
|
||||
0x9C01, 0x5CC0, 0x5D80, 0x9D41, 0x5F00, 0x9FC1, 0x9E81, 0x5E40,
|
||||
0x5A00, 0x9AC1, 0x9B81, 0x5B40, 0x9901, 0x59C0, 0x5880, 0x9841,
|
||||
0x8801, 0x48C0, 0x4980, 0x8941, 0x4B00, 0x8BC1, 0x8A81, 0x4A40,
|
||||
0x4E00, 0x8EC1, 0x8F81, 0x4F40, 0x8D01, 0x4DC0, 0x4C80, 0x8C41,
|
||||
0x4400, 0x84C1, 0x8581, 0x4540, 0x8701, 0x47C0, 0x4680, 0x8641,
|
||||
0x8201, 0x42C0, 0x4380, 0x8341, 0x4100, 0x81C1, 0x8081, 0x4040
|
||||
};
|
||||
|
||||
/**
|
||||
* Compute the CRC-16 for the data buffer
|
||||
*
|
||||
* @param crc previous CRC value
|
||||
* @param buffer data pointer
|
||||
* @param len number of bytes in the buffer
|
||||
* @return the updated CRC value
|
||||
*/
|
||||
crc16_t ext2fs_crc16(crc16_t crc, const void *buffer, unsigned int len)
|
||||
{
|
||||
const unsigned char *cp = buffer;
|
||||
|
||||
while (len--)
|
||||
/*
|
||||
* for an unknown reason, PPC treats __u16 as signed
|
||||
* and keeps doing sign extension on the value.
|
||||
* Instead, use only the low 16 bits of an unsigned
|
||||
* int for holding the CRC value to avoid this.
|
||||
*/
|
||||
crc = (((crc >> 8) & 0xffU) ^
|
||||
crc16_table[(crc ^ *cp++) & 0xffU]) & 0x0000ffffU;
|
||||
return crc;
|
||||
}
|
||||
26
include/e2fsprogs/ext2fs/crc16.h
Executable file
26
include/e2fsprogs/ext2fs/crc16.h
Executable file
@@ -0,0 +1,26 @@
|
||||
/*
|
||||
* crc16.h - CRC-16 routine
|
||||
*
|
||||
* Implements the standard CRC-16:
|
||||
* Width 16
|
||||
* Poly 0x8005 (x16 + x15 + x2 + 1)
|
||||
* Init 0
|
||||
*
|
||||
* Copyright (c) 2005 Ben Gardner <bgardner@wabtec.com>
|
||||
*
|
||||
* This source code is licensed under the GNU General Public License,
|
||||
* Version 2. See the file COPYING for more details.
|
||||
*/
|
||||
|
||||
#ifndef __CRC16_H
|
||||
#define __CRC16_H
|
||||
|
||||
/* for an unknown reason, PPC treats __u16 as signed and keeps doing sign
|
||||
* extension on the value. Instead, use only the low 16 bits of an
|
||||
* unsigned int for holding the CRC value to avoid this.
|
||||
*/
|
||||
typedef unsigned int crc16_t;
|
||||
|
||||
extern crc16_t ext2fs_crc16(crc16_t crc, const void *buffer, unsigned int len);
|
||||
|
||||
#endif /* __CRC16_H */
|
||||
59
include/e2fsprogs/ext2fs/crc32c_defs.h
Executable file
59
include/e2fsprogs/ext2fs/crc32c_defs.h
Executable file
@@ -0,0 +1,59 @@
|
||||
/*
|
||||
* There are multiple 16-bit CRC polynomials in common use, but this is
|
||||
* *the* standard CRC-32 polynomial, first popularized by Ethernet.
|
||||
* x^32+x^26+x^23+x^22+x^16+x^12+x^11+x^10+x^8+x^7+x^5+x^4+x^2+x^1+x^0
|
||||
*/
|
||||
#define CRCPOLY_LE 0xedb88320
|
||||
#define CRCPOLY_BE 0x04c11db7
|
||||
|
||||
/*
|
||||
* This is the CRC32c polynomial, as outlined by Castagnoli.
|
||||
* x^32+x^28+x^27+x^26+x^25+x^23+x^22+x^20+x^19+x^18+x^14+x^13+x^11+x^10+x^9+
|
||||
* x^8+x^6+x^0
|
||||
*/
|
||||
#define CRC32C_POLY_LE 0x82F63B78
|
||||
#define CRC32C_POLY_BE 0x1EDC6F41
|
||||
|
||||
/* How many bits at a time to use. Valid values are 1, 2, 4, 8, 32 and 64. */
|
||||
/* For less performance-sensitive, use 4 */
|
||||
#ifndef CRC_LE_BITS
|
||||
# define CRC_LE_BITS 64
|
||||
#endif
|
||||
#ifndef CRC_BE_BITS
|
||||
# define CRC_BE_BITS 64
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Little-endian CRC computation. Used with serial bit streams sent
|
||||
* lsbit-first. Be sure to use cpu_to_le32() to append the computed CRC.
|
||||
*/
|
||||
#if CRC_LE_BITS > 64 || CRC_LE_BITS < 1 || CRC_LE_BITS == 16 || \
|
||||
CRC_LE_BITS & CRC_LE_BITS-1
|
||||
# error "CRC_LE_BITS must be one of {1, 2, 4, 8, 32, 64}"
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Big-endian CRC computation. Used with serial bit streams sent
|
||||
* msbit-first. Be sure to use cpu_to_be32() to append the computed CRC.
|
||||
*/
|
||||
#if CRC_BE_BITS > 64 || CRC_BE_BITS < 1 || CRC_BE_BITS == 16 || \
|
||||
CRC_BE_BITS & CRC_BE_BITS-1
|
||||
# error "CRC_BE_BITS must be one of {1, 2, 4, 8, 32, 64}"
|
||||
#endif
|
||||
|
||||
|
||||
#define ___constant_swab32(x) \
|
||||
((uint32_t)( \
|
||||
(((uint32_t)(x) & (uint32_t)0x000000ffUL) << 24) | \
|
||||
(((uint32_t)(x) & (uint32_t)0x0000ff00UL) << 8) | \
|
||||
(((uint32_t)(x) & (uint32_t)0x00ff0000UL) >> 8) | \
|
||||
(((uint32_t)(x) & (uint32_t)0xff000000UL) >> 24)))
|
||||
|
||||
|
||||
#if (__GNUC__ >= 3)
|
||||
#define likely(x) __builtin_expect(!!(x), 1)
|
||||
#define unlikely(x) __builtin_expect(!!(x), 0)
|
||||
#else
|
||||
#define likely(x) (x)
|
||||
#define unlikely(x) (x)
|
||||
#endif
|
||||
1044
include/e2fsprogs/ext2fs/crc32c_table.h
Executable file
1044
include/e2fsprogs/ext2fs/crc32c_table.h
Executable file
File diff suppressed because it is too large
Load Diff
157
include/e2fsprogs/ext2fs/dosio.h
Executable file
157
include/e2fsprogs/ext2fs/dosio.h
Executable file
@@ -0,0 +1,157 @@
|
||||
/*
|
||||
* v1.0
|
||||
*
|
||||
* Disk I/O include file for the ext2fs/DOS library.
|
||||
*
|
||||
* Copyright (c) 1997 Mark Habersack
|
||||
*
|
||||
* %Begin-Header%
|
||||
* This file may be redistributed under the terms of the GNU Library
|
||||
* General Public License, version 2.
|
||||
* %End-Header%
|
||||
*/
|
||||
|
||||
#ifndef __diskio_h
|
||||
#define __diskio_h
|
||||
#ifdef __TURBOC__
|
||||
#ifndef __LARGE__
|
||||
# error "ext2fs/DOS library requires LARGE model!"
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef __TURBOC__
|
||||
#include "msdos.h"
|
||||
#endif
|
||||
|
||||
/*
|
||||
* A helper structure used in LBA => CHS conversion
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
unsigned short cyl; /* Cylinder (or track) */
|
||||
unsigned short head;
|
||||
unsigned short sector;
|
||||
unsigned short offset; /* Offset of byte within the sector */
|
||||
} CHS;
|
||||
|
||||
/*
|
||||
* All partition data we need is here
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
char *dev; /* _Linux_ device name (like "/dev/hda1") */
|
||||
unsigned char phys; /* Physical DOS drive number */
|
||||
unsigned long start; /* LBA address of partition start */
|
||||
unsigned long len; /* length of partition in sectors */
|
||||
unsigned char pno; /* Partition number (read from *dev) */
|
||||
|
||||
/* This partition's drive geometry */
|
||||
unsigned short cyls;
|
||||
unsigned short heads;
|
||||
unsigned short sects;
|
||||
} PARTITION;
|
||||
|
||||
/*
|
||||
* PC partition table entry format
|
||||
*/
|
||||
#ifdef __DJGPP__
|
||||
#pragma pack(1)
|
||||
#endif
|
||||
typedef struct
|
||||
{
|
||||
unsigned char active;
|
||||
unsigned char start_head;
|
||||
unsigned char start_sec;
|
||||
unsigned char start_cyl;
|
||||
unsigned char type;
|
||||
unsigned char end_head;
|
||||
unsigned char end_sec;
|
||||
unsigned char end_cyl;
|
||||
unsigned long first_sec_rel;
|
||||
unsigned long size;
|
||||
} PTABLE_ENTRY;
|
||||
#ifdef __DJGPP__
|
||||
#pragma pack()
|
||||
#endif
|
||||
|
||||
/*
|
||||
* INT 0x13 operation codes
|
||||
*/
|
||||
#define DISK_READ 0x02
|
||||
#define DISK_WRITE 0x03
|
||||
#define DISK_GET_GEOMETRY 0x08
|
||||
#define DISK_READY 0x10
|
||||
|
||||
/*
|
||||
* Errors to put in _dio_error
|
||||
*/
|
||||
#define ERR_BADDEV 0x00000001L
|
||||
#define ERR_HARDWARE 0x00000002L
|
||||
#define ERR_NOTSUPP 0x00000003L
|
||||
#define ERR_NOTEXT2FS 0x00000004L
|
||||
#define ERR_EMPTYPART 0x00000005L
|
||||
#define ERR_LINUXSWAP 0x00000006L
|
||||
|
||||
/*
|
||||
* Functions in diskio.c
|
||||
*/
|
||||
|
||||
/*
|
||||
* Variable contains last module's error
|
||||
*/
|
||||
extern unsigned long _dio_error;
|
||||
|
||||
/*
|
||||
* This one contains last hardware error (if _dio_error == ERR_HARDWARE)
|
||||
*/
|
||||
extern unsigned long _dio_hw_error;
|
||||
|
||||
/*
|
||||
* Macros to check for disk hardware errors
|
||||
*/
|
||||
#define HW_OK() ((unsigned char)_dio_hw_error == 0x00)
|
||||
#define HW_BAD_CMD() ((unsigned char)_dio_hw_error == 0x01)
|
||||
#define HW_NO_ADDR_MARK() ((unsigned char)_dio_hw_error == 0x02)
|
||||
#define HW_WRITE_PROT() ((unsigned char)_dio_hw_error == 0x03)
|
||||
#define HW_NO_SECTOR() ((unsigned char)_dio_hw_error == 0x04)
|
||||
#define HW_RESET_FAIL() ((unsigned char)_dio_hw_error == 0x05)
|
||||
#define HW_DISK_CHANGED() ((unsigned char)_dio_hw_error == 0x06)
|
||||
#define HW_DRIVE_FAIL() ((unsigned char)_dio_hw_error == 0x07)
|
||||
#define HW_DMA_OVERRUN() ((unsigned char)_dio_hw_error == 0x08)
|
||||
#define HW_DMA_BOUNDARY() ((unsigned char)_dio_hw_error == 0x09)
|
||||
#define HW_BAD_SECTOR() ((unsigned char)_dio_hw_error == 0x0A)
|
||||
#define HW_BAD_TRACK() ((unsigned char)_dio_hw_error == 0x0B)
|
||||
#define HW_UNSUPP_TRACK() ((unsigned char)_dio_hw_error == 0x0C)
|
||||
#define HW_BAD_CRC_ECC() ((unsigned char)_dio_hw_error == 0x10)
|
||||
#define HW_CRC_ECC_CORR() ((unsigned char)_dio_hw_error == 0x11)
|
||||
#define HW_CONTR_FAIL() ((unsigned char)_dio_hw_error == 0x20)
|
||||
#define HW_SEEK_FAIL() ((unsigned char)_dio_hw_error == 0x40)
|
||||
#define HW_ATTACH_FAIL() ((unsigned char)_dio_hw_error == 0x80)
|
||||
#define HW_DRIVE_NREADY() ((unsigned char)_dio_hw_error == 0xAA)
|
||||
#define HW_UNDEF_ERROR() ((unsigned char)_dio_hw_error == 0xBB)
|
||||
#define HW_WRITE_FAULT() ((unsigned char)_dio_hw_error == 0xCC)
|
||||
#define HW_STATUS_ERROR() ((unsigned char)_dio_hw_error == 0xE0)
|
||||
#define HW_SENSE_FAIL() ((unsigned char)_dio_hw_error == 0xFF)
|
||||
|
||||
|
||||
/*
|
||||
* Open the specified partition.
|
||||
* String 'dev' must have a format:
|
||||
*
|
||||
* /dev/{sd|hd|fd}[X]
|
||||
*
|
||||
* where,
|
||||
*
|
||||
* only one of the option in curly braces can be used and X is an optional
|
||||
* partition number for the given device. If X is not specified, function
|
||||
* scans the drive's partition table in search for the first Linux ext2fs
|
||||
* partition (signature 0x83). Along the way it dives into every extended
|
||||
* partition encountered.
|
||||
* Scan ends if either (a) there are no more used partition entries, or
|
||||
* (b) there is no Xth partition.
|
||||
*
|
||||
* Routine returns 0 on success and !=0 otherwise.
|
||||
*/
|
||||
int open_partition(char *dev);
|
||||
|
||||
#endif /* __diskio_h */
|
||||
37
include/e2fsprogs/ext2fs/e2image.h
Executable file
37
include/e2fsprogs/ext2fs/e2image.h
Executable file
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
* e2image.h --- header file describing the ext2 image format
|
||||
*
|
||||
* Copyright (C) 2000 Theodore Ts'o.
|
||||
*
|
||||
* Note: this uses the POSIX IO interfaces, unlike most of the other
|
||||
* functions in this library. So sue me.
|
||||
*
|
||||
* %Begin-Header%
|
||||
* This file may be redistributed under the terms of the GNU Library
|
||||
* General Public License, version 2.
|
||||
* %End-Header%
|
||||
*/
|
||||
|
||||
struct ext2_image_hdr {
|
||||
__u32 magic_number; /* This must be EXT2_ET_MAGIC_E2IMAGE */
|
||||
char magic_descriptor[16]; /* "Ext2 Image 1.0", w/ null padding */
|
||||
char fs_hostname[64];/* Hostname of machine of image */
|
||||
char fs_netaddr[32]; /* Network address */
|
||||
__u32 fs_netaddr_type;/* 0 = IPV4, 1 = IPV6, etc. */
|
||||
__u32 fs_device; /* Device number of image */
|
||||
char fs_device_name[64]; /* Device name */
|
||||
char fs_uuid[16]; /* UUID of filesystem */
|
||||
__u32 fs_blocksize; /* Block size of the filesystem */
|
||||
__u32 fs_reserved[8];
|
||||
|
||||
__u32 image_device; /* Device number of image file */
|
||||
__u32 image_inode; /* Inode number of image file */
|
||||
__u32 image_time; /* Time of image creation */
|
||||
__u32 image_reserved[8];
|
||||
|
||||
__u32 offset_super; /* Byte offset of the sb and descriptors */
|
||||
__u32 offset_inode; /* Byte offset of the inode table */
|
||||
__u32 offset_inodemap; /* Byte offset of the inode bitmaps */
|
||||
__u32 offset_blockmap; /* Byte offset of the inode bitmaps */
|
||||
__u32 offset_reserved[8];
|
||||
};
|
||||
201
include/e2fsprogs/ext2fs/ext2_err.h
Executable file
201
include/e2fsprogs/ext2fs/ext2_err.h
Executable file
@@ -0,0 +1,201 @@
|
||||
/*
|
||||
* ext2_err.h:
|
||||
* This file is automatically generated; please do not edit it.
|
||||
*/
|
||||
|
||||
#include <et/com_err.h>
|
||||
|
||||
#define EXT2_ET_BASE (2133571328L)
|
||||
#define EXT2_ET_MAGIC_EXT2FS_FILSYS (2133571329L)
|
||||
#define EXT2_ET_MAGIC_BADBLOCKS_LIST (2133571330L)
|
||||
#define EXT2_ET_MAGIC_BADBLOCKS_ITERATE (2133571331L)
|
||||
#define EXT2_ET_MAGIC_INODE_SCAN (2133571332L)
|
||||
#define EXT2_ET_MAGIC_IO_CHANNEL (2133571333L)
|
||||
#define EXT2_ET_MAGIC_UNIX_IO_CHANNEL (2133571334L)
|
||||
#define EXT2_ET_MAGIC_IO_MANAGER (2133571335L)
|
||||
#define EXT2_ET_MAGIC_BLOCK_BITMAP (2133571336L)
|
||||
#define EXT2_ET_MAGIC_INODE_BITMAP (2133571337L)
|
||||
#define EXT2_ET_MAGIC_GENERIC_BITMAP (2133571338L)
|
||||
#define EXT2_ET_MAGIC_TEST_IO_CHANNEL (2133571339L)
|
||||
#define EXT2_ET_MAGIC_DBLIST (2133571340L)
|
||||
#define EXT2_ET_MAGIC_ICOUNT (2133571341L)
|
||||
#define EXT2_ET_MAGIC_PQ_IO_CHANNEL (2133571342L)
|
||||
#define EXT2_ET_MAGIC_EXT2_FILE (2133571343L)
|
||||
#define EXT2_ET_MAGIC_E2IMAGE (2133571344L)
|
||||
#define EXT2_ET_MAGIC_INODE_IO_CHANNEL (2133571345L)
|
||||
#define EXT2_ET_MAGIC_EXTENT_HANDLE (2133571346L)
|
||||
#define EXT2_ET_BAD_MAGIC (2133571347L)
|
||||
#define EXT2_ET_REV_TOO_HIGH (2133571348L)
|
||||
#define EXT2_ET_RO_FILSYS (2133571349L)
|
||||
#define EXT2_ET_GDESC_READ (2133571350L)
|
||||
#define EXT2_ET_GDESC_WRITE (2133571351L)
|
||||
#define EXT2_ET_GDESC_BAD_BLOCK_MAP (2133571352L)
|
||||
#define EXT2_ET_GDESC_BAD_INODE_MAP (2133571353L)
|
||||
#define EXT2_ET_GDESC_BAD_INODE_TABLE (2133571354L)
|
||||
#define EXT2_ET_INODE_BITMAP_WRITE (2133571355L)
|
||||
#define EXT2_ET_INODE_BITMAP_READ (2133571356L)
|
||||
#define EXT2_ET_BLOCK_BITMAP_WRITE (2133571357L)
|
||||
#define EXT2_ET_BLOCK_BITMAP_READ (2133571358L)
|
||||
#define EXT2_ET_INODE_TABLE_WRITE (2133571359L)
|
||||
#define EXT2_ET_INODE_TABLE_READ (2133571360L)
|
||||
#define EXT2_ET_NEXT_INODE_READ (2133571361L)
|
||||
#define EXT2_ET_UNEXPECTED_BLOCK_SIZE (2133571362L)
|
||||
#define EXT2_ET_DIR_CORRUPTED (2133571363L)
|
||||
#define EXT2_ET_SHORT_READ (2133571364L)
|
||||
#define EXT2_ET_SHORT_WRITE (2133571365L)
|
||||
#define EXT2_ET_DIR_NO_SPACE (2133571366L)
|
||||
#define EXT2_ET_NO_INODE_BITMAP (2133571367L)
|
||||
#define EXT2_ET_NO_BLOCK_BITMAP (2133571368L)
|
||||
#define EXT2_ET_BAD_INODE_NUM (2133571369L)
|
||||
#define EXT2_ET_BAD_BLOCK_NUM (2133571370L)
|
||||
#define EXT2_ET_EXPAND_DIR_ERR (2133571371L)
|
||||
#define EXT2_ET_TOOSMALL (2133571372L)
|
||||
#define EXT2_ET_BAD_BLOCK_MARK (2133571373L)
|
||||
#define EXT2_ET_BAD_BLOCK_UNMARK (2133571374L)
|
||||
#define EXT2_ET_BAD_BLOCK_TEST (2133571375L)
|
||||
#define EXT2_ET_BAD_INODE_MARK (2133571376L)
|
||||
#define EXT2_ET_BAD_INODE_UNMARK (2133571377L)
|
||||
#define EXT2_ET_BAD_INODE_TEST (2133571378L)
|
||||
#define EXT2_ET_FUDGE_BLOCK_BITMAP_END (2133571379L)
|
||||
#define EXT2_ET_FUDGE_INODE_BITMAP_END (2133571380L)
|
||||
#define EXT2_ET_BAD_IND_BLOCK (2133571381L)
|
||||
#define EXT2_ET_BAD_DIND_BLOCK (2133571382L)
|
||||
#define EXT2_ET_BAD_TIND_BLOCK (2133571383L)
|
||||
#define EXT2_ET_NEQ_BLOCK_BITMAP (2133571384L)
|
||||
#define EXT2_ET_NEQ_INODE_BITMAP (2133571385L)
|
||||
#define EXT2_ET_BAD_DEVICE_NAME (2133571386L)
|
||||
#define EXT2_ET_MISSING_INODE_TABLE (2133571387L)
|
||||
#define EXT2_ET_CORRUPT_SUPERBLOCK (2133571388L)
|
||||
#define EXT2_ET_BAD_GENERIC_MARK (2133571389L)
|
||||
#define EXT2_ET_BAD_GENERIC_UNMARK (2133571390L)
|
||||
#define EXT2_ET_BAD_GENERIC_TEST (2133571391L)
|
||||
#define EXT2_ET_SYMLINK_LOOP (2133571392L)
|
||||
#define EXT2_ET_CALLBACK_NOTHANDLED (2133571393L)
|
||||
#define EXT2_ET_BAD_BLOCK_IN_INODE_TABLE (2133571394L)
|
||||
#define EXT2_ET_UNSUPP_FEATURE (2133571395L)
|
||||
#define EXT2_ET_RO_UNSUPP_FEATURE (2133571396L)
|
||||
#define EXT2_ET_LLSEEK_FAILED (2133571397L)
|
||||
#define EXT2_ET_NO_MEMORY (2133571398L)
|
||||
#define EXT2_ET_INVALID_ARGUMENT (2133571399L)
|
||||
#define EXT2_ET_BLOCK_ALLOC_FAIL (2133571400L)
|
||||
#define EXT2_ET_INODE_ALLOC_FAIL (2133571401L)
|
||||
#define EXT2_ET_NO_DIRECTORY (2133571402L)
|
||||
#define EXT2_ET_TOO_MANY_REFS (2133571403L)
|
||||
#define EXT2_ET_FILE_NOT_FOUND (2133571404L)
|
||||
#define EXT2_ET_FILE_RO (2133571405L)
|
||||
#define EXT2_ET_DB_NOT_FOUND (2133571406L)
|
||||
#define EXT2_ET_DIR_EXISTS (2133571407L)
|
||||
#define EXT2_ET_UNIMPLEMENTED (2133571408L)
|
||||
#define EXT2_ET_CANCEL_REQUESTED (2133571409L)
|
||||
#define EXT2_ET_FILE_TOO_BIG (2133571410L)
|
||||
#define EXT2_ET_JOURNAL_NOT_BLOCK (2133571411L)
|
||||
#define EXT2_ET_NO_JOURNAL_SB (2133571412L)
|
||||
#define EXT2_ET_JOURNAL_TOO_SMALL (2133571413L)
|
||||
#define EXT2_ET_JOURNAL_UNSUPP_VERSION (2133571414L)
|
||||
#define EXT2_ET_LOAD_EXT_JOURNAL (2133571415L)
|
||||
#define EXT2_ET_NO_JOURNAL (2133571416L)
|
||||
#define EXT2_ET_DIRHASH_UNSUPP (2133571417L)
|
||||
#define EXT2_ET_BAD_EA_BLOCK_NUM (2133571418L)
|
||||
#define EXT2_ET_TOO_MANY_INODES (2133571419L)
|
||||
#define EXT2_ET_NOT_IMAGE_FILE (2133571420L)
|
||||
#define EXT2_ET_RES_GDT_BLOCKS (2133571421L)
|
||||
#define EXT2_ET_RESIZE_INODE_CORRUPT (2133571422L)
|
||||
#define EXT2_ET_SET_BMAP_NO_IND (2133571423L)
|
||||
#define EXT2_ET_TDB_SUCCESS (2133571424L)
|
||||
#define EXT2_ET_TDB_ERR_CORRUPT (2133571425L)
|
||||
#define EXT2_ET_TDB_ERR_IO (2133571426L)
|
||||
#define EXT2_ET_TDB_ERR_LOCK (2133571427L)
|
||||
#define EXT2_ET_TDB_ERR_OOM (2133571428L)
|
||||
#define EXT2_ET_TDB_ERR_EXISTS (2133571429L)
|
||||
#define EXT2_ET_TDB_ERR_NOLOCK (2133571430L)
|
||||
#define EXT2_ET_TDB_ERR_EINVAL (2133571431L)
|
||||
#define EXT2_ET_TDB_ERR_NOEXIST (2133571432L)
|
||||
#define EXT2_ET_TDB_ERR_RDONLY (2133571433L)
|
||||
#define EXT2_ET_DBLIST_EMPTY (2133571434L)
|
||||
#define EXT2_ET_RO_BLOCK_ITERATE (2133571435L)
|
||||
#define EXT2_ET_MAGIC_EXTENT_PATH (2133571436L)
|
||||
#define EXT2_ET_MAGIC_GENERIC_BITMAP64 (2133571437L)
|
||||
#define EXT2_ET_MAGIC_BLOCK_BITMAP64 (2133571438L)
|
||||
#define EXT2_ET_MAGIC_INODE_BITMAP64 (2133571439L)
|
||||
#define EXT2_ET_MAGIC_RESERVED_13 (2133571440L)
|
||||
#define EXT2_ET_MAGIC_RESERVED_14 (2133571441L)
|
||||
#define EXT2_ET_MAGIC_RESERVED_15 (2133571442L)
|
||||
#define EXT2_ET_MAGIC_RESERVED_16 (2133571443L)
|
||||
#define EXT2_ET_MAGIC_RESERVED_17 (2133571444L)
|
||||
#define EXT2_ET_MAGIC_RESERVED_18 (2133571445L)
|
||||
#define EXT2_ET_MAGIC_RESERVED_19 (2133571446L)
|
||||
#define EXT2_ET_EXTENT_HEADER_BAD (2133571447L)
|
||||
#define EXT2_ET_EXTENT_INDEX_BAD (2133571448L)
|
||||
#define EXT2_ET_EXTENT_LEAF_BAD (2133571449L)
|
||||
#define EXT2_ET_EXTENT_NO_SPACE (2133571450L)
|
||||
#define EXT2_ET_INODE_NOT_EXTENT (2133571451L)
|
||||
#define EXT2_ET_EXTENT_NO_NEXT (2133571452L)
|
||||
#define EXT2_ET_EXTENT_NO_PREV (2133571453L)
|
||||
#define EXT2_ET_EXTENT_NO_UP (2133571454L)
|
||||
#define EXT2_ET_EXTENT_NO_DOWN (2133571455L)
|
||||
#define EXT2_ET_NO_CURRENT_NODE (2133571456L)
|
||||
#define EXT2_ET_OP_NOT_SUPPORTED (2133571457L)
|
||||
#define EXT2_ET_CANT_INSERT_EXTENT (2133571458L)
|
||||
#define EXT2_ET_CANT_SPLIT_EXTENT (2133571459L)
|
||||
#define EXT2_ET_EXTENT_NOT_FOUND (2133571460L)
|
||||
#define EXT2_ET_EXTENT_NOT_SUPPORTED (2133571461L)
|
||||
#define EXT2_ET_EXTENT_INVALID_LENGTH (2133571462L)
|
||||
#define EXT2_ET_IO_CHANNEL_NO_SUPPORT_64 (2133571463L)
|
||||
#define EXT2_ET_NO_MTAB_FILE (2133571464L)
|
||||
#define EXT2_ET_CANT_USE_LEGACY_BITMAPS (2133571465L)
|
||||
#define EXT2_ET_MMP_MAGIC_INVALID (2133571466L)
|
||||
#define EXT2_ET_MMP_FAILED (2133571467L)
|
||||
#define EXT2_ET_MMP_FSCK_ON (2133571468L)
|
||||
#define EXT2_ET_MMP_BAD_BLOCK (2133571469L)
|
||||
#define EXT2_ET_MMP_UNKNOWN_SEQ (2133571470L)
|
||||
#define EXT2_ET_MMP_CHANGE_ABORT (2133571471L)
|
||||
#define EXT2_ET_MMP_OPEN_DIRECT (2133571472L)
|
||||
#define EXT2_ET_BAD_DESC_SIZE (2133571473L)
|
||||
#define EXT2_ET_INODE_CSUM_INVALID (2133571474L)
|
||||
#define EXT2_ET_INODE_BITMAP_CSUM_INVALID (2133571475L)
|
||||
#define EXT2_ET_EXTENT_CSUM_INVALID (2133571476L)
|
||||
#define EXT2_ET_DIR_NO_SPACE_FOR_CSUM (2133571477L)
|
||||
#define EXT2_ET_DIR_CSUM_INVALID (2133571478L)
|
||||
#define EXT2_ET_EXT_ATTR_CSUM_INVALID (2133571479L)
|
||||
#define EXT2_ET_SB_CSUM_INVALID (2133571480L)
|
||||
#define EXT2_ET_UNKNOWN_CSUM (2133571481L)
|
||||
#define EXT2_ET_MMP_CSUM_INVALID (2133571482L)
|
||||
#define EXT2_ET_FILE_EXISTS (2133571483L)
|
||||
#define EXT2_ET_BLOCK_BITMAP_CSUM_INVALID (2133571484L)
|
||||
#define EXT2_ET_INLINE_DATA_CANT_ITERATE (2133571485L)
|
||||
#define EXT2_ET_EA_BAD_NAME_LEN (2133571486L)
|
||||
#define EXT2_ET_EA_BAD_VALUE_SIZE (2133571487L)
|
||||
#define EXT2_ET_BAD_EA_HASH (2133571488L)
|
||||
#define EXT2_ET_BAD_EA_HEADER (2133571489L)
|
||||
#define EXT2_ET_EA_KEY_NOT_FOUND (2133571490L)
|
||||
#define EXT2_ET_EA_NO_SPACE (2133571491L)
|
||||
#define EXT2_ET_MISSING_EA_FEATURE (2133571492L)
|
||||
#define EXT2_ET_NO_INLINE_DATA (2133571493L)
|
||||
#define EXT2_ET_INLINE_DATA_NO_BLOCK (2133571494L)
|
||||
#define EXT2_ET_INLINE_DATA_NO_SPACE (2133571495L)
|
||||
#define EXT2_ET_MAGIC_EA_HANDLE (2133571496L)
|
||||
#define EXT2_ET_INODE_IS_GARBAGE (2133571497L)
|
||||
#define EXT2_ET_EA_BAD_VALUE_OFFSET (2133571498L)
|
||||
#define EXT2_ET_JOURNAL_FLAGS_WRONG (2133571499L)
|
||||
#define EXT2_ET_UNDO_FILE_CORRUPT (2133571500L)
|
||||
#define EXT2_ET_UNDO_FILE_WRONG (2133571501L)
|
||||
#define EXT2_ET_FILESYSTEM_CORRUPTED (2133571502L)
|
||||
#define EXT2_ET_BAD_CRC (2133571503L)
|
||||
#define EXT2_ET_CORRUPT_JOURNAL_SB (2133571504L)
|
||||
#define EXT2_ET_INODE_CORRUPTED (2133571505L)
|
||||
#define EXT2_ET_EA_INODE_CORRUPTED (2133571506L)
|
||||
#define EXT2_ET_NO_GDESC (2133571507L)
|
||||
#define EXT2_FILSYS_CORRUPTED (2133571508L)
|
||||
#define EXT2_ET_EXTENT_CYCLE (2133571509L)
|
||||
#define EXT2_ET_EXTERNAL_JOURNAL_NOSUPP (2133571510L)
|
||||
extern const struct error_table et_ext2_error_table;
|
||||
extern void initialize_ext2_error_table(void);
|
||||
|
||||
/* For compatibility with Heimdal */
|
||||
extern void initialize_ext2_error_table_r(struct et_list **list);
|
||||
|
||||
#define ERROR_TABLE_BASE_ext2 (2133571328L)
|
||||
|
||||
/* for compatibility with older versions... */
|
||||
#define init_ext2_err_tbl initialize_ext2_error_table
|
||||
#define ext2_err_base ERROR_TABLE_BASE_ext2
|
||||
73
include/e2fsprogs/ext2fs/ext2_ext_attr.h
Executable file
73
include/e2fsprogs/ext2fs/ext2_ext_attr.h
Executable file
@@ -0,0 +1,73 @@
|
||||
/*
|
||||
File: linux/ext2_ext_attr.h
|
||||
|
||||
On-disk format of extended attributes for the ext2 filesystem.
|
||||
|
||||
(C) 2000 Andreas Gruenbacher, <a.gruenbacher@computer.org>
|
||||
*/
|
||||
|
||||
#ifndef _EXT2_EXT_ATTR_H
|
||||
#define _EXT2_EXT_ATTR_H
|
||||
/* Magic value in attribute blocks */
|
||||
#define EXT2_EXT_ATTR_MAGIC_v1 0xEA010000
|
||||
#define EXT2_EXT_ATTR_MAGIC 0xEA020000
|
||||
|
||||
/* Maximum number of references to one attribute block */
|
||||
#define EXT2_EXT_ATTR_REFCOUNT_MAX 1024
|
||||
|
||||
struct ext2_ext_attr_header {
|
||||
__u32 h_magic; /* magic number for identification */
|
||||
__u32 h_refcount; /* reference count */
|
||||
__u32 h_blocks; /* number of disk blocks used */
|
||||
__u32 h_hash; /* hash value of all attributes */
|
||||
__u32 h_checksum; /* crc32c(uuid+id+xattrs) */
|
||||
/* id = inum if refcount = 1, else blknum */
|
||||
__u32 h_reserved[3]; /* zero right now */
|
||||
};
|
||||
|
||||
struct ext2_ext_attr_entry {
|
||||
__u8 e_name_len; /* length of name */
|
||||
__u8 e_name_index; /* attribute name index */
|
||||
__u16 e_value_offs; /* offset in disk block of value */
|
||||
__u32 e_value_inum; /* inode in which the value is stored */
|
||||
__u32 e_value_size; /* size of attribute value */
|
||||
__u32 e_hash; /* hash value of name and value */
|
||||
#if 0
|
||||
char e_name[0]; /* attribute name */
|
||||
#endif
|
||||
};
|
||||
|
||||
#define EXT2_EXT_ATTR_PAD_BITS 2
|
||||
#define EXT2_EXT_ATTR_PAD ((unsigned) 1<<EXT2_EXT_ATTR_PAD_BITS)
|
||||
#define EXT2_EXT_ATTR_ROUND (EXT2_EXT_ATTR_PAD-1)
|
||||
#define EXT2_EXT_ATTR_LEN(name_len) \
|
||||
(((name_len) + EXT2_EXT_ATTR_ROUND + \
|
||||
sizeof(struct ext2_ext_attr_entry)) & ~EXT2_EXT_ATTR_ROUND)
|
||||
#define EXT2_EXT_ATTR_NEXT(entry) \
|
||||
( (struct ext2_ext_attr_entry *)( \
|
||||
(char *)(entry) + EXT2_EXT_ATTR_LEN((entry)->e_name_len)) )
|
||||
#define EXT2_EXT_ATTR_SIZE(size) \
|
||||
(((size) + EXT2_EXT_ATTR_ROUND) & ~EXT2_EXT_ATTR_ROUND)
|
||||
#define EXT2_EXT_IS_LAST_ENTRY(entry) (*((__u32 *)(entry)) == 0UL)
|
||||
#define EXT2_EXT_ATTR_NAME(entry) \
|
||||
(((char *) (entry)) + sizeof(struct ext2_ext_attr_entry))
|
||||
#define EXT2_XATTR_LEN(name_len) \
|
||||
(((name_len) + EXT2_EXT_ATTR_ROUND + \
|
||||
sizeof(struct ext2_xattr_entry)) & ~EXT2_EXT_ATTR_ROUND)
|
||||
#define EXT2_XATTR_SIZE(size) \
|
||||
(((size) + EXT2_EXT_ATTR_ROUND) & ~EXT2_EXT_ATTR_ROUND)
|
||||
|
||||
#ifdef __KERNEL__
|
||||
# ifdef CONFIG_EXT2_FS_EXT_ATTR
|
||||
extern int ext2_get_ext_attr(struct inode *, const char *, char *, size_t, int);
|
||||
extern int ext2_set_ext_attr(struct inode *, const char *, char *, size_t, int);
|
||||
extern void ext2_ext_attr_free_inode(struct inode *inode);
|
||||
extern void ext2_ext_attr_put_super(struct super_block *sb);
|
||||
extern int ext2_ext_attr_init(void);
|
||||
extern void ext2_ext_attr_done(void);
|
||||
# else
|
||||
# define ext2_get_ext_attr NULL
|
||||
# define ext2_set_ext_attr NULL
|
||||
# endif
|
||||
#endif /* __KERNEL__ */
|
||||
#endif /* _EXT2_EXT_ATTR_H */
|
||||
1189
include/e2fsprogs/ext2fs/ext2_fs.h
Executable file
1189
include/e2fsprogs/ext2fs/ext2_fs.h
Executable file
File diff suppressed because it is too large
Load Diff
179
include/e2fsprogs/ext2fs/ext2_io.h
Executable file
179
include/e2fsprogs/ext2fs/ext2_io.h
Executable file
@@ -0,0 +1,179 @@
|
||||
/*
|
||||
* io.h --- the I/O manager abstraction
|
||||
*
|
||||
* Copyright (C) 1993, 1994, 1995, 1996 Theodore Ts'o.
|
||||
*
|
||||
* %Begin-Header%
|
||||
* This file may be redistributed under the terms of the GNU Library
|
||||
* General Public License, version 2.
|
||||
* %End-Header%
|
||||
*/
|
||||
|
||||
#ifndef _EXT2FS_EXT2_IO_H
|
||||
#define _EXT2FS_EXT2_IO_H
|
||||
|
||||
#include <ext2fs/ext2_types.h>
|
||||
|
||||
/*
|
||||
* ext2_loff_t is defined here since unix_io.c needs it.
|
||||
*/
|
||||
#if defined(__GNUC__) || defined(HAS_LONG_LONG)
|
||||
typedef long long ext2_loff_t;
|
||||
#else
|
||||
typedef long ext2_loff_t;
|
||||
#endif
|
||||
|
||||
/* llseek.c */
|
||||
ext2_loff_t ext2fs_llseek (int, ext2_loff_t, int);
|
||||
|
||||
typedef struct struct_io_manager *io_manager;
|
||||
typedef struct struct_io_channel *io_channel;
|
||||
typedef struct struct_io_stats *io_stats;
|
||||
|
||||
#define CHANNEL_FLAGS_WRITETHROUGH 0x01
|
||||
#define CHANNEL_FLAGS_DISCARD_ZEROES 0x02
|
||||
#define CHANNEL_FLAGS_BLOCK_DEVICE 0x04
|
||||
#define CHANNEL_FLAGS_THREADS 0x08
|
||||
|
||||
#define io_channel_discard_zeroes_data(i) (i->flags & CHANNEL_FLAGS_DISCARD_ZEROES)
|
||||
|
||||
struct struct_io_channel {
|
||||
errcode_t magic;
|
||||
io_manager manager;
|
||||
char *name;
|
||||
int block_size;
|
||||
errcode_t (*read_error)(io_channel channel,
|
||||
unsigned long block,
|
||||
int count,
|
||||
void *data,
|
||||
size_t size,
|
||||
int actual_bytes_read,
|
||||
errcode_t error);
|
||||
errcode_t (*write_error)(io_channel channel,
|
||||
unsigned long block,
|
||||
int count,
|
||||
const void *data,
|
||||
size_t size,
|
||||
int actual_bytes_written,
|
||||
errcode_t error);
|
||||
int refcount;
|
||||
int flags;
|
||||
long reserved[14];
|
||||
void *private_data;
|
||||
void *app_data;
|
||||
int align;
|
||||
};
|
||||
|
||||
struct struct_io_stats {
|
||||
int num_fields;
|
||||
int reserved;
|
||||
unsigned long long bytes_read;
|
||||
unsigned long long bytes_written;
|
||||
};
|
||||
|
||||
struct struct_io_manager {
|
||||
errcode_t magic;
|
||||
const char *name;
|
||||
errcode_t (*open)(const char *name, int flags, io_channel *channel);
|
||||
errcode_t (*close)(io_channel channel);
|
||||
errcode_t (*set_blksize)(io_channel channel, int blksize);
|
||||
errcode_t (*read_blk)(io_channel channel, unsigned long block,
|
||||
int count, void *data);
|
||||
errcode_t (*write_blk)(io_channel channel, unsigned long block,
|
||||
int count, const void *data);
|
||||
errcode_t (*flush)(io_channel channel);
|
||||
errcode_t (*write_byte)(io_channel channel, unsigned long offset,
|
||||
int count, const void *data);
|
||||
errcode_t (*set_option)(io_channel channel, const char *option,
|
||||
const char *arg);
|
||||
errcode_t (*get_stats)(io_channel channel, io_stats *io_stats);
|
||||
errcode_t (*read_blk64)(io_channel channel, unsigned long long block,
|
||||
int count, void *data);
|
||||
errcode_t (*write_blk64)(io_channel channel, unsigned long long block,
|
||||
int count, const void *data);
|
||||
errcode_t (*discard)(io_channel channel, unsigned long long block,
|
||||
unsigned long long count);
|
||||
errcode_t (*cache_readahead)(io_channel channel,
|
||||
unsigned long long block,
|
||||
unsigned long long count);
|
||||
errcode_t (*zeroout)(io_channel channel, unsigned long long block,
|
||||
unsigned long long count);
|
||||
long reserved[14];
|
||||
};
|
||||
|
||||
#define IO_FLAG_RW 0x0001
|
||||
#define IO_FLAG_EXCLUSIVE 0x0002
|
||||
#define IO_FLAG_DIRECT_IO 0x0004
|
||||
#define IO_FLAG_FORCE_BOUNCE 0x0008
|
||||
#define IO_FLAG_THREADS 0x0010
|
||||
#define IO_FLAG_NOCACHE 0x0020
|
||||
|
||||
/*
|
||||
* Convenience functions....
|
||||
*/
|
||||
#define io_channel_close(c) ((c)->manager->close((c)))
|
||||
#define io_channel_set_blksize(c,s) ((c)->manager->set_blksize((c),s))
|
||||
#define io_channel_read_blk(c,b,n,d) ((c)->manager->read_blk((c),b,n,d))
|
||||
#define io_channel_write_blk(c,b,n,d) ((c)->manager->write_blk((c),b,n,d))
|
||||
#define io_channel_flush(c) ((c)->manager->flush((c)))
|
||||
#define io_channel_bumpcount(c) ((c)->refcount++)
|
||||
|
||||
/* io_manager.c */
|
||||
extern errcode_t io_channel_set_options(io_channel channel,
|
||||
const char *options);
|
||||
extern errcode_t io_channel_write_byte(io_channel channel,
|
||||
unsigned long offset,
|
||||
int count, const void *data);
|
||||
extern errcode_t io_channel_read_blk64(io_channel channel,
|
||||
unsigned long long block,
|
||||
int count, void *data);
|
||||
extern errcode_t io_channel_write_blk64(io_channel channel,
|
||||
unsigned long long block,
|
||||
int count, const void *data);
|
||||
extern errcode_t io_channel_discard(io_channel channel,
|
||||
unsigned long long block,
|
||||
unsigned long long count);
|
||||
extern errcode_t io_channel_zeroout(io_channel channel,
|
||||
unsigned long long block,
|
||||
unsigned long long count);
|
||||
extern errcode_t io_channel_alloc_buf(io_channel channel,
|
||||
int count, void *ptr);
|
||||
extern errcode_t io_channel_cache_readahead(io_channel io,
|
||||
unsigned long long block,
|
||||
unsigned long long count);
|
||||
|
||||
#ifdef _WIN32
|
||||
/* windows_io.c */
|
||||
extern io_manager windows_io_manager;
|
||||
#define default_io_manager windows_io_manager
|
||||
#else
|
||||
/* unix_io.c */
|
||||
extern io_manager unix_io_manager;
|
||||
extern io_manager unixfd_io_manager;
|
||||
#define default_io_manager unix_io_manager
|
||||
#endif
|
||||
|
||||
/* sparse_io.c */
|
||||
extern io_manager sparse_io_manager;
|
||||
extern io_manager sparsefd_io_manager;
|
||||
|
||||
/* undo_io.c */
|
||||
extern io_manager undo_io_manager;
|
||||
extern errcode_t set_undo_io_backing_manager(io_manager manager);
|
||||
extern errcode_t set_undo_io_backup_file(char *file_name);
|
||||
|
||||
/* test_io.c */
|
||||
extern io_manager test_io_manager, test_io_backing_manager;
|
||||
extern void (*test_io_cb_read_blk)
|
||||
(unsigned long block, int count, errcode_t err);
|
||||
extern void (*test_io_cb_write_blk)
|
||||
(unsigned long block, int count, errcode_t err);
|
||||
extern void (*test_io_cb_read_blk64)
|
||||
(unsigned long long block, int count, errcode_t err);
|
||||
extern void (*test_io_cb_write_blk64)
|
||||
(unsigned long long block, int count, errcode_t err);
|
||||
extern void (*test_io_cb_set_blksize)
|
||||
(int blksize, errcode_t err);
|
||||
|
||||
#endif /* _EXT2FS_EXT2_IO_H */
|
||||
|
||||
45
include/e2fsprogs/ext2fs/ext2_types.h
Executable file
45
include/e2fsprogs/ext2fs/ext2_types.h
Executable file
@@ -0,0 +1,45 @@
|
||||
/*
|
||||
* If linux/types.h is already been included, assume it has defined
|
||||
* everything we need. (cross fingers) Other header files may have
|
||||
* also defined the types that we need.
|
||||
*/
|
||||
#if (!defined(_LINUX_TYPES_H) && !defined(_BLKID_TYPES_H) && \
|
||||
!defined(_EXT2_TYPES_H) && !defined(_UUID_TYPES_H))
|
||||
#define _EXT2_TYPES_H
|
||||
|
||||
typedef unsigned char __u8;
|
||||
typedef __signed__ char __s8;
|
||||
typedef unsigned short __u16;
|
||||
typedef __signed__ short __s16;
|
||||
typedef unsigned int __u32;
|
||||
typedef __signed__ int __s32;
|
||||
typedef unsigned long long __u64;
|
||||
typedef __signed__ long long __s64;
|
||||
#endif
|
||||
|
||||
#include <stdint.h> //uintptr_t
|
||||
|
||||
/* endian checking stuff */
|
||||
#ifndef EXT2_ENDIAN_H_
|
||||
#define EXT2_ENDIAN_H_
|
||||
|
||||
#ifdef __CHECKER__
|
||||
#ifndef __bitwise
|
||||
#define __bitwise __attribute__((bitwise))
|
||||
#endif
|
||||
#define __force __attribute__((force))
|
||||
#else
|
||||
#ifndef __bitwise
|
||||
#define __bitwise
|
||||
#endif
|
||||
#define __force
|
||||
#endif
|
||||
|
||||
typedef __u16 __bitwise __le16;
|
||||
typedef __u32 __bitwise __le32;
|
||||
typedef __u64 __bitwise __le64;
|
||||
typedef __u16 __bitwise __be16;
|
||||
typedef __u32 __bitwise __be32;
|
||||
typedef __u64 __bitwise __be64;
|
||||
|
||||
#endif /* EXT2_ENDIAN_H_ */
|
||||
2191
include/e2fsprogs/ext2fs/ext2fs.h
Executable file
2191
include/e2fsprogs/ext2fs/ext2fs.h
Executable file
File diff suppressed because it is too large
Load Diff
210
include/e2fsprogs/ext2fs/ext2fsP.h
Executable file
210
include/e2fsprogs/ext2fs/ext2fsP.h
Executable file
@@ -0,0 +1,210 @@
|
||||
/*
|
||||
* ext2fsP.h --- private header file for ext2 library
|
||||
*
|
||||
* Copyright (C) 1997 Theodore Ts'o.
|
||||
*
|
||||
* %Begin-Header%
|
||||
* This file may be redistributed under the terms of the GNU Library
|
||||
* General Public License, version 2.
|
||||
* %End-Header%
|
||||
*/
|
||||
|
||||
#if HAVE_SYS_STAT_H
|
||||
#include <sys/stat.h>
|
||||
#endif
|
||||
|
||||
#include "ext2fs.h"
|
||||
|
||||
#define EXT2FS_MAX_NESTED_LINKS 8
|
||||
|
||||
static inline int ext2fsP_is_disk_device(mode_t mode)
|
||||
{
|
||||
#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
|
||||
return S_ISBLK(mode) || S_ISCHR(mode);
|
||||
#else
|
||||
return S_ISBLK(mode);
|
||||
#endif
|
||||
}
|
||||
|
||||
/*
|
||||
* Badblocks list
|
||||
*/
|
||||
struct ext2_struct_u32_list {
|
||||
int magic;
|
||||
int num;
|
||||
int size;
|
||||
__u32 *list;
|
||||
int badblocks_flags;
|
||||
};
|
||||
|
||||
struct ext2_struct_u32_iterate {
|
||||
int magic;
|
||||
ext2_u32_list bb;
|
||||
int ptr;
|
||||
};
|
||||
|
||||
|
||||
/*
|
||||
* Directory block iterator definition
|
||||
*/
|
||||
struct ext2_struct_dblist {
|
||||
int magic;
|
||||
ext2_filsys fs;
|
||||
unsigned long long size;
|
||||
unsigned long long count;
|
||||
int sorted;
|
||||
struct ext2_db_entry2 * list;
|
||||
};
|
||||
|
||||
/*
|
||||
* For directory iterators
|
||||
*/
|
||||
struct dir_context {
|
||||
ext2_ino_t dir;
|
||||
int flags;
|
||||
char *buf;
|
||||
unsigned int buflen;
|
||||
int (*func)(ext2_ino_t dir,
|
||||
int entry,
|
||||
struct ext2_dir_entry *dirent,
|
||||
int offset,
|
||||
int blocksize,
|
||||
char *buf,
|
||||
void *priv_data);
|
||||
void *priv_data;
|
||||
errcode_t errcode;
|
||||
};
|
||||
|
||||
/*
|
||||
* Inode cache structure
|
||||
*/
|
||||
struct ext2_inode_cache {
|
||||
void * buffer;
|
||||
blk64_t buffer_blk;
|
||||
int cache_last;
|
||||
unsigned int cache_size;
|
||||
int refcount;
|
||||
struct ext2_inode_cache_ent *cache;
|
||||
};
|
||||
|
||||
struct ext2_inode_cache_ent {
|
||||
ext2_ino_t ino;
|
||||
struct ext2_inode *inode;
|
||||
};
|
||||
|
||||
/*
|
||||
* NLS definitions
|
||||
*/
|
||||
struct ext2fs_nls_table {
|
||||
int version;
|
||||
const struct ext2fs_nls_ops *ops;
|
||||
};
|
||||
|
||||
struct ext2fs_nls_ops {
|
||||
int (*casefold)(const struct ext2fs_nls_table *charset,
|
||||
const unsigned char *str, size_t len,
|
||||
unsigned char *dest, size_t dlen);
|
||||
int (*validate)(const struct ext2fs_nls_table *table,
|
||||
char *s, size_t len, char **pos);
|
||||
int (*casefold_cmp)(const struct ext2fs_nls_table *table,
|
||||
const unsigned char *str1, size_t len1,
|
||||
const unsigned char *str2, size_t len2);
|
||||
};
|
||||
|
||||
/* Function prototypes */
|
||||
|
||||
extern int ext2fs_process_dir_block(ext2_filsys fs,
|
||||
blk64_t *blocknr,
|
||||
e2_blkcnt_t blockcnt,
|
||||
blk64_t ref_block,
|
||||
int ref_offset,
|
||||
void *priv_data);
|
||||
|
||||
extern errcode_t ext2fs_inline_data_ea_remove(ext2_filsys fs, ext2_ino_t ino);
|
||||
extern errcode_t ext2fs_inline_data_expand(ext2_filsys fs, ext2_ino_t ino);
|
||||
extern int ext2fs_inline_data_dir_iterate(ext2_filsys fs,
|
||||
ext2_ino_t ino,
|
||||
void *priv_data);
|
||||
|
||||
/* Generic numeric progress meter */
|
||||
|
||||
struct ext2fs_numeric_progress_struct {
|
||||
__u64 max;
|
||||
int log_max;
|
||||
int skip_progress;
|
||||
};
|
||||
|
||||
/*
|
||||
* progress callback functions
|
||||
*/
|
||||
struct ext2fs_progress_ops {
|
||||
void (*init)(ext2_filsys fs,
|
||||
struct ext2fs_numeric_progress_struct * progress,
|
||||
const char *label, __u64 max);
|
||||
void (*update)(ext2_filsys fs,
|
||||
struct ext2fs_numeric_progress_struct * progress,
|
||||
__u64 val);
|
||||
void (*close)(ext2_filsys fs,
|
||||
struct ext2fs_numeric_progress_struct * progress,
|
||||
const char *message);
|
||||
};
|
||||
|
||||
extern struct ext2fs_progress_ops ext2fs_numeric_progress_ops;
|
||||
|
||||
extern void ext2fs_numeric_progress_init(ext2_filsys fs,
|
||||
struct ext2fs_numeric_progress_struct * progress,
|
||||
const char *label, __u64 max);
|
||||
extern void ext2fs_numeric_progress_update(ext2_filsys fs,
|
||||
struct ext2fs_numeric_progress_struct * progress,
|
||||
__u64 val);
|
||||
extern void ext2fs_numeric_progress_close(ext2_filsys fs,
|
||||
struct ext2fs_numeric_progress_struct * progress,
|
||||
const char *message);
|
||||
|
||||
/*
|
||||
* 64-bit bitmap support
|
||||
*/
|
||||
|
||||
extern errcode_t ext2fs_alloc_generic_bmap(ext2_filsys fs, errcode_t magic,
|
||||
int type, __u64 start, __u64 end,
|
||||
__u64 real_end,
|
||||
const char * description,
|
||||
ext2fs_generic_bitmap *bmap);
|
||||
|
||||
extern void ext2fs_free_generic_bmap(ext2fs_generic_bitmap bmap);
|
||||
|
||||
extern errcode_t ext2fs_copy_generic_bmap(ext2fs_generic_bitmap src,
|
||||
ext2fs_generic_bitmap *dest);
|
||||
|
||||
extern errcode_t ext2fs_resize_generic_bmap(ext2fs_generic_bitmap bmap,
|
||||
__u64 new_end,
|
||||
__u64 new_real_end);
|
||||
extern errcode_t ext2fs_fudge_generic_bmap_end(ext2fs_generic_bitmap bitmap,
|
||||
errcode_t neq,
|
||||
__u64 end, __u64 *oend);
|
||||
extern int ext2fs_mark_generic_bmap(ext2fs_generic_bitmap bitmap,
|
||||
__u64 arg);
|
||||
extern int ext2fs_unmark_generic_bmap(ext2fs_generic_bitmap bitmap,
|
||||
__u64 arg);
|
||||
extern int ext2fs_test_generic_bmap(ext2fs_generic_bitmap bitmap,
|
||||
__u64 arg);
|
||||
extern errcode_t ext2fs_set_generic_bmap_range(ext2fs_generic_bitmap bitmap,
|
||||
__u64 start, unsigned int num,
|
||||
void *in);
|
||||
extern errcode_t ext2fs_get_generic_bmap_range(ext2fs_generic_bitmap bitmap,
|
||||
__u64 start, unsigned int num,
|
||||
void *out);
|
||||
extern void ext2fs_warn_bitmap32(ext2fs_generic_bitmap bitmap,const char *func);
|
||||
|
||||
extern int ext2fs_mem_is_zero(const char *mem, size_t len);
|
||||
|
||||
extern int ext2fs_file_block_offset_too_big(ext2_filsys fs,
|
||||
struct ext2_inode *inode,
|
||||
blk64_t offset);
|
||||
|
||||
/* atexit support */
|
||||
typedef void (*ext2_exit_fn)(void *);
|
||||
errcode_t ext2fs_add_exit_fn(ext2_exit_fn fn, void *data);
|
||||
errcode_t ext2fs_remove_exit_fn(ext2_exit_fn fn, void *data);
|
||||
|
||||
#define EXT2FS_BUILD_BUG_ON(cond) ((void)sizeof(char[1 - 2*!!(cond)]))
|
||||
127
include/e2fsprogs/ext2fs/ext3_extents.h
Executable file
127
include/e2fsprogs/ext2fs/ext3_extents.h
Executable file
@@ -0,0 +1,127 @@
|
||||
/*
|
||||
* Copyright (c) 2003,2004 Cluster File Systems, Inc, info@clusterfs.com
|
||||
* Written by Alex Tomas <alex@clusterfs.com>
|
||||
*
|
||||
* %Begin-Header%
|
||||
* This file may be redistributed under the terms of the GNU Library
|
||||
* General Public License, version 2.
|
||||
* %End-Header%
|
||||
*/
|
||||
|
||||
#ifndef _LINUX_EXT3_EXTENTS
|
||||
#define _LINUX_EXT3_EXTENTS
|
||||
|
||||
/*
|
||||
* ext3_inode has i_block array (total 60 bytes)
|
||||
* first 4 bytes are used to store:
|
||||
* - tree depth (0 mean there is no tree yet. all extents in the inode)
|
||||
* - number of alive extents in the inode
|
||||
*/
|
||||
|
||||
/*
|
||||
* This is extent tail on-disk structure.
|
||||
* All other extent structures are 12 bytes long. It turns out that
|
||||
* block_size % 12 >= 4 for at least all powers of 2 greater than 512, which
|
||||
* covers all valid ext4 block sizes. Therefore, this tail structure can be
|
||||
* crammed into the end of the block without having to rebalance the tree.
|
||||
*/
|
||||
struct ext3_extent_tail {
|
||||
__le32 et_checksum; /* crc32c(uuid+inum+extent_block) */
|
||||
};
|
||||
|
||||
/*
|
||||
* this is extent on-disk structure
|
||||
* it's used at the bottom of the tree
|
||||
*/
|
||||
struct ext3_extent {
|
||||
__le32 ee_block; /* first logical block extent covers */
|
||||
__le16 ee_len; /* number of blocks covered by extent */
|
||||
__le16 ee_start_hi; /* high 16 bits of physical block */
|
||||
__le32 ee_start; /* low 32 bigs of physical block */
|
||||
};
|
||||
|
||||
/*
|
||||
* this is index on-disk structure
|
||||
* it's used at all the levels, but the bottom
|
||||
*/
|
||||
struct ext3_extent_idx {
|
||||
__le32 ei_block; /* index covers logical blocks from 'block' */
|
||||
__le32 ei_leaf; /* pointer to the physical block of the next *
|
||||
* level. leaf or next index could bet here */
|
||||
__le16 ei_leaf_hi; /* high 16 bits of physical block */
|
||||
__le16 ei_unused;
|
||||
};
|
||||
|
||||
/*
|
||||
* each block (leaves and indexes), even inode-stored has header
|
||||
*/
|
||||
struct ext3_extent_header {
|
||||
__le16 eh_magic; /* probably will support different formats */
|
||||
__le16 eh_entries; /* number of valid entries */
|
||||
__le16 eh_max; /* capacity of store in entries */
|
||||
__le16 eh_depth; /* has tree real underlying blocks? */
|
||||
__le32 eh_generation; /* generation of the tree */
|
||||
};
|
||||
|
||||
#define EXT3_EXT_MAGIC 0xf30a
|
||||
|
||||
/*
|
||||
* array of ext3_ext_path contains path to some extent
|
||||
* creation/lookup routines use it for traversal/splitting/etc
|
||||
* truncate uses it to simulate recursive walking
|
||||
*/
|
||||
struct ext3_ext_path {
|
||||
__u32 p_block;
|
||||
__u16 p_depth;
|
||||
struct ext3_extent *p_ext;
|
||||
struct ext3_extent_idx *p_idx;
|
||||
struct ext3_extent_header *p_hdr;
|
||||
struct buffer_head *p_bh;
|
||||
};
|
||||
|
||||
/*
|
||||
* EXT_INIT_MAX_LEN is the maximum number of blocks we can have in an
|
||||
* initialized extent. This is 2^15 and not (2^16 - 1), since we use the
|
||||
* MSB of ee_len field in the extent datastructure to signify if this
|
||||
* particular extent is an initialized extent or an uninitialized (i.e.
|
||||
* preallocated).
|
||||
* EXT_UNINIT_MAX_LEN is the maximum number of blocks we can have in an
|
||||
* uninitialized extent.
|
||||
* If ee_len is <= 0x8000, it is an initialized extent. Otherwise, it is an
|
||||
* uninitialized one. In other words, if MSB of ee_len is set, it is an
|
||||
* uninitialized extent with only one special scenario when ee_len = 0x8000.
|
||||
* In this case we can not have an uninitialized extent of zero length and
|
||||
* thus we make it as a special case of initialized extent with 0x8000 length.
|
||||
* This way we get better extent-to-group alignment for initialized extents.
|
||||
* Hence, the maximum number of blocks we can have in an *initialized*
|
||||
* extent is 2^15 (32768) and in an *uninitialized* extent is 2^15-1 (32767).
|
||||
*/
|
||||
#define EXT_INIT_MAX_LEN (1UL << 15)
|
||||
#define EXT_UNINIT_MAX_LEN (EXT_INIT_MAX_LEN - 1)
|
||||
#define EXT_MAX_EXTENT_LBLK (((__u64) 1 << 32) - 1)
|
||||
#define EXT_MAX_EXTENT_PBLK (((__u64) 1 << 48) - 1)
|
||||
|
||||
#define EXT_FIRST_EXTENT(__hdr__) \
|
||||
((struct ext3_extent *) (((char *) (__hdr__)) + \
|
||||
sizeof(struct ext3_extent_header)))
|
||||
#define EXT_FIRST_INDEX(__hdr__) \
|
||||
((struct ext3_extent_idx *) (((char *) (__hdr__)) + \
|
||||
sizeof(struct ext3_extent_header)))
|
||||
#define EXT_HAS_FREE_INDEX(__path__) \
|
||||
(ext2fs_le16_to_cpu((__path__)->p_hdr->eh_entries) < \
|
||||
ext2fs_le16_to_cpu((__path__)->p_hdr->eh_max))
|
||||
#define EXT_LAST_EXTENT(__hdr__) \
|
||||
(EXT_FIRST_EXTENT((__hdr__)) + \
|
||||
ext2fs_le16_to_cpu((__hdr__)->eh_entries) - 1)
|
||||
#define EXT_LAST_INDEX(__hdr__) \
|
||||
(EXT_FIRST_INDEX((__hdr__)) + \
|
||||
ext2fs_le16_to_cpu((__hdr__)->eh_entries) - 1)
|
||||
#define EXT_MAX_EXTENT(__hdr__) \
|
||||
(EXT_FIRST_EXTENT((__hdr__)) + \
|
||||
ext2fs_le16_to_cpu((__hdr__)->eh_max) - 1)
|
||||
#define EXT_MAX_INDEX(__hdr__) \
|
||||
(EXT_FIRST_INDEX((__hdr__)) + \
|
||||
ext2fs_le16_to_cpu((__hdr__)->eh_max) - 1)
|
||||
|
||||
#endif /* _LINUX_EXT3_EXTENTS */
|
||||
|
||||
62
include/e2fsprogs/ext2fs/ext4_acl.h
Executable file
62
include/e2fsprogs/ext2fs/ext4_acl.h
Executable file
@@ -0,0 +1,62 @@
|
||||
/*
|
||||
* Ext4's on-disk acl format. From linux/fs/ext4/acl.h
|
||||
*/
|
||||
|
||||
#define EXT4_ACL_VERSION 0x0001
|
||||
|
||||
/* 23.2.5 acl_tag_t values */
|
||||
|
||||
#define ACL_UNDEFINED_TAG (0x00)
|
||||
#define ACL_USER_OBJ (0x01)
|
||||
#define ACL_USER (0x02)
|
||||
#define ACL_GROUP_OBJ (0x04)
|
||||
#define ACL_GROUP (0x08)
|
||||
#define ACL_MASK (0x10)
|
||||
#define ACL_OTHER (0x20)
|
||||
|
||||
/* 23.3.6 acl_type_t values */
|
||||
|
||||
#define ACL_TYPE_ACCESS (0x8000)
|
||||
#define ACL_TYPE_DEFAULT (0x4000)
|
||||
|
||||
/* 23.2.7 ACL qualifier constants */
|
||||
|
||||
#define ACL_UNDEFINED_ID ((id_t)-1)
|
||||
|
||||
typedef struct {
|
||||
__le16 e_tag;
|
||||
__le16 e_perm;
|
||||
__le32 e_id;
|
||||
} ext4_acl_entry;
|
||||
|
||||
typedef struct {
|
||||
__le16 e_tag;
|
||||
__le16 e_perm;
|
||||
} ext4_acl_entry_short;
|
||||
|
||||
typedef struct {
|
||||
__le32 a_version;
|
||||
} ext4_acl_header;
|
||||
|
||||
|
||||
/* Supported ACL a_version fields */
|
||||
#define POSIX_ACL_XATTR_VERSION 0x0002
|
||||
|
||||
typedef struct {
|
||||
__le16 e_tag;
|
||||
__le16 e_perm;
|
||||
__le32 e_id;
|
||||
} posix_acl_xattr_entry;
|
||||
|
||||
typedef struct {
|
||||
__le32 a_version;
|
||||
#if __GNUC_PREREQ (4, 8)
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wpedantic"
|
||||
#endif
|
||||
posix_acl_xattr_entry a_entries[0];
|
||||
#if __GNUC_PREREQ (4, 8)
|
||||
#pragma GCC diagnostic pop
|
||||
#endif
|
||||
} posix_acl_xattr_header;
|
||||
|
||||
190
include/e2fsprogs/ext2fs/fast_commit.h
Executable file
190
include/e2fsprogs/ext2fs/fast_commit.h
Executable file
@@ -0,0 +1,190 @@
|
||||
/* SPDX-License-Identifier: GPL-2.0 */
|
||||
|
||||
#ifndef __FAST_COMMIT_H__
|
||||
#define __FAST_COMMIT_H__
|
||||
|
||||
#include "jfs_compat.h"
|
||||
|
||||
/*
|
||||
* Note this file is present in e2fsprogs/lib/ext2fs/fast_commit.h and
|
||||
* linux/fs/ext4/fast_commit.h. These file should always be byte identical.
|
||||
*/
|
||||
|
||||
/* Fast commit tags */
|
||||
#define EXT4_FC_TAG_ADD_RANGE 0x0001
|
||||
#define EXT4_FC_TAG_DEL_RANGE 0x0002
|
||||
#define EXT4_FC_TAG_CREAT 0x0003
|
||||
#define EXT4_FC_TAG_LINK 0x0004
|
||||
#define EXT4_FC_TAG_UNLINK 0x0005
|
||||
#define EXT4_FC_TAG_INODE 0x0006
|
||||
#define EXT4_FC_TAG_PAD 0x0007
|
||||
#define EXT4_FC_TAG_TAIL 0x0008
|
||||
#define EXT4_FC_TAG_HEAD 0x0009
|
||||
|
||||
#define EXT4_FC_SUPPORTED_FEATURES 0x0
|
||||
|
||||
/* On disk fast commit tlv value structures */
|
||||
|
||||
/* Fast commit on disk tag length structure */
|
||||
struct ext4_fc_tl {
|
||||
__le16 fc_tag;
|
||||
__le16 fc_len;
|
||||
};
|
||||
|
||||
/* Value structure for tag EXT4_FC_TAG_HEAD. */
|
||||
struct ext4_fc_head {
|
||||
__le32 fc_features;
|
||||
__le32 fc_tid;
|
||||
};
|
||||
|
||||
/* Value structure for EXT4_FC_TAG_ADD_RANGE. */
|
||||
struct ext4_fc_add_range {
|
||||
__le32 fc_ino;
|
||||
__u8 fc_ex[12];
|
||||
};
|
||||
|
||||
/* Value structure for tag EXT4_FC_TAG_DEL_RANGE. */
|
||||
struct ext4_fc_del_range {
|
||||
__le32 fc_ino;
|
||||
__le32 fc_lblk;
|
||||
__le32 fc_len;
|
||||
};
|
||||
|
||||
/*
|
||||
* This is the value structure for tags EXT4_FC_TAG_CREAT, EXT4_FC_TAG_LINK
|
||||
* and EXT4_FC_TAG_UNLINK.
|
||||
*/
|
||||
struct ext4_fc_dentry_info {
|
||||
__le32 fc_parent_ino;
|
||||
__le32 fc_ino;
|
||||
__u8 fc_dname[0];
|
||||
};
|
||||
|
||||
/* Value structure for EXT4_FC_TAG_INODE and EXT4_FC_TAG_INODE_PARTIAL. */
|
||||
struct ext4_fc_inode {
|
||||
__le32 fc_ino;
|
||||
__u8 fc_raw_inode[0];
|
||||
};
|
||||
|
||||
/* Value structure for tag EXT4_FC_TAG_TAIL. */
|
||||
struct ext4_fc_tail {
|
||||
__le32 fc_tid;
|
||||
__le32 fc_crc;
|
||||
};
|
||||
|
||||
/*
|
||||
* Fast commit reason codes
|
||||
*/
|
||||
enum {
|
||||
/*
|
||||
* Commit status codes:
|
||||
*/
|
||||
EXT4_FC_REASON_OK = 0,
|
||||
EXT4_FC_REASON_INELIGIBLE,
|
||||
EXT4_FC_REASON_ALREADY_COMMITTED,
|
||||
EXT4_FC_REASON_FC_START_FAILED,
|
||||
EXT4_FC_REASON_FC_FAILED,
|
||||
|
||||
/*
|
||||
* Fast commit ineligiblity reasons:
|
||||
*/
|
||||
EXT4_FC_REASON_XATTR = 0,
|
||||
EXT4_FC_REASON_CROSS_RENAME,
|
||||
EXT4_FC_REASON_JOURNAL_FLAG_CHANGE,
|
||||
EXT4_FC_REASON_NOMEM,
|
||||
EXT4_FC_REASON_SWAP_BOOT,
|
||||
EXT4_FC_REASON_RESIZE,
|
||||
EXT4_FC_REASON_RENAME_DIR,
|
||||
EXT4_FC_REASON_FALLOC_RANGE,
|
||||
EXT4_FC_REASON_INODE_JOURNAL_DATA,
|
||||
EXT4_FC_COMMIT_FAILED,
|
||||
EXT4_FC_REASON_MAX
|
||||
};
|
||||
|
||||
#ifdef __KERNEL__
|
||||
/*
|
||||
* In memory list of dentry updates that are performed on the file
|
||||
* system used by fast commit code.
|
||||
*/
|
||||
struct ext4_fc_dentry_update {
|
||||
int fcd_op; /* Type of update create / unlink / link */
|
||||
int fcd_parent; /* Parent inode number */
|
||||
int fcd_ino; /* Inode number */
|
||||
struct qstr fcd_name; /* Dirent name */
|
||||
unsigned char fcd_iname[DNAME_INLINE_LEN]; /* Dirent name string */
|
||||
struct list_head fcd_list;
|
||||
};
|
||||
|
||||
struct ext4_fc_stats {
|
||||
unsigned int fc_ineligible_reason_count[EXT4_FC_REASON_MAX];
|
||||
unsigned long fc_num_commits;
|
||||
unsigned long fc_ineligible_commits;
|
||||
unsigned long fc_numblks;
|
||||
};
|
||||
|
||||
#define EXT4_FC_REPLAY_REALLOC_INCREMENT 4
|
||||
|
||||
/*
|
||||
* Physical block regions added to different inodes due to fast commit
|
||||
* recovery. These are set during the SCAN phase. During the replay phase,
|
||||
* our allocator excludes these from its allocation. This ensures that
|
||||
* we don't accidentally allocating a block that is going to be used by
|
||||
* another inode.
|
||||
*/
|
||||
struct ext4_fc_alloc_region {
|
||||
ext4_lblk_t lblk;
|
||||
ext4_fsblk_t pblk;
|
||||
int ino, len;
|
||||
};
|
||||
|
||||
/*
|
||||
* Fast commit replay state.
|
||||
*/
|
||||
struct ext4_fc_replay_state {
|
||||
int fc_replay_num_tags;
|
||||
int fc_replay_expected_off;
|
||||
int fc_current_pass;
|
||||
int fc_cur_tag;
|
||||
int fc_crc;
|
||||
struct ext4_fc_alloc_region *fc_regions;
|
||||
int fc_regions_size, fc_regions_used, fc_regions_valid;
|
||||
int *fc_modified_inodes;
|
||||
int fc_modified_inodes_used, fc_modified_inodes_size;
|
||||
};
|
||||
|
||||
#define region_last(__region) (((__region)->lblk) + ((__region)->len) - 1)
|
||||
#endif
|
||||
|
||||
static inline const char *tag2str(__u16 tag)
|
||||
{
|
||||
switch (tag) {
|
||||
case EXT4_FC_TAG_LINK:
|
||||
return "ADD_ENTRY";
|
||||
case EXT4_FC_TAG_UNLINK:
|
||||
return "DEL_ENTRY";
|
||||
case EXT4_FC_TAG_ADD_RANGE:
|
||||
return "ADD_RANGE";
|
||||
case EXT4_FC_TAG_CREAT:
|
||||
return "CREAT_DENTRY";
|
||||
case EXT4_FC_TAG_DEL_RANGE:
|
||||
return "DEL_RANGE";
|
||||
case EXT4_FC_TAG_INODE:
|
||||
return "INODE";
|
||||
case EXT4_FC_TAG_PAD:
|
||||
return "PAD";
|
||||
case EXT4_FC_TAG_TAIL:
|
||||
return "TAIL";
|
||||
case EXT4_FC_TAG_HEAD:
|
||||
return "HEAD";
|
||||
default:
|
||||
return "ERROR";
|
||||
}
|
||||
}
|
||||
|
||||
/* Get length of a particular tlv */
|
||||
static inline int ext4_fc_tag_len(struct ext4_fc_tl *tl)
|
||||
{
|
||||
return le16_to_cpu(tl->fc_len);
|
||||
}
|
||||
|
||||
#endif /* __FAST_COMMIT_H__ */
|
||||
93
include/e2fsprogs/ext2fs/fiemap.h
Executable file
93
include/e2fsprogs/ext2fs/fiemap.h
Executable file
@@ -0,0 +1,93 @@
|
||||
/*
|
||||
* FS_IOC_FIEMAP ioctl infrastructure.
|
||||
*
|
||||
* Some portions copyright (C) 2007 Cluster File Systems, Inc
|
||||
*
|
||||
* Authors: Mark Fasheh <mfasheh@suse.com>
|
||||
* Kalpak Shah <kalpak.shah@sun.com>
|
||||
* Andreas Dilger <adilger@sun.com>
|
||||
*/
|
||||
|
||||
#ifndef _LINUX_FIEMAP_H
|
||||
#define _LINUX_FIEMAP_H
|
||||
|
||||
struct fiemap_extent {
|
||||
__u64 fe_logical; /* logical offset in bytes for the start of
|
||||
* the extent from the beginning of the file */
|
||||
__u64 fe_physical; /* physical offset in bytes for the start
|
||||
* of the extent from the beginning of the disk */
|
||||
__u64 fe_length; /* length in bytes for this extent */
|
||||
__u64 fe_reserved64[2];
|
||||
__u32 fe_flags; /* FIEMAP_EXTENT_* flags for this extent */
|
||||
__u32 fe_reserved[3];
|
||||
};
|
||||
|
||||
struct fiemap {
|
||||
__u64 fm_start; /* logical offset (inclusive) at
|
||||
* which to start mapping (in) */
|
||||
__u64 fm_length; /* logical length of mapping which
|
||||
* userspace wants (in) */
|
||||
__u32 fm_flags; /* FIEMAP_FLAG_* flags for request (in/out) */
|
||||
__u32 fm_mapped_extents;/* number of extents that were mapped (out) */
|
||||
__u32 fm_extent_count; /* size of fm_extents array (in) */
|
||||
__u32 fm_reserved;
|
||||
#if __GNUC_PREREQ (4, 8)
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wpedantic"
|
||||
#endif
|
||||
struct fiemap_extent fm_extents[0]; /* array of mapped extents (out) */
|
||||
#if __GNUC_PREREQ (4, 8)
|
||||
#pragma GCC diagnostic pop
|
||||
#endif
|
||||
};
|
||||
|
||||
#if defined(__linux__) && !defined(FS_IOC_FIEMAP)
|
||||
#define FS_IOC_FIEMAP _IOWR('f', 11, struct fiemap)
|
||||
#endif
|
||||
|
||||
#if defined(__linux__) && !defined(FS_IOC_GETSTATE)
|
||||
#define EXT4_IOC_GETSTATE _IOW('f', 41, __u32)
|
||||
#endif
|
||||
|
||||
#if defined(__linux__) && !defined(EXT4_IOC_GET_ES_CACHE)
|
||||
#define EXT4_IOC_GET_ES_CACHE _IOWR('f', 42, struct fiemap)
|
||||
#endif
|
||||
|
||||
#if defined(__linux__) && !defined(EXT4_STATE_FLAG_EXT_PRECACHED)
|
||||
#define EXT4_STATE_FLAG_EXT_PRECACHED 0x00000001
|
||||
#endif
|
||||
|
||||
#define FIEMAP_MAX_OFFSET (~0ULL)
|
||||
|
||||
#define FIEMAP_FLAG_SYNC 0x00000001 /* sync file data before map */
|
||||
#define FIEMAP_FLAG_XATTR 0x00000002 /* map extended attribute tree */
|
||||
#define FIEMAP_FLAG_CACHE 0x00000004 /* request caching of the extents */
|
||||
|
||||
#define FIEMAP_FLAGS_COMPAT (FIEMAP_FLAG_SYNC | FIEMAP_FLAG_XATTR)
|
||||
|
||||
#define FIEMAP_EXTENT_LAST 0x00000001 /* Last extent in file. */
|
||||
#define FIEMAP_EXTENT_UNKNOWN 0x00000002 /* Data location unknown. */
|
||||
#define FIEMAP_EXTENT_DELALLOC 0x00000004 /* Location still pending.
|
||||
* Sets EXTENT_UNKNOWN. */
|
||||
#define FIEMAP_EXTENT_ENCODED 0x00000008 /* Data can not be read
|
||||
* while fs is unmounted */
|
||||
#define FIEMAP_EXTENT_DATA_ENCRYPTED 0x00000080 /* Data is encrypted by fs.
|
||||
* Sets EXTENT_NO_BYPASS. */
|
||||
#define FIEMAP_EXTENT_NOT_ALIGNED 0x00000100 /* Extent offsets may not be
|
||||
* block aligned. */
|
||||
#define FIEMAP_EXTENT_DATA_INLINE 0x00000200 /* Data mixed with metadata.
|
||||
* Sets EXTENT_NOT_ALIGNED.*/
|
||||
#define FIEMAP_EXTENT_DATA_TAIL 0x00000400 /* Multiple files in block.
|
||||
* Sets EXTENT_NOT_ALIGNED.*/
|
||||
#define FIEMAP_EXTENT_UNWRITTEN 0x00000800 /* Space allocated, but
|
||||
* no data (i.e. zero). */
|
||||
#define FIEMAP_EXTENT_MERGED 0x00001000 /* File does not natively
|
||||
* support extents. Result
|
||||
* merged for efficiency. */
|
||||
#define FIEMAP_EXTENT_SHARED 0x00002000 /* Space shared with other
|
||||
* files. */
|
||||
|
||||
#define EXT4_FIEMAP_EXTENT_HOLE 0x08000000 /* Entry in extent status
|
||||
cache for a hole*/
|
||||
|
||||
#endif /* _LINUX_FIEMAP_H */
|
||||
42
include/e2fsprogs/ext2fs/hashmap.h
Executable file
42
include/e2fsprogs/ext2fs/hashmap.h
Executable file
@@ -0,0 +1,42 @@
|
||||
#ifndef HASHMAP_H
|
||||
# define HASHMAP_H
|
||||
|
||||
# include <stdlib.h>
|
||||
# include <stdint.h>
|
||||
|
||||
#ifndef __GNUC_PREREQ
|
||||
#if defined(__GNUC__) && defined(__GNUC_MINOR__)
|
||||
#define __GNUC_PREREQ(maj, min) \
|
||||
((__GNUC__ << 16) + __GNUC_MINOR__ >= ((maj) << 16) + (min))
|
||||
#else
|
||||
#define __GNUC_PREREQ(maj, min) 0
|
||||
#endif
|
||||
#endif
|
||||
|
||||
struct ext2fs_hashmap;
|
||||
|
||||
struct ext2fs_hashmap_entry {
|
||||
void *data;
|
||||
const void *key;
|
||||
size_t key_len;
|
||||
struct ext2fs_hashmap_entry *next;
|
||||
struct ext2fs_hashmap_entry *list_next;
|
||||
struct ext2fs_hashmap_entry *list_prev;
|
||||
};
|
||||
|
||||
struct ext2fs_hashmap *ext2fs_hashmap_create(
|
||||
uint32_t(*hash_fct)(const void*, size_t),
|
||||
void(*free_fct)(void*), size_t size);
|
||||
int ext2fs_hashmap_add(struct ext2fs_hashmap *h,
|
||||
void *data, const void *key,size_t key_len);
|
||||
void *ext2fs_hashmap_lookup(struct ext2fs_hashmap *h, const void *key,
|
||||
size_t key_len);
|
||||
void *ext2fs_hashmap_iter_in_order(struct ext2fs_hashmap *h,
|
||||
struct ext2fs_hashmap_entry **it);
|
||||
void ext2fs_hashmap_del(struct ext2fs_hashmap *h,
|
||||
struct ext2fs_hashmap_entry *e);
|
||||
void ext2fs_hashmap_free(struct ext2fs_hashmap *h);
|
||||
|
||||
uint32_t ext2fs_djb2_hash(const void *str, size_t size);
|
||||
|
||||
#endif /* !HASHMAP_H */
|
||||
114
include/e2fsprogs/ext2fs/irel.h
Executable file
114
include/e2fsprogs/ext2fs/irel.h
Executable file
@@ -0,0 +1,114 @@
|
||||
/*
|
||||
* irel.h
|
||||
*
|
||||
* Copyright (C) 1996, 1997 Theodore Ts'o.
|
||||
*
|
||||
* %Begin-Header%
|
||||
* This file may be redistributed under the terms of the GNU Library
|
||||
* General Public License, version 2.
|
||||
* %End-Header%
|
||||
*/
|
||||
|
||||
struct ext2_inode_reference {
|
||||
blk64_t block;
|
||||
__u16 offset;
|
||||
};
|
||||
|
||||
struct ext2_inode_relocate_entry {
|
||||
ext2_ino_t new;
|
||||
ext2_ino_t orig;
|
||||
__u16 flags;
|
||||
__u16 max_refs;
|
||||
};
|
||||
|
||||
typedef struct ext2_inode_relocation_table *ext2_irel;
|
||||
|
||||
struct ext2_inode_relocation_table {
|
||||
__u32 magic;
|
||||
char *name;
|
||||
ext2_ino_t current;
|
||||
void *priv_data;
|
||||
|
||||
/*
|
||||
* Add an inode relocation entry.
|
||||
*/
|
||||
errcode_t (*put)(ext2_irel irel, ext2_ino_t old,
|
||||
struct ext2_inode_relocate_entry *ent);
|
||||
/*
|
||||
* Get an inode relocation entry.
|
||||
*/
|
||||
errcode_t (*get)(ext2_irel irel, ext2_ino_t old,
|
||||
struct ext2_inode_relocate_entry *ent);
|
||||
|
||||
/*
|
||||
* Get an inode relocation entry by its original inode number
|
||||
*/
|
||||
errcode_t (*get_by_orig)(ext2_irel irel, ext2_ino_t orig, ext2_ino_t *old,
|
||||
struct ext2_inode_relocate_entry *ent);
|
||||
|
||||
/*
|
||||
* Initialize for iterating over the inode relocation entries.
|
||||
*/
|
||||
errcode_t (*start_iter)(ext2_irel irel);
|
||||
|
||||
/*
|
||||
* The iterator function for the inode relocation entries.
|
||||
* Returns an inode number of 0 when out of entries.
|
||||
*/
|
||||
errcode_t (*next)(ext2_irel irel, ext2_ino_t *old,
|
||||
struct ext2_inode_relocate_entry *ent);
|
||||
|
||||
/*
|
||||
* Add an inode reference (i.e., note the fact that a
|
||||
* particular block/offset contains a reference to an inode)
|
||||
*/
|
||||
errcode_t (*add_ref)(ext2_irel irel, ext2_ino_t ino,
|
||||
struct ext2_inode_reference *ref);
|
||||
|
||||
/*
|
||||
* Initialize for iterating over the inode references for a
|
||||
* particular inode.
|
||||
*/
|
||||
errcode_t (*start_iter_ref)(ext2_irel irel, ext2_ino_t ino);
|
||||
|
||||
/*
|
||||
* The iterator function for the inode references for an
|
||||
* inode. The references for only one inode can be iterator
|
||||
* over at a time, as the iterator state is stored in ext2_irel.
|
||||
*/
|
||||
errcode_t (*next_ref)(ext2_irel irel,
|
||||
struct ext2_inode_reference *ref);
|
||||
|
||||
/*
|
||||
* Move the inode relocation table from one inode number to
|
||||
* another. Note that the inode references also must move.
|
||||
*/
|
||||
errcode_t (*move)(ext2_irel irel, ext2_ino_t old, ext2_ino_t new);
|
||||
|
||||
/*
|
||||
* Remove an inode relocation entry, along with all of the
|
||||
* inode references.
|
||||
*/
|
||||
errcode_t (*delete)(ext2_irel irel, ext2_ino_t old);
|
||||
|
||||
/*
|
||||
* Free the inode relocation table.
|
||||
*/
|
||||
errcode_t (*free)(ext2_irel irel);
|
||||
};
|
||||
|
||||
errcode_t ext2fs_irel_memarray_create(char *name, ext2_ino_t max_inode,
|
||||
ext2_irel *irel);
|
||||
|
||||
#define ext2fs_irel_put(irel, old, ent) ((irel)->put((irel), old, ent))
|
||||
#define ext2fs_irel_get(irel, old, ent) ((irel)->get((irel), old, ent))
|
||||
#define ext2fs_irel_get_by_orig(irel, orig, old, ent) \
|
||||
((irel)->get_by_orig((irel), orig, old, ent))
|
||||
#define ext2fs_irel_start_iter(irel) ((irel)->start_iter((irel)))
|
||||
#define ext2fs_irel_next(irel, old, ent) ((irel)->next((irel), old, ent))
|
||||
#define ext2fs_irel_add_ref(irel, ino, ref) ((irel)->add_ref((irel), ino, ref))
|
||||
#define ext2fs_irel_start_iter_ref(irel, ino) ((irel)->start_iter_ref((irel), ino))
|
||||
#define ext2fs_irel_next_ref(irel, ref) ((irel)->next_ref((irel), ref))
|
||||
#define ext2fs_irel_move(irel, old, new) ((irel)->move((irel), old, new))
|
||||
#define ext2fs_irel_delete(irel, old) ((irel)->delete((irel), old))
|
||||
#define ext2fs_irel_free(irel) ((irel)->free((irel)))
|
||||
113
include/e2fsprogs/ext2fs/jfs_compat.h
Executable file
113
include/e2fsprogs/ext2fs/jfs_compat.h
Executable file
@@ -0,0 +1,113 @@
|
||||
|
||||
#ifndef _JFS_COMPAT_H
|
||||
#define _JFS_COMPAT_H
|
||||
|
||||
#include "kernel-list.h"
|
||||
#include <errno.h>
|
||||
#ifdef HAVE_NETINET_IN_H
|
||||
#include <netinet/in.h>
|
||||
#endif
|
||||
#include <arpa/inet.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#define printk printf
|
||||
#define KERN_ERR ""
|
||||
#define KERN_DEBUG ""
|
||||
|
||||
#define REQ_OP_READ 0
|
||||
#define REQ_OP_WRITE 1
|
||||
|
||||
#define cpu_to_le16(x) ext2fs_cpu_to_le16(x)
|
||||
#define cpu_to_be16(x) ext2fs_cpu_to_be16(x)
|
||||
#define cpu_to_le32(x) ext2fs_cpu_to_le32(x)
|
||||
#define cpu_to_be32(x) ext2fs_cpu_to_be32(x)
|
||||
#define cpu_to_le64(x) ext2fs_cpu_to_le64(x)
|
||||
#define cpu_to_be64(x) ext2fs_cpu_to_be64(x)
|
||||
|
||||
#define le16_to_cpu(x) ext2fs_le16_to_cpu(x)
|
||||
#define be16_to_cpu(x) ext2fs_be16_to_cpu(x)
|
||||
#define le32_to_cpu(x) ext2fs_le32_to_cpu(x)
|
||||
#define be32_to_cpu(x) ext2fs_be32_to_cpu(x)
|
||||
#define le64_to_cpu(x) ext2fs_le64_to_cpu(x)
|
||||
#define be64_to_cpu(x) ext2fs_be64_to_cpu(x)
|
||||
|
||||
typedef unsigned int tid_t;
|
||||
typedef struct journal_s journal_t;
|
||||
typedef struct kdev_s *kdev_t;
|
||||
|
||||
struct buffer_head;
|
||||
struct inode;
|
||||
|
||||
typedef unsigned int gfp_t;
|
||||
#define GFP_KERNEL 0
|
||||
#define GFP_NOFS 0
|
||||
#define __GFP_NOFAIL 0
|
||||
#define JBD2_TAG_SIZE32 JBD_TAG_SIZE32
|
||||
#define JBD2_BARRIER 0
|
||||
typedef __u64 u64;
|
||||
#define put_bh(x) brelse(x)
|
||||
|
||||
#define crc32_be(x, y, z) ext2fs_crc32_be((x), (y), (z))
|
||||
#define spin_lock_init(x)
|
||||
#define spin_lock(x)
|
||||
#define spin_unlock(x)
|
||||
#define SLAB_HWCACHE_ALIGN 0
|
||||
#define SLAB_TEMPORARY 0
|
||||
#define KMEM_CACHE(__struct, __flags) kmem_cache_create(#__struct,\
|
||||
sizeof(struct __struct), __alignof__(struct __struct),\
|
||||
(__flags), NULL)
|
||||
|
||||
#define blkdev_issue_flush(kdev) sync_blockdev(kdev)
|
||||
#define is_power_of_2(x) ((x) != 0 && (((x) & ((x) - 1)) == 0))
|
||||
#define pr_emerg(fmt)
|
||||
#define pr_err(...)
|
||||
|
||||
enum passtype {PASS_SCAN, PASS_REVOKE, PASS_REPLAY};
|
||||
|
||||
#define JBD2_FC_REPLAY_STOP 0
|
||||
#define JBD2_FC_REPLAY_CONTINUE 1
|
||||
|
||||
struct journal_s
|
||||
{
|
||||
unsigned long j_flags;
|
||||
int j_errno;
|
||||
struct buffer_head * j_sb_buffer;
|
||||
struct journal_superblock_s *j_superblock;
|
||||
int j_format_version;
|
||||
unsigned long j_head;
|
||||
unsigned long j_tail;
|
||||
unsigned long j_fc_first;
|
||||
unsigned long j_fc_off;
|
||||
unsigned long j_fc_last;
|
||||
unsigned long j_free;
|
||||
unsigned long j_first, j_last;
|
||||
kdev_t j_dev;
|
||||
kdev_t j_fs_dev;
|
||||
int j_blocksize;
|
||||
unsigned int j_blk_offset;
|
||||
unsigned int j_total_len;
|
||||
struct inode * j_inode;
|
||||
tid_t j_tail_sequence;
|
||||
tid_t j_transaction_sequence;
|
||||
__u8 j_uuid[16];
|
||||
struct jbd2_revoke_table_s *j_revoke;
|
||||
struct jbd2_revoke_table_s *j_revoke_table[2];
|
||||
tid_t j_failed_commit;
|
||||
__u32 j_csum_seed;
|
||||
int (*j_fc_replay_callback)(struct journal_s *journal,
|
||||
struct buffer_head *bh,
|
||||
enum passtype pass, int off,
|
||||
tid_t expected_tid);
|
||||
|
||||
};
|
||||
|
||||
#define is_journal_abort(x) 0
|
||||
|
||||
#define BUFFER_TRACE(bh, info) do {} while (0)
|
||||
|
||||
/* Need this so we can compile with configure --enable-gcc-wall */
|
||||
#ifdef NO_INLINE_FUNCS
|
||||
#define inline
|
||||
#endif
|
||||
|
||||
#endif /* _JFS_COMPAT_H */
|
||||
456
include/e2fsprogs/ext2fs/kernel-jbd.h
Executable file
456
include/e2fsprogs/ext2fs/kernel-jbd.h
Executable file
@@ -0,0 +1,456 @@
|
||||
/*
|
||||
* linux/include/linux/jbd.h
|
||||
*
|
||||
* Written by Stephen C. Tweedie <sct@redhat.com>
|
||||
*
|
||||
* Copyright 1998-2000 Red Hat, Inc --- All Rights Reserved
|
||||
*
|
||||
* This file is part of the Linux kernel and is made available under
|
||||
* the terms of the GNU General Public License, version 2, or at your
|
||||
* option, any later version, incorporated herein by reference.
|
||||
*
|
||||
* Definitions for transaction data structures for the buffer cache
|
||||
* filesystem journaling support.
|
||||
*/
|
||||
|
||||
#ifndef _LINUX_JBD_H
|
||||
#define _LINUX_JBD_H
|
||||
|
||||
#include "jfs_compat.h"
|
||||
#define JFS_DEBUG
|
||||
#define jfs_debug jbd_debug
|
||||
|
||||
#ifndef __GNUC__
|
||||
#define __FUNCTION__ ""
|
||||
#endif
|
||||
|
||||
#define journal_oom_retry 0
|
||||
|
||||
#ifdef CONFIG_JBD_DEBUG
|
||||
/*
|
||||
* Define JBD_EXPENSIVE_CHECKING to enable more expensive internal
|
||||
* consistency checks. By default we don't do this unless
|
||||
* CONFIG_JBD_DEBUG is on.
|
||||
*/
|
||||
#define JBD_EXPENSIVE_CHECKING
|
||||
extern int journal_enable_debug;
|
||||
#else
|
||||
#define journal_enable_debug (-1)
|
||||
#endif /* !CONFIG_JBD_DEBUG */
|
||||
|
||||
#ifdef __STDC__
|
||||
#define jbd_debug(n, f, a...) \
|
||||
do { \
|
||||
if ((n) <= journal_enable_debug) { \
|
||||
printk (KERN_DEBUG "(%s, %d): %s: ", \
|
||||
__FILE__, __LINE__, __FUNCTION__); \
|
||||
printk (f, ## a); \
|
||||
} \
|
||||
} while (0)
|
||||
#else
|
||||
#define jbd_debug(x) /* AIX doesn't do STDC */
|
||||
#endif /* !__STDC__ */
|
||||
|
||||
extern void * __jbd_kmalloc (char *where, size_t size, int flags, int retry);
|
||||
#define jbd_kmalloc(size, flags) \
|
||||
__jbd_kmalloc(__FUNCTION__, (size), (flags), journal_oom_retry)
|
||||
#define jbd_rep_kmalloc(size, flags) \
|
||||
__jbd_kmalloc(__FUNCTION__, (size), (flags), 1)
|
||||
|
||||
#define JBD2_MIN_JOURNAL_BLOCKS 1024
|
||||
#define JBD2_DEFAULT_FAST_COMMIT_BLOCKS 256
|
||||
|
||||
/*
|
||||
* Internal structures used by the logging mechanism:
|
||||
*/
|
||||
|
||||
#define JBD2_MAGIC_NUMBER 0xc03b3998U /* The first 4 bytes of /dev/random! */
|
||||
|
||||
/*
|
||||
* On-disk structures
|
||||
*/
|
||||
|
||||
/*
|
||||
* Descriptor block types:
|
||||
*/
|
||||
|
||||
#define JBD2_DESCRIPTOR_BLOCK 1
|
||||
#define JBD2_COMMIT_BLOCK 2
|
||||
#define JBD2_SUPERBLOCK_V1 3
|
||||
#define JBD2_SUPERBLOCK_V2 4
|
||||
#define JBD2_REVOKE_BLOCK 5
|
||||
#define JBD2_FC_BLOCK 6
|
||||
|
||||
/*
|
||||
* Standard header for all descriptor blocks:
|
||||
*/
|
||||
typedef struct journal_header_s
|
||||
{
|
||||
__be32 h_magic;
|
||||
__be32 h_blocktype;
|
||||
__be32 h_sequence;
|
||||
} journal_header_t;
|
||||
|
||||
/*
|
||||
* Checksum types.
|
||||
*/
|
||||
#define JBD2_CRC32_CHKSUM 1
|
||||
#define JBD2_MD5_CHKSUM 2
|
||||
#define JBD2_SHA1_CHKSUM 3
|
||||
#define JBD2_CRC32C_CHKSUM 4
|
||||
|
||||
#define JBD2_CRC32_CHKSUM_SIZE 4
|
||||
|
||||
#define JBD2_CHECKSUM_BYTES (32 / sizeof(__u32))
|
||||
/*
|
||||
* Commit block header for storing transactional checksums:
|
||||
*
|
||||
* NOTE: If FEATURE_COMPAT_CHECKSUM (checksum v1) is set, the h_chksum*
|
||||
* fields are used to store a checksum of the descriptor and data blocks.
|
||||
*
|
||||
* If FEATURE_INCOMPAT_CSUM_V2 (checksum v2) is set, then the h_chksum
|
||||
* field is used to store crc32c(uuid+commit_block). Each journal metadata
|
||||
* block gets its own checksum, and data block checksums are stored in
|
||||
* journal_block_tag (in the descriptor). The other h_chksum* fields are
|
||||
* not used.
|
||||
*
|
||||
* If FEATURE_INCOMPAT_CSUM_V3 is set, the descriptor block uses
|
||||
* journal_block_tag3_t to store a full 32-bit checksum. Everything else
|
||||
* is the same as v2.
|
||||
*
|
||||
* Checksum v1, v2, and v3 are mutually exclusive features.
|
||||
*/
|
||||
struct commit_header {
|
||||
__be32 h_magic;
|
||||
__be32 h_blocktype;
|
||||
__be32 h_sequence;
|
||||
unsigned char h_chksum_type;
|
||||
unsigned char h_chksum_size;
|
||||
unsigned char h_padding[2];
|
||||
__be32 h_chksum[JBD2_CHECKSUM_BYTES];
|
||||
__be64 h_commit_sec;
|
||||
__be32 h_commit_nsec;
|
||||
};
|
||||
|
||||
/*
|
||||
* The block tag: used to describe a single buffer in the journal
|
||||
*/
|
||||
typedef struct journal_block_tag3_s
|
||||
{
|
||||
__be32 t_blocknr; /* The on-disk block number */
|
||||
__be32 t_flags; /* See below */
|
||||
__be32 t_blocknr_high; /* most-significant high 32bits. */
|
||||
__be32 t_checksum; /* crc32c(uuid+seq+block) */
|
||||
} journal_block_tag3_t;
|
||||
|
||||
typedef struct journal_block_tag_s
|
||||
{
|
||||
__be32 t_blocknr; /* The on-disk block number */
|
||||
__be16 t_checksum; /* truncated crc32c(uuid+seq+block) */
|
||||
__be16 t_flags; /* See below */
|
||||
__be32 t_blocknr_high; /* most-significant high 32bits. */
|
||||
} journal_block_tag_t;
|
||||
|
||||
/* Tail of descriptor or revoke block, for checksumming */
|
||||
struct jbd2_journal_block_tail {
|
||||
__be32 t_checksum;
|
||||
};
|
||||
|
||||
/*
|
||||
* The revoke descriptor: used on disk to describe a series of blocks to
|
||||
* be revoked from the log
|
||||
*/
|
||||
typedef struct journal_revoke_header_s
|
||||
{
|
||||
journal_header_t r_header;
|
||||
__be32 r_count; /* Count of bytes used in the block */
|
||||
} jbd2_journal_revoke_header_t;
|
||||
|
||||
/* Definitions for the journal tag flags word: */
|
||||
#define JBD2_FLAG_ESCAPE 1 /* on-disk block is escaped */
|
||||
#define JBD2_FLAG_SAME_UUID 2 /* block has same uuid as previous */
|
||||
#define JBD2_FLAG_DELETED 4 /* block deleted by this transaction */
|
||||
#define JBD2_FLAG_LAST_TAG 8 /* last tag in this descriptor block */
|
||||
|
||||
|
||||
#define UUID_SIZE 16
|
||||
#define JBD2_USERS_MAX 48
|
||||
#define JBD2_USERS_SIZE (UUID_SIZE * JBD2_USERS_MAX)
|
||||
/*
|
||||
* The journal superblock. All fields are in big-endian byte order.
|
||||
*/
|
||||
typedef struct journal_superblock_s
|
||||
{
|
||||
/* 0x0000 */
|
||||
journal_header_t s_header;
|
||||
|
||||
/* 0x000C */
|
||||
/* Static information describing the journal */
|
||||
__be32 s_blocksize; /* journal device blocksize */
|
||||
__be32 s_maxlen; /* total blocks in journal file */
|
||||
__be32 s_first; /* first block of log information */
|
||||
|
||||
/* 0x0018 */
|
||||
/* Dynamic information describing the current state of the log */
|
||||
__be32 s_sequence; /* first commit ID expected in log */
|
||||
__be32 s_start; /* blocknr of start of log */
|
||||
|
||||
/* 0x0020 */
|
||||
/* Error value, as set by journal_abort(). */
|
||||
__s32 s_errno;
|
||||
|
||||
/* 0x0024 */
|
||||
/* Remaining fields are only valid in a version-2 superblock */
|
||||
__be32 s_feature_compat; /* compatible feature set */
|
||||
__be32 s_feature_incompat; /* incompatible feature set */
|
||||
__be32 s_feature_ro_compat; /* readonly-compatible feature set */
|
||||
/* 0x0030 */
|
||||
__u8 s_uuid[16]; /* 128-bit uuid for journal */
|
||||
|
||||
/* 0x0040 */
|
||||
__be32 s_nr_users; /* Nr of filesystems sharing log */
|
||||
|
||||
__be32 s_dynsuper; /* Blocknr of dynamic superblock copy*/
|
||||
|
||||
/* 0x0048 */
|
||||
__be32 s_max_transaction; /* Limit of journal blocks per trans.*/
|
||||
__be32 s_max_trans_data; /* Limit of data blocks per trans. */
|
||||
|
||||
/* 0x0050 */
|
||||
__u8 s_checksum_type; /* checksum type */
|
||||
__u8 s_padding2[3];
|
||||
/* 0x0054 */
|
||||
__be32 s_num_fc_blks; /* Number of fast commit blocks */
|
||||
/* 0x0058 */
|
||||
__be32 s_padding[41];
|
||||
__be32 s_checksum; /* crc32c(superblock) */
|
||||
|
||||
/* 0x0100 */
|
||||
__u8 s_users[JBD2_USERS_SIZE]; /* ids of all fs'es sharing the log */
|
||||
|
||||
/* 0x0400 */
|
||||
} journal_superblock_t;
|
||||
|
||||
#define JBD2_HAS_COMPAT_FEATURE(j,mask) \
|
||||
((j)->j_format_version >= 2 && \
|
||||
((j)->j_superblock->s_feature_compat & ext2fs_cpu_to_be32((mask))))
|
||||
#define JBD2_HAS_RO_COMPAT_FEATURE(j,mask) \
|
||||
((j)->j_format_version >= 2 && \
|
||||
((j)->j_superblock->s_feature_ro_compat & ext2fs_cpu_to_be32((mask))))
|
||||
#define JBD2_HAS_INCOMPAT_FEATURE(j,mask) \
|
||||
((j)->j_format_version >= 2 && \
|
||||
((j)->j_superblock->s_feature_incompat & ext2fs_cpu_to_be32((mask))))
|
||||
|
||||
#define JBD2_FEATURE_COMPAT_CHECKSUM 0x00000001
|
||||
|
||||
#define JBD2_FEATURE_INCOMPAT_REVOKE 0x00000001
|
||||
#define JBD2_FEATURE_INCOMPAT_64BIT 0x00000002
|
||||
#define JBD2_FEATURE_INCOMPAT_ASYNC_COMMIT 0x00000004
|
||||
#define JBD2_FEATURE_INCOMPAT_CSUM_V2 0x00000008
|
||||
#define JBD2_FEATURE_INCOMPAT_CSUM_V3 0x00000010
|
||||
#define JBD2_FEATURE_INCOMPAT_FAST_COMMIT 0x00000020
|
||||
|
||||
/* Features known to this kernel version: */
|
||||
#define JBD2_KNOWN_COMPAT_FEATURES 0
|
||||
#define JBD2_KNOWN_ROCOMPAT_FEATURES 0
|
||||
#define JBD2_KNOWN_INCOMPAT_FEATURES (JBD2_FEATURE_INCOMPAT_REVOKE|\
|
||||
JBD2_FEATURE_INCOMPAT_ASYNC_COMMIT| \
|
||||
JBD2_FEATURE_INCOMPAT_64BIT|\
|
||||
JBD2_FEATURE_INCOMPAT_CSUM_V2| \
|
||||
JBD2_FEATURE_INCOMPAT_CSUM_V3 | \
|
||||
JBD2_FEATURE_INCOMPAT_FAST_COMMIT)
|
||||
|
||||
#ifdef NO_INLINE_FUNCS
|
||||
extern size_t journal_tag_bytes(journal_t *journal);
|
||||
extern int jbd2_journal_has_csum_v2or3(journal_t *journal);
|
||||
extern int jbd2_journal_get_num_fc_blks(journal_superblock_t *jsb);
|
||||
extern int tid_gt(tid_t x, tid_t y) EXT2FS_ATTR((unused));
|
||||
extern int tid_geq(tid_t x, tid_t y) EXT2FS_ATTR((unused));
|
||||
#endif
|
||||
|
||||
#if (defined(E2FSCK_INCLUDE_INLINE_FUNCS) || !defined(NO_INLINE_FUNCS))
|
||||
#ifdef E2FSCK_INCLUDE_INLINE_FUNCS
|
||||
#if (__STDC_VERSION__ >= 199901L)
|
||||
#define _INLINE_ extern inline
|
||||
#else
|
||||
#define _INLINE_ inline
|
||||
#endif
|
||||
#else /* !E2FSCK_INCLUDE_INLINE FUNCS */
|
||||
#if (__STDC_VERSION__ >= 199901L)
|
||||
#define _INLINE_ inline
|
||||
#else /* not C99 */
|
||||
#ifdef __GNUC__
|
||||
#define _INLINE_ extern __inline__
|
||||
#else /* For Watcom C */
|
||||
#define _INLINE_ extern inline
|
||||
#endif /* __GNUC__ */
|
||||
#endif /* __STDC_VERSION__ >= 199901L */
|
||||
#endif /* INCLUDE_INLINE_FUNCS */
|
||||
|
||||
/* journal feature predicate functions */
|
||||
#define JBD2_FEATURE_COMPAT_FUNCS(name, flagname) \
|
||||
_INLINE_ int jbd2_has_feature_##name(journal_t *j); \
|
||||
_INLINE_ int jbd2_has_feature_##name(journal_t *j) \
|
||||
{ \
|
||||
return ((j)->j_format_version >= 2 && \
|
||||
((j)->j_superblock->s_feature_compat & \
|
||||
ext2fs_cpu_to_be32(JBD2_FEATURE_COMPAT_##flagname)) != 0); \
|
||||
} \
|
||||
_INLINE_ void jbd2_set_feature_##name(journal_t *j); \
|
||||
_INLINE_ void jbd2_set_feature_##name(journal_t *j) \
|
||||
{ \
|
||||
(j)->j_superblock->s_feature_compat |= \
|
||||
ext2fs_cpu_to_be32(JBD2_FEATURE_COMPAT_##flagname); \
|
||||
} \
|
||||
_INLINE_ void jbd2_clear_feature_##name(journal_t *j); \
|
||||
_INLINE_ void jbd2_clear_feature_##name(journal_t *j) \
|
||||
{ \
|
||||
(j)->j_superblock->s_feature_compat &= \
|
||||
~ext2fs_cpu_to_be32(JBD2_FEATURE_COMPAT_##flagname); \
|
||||
}
|
||||
|
||||
#define JBD2_FEATURE_RO_COMPAT_FUNCS(name, flagname) \
|
||||
_INLINE_ int jbd2_has_feature_##name(journal_t *j); \
|
||||
_INLINE_ int jbd2_has_feature_##name(journal_t *j) \
|
||||
{ \
|
||||
return ((j)->j_format_version >= 2 && \
|
||||
((j)->j_superblock->s_feature_ro_compat & \
|
||||
ext2fs_cpu_to_be32(JBD2_FEATURE_RO_COMPAT_##flagname)) != 0); \
|
||||
} \
|
||||
_INLINE_ void jbd2_set_feature_##name(journal_t *j); \
|
||||
_INLINE_ void jbd2_set_feature_##name(journal_t *j) \
|
||||
{ \
|
||||
(j)->j_superblock->s_feature_ro_compat |= \
|
||||
ext2fs_cpu_to_be32(JBD2_FEATURE_RO_COMPAT_##flagname); \
|
||||
} \
|
||||
_INLINE_ void jbd2_clear_feature_##name(journal_t *j); \
|
||||
_INLINE_ void jbd2_clear_feature_##name(journal_t *j) \
|
||||
{ \
|
||||
(j)->j_superblock->s_feature_ro_compat &= \
|
||||
~ext2fs_cpu_to_be32(JBD2_FEATURE_RO_COMPAT_##flagname); \
|
||||
}
|
||||
|
||||
#define JBD2_FEATURE_INCOMPAT_FUNCS(name, flagname) \
|
||||
_INLINE_ int jbd2_has_feature_##name(journal_t *j); \
|
||||
_INLINE_ int jbd2_has_feature_##name(journal_t *j) \
|
||||
{ \
|
||||
return ((j)->j_format_version >= 2 && \
|
||||
((j)->j_superblock->s_feature_incompat & \
|
||||
ext2fs_cpu_to_be32(JBD2_FEATURE_INCOMPAT_##flagname)) != 0); \
|
||||
} \
|
||||
_INLINE_ void jbd2_set_feature_##name(journal_t *j); \
|
||||
_INLINE_ void jbd2_set_feature_##name(journal_t *j) \
|
||||
{ \
|
||||
(j)->j_superblock->s_feature_incompat |= \
|
||||
ext2fs_cpu_to_be32(JBD2_FEATURE_INCOMPAT_##flagname); \
|
||||
} \
|
||||
_INLINE_ void jbd2_clear_feature_##name(journal_t *j); \
|
||||
_INLINE_ void jbd2_clear_feature_##name(journal_t *j) \
|
||||
{ \
|
||||
(j)->j_superblock->s_feature_incompat &= \
|
||||
~ext2fs_cpu_to_be32(JBD2_FEATURE_INCOMPAT_##flagname); \
|
||||
}
|
||||
|
||||
#else
|
||||
#define JBD2_FEATURE_COMPAT_FUNCS(name, flagname) \
|
||||
extern int jbd2_has_feature_##name(journal_t *j); \
|
||||
extern void jbd2_set_feature_##name(journal_t *j); \
|
||||
extern void jbd2_clear_feature_##name(journal_t *j);
|
||||
|
||||
#define JBD2_FEATURE_RO_COMPAT_FUNCS(name, flagname) \
|
||||
extern int jbd2_has_feature_##name(journal_t *j); \
|
||||
extern void jbd2_set_feature_##name(journal_t *j); \
|
||||
extern void jbd2_clear_feature_##name(journal_t *j);
|
||||
|
||||
#define JBD2_FEATURE_INCOMPAT_FUNCS(name, flagname) \
|
||||
extern int jbd2_has_feature_##name(journal_t *j); \
|
||||
extern void jbd2_set_feature_##name(journal_t *j); \
|
||||
extern void jbd2_clear_feature_##name(journal_t *j);
|
||||
|
||||
#endif /* (defined(E2FSCK_INCLUDE_INLINE_FUNCS) || !defined(NO_INLINE_FUNCS)) */
|
||||
|
||||
JBD2_FEATURE_COMPAT_FUNCS(checksum, CHECKSUM)
|
||||
|
||||
JBD2_FEATURE_INCOMPAT_FUNCS(revoke, REVOKE)
|
||||
JBD2_FEATURE_INCOMPAT_FUNCS(64bit, 64BIT)
|
||||
JBD2_FEATURE_INCOMPAT_FUNCS(async_commit, ASYNC_COMMIT)
|
||||
JBD2_FEATURE_INCOMPAT_FUNCS(csum2, CSUM_V2)
|
||||
JBD2_FEATURE_INCOMPAT_FUNCS(csum3, CSUM_V3)
|
||||
JBD2_FEATURE_INCOMPAT_FUNCS(fast_commit, FAST_COMMIT)
|
||||
|
||||
#if (defined(E2FSCK_INCLUDE_INLINE_FUNCS) || !defined(NO_INLINE_FUNCS))
|
||||
/*
|
||||
* helper functions to deal with 32 or 64bit block numbers.
|
||||
*/
|
||||
_INLINE_ size_t journal_tag_bytes(journal_t *journal)
|
||||
{
|
||||
size_t sz;
|
||||
|
||||
if (jbd2_has_feature_csum3(journal))
|
||||
return sizeof(journal_block_tag3_t);
|
||||
|
||||
sz = sizeof(journal_block_tag_t);
|
||||
|
||||
if (jbd2_has_feature_csum2(journal))
|
||||
sz += sizeof(__u16);
|
||||
|
||||
if (jbd2_has_feature_64bit(journal))
|
||||
return sz;
|
||||
|
||||
return sz - sizeof(__u32);
|
||||
}
|
||||
|
||||
_INLINE_ int jbd2_journal_has_csum_v2or3(journal_t *journal)
|
||||
{
|
||||
if (jbd2_has_feature_csum2(journal) || jbd2_has_feature_csum3(journal))
|
||||
return 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
_INLINE_ int jbd2_journal_get_num_fc_blks(journal_superblock_t *jsb)
|
||||
{
|
||||
int num_fc_blocks = be32_to_cpu(jsb->s_num_fc_blks);
|
||||
|
||||
return num_fc_blocks ? num_fc_blocks : JBD2_DEFAULT_FAST_COMMIT_BLOCKS;
|
||||
}
|
||||
|
||||
/* Comparison functions for transaction IDs: perform comparisons using
|
||||
* modulo arithmetic so that they work over sequence number wraps. */
|
||||
|
||||
_INLINE_ int tid_gt(tid_t x, tid_t y)
|
||||
{
|
||||
int difference = (x - y);
|
||||
return (difference > 0);
|
||||
}
|
||||
|
||||
_INLINE_ int tid_geq(tid_t x, tid_t y)
|
||||
{
|
||||
int difference = (x - y);
|
||||
return (difference >= 0);
|
||||
}
|
||||
#endif /* (defined(E2FSCK_INCLUDE_INLINE_FUNCS) || !defined(NO_INLINE_FUNCS)) */
|
||||
|
||||
#undef _INLINE_
|
||||
|
||||
extern int journal_blocks_per_page(struct inode *inode);
|
||||
|
||||
/*
|
||||
* Definitions which augment the buffer_head layer
|
||||
*/
|
||||
|
||||
/* journaling buffer types */
|
||||
#define BJ_None 0 /* Not journaled */
|
||||
#define BJ_SyncData 1 /* Normal data: flush before commit */
|
||||
#define BJ_AsyncData 2 /* writepage data: wait on it before commit */
|
||||
#define BJ_Metadata 3 /* Normal journaled metadata */
|
||||
#define BJ_Forget 4 /* Buffer superseded by this transaction */
|
||||
#define BJ_IO 5 /* Buffer is for temporary IO use */
|
||||
#define BJ_Shadow 6 /* Buffer contents being shadowed to the log */
|
||||
#define BJ_LogCtl 7 /* Buffer contains log descriptors */
|
||||
#define BJ_Reserved 8 /* Buffer is reserved for access by journal */
|
||||
#define BJ_Types 9
|
||||
|
||||
extern int jbd_blocks_per_page(struct inode *inode);
|
||||
|
||||
#endif /* _LINUX_JBD_H */
|
||||
111
include/e2fsprogs/ext2fs/kernel-list.h
Executable file
111
include/e2fsprogs/ext2fs/kernel-list.h
Executable file
@@ -0,0 +1,111 @@
|
||||
#ifndef _LINUX_LIST_H
|
||||
#define _LINUX_LIST_H
|
||||
|
||||
#include "compiler.h"
|
||||
|
||||
/*
|
||||
* Simple doubly linked list implementation.
|
||||
*
|
||||
* Some of the internal functions ("__xxx") are useful when
|
||||
* manipulating whole lists rather than single entries, as
|
||||
* sometimes we already know the next/prev entries and we can
|
||||
* generate better code by using them directly rather than
|
||||
* using the generic single-entry routines.
|
||||
*/
|
||||
|
||||
struct list_head {
|
||||
struct list_head *next, *prev;
|
||||
};
|
||||
|
||||
#define LIST_HEAD_INIT(name) { &(name), &(name) }
|
||||
|
||||
#define INIT_LIST_HEAD(ptr) do { \
|
||||
(ptr)->next = (ptr); (ptr)->prev = (ptr); \
|
||||
} while (0)
|
||||
|
||||
#if (!defined(__GNUC__) && !defined(__WATCOMC__))
|
||||
#define __inline__
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Insert a new entry between two known consecutive entries.
|
||||
*
|
||||
* This is only for internal list manipulation where we know
|
||||
* the prev/next entries already!
|
||||
*/
|
||||
static __inline__ void __list_add(struct list_head * new,
|
||||
struct list_head * prev,
|
||||
struct list_head * next)
|
||||
{
|
||||
next->prev = new;
|
||||
new->next = next;
|
||||
new->prev = prev;
|
||||
prev->next = new;
|
||||
}
|
||||
|
||||
/*
|
||||
* Insert a new entry after the specified head..
|
||||
*/
|
||||
static __inline__ void list_add(struct list_head *new, struct list_head *head)
|
||||
{
|
||||
__list_add(new, head, head->next);
|
||||
}
|
||||
|
||||
/*
|
||||
* Insert a new entry at the tail
|
||||
*/
|
||||
static __inline__ void list_add_tail(struct list_head *new, struct list_head *head)
|
||||
{
|
||||
__list_add(new, head->prev, head);
|
||||
}
|
||||
|
||||
/*
|
||||
* Delete a list entry by making the prev/next entries
|
||||
* point to each other.
|
||||
*
|
||||
* This is only for internal list manipulation where we know
|
||||
* the prev/next entries already!
|
||||
*/
|
||||
static __inline__ void __list_del(struct list_head * prev,
|
||||
struct list_head * next)
|
||||
{
|
||||
next->prev = prev;
|
||||
prev->next = next;
|
||||
}
|
||||
|
||||
static __inline__ void list_del(struct list_head *entry)
|
||||
{
|
||||
__list_del(entry->prev, entry->next);
|
||||
}
|
||||
|
||||
static __inline__ int list_empty(struct list_head *head)
|
||||
{
|
||||
return head->next == head;
|
||||
}
|
||||
|
||||
/*
|
||||
* Splice in "list" into "head"
|
||||
*/
|
||||
static __inline__ void list_splice(struct list_head *list, struct list_head *head)
|
||||
{
|
||||
struct list_head *first = list->next;
|
||||
|
||||
if (first != list) {
|
||||
struct list_head *last = list->prev;
|
||||
struct list_head *at = head->next;
|
||||
|
||||
first->prev = head;
|
||||
head->next = first;
|
||||
|
||||
last->next = at;
|
||||
at->prev = last;
|
||||
}
|
||||
}
|
||||
|
||||
#define list_entry(ptr, type, member) \
|
||||
container_of(ptr, type, member)
|
||||
|
||||
#define list_for_each(pos, head) \
|
||||
for (pos = (head)->next; pos != (head); pos = pos->next)
|
||||
|
||||
#endif
|
||||
114
include/e2fsprogs/ext2fs/qcow2.h
Executable file
114
include/e2fsprogs/ext2fs/qcow2.h
Executable file
@@ -0,0 +1,114 @@
|
||||
/*
|
||||
* qcow2.h --- structures and function prototypes for qcow2.c to generate
|
||||
* qcow2 formatted disk images. This format is used originally by QEMU
|
||||
* for virtual machines, and stores the filesystem data on disk in a
|
||||
* packed format to avoid creating sparse image files that need lots of
|
||||
* seeking to read and write.
|
||||
*
|
||||
* The qcow2 format supports zlib compression, but that is not yet
|
||||
* implemented.
|
||||
*
|
||||
* It is possible to directly mount a qcow2 image using qemu-nbd:
|
||||
*
|
||||
* [root]# modprobe nbd max_part=63
|
||||
* [root]# qemu-nbd -c /dev/nbd0 image.img
|
||||
* [root]# mount /dev/nbd0p1 /mnt/qemu
|
||||
*
|
||||
* Format details at http://people.gnome.org/~markmc/qcow-image-format.html
|
||||
*
|
||||
* Copyright (C) 2010 Red Hat, Inc., Lukas Czerner <lczerner@redhat.com>
|
||||
*
|
||||
* %Begin-Header%
|
||||
* This file may be redistributed under the terms of the GNU Public
|
||||
* License.
|
||||
* %End-Header%
|
||||
*/
|
||||
|
||||
/* Number of l2 tables in memory before writeback */
|
||||
#define L2_CACHE_PREALLOC 512
|
||||
|
||||
|
||||
#define QCOW_MAGIC (('Q' << 24) | ('F' << 16) | ('I' << 8) | 0xfb)
|
||||
#define QCOW_VERSION 2
|
||||
#define QCOW_OFLAG_COPIED (1ULL << 63)
|
||||
#define QCOW_OFLAG_COMPRESSED (1ULL << 62)
|
||||
|
||||
#define QCOW_COMPRESSED 1
|
||||
#define QCOW_ENCRYPTED 2
|
||||
#define QCOW_CORRUPTED 3
|
||||
|
||||
struct ext2_qcow2_hdr {
|
||||
__u32 magic;
|
||||
__u32 version;
|
||||
|
||||
__u64 backing_file_offset;
|
||||
__u32 backing_file_size;
|
||||
|
||||
__u32 cluster_bits;
|
||||
__u64 size;
|
||||
__u32 crypt_method;
|
||||
|
||||
__u32 l1_size;
|
||||
__u64 l1_table_offset;
|
||||
|
||||
__u64 refcount_table_offset;
|
||||
__u32 refcount_table_clusters;
|
||||
|
||||
__u32 nb_snapshots;
|
||||
__u64 snapshots_offset;
|
||||
};
|
||||
|
||||
typedef struct ext2_qcow2_l2_table L2_CACHE_HEAD;
|
||||
|
||||
struct ext2_qcow2_l2_table {
|
||||
__u32 l1_index;
|
||||
__u64 offset;
|
||||
__u64 *data;
|
||||
L2_CACHE_HEAD *next;
|
||||
};
|
||||
|
||||
struct ext2_qcow2_l2_cache {
|
||||
L2_CACHE_HEAD *used_head;
|
||||
L2_CACHE_HEAD *used_tail;
|
||||
L2_CACHE_HEAD *free_head;
|
||||
__u32 free;
|
||||
__u32 count;
|
||||
__u64 next_offset;
|
||||
};
|
||||
|
||||
struct ext2_qcow2_refcount {
|
||||
__u64 *refcount_table;
|
||||
__u64 refcount_table_offset;
|
||||
__u64 refcount_block_offset;
|
||||
|
||||
__u32 refcount_table_clusters;
|
||||
__u32 refcount_table_index;
|
||||
__u32 refcount_block_index;
|
||||
|
||||
__u16 *refcount_block;
|
||||
};
|
||||
|
||||
struct ext2_qcow2_image {
|
||||
int fd;
|
||||
struct ext2_qcow2_hdr *hdr;
|
||||
struct ext2_qcow2_l2_cache *l2_cache;
|
||||
struct ext2_qcow2_refcount refcount;
|
||||
__u32 cluster_size;
|
||||
__u32 cluster_bits;
|
||||
__u32 l1_size;
|
||||
__u32 l2_size;
|
||||
|
||||
__u64 *l1_table;
|
||||
__u64 l2_offset;
|
||||
__u64 l1_offset;
|
||||
__u64 image_size;
|
||||
};
|
||||
|
||||
/* Function prototypes */
|
||||
|
||||
/* qcow2.c */
|
||||
|
||||
/* Functions for converting qcow2 image into raw image */
|
||||
struct ext2_qcow2_hdr *qcow2_read_header(int);
|
||||
int qcow2_write_raw_image(int, int, struct ext2_qcow2_hdr *);
|
||||
|
||||
183
include/e2fsprogs/ext2fs/rbtree.h
Executable file
183
include/e2fsprogs/ext2fs/rbtree.h
Executable file
@@ -0,0 +1,183 @@
|
||||
/*
|
||||
Red Black Trees
|
||||
(C) 1999 Andrea Arcangeli <andrea@suse.de>
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
linux/include/linux/rbtree.h
|
||||
|
||||
To use rbtrees you'll have to implement your own insert and search cores.
|
||||
This will avoid us to use callbacks and to drop dramatically performances.
|
||||
I know it's not the cleaner way, but in C (not in C++) to get
|
||||
performances and genericity...
|
||||
|
||||
Some example of insert and search follows here. The search is a plain
|
||||
normal search over an ordered tree. The insert instead must be implemented
|
||||
in two steps: First, the code must insert the element in order as a red leaf
|
||||
in the tree, and then the support library function rb_insert_color() must
|
||||
be called. Such function will do the not trivial work to rebalance the
|
||||
rbtree, if necessary.
|
||||
|
||||
-----------------------------------------------------------------------
|
||||
static inline struct page * rb_search_page_cache(struct inode * inode,
|
||||
unsigned long offset)
|
||||
{
|
||||
struct rb_node * n = inode->i_rb_page_cache.rb_node;
|
||||
struct page * page;
|
||||
|
||||
while (n)
|
||||
{
|
||||
page = rb_entry(n, struct page, rb_page_cache);
|
||||
|
||||
if (offset < page->offset)
|
||||
n = n->rb_left;
|
||||
else if (offset > page->offset)
|
||||
n = n->rb_right;
|
||||
else
|
||||
return page;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static inline struct page * __rb_insert_page_cache(struct inode * inode,
|
||||
unsigned long offset,
|
||||
struct rb_node * node)
|
||||
{
|
||||
struct rb_node ** p = &inode->i_rb_page_cache.rb_node;
|
||||
struct rb_node * parent = NULL;
|
||||
struct page * page;
|
||||
|
||||
while (*p)
|
||||
{
|
||||
parent = *p;
|
||||
page = rb_entry(parent, struct page, rb_page_cache);
|
||||
|
||||
if (offset < page->offset)
|
||||
p = &(*p)->rb_left;
|
||||
else if (offset > page->offset)
|
||||
p = &(*p)->rb_right;
|
||||
else
|
||||
return page;
|
||||
}
|
||||
|
||||
rb_link_node(node, parent, p);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static inline struct page * rb_insert_page_cache(struct inode * inode,
|
||||
unsigned long offset,
|
||||
struct rb_node * node)
|
||||
{
|
||||
struct page * ret;
|
||||
if ((ret = __rb_insert_page_cache(inode, offset, node)))
|
||||
goto out;
|
||||
rb_insert_color(node, &inode->i_rb_page_cache);
|
||||
out:
|
||||
return ret;
|
||||
}
|
||||
-----------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
#ifndef _LINUX_RBTREE_H
|
||||
#define _LINUX_RBTREE_H
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdint.h>
|
||||
#include "compiler.h"
|
||||
|
||||
#if __GNUC_PREREQ (4, 6)
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wunused-function"
|
||||
#endif
|
||||
|
||||
struct rb_node
|
||||
{
|
||||
uintptr_t rb_parent_color;
|
||||
#define RB_RED 0
|
||||
#define RB_BLACK 1
|
||||
struct rb_node *rb_right;
|
||||
struct rb_node *rb_left;
|
||||
} __attribute__((aligned(sizeof(long))));
|
||||
/* The alignment might seem pointless, but allegedly CRIS needs it */
|
||||
|
||||
struct rb_root
|
||||
{
|
||||
struct rb_node *rb_node;
|
||||
};
|
||||
|
||||
|
||||
#define ext2fs_rb_parent(r) ((struct rb_node *)((r)->rb_parent_color & ~3))
|
||||
#define ext2fs_rb_color(r) ((r)->rb_parent_color & 1)
|
||||
#define ext2fs_rb_is_red(r) (!ext2fs_rb_color(r))
|
||||
#define ext2fs_rb_is_black(r) ext2fs_rb_color(r)
|
||||
#define ext2fs_rb_set_red(r) do { (r)->rb_parent_color &= ~1; } while (0)
|
||||
#define ext2fs_rb_set_black(r) do { (r)->rb_parent_color |= 1; } while (0)
|
||||
|
||||
static inline void ext2fs_rb_set_parent(struct rb_node *rb, struct rb_node *p)
|
||||
{
|
||||
rb->rb_parent_color = (rb->rb_parent_color & 3) | (uintptr_t)p;
|
||||
}
|
||||
static inline void ext2fs_rb_set_color(struct rb_node *rb, int color)
|
||||
{
|
||||
rb->rb_parent_color = (rb->rb_parent_color & ~1) | color;
|
||||
}
|
||||
|
||||
#define RB_ROOT (struct rb_root) { NULL, }
|
||||
#define ext2fs_rb_entry(ptr, type, member) container_of(ptr, type, member)
|
||||
|
||||
static inline int ext2fs_rb_empty_root(struct rb_root *root)
|
||||
{
|
||||
return root->rb_node == NULL;
|
||||
}
|
||||
|
||||
static inline int ext2fs_rb_empty_node(struct rb_node *node)
|
||||
{
|
||||
return ext2fs_rb_parent(node) == node;
|
||||
}
|
||||
|
||||
static inline void ext2fs_rb_clear_node(struct rb_node *node)
|
||||
{
|
||||
ext2fs_rb_set_parent(node, node);
|
||||
}
|
||||
|
||||
extern void ext2fs_rb_insert_color(struct rb_node *, struct rb_root *);
|
||||
extern void ext2fs_rb_erase(struct rb_node *, struct rb_root *);
|
||||
|
||||
/* Find logical next and previous nodes in a tree */
|
||||
extern struct rb_node *ext2fs_rb_next(struct rb_node *);
|
||||
extern struct rb_node *ext2fs_rb_prev(struct rb_node *);
|
||||
extern struct rb_node *ext2fs_rb_first(const struct rb_root *);
|
||||
extern struct rb_node *ext2fs_rb_last(const struct rb_root *);
|
||||
|
||||
/* Fast replacement of a single node without remove/rebalance/add/rebalance */
|
||||
extern void ext2fs_rb_replace_node(struct rb_node *victim, struct rb_node *new,
|
||||
struct rb_root *root);
|
||||
|
||||
static inline void ext2fs_rb_link_node(struct rb_node * node,
|
||||
struct rb_node * parent,
|
||||
struct rb_node ** rb_link)
|
||||
{
|
||||
node->rb_parent_color = (uintptr_t)parent;
|
||||
node->rb_left = node->rb_right = NULL;
|
||||
|
||||
*rb_link = node;
|
||||
}
|
||||
|
||||
#if __GNUC_PREREQ (4, 6)
|
||||
#pragma GCC diagnostic pop
|
||||
#endif
|
||||
|
||||
#endif /* _LINUX_RBTREE_H */
|
||||
215
include/e2fsprogs/ext2fs/tdb.h
Executable file
215
include/e2fsprogs/ext2fs/tdb.h
Executable file
@@ -0,0 +1,215 @@
|
||||
#ifndef __TDB_H__
|
||||
#define __TDB_H__
|
||||
|
||||
/*
|
||||
Unix SMB/CIFS implementation.
|
||||
|
||||
trivial database library
|
||||
|
||||
Copyright (C) Andrew Tridgell 1999-2004
|
||||
|
||||
** NOTE! The following LGPL license applies to the tdb
|
||||
** library. This does NOT imply that all of Samba is released
|
||||
** under the LGPL
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
/* flags to tdb_store() */
|
||||
#define TDB_REPLACE 1
|
||||
#define TDB_INSERT 2
|
||||
#define TDB_MODIFY 3
|
||||
|
||||
/* flags for tdb_open() */
|
||||
#define TDB_DEFAULT 0 /* just a readability place holder */
|
||||
#define TDB_CLEAR_IF_FIRST 1
|
||||
#define TDB_INTERNAL 2 /* don't store on disk */
|
||||
#define TDB_NOLOCK 4 /* don't do any locking */
|
||||
#define TDB_NOMMAP 8 /* don't use mmap */
|
||||
#define TDB_CONVERT 16 /* convert endian (internal use) */
|
||||
#define TDB_BIGENDIAN 32 /* header is big-endian (internal use) */
|
||||
#define TDB_NOSYNC 64 /* don't use synchronous transactions */
|
||||
#define TDB_SEQNUM 128 /* maintain a sequence number */
|
||||
|
||||
#define TDB_ERRCODE(code, ret) ((tdb->ecode = (code)), ret)
|
||||
|
||||
/* error codes */
|
||||
enum TDB_ERROR {TDB_SUCCESS=0, TDB_ERR_CORRUPT, TDB_ERR_IO, TDB_ERR_LOCK,
|
||||
TDB_ERR_OOM, TDB_ERR_EXISTS, TDB_ERR_NOLOCK, TDB_ERR_LOCK_TIMEOUT,
|
||||
TDB_ERR_NOEXIST, TDB_ERR_EINVAL, TDB_ERR_RDONLY};
|
||||
|
||||
/* debugging uses one of the following levels */
|
||||
enum tdb_debug_level {TDB_DEBUG_FATAL = 0, TDB_DEBUG_ERROR,
|
||||
TDB_DEBUG_WARNING, TDB_DEBUG_TRACE};
|
||||
|
||||
typedef struct TDB_DATA {
|
||||
unsigned char *dptr;
|
||||
size_t dsize;
|
||||
} TDB_DATA;
|
||||
|
||||
#ifndef PRINTF_ATTRIBUTE
|
||||
#if (__GNUC__ >= 3)
|
||||
/** Use gcc attribute to check printf fns. a1 is the 1-based index of
|
||||
* the parameter containing the format, and a2 the index of the first
|
||||
* argument. Note that some gcc 2.x versions don't handle this
|
||||
* properly **/
|
||||
#define PRINTF_ATTRIBUTE(a1, a2) __attribute__ ((format (__printf__, a1, a2)))
|
||||
#else
|
||||
#define PRINTF_ATTRIBUTE(a1, a2)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* ext2fs tdb renames */
|
||||
#define tdb_open ext2fs_tdb_open
|
||||
#define tdb_open_ex ext2fs_tdb_open_ex
|
||||
#define tdb_set_max_dead ext2fs_tdb_set_max_dead
|
||||
#define tdb_reopen ext2fs_tdb_reopen
|
||||
#define tdb_reopen_all ext2fs_tdb_reopen_all
|
||||
#define tdb_set_logging_function ext2fs_tdb_set_logging_function
|
||||
#define tdb_error ext2fs_tdb_error
|
||||
#define tdb_errorstr ext2fs_tdb_errorstr
|
||||
#define tdb_fetch ext2fs_tdb_fetch
|
||||
#define tdb_parse_record ext2fs_tdb_parse_record
|
||||
#define tdb_delete ext2fs_tdb_delete
|
||||
#define tdb_store ext2fs_tdb_store
|
||||
#define tdb_append ext2fs_tdb_append
|
||||
#define tdb_close ext2fs_tdb_close
|
||||
#define tdb_firstkey ext2fs_tdb_firstkey
|
||||
#define tdb_nextkey ext2fs_tdb_nextkey
|
||||
#define tdb_traverse ext2fs_tdb_traverse
|
||||
#define tdb_traverse_read ext2fs_tdb_traverse_read
|
||||
#define tdb_exists ext2fs_tdb_exists
|
||||
#define tdb_lockall ext2fs_tdb_lockall
|
||||
#define tdb_unlockall ext2fs_tdb_unlockall
|
||||
#define tdb_lockall_read ext2fs_tdb_lockall_read
|
||||
#define tdb_unlockall_read ext2fs_tdb_unlockall_read
|
||||
#define tdb_name ext2fs_tdb_name
|
||||
#define tdb_fd ext2fs_tdb_fd
|
||||
#define tdb_log_fn ext2fs_tdb_log_fn
|
||||
#define tdb_get_logging_private ext2fs_tdb_get_logging_private
|
||||
#define tdb_transaction_start ext2fs_tdb_transaction_start
|
||||
#define tdb_transaction_commit ext2fs_tdb_transaction_commit
|
||||
#define tdb_transaction_cancel ext2fs_tdb_transaction_cancel
|
||||
#define tdb_transaction_recover ext2fs_tdb_transaction_recover
|
||||
#define tdb_get_seqnum ext2fs_tdb_get_seqnum
|
||||
#define tdb_hash_size ext2fs_tdb_hash_size
|
||||
#define tdb_map_size ext2fs_tdb_map_size
|
||||
#define tdb_get_flags ext2fs_tdb_get_flags
|
||||
#define tdb_chainlock ext2fs_tdb_chainlock
|
||||
#define tdb_chainunlock ext2fs_tdb_chainunlock
|
||||
#define tdb_chainlock_read ext2fs_tdb_chainlock_read
|
||||
#define tdb_chainunlock_read ext2fs_tdb_chainunlock_read
|
||||
#define tdb_dump_all ext2fs_tdb_dump_all
|
||||
#define tdb_printfreelist ext2fs_tdb_printfreelist
|
||||
#define tdb_validate_freelist ext2fs_tdb_validate_freelist
|
||||
#define tdb_chainlock_mark ext2fs_tdb_chainlock_mark
|
||||
#define tdb_chainlock_nonblock ext2fs_tdb_chainlock_nonblock
|
||||
#define tdb_chainlock_unmark ext2fs_tdb_chainlock_unmark
|
||||
#define tdb_enable_seqnum ext2fs_tdb_enable_seqnum
|
||||
#define tdb_increment_seqnum_nonblock ext2fs_tdb_increment_seqnum_nonblock
|
||||
#define tdb_lock_nonblock ext2fs_tdb_lock_nonblock
|
||||
#define tdb_lockall_mark ext2fs_tdb_lockall_mark
|
||||
#define tdb_lockall_nonblock ext2fs_tdb_lockall_nonblock
|
||||
#define tdb_lockall_read_nonblock ext2fs_tdb_lockall_read_nonblock
|
||||
#define tdb_lockall_unmark ext2fs_tdb_lockall_unmark
|
||||
#define tdb_flush ext2fs_tdb_flush
|
||||
|
||||
/* this is the context structure that is returned from a db open */
|
||||
typedef struct tdb_context TDB_CONTEXT;
|
||||
|
||||
typedef int (*tdb_traverse_func)(struct tdb_context *, TDB_DATA, TDB_DATA, void *);
|
||||
typedef void (*tdb_log_func)(struct tdb_context *, enum tdb_debug_level, const char *, ...) PRINTF_ATTRIBUTE(3, 4);
|
||||
typedef unsigned int (*tdb_hash_func)(TDB_DATA *key);
|
||||
|
||||
struct tdb_logging_context {
|
||||
tdb_log_func log_fn;
|
||||
void *log_private;
|
||||
};
|
||||
|
||||
struct tdb_context *tdb_open(const char *name, int hash_size, int tdb_flags,
|
||||
int open_flags, mode_t mode);
|
||||
struct tdb_context *tdb_open_ex(const char *name, int hash_size, int tdb_flags,
|
||||
int open_flags, mode_t mode,
|
||||
const struct tdb_logging_context *log_ctx,
|
||||
tdb_hash_func hash_fn);
|
||||
void tdb_set_max_dead(struct tdb_context *tdb, int max_dead);
|
||||
|
||||
int tdb_reopen(struct tdb_context *tdb);
|
||||
int tdb_reopen_all(int parent_longlived);
|
||||
void tdb_set_logging_function(struct tdb_context *tdb, const struct tdb_logging_context *log_ctx);
|
||||
enum TDB_ERROR tdb_error(struct tdb_context *tdb);
|
||||
const char *tdb_errorstr(struct tdb_context *tdb);
|
||||
TDB_DATA tdb_fetch(struct tdb_context *tdb, TDB_DATA key);
|
||||
int tdb_parse_record(struct tdb_context *tdb, TDB_DATA key,
|
||||
int (*parser)(TDB_DATA key, TDB_DATA data,
|
||||
void *private_data),
|
||||
void *private_data);
|
||||
int tdb_delete(struct tdb_context *tdb, TDB_DATA key);
|
||||
int tdb_store(struct tdb_context *tdb, TDB_DATA key, TDB_DATA dbuf, int flag);
|
||||
int tdb_append(struct tdb_context *tdb, TDB_DATA key, TDB_DATA new_dbuf);
|
||||
int tdb_close(struct tdb_context *tdb);
|
||||
TDB_DATA tdb_firstkey(struct tdb_context *tdb);
|
||||
TDB_DATA tdb_nextkey(struct tdb_context *tdb, TDB_DATA key);
|
||||
int tdb_traverse(struct tdb_context *tdb, tdb_traverse_func fn, void *);
|
||||
int tdb_traverse_read(struct tdb_context *tdb, tdb_traverse_func fn, void *);
|
||||
int tdb_exists(struct tdb_context *tdb, TDB_DATA key);
|
||||
int tdb_lockall(struct tdb_context *tdb);
|
||||
int tdb_lockall_nonblock(struct tdb_context *tdb);
|
||||
int tdb_unlockall(struct tdb_context *tdb);
|
||||
int tdb_lockall_read(struct tdb_context *tdb);
|
||||
int tdb_lockall_read_nonblock(struct tdb_context *tdb);
|
||||
int tdb_unlockall_read(struct tdb_context *tdb);
|
||||
int tdb_lockall_mark(struct tdb_context *tdb);
|
||||
int tdb_lockall_unmark(struct tdb_context *tdb);
|
||||
const char *tdb_name(struct tdb_context *tdb);
|
||||
int tdb_fd(struct tdb_context *tdb);
|
||||
tdb_log_func tdb_log_fn(struct tdb_context *tdb);
|
||||
void *tdb_get_logging_private(struct tdb_context *tdb);
|
||||
int tdb_transaction_start(struct tdb_context *tdb);
|
||||
int tdb_transaction_commit(struct tdb_context *tdb);
|
||||
int tdb_transaction_cancel(struct tdb_context *tdb);
|
||||
int tdb_transaction_recover(struct tdb_context *tdb);
|
||||
int tdb_get_seqnum(struct tdb_context *tdb);
|
||||
int tdb_hash_size(struct tdb_context *tdb);
|
||||
size_t tdb_map_size(struct tdb_context *tdb);
|
||||
int tdb_get_flags(struct tdb_context *tdb);
|
||||
void tdb_enable_seqnum(struct tdb_context *tdb);
|
||||
void tdb_increment_seqnum_nonblock(struct tdb_context *tdb);
|
||||
int tdb_flush(struct tdb_context *tdb);
|
||||
|
||||
/* Low level locking functions: use with care */
|
||||
int tdb_chainlock(struct tdb_context *tdb, TDB_DATA key);
|
||||
int tdb_chainlock_nonblock(struct tdb_context *tdb, TDB_DATA key);
|
||||
int tdb_chainunlock(struct tdb_context *tdb, TDB_DATA key);
|
||||
int tdb_chainlock_read(struct tdb_context *tdb, TDB_DATA key);
|
||||
int tdb_chainunlock_read(struct tdb_context *tdb, TDB_DATA key);
|
||||
int tdb_chainlock_mark(struct tdb_context *tdb, TDB_DATA key);
|
||||
int tdb_chainlock_unmark(struct tdb_context *tdb, TDB_DATA key);
|
||||
|
||||
/* Debug functions. Not used in production. */
|
||||
void tdb_dump_all(struct tdb_context *tdb);
|
||||
int tdb_printfreelist(struct tdb_context *tdb);
|
||||
int tdb_validate_freelist(struct tdb_context *tdb, int *pnum_entries);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* tdb.h */
|
||||
4109
include/e2fsprogs/ext2fs/utf8data.h
Executable file
4109
include/e2fsprogs/ext2fs/utf8data.h
Executable file
File diff suppressed because it is too large
Load Diff
120
include/e2fsprogs/ext2fs/utf8n.h
Executable file
120
include/e2fsprogs/ext2fs/utf8n.h
Executable file
@@ -0,0 +1,120 @@
|
||||
/*
|
||||
* Copyright (c) 2014 SGI.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it would be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
*/
|
||||
|
||||
/* This code is copied from the linux kernel. We have a userspace
|
||||
* version here to such that hashes will match that implementation.
|
||||
*/
|
||||
|
||||
#ifndef UTF8NORM_H
|
||||
#define UTF8NORM_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
|
||||
/* Encoding a unicode version number as a single unsigned int. */
|
||||
#define UNICODE_MAJ_SHIFT (16)
|
||||
#define UNICODE_MIN_SHIFT (8)
|
||||
|
||||
#define UNICODE_AGE(MAJ, MIN, REV) \
|
||||
(((unsigned int)(MAJ) << UNICODE_MAJ_SHIFT) | \
|
||||
((unsigned int)(MIN) << UNICODE_MIN_SHIFT) | \
|
||||
((unsigned int)(REV)))
|
||||
|
||||
/* Highest unicode version supported by the data tables. */
|
||||
extern int utf8version_is_supported(uint8_t maj, uint8_t min, uint8_t rev);
|
||||
extern int utf8version_latest(void);
|
||||
|
||||
/*
|
||||
* Look for the correct const struct utf8data for a unicode version.
|
||||
* Returns NULL if the version requested is too new.
|
||||
*
|
||||
* Two normalization forms are supported: nfdi and nfdicf.
|
||||
*
|
||||
* nfdi:
|
||||
* - Apply unicode normalization form NFD.
|
||||
* - Remove any Default_Ignorable_Code_Point.
|
||||
*
|
||||
* nfdicf:
|
||||
* - Apply unicode normalization form NFD.
|
||||
* - Remove any Default_Ignorable_Code_Point.
|
||||
* - Apply a full casefold (C + F).
|
||||
*/
|
||||
extern const struct utf8data *utf8nfdi(unsigned int maxage);
|
||||
extern const struct utf8data *utf8nfdicf(unsigned int maxage);
|
||||
|
||||
/*
|
||||
* Determine the maximum age of any unicode character in the string.
|
||||
* Returns 0 if only unassigned code points are present.
|
||||
* Returns -1 if the input is not valid UTF-8.
|
||||
*/
|
||||
extern int utf8agemax(const struct utf8data *data, const char *s);
|
||||
extern int utf8nagemax(const struct utf8data *data, const char *s, size_t len);
|
||||
|
||||
/*
|
||||
* Determine the minimum age of any unicode character in the string.
|
||||
* Returns 0 if any unassigned code points are present.
|
||||
* Returns -1 if the input is not valid UTF-8.
|
||||
*/
|
||||
extern int utf8agemin(const struct utf8data *data, const char *s);
|
||||
extern int utf8nagemin(const struct utf8data *data, const char *s, size_t len);
|
||||
|
||||
/*
|
||||
* Determine the length of the normalized from of the string,
|
||||
* excluding any terminating NULL byte.
|
||||
* Returns 0 if only ignorable code points are present.
|
||||
* Returns -1 if the input is not valid UTF-8.
|
||||
*/
|
||||
extern ssize_t utf8len(const struct utf8data *data, const char *s);
|
||||
extern ssize_t utf8nlen(const struct utf8data *data, const char *s, size_t len);
|
||||
|
||||
/* Needed in struct utf8cursor below. */
|
||||
#define UTF8HANGULLEAF (12)
|
||||
|
||||
/*
|
||||
* Cursor structure used by the normalizer.
|
||||
*/
|
||||
struct utf8cursor {
|
||||
const struct utf8data *data;
|
||||
const char *s;
|
||||
const char *p;
|
||||
const char *ss;
|
||||
const char *sp;
|
||||
unsigned int len;
|
||||
unsigned int slen;
|
||||
short int ccc;
|
||||
short int nccc;
|
||||
unsigned char hangul[UTF8HANGULLEAF];
|
||||
};
|
||||
|
||||
/*
|
||||
* Initialize a utf8cursor to normalize a string.
|
||||
* Returns 0 on success.
|
||||
* Returns -1 on failure.
|
||||
*/
|
||||
extern int utf8cursor(struct utf8cursor *u8c, const struct utf8data *data,
|
||||
const char *s);
|
||||
extern int utf8ncursor(struct utf8cursor *u8c, const struct utf8data *data,
|
||||
const char *s, size_t len);
|
||||
|
||||
/*
|
||||
* Get the next byte in the normalization.
|
||||
* Returns a value > 0 && < 256 on success.
|
||||
* Returns 0 when the end of the normalization is reached.
|
||||
* Returns -1 if the string being normalized is not valid UTF-8.
|
||||
*/
|
||||
extern int utf8byte(struct utf8cursor *u8c);
|
||||
|
||||
#endif /* UTF8NORM_H */
|
||||
Reference in New Issue
Block a user