📄 squashfs_fs.h
字号:
extern int squashfs_uncompress_block(void *d, int dstlen, void *s, int srclen);extern int squashfs_uncompress_init(void);extern int squashfs_uncompress_exit(void);/* * macros to convert each packed bitfield structure from little endian to big * endian and vice versa. These are needed when creating or using a filesystem on a * machine with different byte ordering to the target architecture. * */#define SQUASHFS_SWAP_SUPER_BLOCK(s, d) {\ SQUASHFS_MEMSET(s, d, sizeof(squashfs_super_block));\ SQUASHFS_SWAP((s)->s_magic, d, 0, 32);\ SQUASHFS_SWAP((s)->inodes, d, 32, 32);\ SQUASHFS_SWAP((s)->bytes_used, d, 64, 32);\ SQUASHFS_SWAP((s)->uid_start, d, 96, 32);\ SQUASHFS_SWAP((s)->guid_start, d, 128, 32);\ SQUASHFS_SWAP((s)->inode_table_start, d, 160, 32);\ SQUASHFS_SWAP((s)->directory_table_start, d, 192, 32);\ SQUASHFS_SWAP((s)->s_major, d, 224, 16);\ SQUASHFS_SWAP((s)->s_minor, d, 240, 16);\ SQUASHFS_SWAP((s)->block_size_1, d, 256, 16);\ SQUASHFS_SWAP((s)->block_log, d, 272, 16);\ SQUASHFS_SWAP((s)->flags, d, 288, 8);\ SQUASHFS_SWAP((s)->no_uids, d, 296, 8);\ SQUASHFS_SWAP((s)->no_guids, d, 304, 8);\ SQUASHFS_SWAP((s)->mkfs_time, d, 312, 32);\ SQUASHFS_SWAP((s)->root_inode, d, 344, 64);\ SQUASHFS_SWAP((s)->block_size, d, 408, 32);\ SQUASHFS_SWAP((s)->fragments, d, 440, 32);\ SQUASHFS_SWAP((s)->fragment_table_start, d, 472, 32);\}#define SQUASHFS_SWAP_BASE_INODE_HEADER(s, d, n) {\ SQUASHFS_MEMSET(s, d, n);\ SQUASHFS_SWAP((s)->inode_type, d, 0, 4);\ SQUASHFS_SWAP((s)->mode, d, 4, 12);\ SQUASHFS_SWAP((s)->uid, d, 16, 8);\ SQUASHFS_SWAP((s)->guid, d, 24, 8);\}#define SQUASHFS_SWAP_IPC_INODE_HEADER(s, d) SQUASHFS_SWAP_BASE_INODE_HEADER(s, d, sizeof(squashfs_ipc_inode_header))#define SQUASHFS_SWAP_DEV_INODE_HEADER(s, d) {\ SQUASHFS_SWAP_BASE_INODE_HEADER(s, d, sizeof(squashfs_dev_inode_header));\ SQUASHFS_SWAP((s)->rdev, d, 32, 16);\}#define SQUASHFS_SWAP_SYMLINK_INODE_HEADER(s, d) {\ SQUASHFS_SWAP_BASE_INODE_HEADER(s, d, sizeof(squashfs_symlink_inode_header));\ SQUASHFS_SWAP((s)->symlink_size, d, 32, 16);\}#define SQUASHFS_SWAP_REG_INODE_HEADER(s, d) {\ SQUASHFS_SWAP_BASE_INODE_HEADER(s, d, sizeof(squashfs_reg_inode_header));\ SQUASHFS_SWAP((s)->mtime, d, 32, 32);\ SQUASHFS_SWAP((s)->start_block, d, 64, 32);\ SQUASHFS_SWAP((s)->fragment, d, 96, 32);\ SQUASHFS_SWAP((s)->offset, d, 128, 32);\ SQUASHFS_SWAP((s)->file_size, d, 160, SQUASHFS_MAX_FILE_SIZE_LOG);\}#define SQUASHFS_SWAP_DIR_INODE_HEADER(s, d) {\ SQUASHFS_SWAP_BASE_INODE_HEADER(s, d, sizeof(squashfs_dir_inode_header));\ SQUASHFS_SWAP((s)->file_size, d, 32, 19);\ SQUASHFS_SWAP((s)->offset, d, 51, 13);\ SQUASHFS_SWAP((s)->mtime, d, 64, 32);\ SQUASHFS_SWAP((s)->start_block, d, 96, 24);\}#define SQUASHFS_SWAP_LDIR_INODE_HEADER(s, d) {\ SQUASHFS_SWAP_BASE_INODE_HEADER(s, d, sizeof(squashfs_ldir_inode_header));\ SQUASHFS_SWAP((s)->file_size, d, 32, 27);\ SQUASHFS_SWAP((s)->offset, d, 59, 13);\ SQUASHFS_SWAP((s)->mtime, d, 72, 32);\ SQUASHFS_SWAP((s)->start_block, d, 104, 24);\ SQUASHFS_SWAP((s)->i_count, d, 128, 16);\}#define SQUASHFS_SWAP_DIR_INDEX(s, d) {\ SQUASHFS_MEMSET(s, d, sizeof(squashfs_dir_index));\ SQUASHFS_SWAP((s)->index, d, 0, 27);\ SQUASHFS_SWAP((s)->start_block, d, 27, 29);\ SQUASHFS_SWAP((s)->size, d, 56, 8);\}#define SQUASHFS_SWAP_DIR_HEADER(s, d) {\ SQUASHFS_MEMSET(s, d, sizeof(squashfs_dir_header));\ SQUASHFS_SWAP((s)->count, d, 0, 8);\ SQUASHFS_SWAP((s)->start_block, d, 8, 24);\}#define SQUASHFS_SWAP_DIR_ENTRY(s, d) {\ SQUASHFS_MEMSET(s, d, sizeof(squashfs_dir_entry));\ SQUASHFS_SWAP((s)->offset, d, 0, 13);\ SQUASHFS_SWAP((s)->type, d, 13, 3);\ SQUASHFS_SWAP((s)->size, d, 16, 8);\}#define SQUASHFS_SWAP_FRAGMENT_ENTRY(s, d) {\ SQUASHFS_MEMSET(s, d, sizeof(squashfs_fragment_entry));\ SQUASHFS_SWAP((s)->start_block, d, 0, 32);\ SQUASHFS_SWAP((s)->size, d, 32, 32);\}#define SQUASHFS_SWAP_SHORTS(s, d, n) {\ int entry;\ int bit_position;\ SQUASHFS_MEMSET(s, d, n * 2);\ for(entry = 0, bit_position = 0; entry < n; entry++, bit_position += 16)\ SQUASHFS_SWAP(s[entry], d, bit_position, 16);\}#define SQUASHFS_SWAP_INTS(s, d, n) {\ int entry;\ int bit_position;\ SQUASHFS_MEMSET(s, d, n * 4);\ for(entry = 0, bit_position = 0; entry < n; entry++, bit_position += 32)\ SQUASHFS_SWAP(s[entry], d, bit_position, 32);\}#define SQUASHFS_SWAP_DATA(s, d, n, bits) {\ int entry;\ int bit_position;\ SQUASHFS_MEMSET(s, d, n * bits / 8);\ for(entry = 0, bit_position = 0; entry < n; entry++, bit_position += bits)\ SQUASHFS_SWAP(s[entry], d, bit_position, bits);\}#define SQUASHFS_SWAP_FRAGMENT_INDEXES(s, d, n) SQUASHFS_SWAP_INTS(s, d, n)#ifdef SQUASHFS_1_0_COMPATIBILITYtypedef struct { unsigned int inode_type:4; unsigned int mode:12; /* protection */ unsigned int uid:4; /* index into uid table */ unsigned int guid:4; /* index into guid table */} __attribute__ ((packed)) squashfs_base_inode_header_1;typedef struct { unsigned int inode_type:4; unsigned int mode:12; /* protection */ unsigned int uid:4; /* index into uid table */ unsigned int guid:4; /* index into guid table */ unsigned int type:4; unsigned int offset:4;} __attribute__ ((packed)) squashfs_ipc_inode_header_1;typedef struct { unsigned int inode_type:4; unsigned int mode:12; /* protection */ unsigned int uid:4; /* index into uid table */ unsigned int guid:4; /* index into guid table */ unsigned short rdev;} __attribute__ ((packed)) squashfs_dev_inode_header_1; typedef struct { unsigned int inode_type:4; unsigned int mode:12; /* protection */ unsigned int uid:4; /* index into uid table */ unsigned int guid:4; /* index into guid table */ unsigned short symlink_size; char symlink[0];} __attribute__ ((packed)) squashfs_symlink_inode_header_1;typedef struct { unsigned int inode_type:4; unsigned int mode:12; /* protection */ unsigned int uid:4; /* index into uid table */ unsigned int guid:4; /* index into guid table */ unsigned int mtime; squashfs_block start_block; unsigned int file_size:SQUASHFS_MAX_FILE_SIZE_LOG; unsigned short block_list[0];} __attribute__ ((packed)) squashfs_reg_inode_header_1;typedef struct { unsigned int inode_type:4; unsigned int mode:12; /* protection */ unsigned int uid:4; /* index into uid table */ unsigned int guid:4; /* index into guid table */ unsigned int file_size:19; unsigned int offset:13; unsigned int mtime; unsigned int start_block:24;} __attribute__ ((packed)) squashfs_dir_inode_header_1;#define SQUASHFS_SWAP_BASE_INODE_HEADER_1(s, d, n) {\ SQUASHFS_MEMSET(s, d, n);\ SQUASHFS_SWAP((s)->inode_type, d, 0, 4);\ SQUASHFS_SWAP((s)->mode, d, 4, 12);\ SQUASHFS_SWAP((s)->uid, d, 16, 4);\ SQUASHFS_SWAP((s)->guid, d, 20, 4);\}#define SQUASHFS_SWAP_IPC_INODE_HEADER_1(s, d) {\ SQUASHFS_SWAP_BASE_INODE_HEADER_1(s, d, sizeof(squashfs_ipc_inode_header_1));\ SQUASHFS_SWAP((s)->type, d, 24, 4);\ SQUASHFS_SWAP((s)->offset, d, 28, 4);\}#define SQUASHFS_SWAP_DEV_INODE_HEADER_1(s, d) {\ SQUASHFS_SWAP_BASE_INODE_HEADER_1(s, d, sizeof(squashfs_dev_inode_header_1));\ SQUASHFS_SWAP((s)->rdev, d, 24, 16);\}#define SQUASHFS_SWAP_SYMLINK_INODE_HEADER_1(s, d) {\ SQUASHFS_SWAP_BASE_INODE_HEADER(s, d, sizeof(squashfs_symlink_inode_header_1));\ SQUASHFS_SWAP((s)->symlink_size, d, 24, 16);\}#define SQUASHFS_SWAP_REG_INODE_HEADER_1(s, d) {\ SQUASHFS_SWAP_BASE_INODE_HEADER(s, d, sizeof(squashfs_reg_inode_header_1));\ SQUASHFS_SWAP((s)->mtime, d, 24, 32);\ SQUASHFS_SWAP((s)->start_block, d, 56, 32);\ SQUASHFS_SWAP((s)->file_size, d, 88, SQUASHFS_MAX_FILE_SIZE_LOG);\}#define SQUASHFS_SWAP_DIR_INODE_HEADER_1(s, d) {\ SQUASHFS_SWAP_BASE_INODE_HEADER(s, d, sizeof(squashfs_dir_inode_header_1));\ SQUASHFS_SWAP((s)->file_size, d, 24, 19);\ SQUASHFS_SWAP((s)->offset, d, 43, 13);\ SQUASHFS_SWAP((s)->mtime, d, 56, 32);\ SQUASHFS_SWAP((s)->start_block, d, 88, 24);\}#endif#ifdef __KERNEL__/* * macros used to swap each structure entry, taking into account * bitfields and different bitfield placing conventions on differing architectures */#include <asm/byteorder.h>#ifdef __BIG_ENDIAN /* convert from little endian to big endian */#define SQUASHFS_SWAP(value, p, pos, tbits) _SQUASHFS_SWAP(value, p, pos, tbits, b_pos)#else /* convert from big endian to little endian */ #define SQUASHFS_SWAP(value, p, pos, tbits) _SQUASHFS_SWAP(value, p, pos, tbits, 64 - tbits - b_pos)#endif#define _SQUASHFS_SWAP(value, p, pos, tbits, SHIFT) {\ int bits;\ int b_pos = pos % 8;\ unsigned long long val = 0;\ unsigned char *s = (unsigned char *)p + (pos / 8);\ unsigned char *d = ((unsigned char *) &val) + 7;\ for(bits = 0; bits < (tbits + b_pos); bits += 8) \ *d-- = *s++;\ value = (val >> (SHIFT))/* & ((1 << tbits) - 1)*/;\}#define SQUASHFS_MEMSET(s, d, n) memset(s, 0, n);#endif#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -