1#ifndef SQUASHFS_SWAP_H 2#define SQUASHFS_SWAP_H 3/* 4 * Squashfs 5 * 6 * Copyright (c) 2008, 2009, 2010 7 * Phillip Lougher <phillip@lougher.demon.co.uk> 8 * 9 * This program is free software; you can redistribute it and/or 10 * modify it under the terms of the GNU General Public License 11 * as published by the Free Software Foundation; either version 2, 12 * or (at your option) any later version. 13 * 14 * This program is distributed in the hope that it will be useful, 15 * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 * GNU General Public License for more details. 18 * 19 * You should have received a copy of the GNU General Public License 20 * along with this program; if not, write to the Free Software 21 * Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 22 * 23 * squashfs_swap.h 24 */ 25 26/* 27 * macros to convert each stucture from big endian to little endian 28 */ 29 30#if __BYTE_ORDER == __BIG_ENDIAN 31#include <stddef.h> 32extern void swap_le16(void *, void *); 33extern void swap_le32(void *, void *); 34extern void swap_le64(void *, void *); 35extern void swap_le16_num(void *, void *, int); 36extern void swap_le32_num(void *, void *, int); 37extern void swap_le64_num(void *, void *, int); 38extern unsigned short inswap_le16(unsigned short); 39extern unsigned int inswap_le32(unsigned int); 40extern long long inswap_le64(long long); 41extern void inswap_le16_num(unsigned short *, int); 42extern void inswap_le32_num(unsigned int *, int); 43extern void inswap_le64_num(long long *, int); 44 45#define _SQUASHFS_SWAP_SUPER_BLOCK(s, d, SWAP_FUNC) {\ 46 SWAP_FUNC(32, s, d, s_magic, struct squashfs_super_block);\ 47 SWAP_FUNC(32, s, d, inodes, struct squashfs_super_block);\ 48 SWAP_FUNC(32, s, d, mkfs_time, struct squashfs_super_block);\ 49 SWAP_FUNC(32, s, d, block_size, struct squashfs_super_block);\ 50 SWAP_FUNC(32, s, d, fragments, struct squashfs_super_block);\ 51 SWAP_FUNC(16, s, d, compression, struct squashfs_super_block);\ 52 SWAP_FUNC(16, s, d, block_log, struct squashfs_super_block);\ 53 SWAP_FUNC(16, s, d, flags, struct squashfs_super_block);\ 54 SWAP_FUNC(16, s, d, no_ids, struct squashfs_super_block);\ 55 SWAP_FUNC(16, s, d, s_major, struct squashfs_super_block);\ 56 SWAP_FUNC(16, s, d, s_minor, struct squashfs_super_block);\ 57 SWAP_FUNC(64, s, d, root_inode, struct squashfs_super_block);\ 58 SWAP_FUNC(64, s, d, bytes_used, struct squashfs_super_block);\ 59 SWAP_FUNC(64, s, d, id_table_start, struct squashfs_super_block);\ 60 SWAP_FUNC(64, s, d, xattr_id_table_start, struct squashfs_super_block);\ 61 SWAP_FUNC(64, s, d, inode_table_start, struct squashfs_super_block);\ 62 SWAP_FUNC(64, s, d, directory_table_start, struct squashfs_super_block);\ 63 SWAP_FUNC(64, s, d, fragment_table_start, struct squashfs_super_block);\ 64 SWAP_FUNC(64, s, d, lookup_table_start, struct squashfs_super_block);\ 65} 66 67#define _SQUASHFS_SWAP_DIR_INDEX(s, d, SWAP_FUNC) {\ 68 SWAP_FUNC(32, s, d, index, struct squashfs_dir_index);\ 69 SWAP_FUNC(32, s, d, start_block, struct squashfs_dir_index);\ 70 SWAP_FUNC(32, s, d, size, struct squashfs_dir_index);\ 71} 72 73#define _SQUASHFS_SWAP_BASE_INODE_HEADER(s, d, SWAP_FUNC) {\ 74 SWAP_FUNC(16, s, d, inode_type, struct squashfs_base_inode_header);\ 75 SWAP_FUNC(16, s, d, mode, struct squashfs_base_inode_header);\ 76 SWAP_FUNC(16, s, d, uid, struct squashfs_base_inode_header);\ 77 SWAP_FUNC(16, s, d, guid, struct squashfs_base_inode_header);\ 78 SWAP_FUNC(32, s, d, mtime, struct squashfs_base_inode_header);\ 79 SWAP_FUNC(32, s, d, inode_number, struct squashfs_base_inode_header);\ 80} 81 82#define _SQUASHFS_SWAP_IPC_INODE_HEADER(s, d, SWAP_FUNC) {\ 83 SWAP_FUNC(16, s, d, inode_type, struct squashfs_ipc_inode_header);\ 84 SWAP_FUNC(16, s, d, mode, struct squashfs_ipc_inode_header);\ 85 SWAP_FUNC(16, s, d, uid, struct squashfs_ipc_inode_header);\ 86 SWAP_FUNC(16, s, d, guid, struct squashfs_ipc_inode_header);\ 87 SWAP_FUNC(32, s, d, mtime, struct squashfs_ipc_inode_header);\ 88 SWAP_FUNC(32, s, d, inode_number, struct squashfs_ipc_inode_header);\ 89 SWAP_FUNC(32, s, d, nlink, struct squashfs_ipc_inode_header);\ 90} 91 92#define _SQUASHFS_SWAP_LIPC_INODE_HEADER(s, d, SWAP_FUNC) {\ 93 SWAP_FUNC(16, s, d, inode_type, struct squashfs_lipc_inode_header);\ 94 SWAP_FUNC(16, s, d, mode, struct squashfs_lipc_inode_header);\ 95 SWAP_FUNC(16, s, d, uid, struct squashfs_lipc_inode_header);\ 96 SWAP_FUNC(16, s, d, guid, struct squashfs_lipc_inode_header);\ 97 SWAP_FUNC(32, s, d, mtime, struct squashfs_lipc_inode_header);\ 98 SWAP_FUNC(32, s, d, inode_number, struct squashfs_lipc_inode_header);\ 99 SWAP_FUNC(32, s, d, nlink, struct squashfs_lipc_inode_header);\ 100 SWAP_FUNC(32, s, d, xattr, struct squashfs_lipc_inode_header);\ 101} 102 103#define _SQUASHFS_SWAP_DEV_INODE_HEADER(s, d, SWAP_FUNC) {\ 104 SWAP_FUNC(16, s, d, inode_type, struct squashfs_dev_inode_header);\ 105 SWAP_FUNC(16, s, d, mode, struct squashfs_dev_inode_header);\ 106 SWAP_FUNC(16, s, d, uid, struct squashfs_dev_inode_header);\ 107 SWAP_FUNC(16, s, d, guid, struct squashfs_dev_inode_header);\ 108 SWAP_FUNC(32, s, d, mtime, struct squashfs_dev_inode_header);\ 109 SWAP_FUNC(32, s, d, inode_number, struct squashfs_dev_inode_header);\ 110 SWAP_FUNC(32, s, d, nlink, struct squashfs_dev_inode_header);\ 111 SWAP_FUNC(32, s, d, rdev, struct squashfs_dev_inode_header);\ 112} 113 114#define _SQUASHFS_SWAP_LDEV_INODE_HEADER(s, d, SWAP_FUNC) {\ 115 SWAP_FUNC(16, s, d, inode_type, struct squashfs_ldev_inode_header);\ 116 SWAP_FUNC(16, s, d, mode, struct squashfs_ldev_inode_header);\ 117 SWAP_FUNC(16, s, d, uid, struct squashfs_ldev_inode_header);\ 118 SWAP_FUNC(16, s, d, guid, struct squashfs_ldev_inode_header);\ 119 SWAP_FUNC(32, s, d, mtime, struct squashfs_ldev_inode_header);\ 120 SWAP_FUNC(32, s, d, inode_number, struct squashfs_ldev_inode_header);\ 121 SWAP_FUNC(32, s, d, nlink, struct squashfs_ldev_inode_header);\ 122 SWAP_FUNC(32, s, d, rdev, struct squashfs_ldev_inode_header);\ 123 SWAP_FUNC(32, s, d, xattr, struct squashfs_ldev_inode_header);\ 124} 125 126#define _SQUASHFS_SWAP_SYMLINK_INODE_HEADER(s, d, SWAP_FUNC) {\ 127 SWAP_FUNC(16, s, d, inode_type, struct squashfs_symlink_inode_header);\ 128 SWAP_FUNC(16, s, d, mode, struct squashfs_symlink_inode_header);\ 129 SWAP_FUNC(16, s, d, uid, struct squashfs_symlink_inode_header);\ 130 SWAP_FUNC(16, s, d, guid, struct squashfs_symlink_inode_header);\ 131 SWAP_FUNC(32, s, d, mtime, struct squashfs_symlink_inode_header);\ 132 SWAP_FUNC(32, s, d, inode_number, struct squashfs_symlink_inode_header);\ 133 SWAP_FUNC(32, s, d, nlink, struct squashfs_symlink_inode_header);\ 134 SWAP_FUNC(32, s, d, symlink_size, struct squashfs_symlink_inode_header);\ 135} 136 137#define _SQUASHFS_SWAP_REG_INODE_HEADER(s, d, SWAP_FUNC) {\ 138 SWAP_FUNC(16, s, d, inode_type, struct squashfs_reg_inode_header);\ 139 SWAP_FUNC(16, s, d, mode, struct squashfs_reg_inode_header);\ 140 SWAP_FUNC(16, s, d, uid, struct squashfs_reg_inode_header);\ 141 SWAP_FUNC(16, s, d, guid, struct squashfs_reg_inode_header);\ 142 SWAP_FUNC(32, s, d, mtime, struct squashfs_reg_inode_header);\ 143 SWAP_FUNC(32, s, d, inode_number, struct squashfs_reg_inode_header);\ 144 SWAP_FUNC(32, s, d, start_block, struct squashfs_reg_inode_header);\ 145 SWAP_FUNC(32, s, d, fragment, struct squashfs_reg_inode_header);\ 146 SWAP_FUNC(32, s, d, offset, struct squashfs_reg_inode_header);\ 147 SWAP_FUNC(32, s, d, file_size, struct squashfs_reg_inode_header);\ 148} 149 150#define _SQUASHFS_SWAP_LREG_INODE_HEADER(s, d, SWAP_FUNC) {\ 151 SWAP_FUNC(16, s, d, inode_type, struct squashfs_lreg_inode_header);\ 152 SWAP_FUNC(16, s, d, mode, struct squashfs_lreg_inode_header);\ 153 SWAP_FUNC(16, s, d, uid, struct squashfs_lreg_inode_header);\ 154 SWAP_FUNC(16, s, d, guid, struct squashfs_lreg_inode_header);\ 155 SWAP_FUNC(32, s, d, mtime, struct squashfs_lreg_inode_header);\ 156 SWAP_FUNC(32, s, d, inode_number, struct squashfs_lreg_inode_header);\ 157 SWAP_FUNC(64, s, d, start_block, struct squashfs_lreg_inode_header);\ 158 SWAP_FUNC(64, s, d, file_size, struct squashfs_lreg_inode_header);\ 159 SWAP_FUNC(64, s, d, sparse, struct squashfs_lreg_inode_header);\ 160 SWAP_FUNC(32, s, d, nlink, struct squashfs_lreg_inode_header);\ 161 SWAP_FUNC(32, s, d, fragment, struct squashfs_lreg_inode_header);\ 162 SWAP_FUNC(32, s, d, offset, struct squashfs_lreg_inode_header);\ 163 SWAP_FUNC(32, s, d, xattr, struct squashfs_lreg_inode_header);\ 164} 165 166#define _SQUASHFS_SWAP_DIR_INODE_HEADER(s, d, SWAP_FUNC) {\ 167 SWAP_FUNC(16, s, d, inode_type, struct squashfs_dir_inode_header);\ 168 SWAP_FUNC(16, s, d, mode, struct squashfs_dir_inode_header);\ 169 SWAP_FUNC(16, s, d, uid, struct squashfs_dir_inode_header);\ 170 SWAP_FUNC(16, s, d, guid, struct squashfs_dir_inode_header);\ 171 SWAP_FUNC(32, s, d, mtime, struct squashfs_dir_inode_header);\ 172 SWAP_FUNC(32, s, d, inode_number, struct squashfs_dir_inode_header);\ 173 SWAP_FUNC(32, s, d, start_block, struct squashfs_dir_inode_header);\ 174 SWAP_FUNC(32, s, d, nlink, struct squashfs_dir_inode_header);\ 175 SWAP_FUNC(16, s, d, file_size, struct squashfs_dir_inode_header);\ 176 SWAP_FUNC(16, s, d, offset, struct squashfs_dir_inode_header);\ 177 SWAP_FUNC(32, s, d, parent_inode, struct squashfs_dir_inode_header);\ 178} 179 180#define _SQUASHFS_SWAP_LDIR_INODE_HEADER(s, d, SWAP_FUNC) {\ 181 SWAP_FUNC(16, s, d, inode_type, struct squashfs_ldir_inode_header);\ 182 SWAP_FUNC(16, s, d, mode, struct squashfs_ldir_inode_header);\ 183 SWAP_FUNC(16, s, d, uid, struct squashfs_ldir_inode_header);\ 184 SWAP_FUNC(16, s, d, guid, struct squashfs_ldir_inode_header);\ 185 SWAP_FUNC(32, s, d, mtime, struct squashfs_ldir_inode_header);\ 186 SWAP_FUNC(32, s, d, inode_number, struct squashfs_ldir_inode_header);\ 187 SWAP_FUNC(32, s, d, nlink, struct squashfs_ldir_inode_header);\ 188 SWAP_FUNC(32, s, d, file_size, struct squashfs_ldir_inode_header);\ 189 SWAP_FUNC(32, s, d, start_block, struct squashfs_ldir_inode_header);\ 190 SWAP_FUNC(32, s, d, parent_inode, struct squashfs_ldir_inode_header);\ 191 SWAP_FUNC(16, s, d, i_count, struct squashfs_ldir_inode_header);\ 192 SWAP_FUNC(16, s, d, offset, struct squashfs_ldir_inode_header);\ 193 SWAP_FUNC(32, s, d, xattr, struct squashfs_ldir_inode_header);\ 194} 195 196#define _SQUASHFS_SWAP_DIR_ENTRY(s, d, SWAP_FUNC) {\ 197 SWAP_FUNC(16, s, d, offset, struct squashfs_dir_entry);\ 198 SWAP_FUNC##S(16, s, d, inode_number, struct squashfs_dir_entry);\ 199 SWAP_FUNC(16, s, d, type, struct squashfs_dir_entry);\ 200 SWAP_FUNC(16, s, d, size, struct squashfs_dir_entry);\ 201} 202 203#define _SQUASHFS_SWAP_DIR_HEADER(s, d, SWAP_FUNC) {\ 204 SWAP_FUNC(32, s, d, count, struct squashfs_dir_header);\ 205 SWAP_FUNC(32, s, d, start_block, struct squashfs_dir_header);\ 206 SWAP_FUNC(32, s, d, inode_number, struct squashfs_dir_header);\ 207} 208 209#define _SQUASHFS_SWAP_FRAGMENT_ENTRY(s, d, SWAP_FUNC) {\ 210 SWAP_FUNC(64, s, d, start_block, struct squashfs_fragment_entry);\ 211 SWAP_FUNC(32, s, d, size, struct squashfs_fragment_entry);\ 212} 213 214#define _SQUASHFS_SWAP_XATTR_ENTRY(s, d, SWAP_FUNC) {\ 215 SWAP_FUNC(16, s, d, type, struct squashfs_xattr_entry);\ 216 SWAP_FUNC(16, s, d, size, struct squashfs_xattr_entry);\ 217} 218 219#define _SQUASHFS_SWAP_XATTR_VAL(s, d, SWAP_FUNC) {\ 220 SWAP_FUNC(32, s, d, vsize, struct squashfs_xattr_val);\ 221} 222 223#define _SQUASHFS_SWAP_XATTR_ID(s, d, SWAP_FUNC) {\ 224 SWAP_FUNC(64, s, d, xattr, struct squashfs_xattr_id);\ 225 SWAP_FUNC(32, s, d, count, struct squashfs_xattr_id);\ 226 SWAP_FUNC(32, s, d, size, struct squashfs_xattr_id);\ 227} 228 229#define _SQUASHFS_SWAP_XATTR_TABLE(s, d, SWAP_FUNC) {\ 230 SWAP_FUNC(64, s, d, xattr_table_start, struct squashfs_xattr_table);\ 231 SWAP_FUNC(32, s, d, xattr_ids, struct squashfs_xattr_table);\ 232} 233 234/* big endian architecture copy and swap macros */ 235#define SQUASHFS_SWAP_SUPER_BLOCK(s, d) \ 236 _SQUASHFS_SWAP_SUPER_BLOCK(s, d, SWAP_LE) 237#define SQUASHFS_SWAP_DIR_INDEX(s, d) \ 238 _SQUASHFS_SWAP_DIR_INDEX(s, d, SWAP_LE) 239#define SQUASHFS_SWAP_BASE_INODE_HEADER(s, d) \ 240 _SQUASHFS_SWAP_BASE_INODE_HEADER(s, d, SWAP_LE) 241#define SQUASHFS_SWAP_IPC_INODE_HEADER(s, d) \ 242 _SQUASHFS_SWAP_IPC_INODE_HEADER(s, d, SWAP_LE) 243#define SQUASHFS_SWAP_LIPC_INODE_HEADER(s, d) \ 244 _SQUASHFS_SWAP_LIPC_INODE_HEADER(s, d, SWAP_LE) 245#define SQUASHFS_SWAP_DEV_INODE_HEADER(s, d) \ 246 _SQUASHFS_SWAP_DEV_INODE_HEADER(s, d, SWAP_LE) 247#define SQUASHFS_SWAP_LDEV_INODE_HEADER(s, d) \ 248 _SQUASHFS_SWAP_LDEV_INODE_HEADER(s, d, SWAP_LE) 249#define SQUASHFS_SWAP_SYMLINK_INODE_HEADER(s, d) \ 250 _SQUASHFS_SWAP_SYMLINK_INODE_HEADER(s, d, SWAP_LE) 251#define SQUASHFS_SWAP_REG_INODE_HEADER(s, d) \ 252 _SQUASHFS_SWAP_REG_INODE_HEADER(s, d, SWAP_LE) 253#define SQUASHFS_SWAP_LREG_INODE_HEADER(s, d) \ 254 _SQUASHFS_SWAP_LREG_INODE_HEADER(s, d, SWAP_LE) 255#define SQUASHFS_SWAP_DIR_INODE_HEADER(s, d) \ 256 _SQUASHFS_SWAP_DIR_INODE_HEADER(s, d, SWAP_LE) 257#define SQUASHFS_SWAP_LDIR_INODE_HEADER(s, d) \ 258 _SQUASHFS_SWAP_LDIR_INODE_HEADER(s, d, SWAP_LE) 259#define SQUASHFS_SWAP_DIR_ENTRY(s, d) \ 260 _SQUASHFS_SWAP_DIR_ENTRY(s, d, SWAP_LE) 261#define SQUASHFS_SWAP_DIR_HEADER(s, d) \ 262 _SQUASHFS_SWAP_DIR_HEADER(s, d, SWAP_LE) 263#define SQUASHFS_SWAP_FRAGMENT_ENTRY(s, d) \ 264 _SQUASHFS_SWAP_FRAGMENT_ENTRY(s, d, SWAP_LE) 265#define SQUASHFS_SWAP_XATTR_ENTRY(s, d) \ 266 _SQUASHFS_SWAP_XATTR_ENTRY(s, d, SWAP_LE) 267#define SQUASHFS_SWAP_XATTR_VAL(s, d) \ 268 _SQUASHFS_SWAP_XATTR_VAL(s, d, SWAP_LE) 269#define SQUASHFS_SWAP_XATTR_ID(s, d) \ 270 _SQUASHFS_SWAP_XATTR_ID(s, d, SWAP_LE) 271#define SQUASHFS_SWAP_XATTR_TABLE(s, d) \ 272 _SQUASHFS_SWAP_XATTR_TABLE(s, d, SWAP_LE) 273#define SWAP_LE(bits, s, d, field, type) \ 274 SWAP_LE##bits(((void *)(s)) + offsetof(type, field), \ 275 ((void *)(d)) + offsetof(type, field)) 276#define SWAP_LES(bits, s, d, field, type) \ 277 SWAP_LE(bits, s, d, field, type) 278#define SQUASHFS_SWAP_INODE_T(s, d) SQUASHFS_SWAP_LONG_LONGS(s, d, 1) 279#define SQUASHFS_SWAP_FRAGMENT_INDEXES(s, d, n) \ 280 SQUASHFS_SWAP_LONG_LONGS(s, d, n) 281#define SQUASHFS_SWAP_LOOKUP_BLOCKS(s, d, n) SQUASHFS_SWAP_LONG_LONGS(s, d, n) 282#define SQUASHFS_SWAP_ID_BLOCKS(s, d, n) SQUASHFS_SWAP_LONG_LONGS(s, d, n) 283 284/* big endian architecture swap in-place macros */ 285#define SQUASHFS_INSWAP_SUPER_BLOCK(s) \ 286 _SQUASHFS_SWAP_SUPER_BLOCK(s, s, INSWAP_LE) 287#define SQUASHFS_INSWAP_DIR_INDEX(s) \ 288 _SQUASHFS_SWAP_DIR_INDEX(s, s, INSWAP_LE) 289#define SQUASHFS_INSWAP_BASE_INODE_HEADER(s) \ 290 _SQUASHFS_SWAP_BASE_INODE_HEADER(s, s, INSWAP_LE) 291#define SQUASHFS_INSWAP_IPC_INODE_HEADER(s) \ 292 _SQUASHFS_SWAP_IPC_INODE_HEADER(s, s, INSWAP_LE) 293#define SQUASHFS_INSWAP_LIPC_INODE_HEADER(s) \ 294 _SQUASHFS_SWAP_LIPC_INODE_HEADER(s, s, INSWAP_LE) 295#define SQUASHFS_INSWAP_DEV_INODE_HEADER(s) \ 296 _SQUASHFS_SWAP_DEV_INODE_HEADER(s, s, INSWAP_LE) 297#define SQUASHFS_INSWAP_LDEV_INODE_HEADER(s) \ 298 _SQUASHFS_SWAP_LDEV_INODE_HEADER(s, s, INSWAP_LE) 299#define SQUASHFS_INSWAP_SYMLINK_INODE_HEADER(s) \ 300 _SQUASHFS_SWAP_SYMLINK_INODE_HEADER(s, s, INSWAP_LE) 301#define SQUASHFS_INSWAP_REG_INODE_HEADER(s) \ 302 _SQUASHFS_SWAP_REG_INODE_HEADER(s, s, INSWAP_LE) 303#define SQUASHFS_INSWAP_LREG_INODE_HEADER(s) \ 304 _SQUASHFS_SWAP_LREG_INODE_HEADER(s, s, INSWAP_LE) 305#define SQUASHFS_INSWAP_DIR_INODE_HEADER(s) \ 306 _SQUASHFS_SWAP_DIR_INODE_HEADER(s, s, INSWAP_LE) 307#define SQUASHFS_INSWAP_LDIR_INODE_HEADER(s) \ 308 _SQUASHFS_SWAP_LDIR_INODE_HEADER(s, s, INSWAP_LE) 309#define SQUASHFS_INSWAP_DIR_ENTRY(s) \ 310 _SQUASHFS_SWAP_DIR_ENTRY(s, s, INSWAP_LE) 311#define SQUASHFS_INSWAP_DIR_HEADER(s) \ 312 _SQUASHFS_SWAP_DIR_HEADER(s, s, INSWAP_LE) 313#define SQUASHFS_INSWAP_FRAGMENT_ENTRY(s) \ 314 _SQUASHFS_SWAP_FRAGMENT_ENTRY(s, s, INSWAP_LE) 315#define SQUASHFS_INSWAP_XATTR_ENTRY(s) \ 316 _SQUASHFS_SWAP_XATTR_ENTRY(s, s, INSWAP_LE) 317#define SQUASHFS_INSWAP_XATTR_VAL(s) \ 318 _SQUASHFS_SWAP_XATTR_VAL(s, s, INSWAP_LE) 319#define SQUASHFS_INSWAP_XATTR_ID(s) \ 320 _SQUASHFS_SWAP_XATTR_ID(s, s, INSWAP_LE) 321#define SQUASHFS_INSWAP_XATTR_TABLE(s) \ 322 _SQUASHFS_SWAP_XATTR_TABLE(s, s, INSWAP_LE) 323#define INSWAP_LE(bits, s, d, field, type) \ 324 (s)->field = inswap_le##bits((s)->field) 325#define INSWAP_LES(bits, s, d, field, type) \ 326 (s)->field = (short) inswap_le##bits((unsigned short) \ 327 (s)->field) 328#define SQUASHFS_INSWAP_INODE_T(s) s = inswap_le64(s) 329#define SQUASHFS_INSWAP_FRAGMENT_INDEXES(s, n) inswap_le64_num(s, n) 330#define SQUASHFS_INSWAP_LOOKUP_BLOCKS(s, n) inswap_le64_num(s, n) 331#define SQUASHFS_INSWAP_ID_BLOCKS(s, n) inswap_le64_num(s, n) 332#define SQUASHFS_INSWAP_SHORTS(s, n) inswap_le16_num(s, n) 333#define SQUASHFS_INSWAP_INTS(s, n) inswap_le32_num(s, n) 334#define SQUASHFS_INSWAP_LONG_LONGS(s, n) inswap_le64_num(s, n) 335#else 336/* little endian architecture, just copy */ 337#define SQUASHFS_SWAP_SUPER_BLOCK(s, d) \ 338 SQUASHFS_MEMCPY(s, d, sizeof(*(s))) 339#define SQUASHFS_SWAP_DIR_INDEX(s, d) \ 340 SQUASHFS_MEMCPY(s, d, sizeof(*(s))) 341#define SQUASHFS_SWAP_BASE_INODE_HEADER(s, d) \ 342 SQUASHFS_MEMCPY(s, d, sizeof(*(s))) 343#define SQUASHFS_SWAP_IPC_INODE_HEADER(s, d) \ 344 SQUASHFS_MEMCPY(s, d, sizeof(*(s))) 345#define SQUASHFS_SWAP_LIPC_INODE_HEADER(s, d) \ 346 SQUASHFS_MEMCPY(s, d, sizeof(*(s))) 347#define SQUASHFS_SWAP_DEV_INODE_HEADER(s, d) \ 348 SQUASHFS_MEMCPY(s, d, sizeof(*(s))) 349#define SQUASHFS_SWAP_LDEV_INODE_HEADER(s, d) \ 350 SQUASHFS_MEMCPY(s, d, sizeof(*(s))) 351#define SQUASHFS_SWAP_SYMLINK_INODE_HEADER(s, d) \ 352 SQUASHFS_MEMCPY(s, d, sizeof(*(s))) 353#define SQUASHFS_SWAP_REG_INODE_HEADER(s, d) \ 354 SQUASHFS_MEMCPY(s, d, sizeof(*(s))) 355#define SQUASHFS_SWAP_LREG_INODE_HEADER(s, d) \ 356 SQUASHFS_MEMCPY(s, d, sizeof(*(s))) 357#define SQUASHFS_SWAP_DIR_INODE_HEADER(s, d) \ 358 SQUASHFS_MEMCPY(s, d, sizeof(*(s))) 359#define SQUASHFS_SWAP_LDIR_INODE_HEADER(s, d) \ 360 SQUASHFS_MEMCPY(s, d, sizeof(*(s))) 361#define SQUASHFS_SWAP_DIR_ENTRY(s, d) \ 362 SQUASHFS_MEMCPY(s, d, sizeof(*(s))) 363#define SQUASHFS_SWAP_DIR_HEADER(s, d) \ 364 SQUASHFS_MEMCPY(s, d, sizeof(*(s))) 365#define SQUASHFS_SWAP_FRAGMENT_ENTRY(s, d) \ 366 SQUASHFS_MEMCPY(s, d, sizeof(*(s))) 367#define SQUASHFS_SWAP_XATTR_ENTRY(s, d) \ 368 SQUASHFS_MEMCPY(s, d, sizeof(*(s))) 369#define SQUASHFS_SWAP_XATTR_VAL(s, d) \ 370 SQUASHFS_MEMCPY(s, d, sizeof(*(s))) 371#define SQUASHFS_SWAP_XATTR_ID(s, d) \ 372 SQUASHFS_MEMCPY(s, d, sizeof(*(s))) 373#define SQUASHFS_SWAP_XATTR_TABLE(s, d) \ 374 SQUASHFS_MEMCPY(s, d, sizeof(*(s))) 375#define SQUASHFS_SWAP_INODE_T(s, d) SQUASHFS_SWAP_LONG_LONGS(s, d, 1) 376#define SQUASHFS_SWAP_FRAGMENT_INDEXES(s, d, n) \ 377 SQUASHFS_SWAP_LONG_LONGS(s, d, n) 378#define SQUASHFS_SWAP_LOOKUP_BLOCKS(s, d, n) SQUASHFS_SWAP_LONG_LONGS(s, d, n) 379#define SQUASHFS_SWAP_ID_BLOCKS(s, d, n) SQUASHFS_SWAP_LONG_LONGS(s, d, n) 380 381/* little endian architecture, data already in place so do nothing */ 382#define SQUASHFS_INSWAP_SUPER_BLOCK(s) 383#define SQUASHFS_INSWAP_DIR_INDEX(s) 384#define SQUASHFS_INSWAP_BASE_INODE_HEADER(s) 385#define SQUASHFS_INSWAP_IPC_INODE_HEADER(s) 386#define SQUASHFS_INSWAP_LIPC_INODE_HEADER(s) 387#define SQUASHFS_INSWAP_DEV_INODE_HEADER(s) 388#define SQUASHFS_INSWAP_LDEV_INODE_HEADER(s) 389#define SQUASHFS_INSWAP_SYMLINK_INODE_HEADER(s) 390#define SQUASHFS_INSWAP_REG_INODE_HEADER(s) 391#define SQUASHFS_INSWAP_LREG_INODE_HEADER(s) 392#define SQUASHFS_INSWAP_DIR_INODE_HEADER(s) 393#define SQUASHFS_INSWAP_LDIR_INODE_HEADER(s) 394#define SQUASHFS_INSWAP_DIR_ENTRY(s) 395#define SQUASHFS_INSWAP_DIR_HEADER(s) 396#define SQUASHFS_INSWAP_FRAGMENT_ENTRY(s) 397#define SQUASHFS_INSWAP_XATTR_ENTRY(s) 398#define SQUASHFS_INSWAP_XATTR_VAL(s) 399#define SQUASHFS_INSWAP_XATTR_ID(s) 400#define SQUASHFS_INSWAP_XATTR_TABLE(s) 401#define SQUASHFS_INSWAP_INODE_T(s) 402#define SQUASHFS_INSWAP_FRAGMENT_INDEXES(s, n) 403#define SQUASHFS_INSWAP_LOOKUP_BLOCKS(s, n) 404#define SQUASHFS_INSWAP_ID_BLOCKS(s, n) 405#define SQUASHFS_INSWAP_SHORTS(s, n) 406#define SQUASHFS_INSWAP_INTS(s, n) 407#define SQUASHFS_INSWAP_LONG_LONGS(s, n) 408#endif 409#endif 410