11b899fc316f7eba7a31da12dc0c9b69ada441059plougher#ifndef SQUASHFS_SWAP_H
21b899fc316f7eba7a31da12dc0c9b69ada441059plougher#define SQUASHFS_SWAP_H
31b899fc316f7eba7a31da12dc0c9b69ada441059plougher/*
41b899fc316f7eba7a31da12dc0c9b69ada441059plougher * Squashfs
51b899fc316f7eba7a31da12dc0c9b69ada441059plougher *
693fce13e13cbbbaa652028c627ce37e96a9679e8Phillip Lougher * Copyright (c) 2008, 2009, 2010, 2013, 2014
783d42a3fc898962aa1f1e8387f2ccb1114e0d294Phillip Lougher * Phillip Lougher <phillip@squashfs.org.uk>
81b899fc316f7eba7a31da12dc0c9b69ada441059plougher *
91b899fc316f7eba7a31da12dc0c9b69ada441059plougher * This program is free software; you can redistribute it and/or
101b899fc316f7eba7a31da12dc0c9b69ada441059plougher * modify it under the terms of the GNU General Public License
111b899fc316f7eba7a31da12dc0c9b69ada441059plougher * as published by the Free Software Foundation; either version 2,
121b899fc316f7eba7a31da12dc0c9b69ada441059plougher * or (at your option) any later version.
131b899fc316f7eba7a31da12dc0c9b69ada441059plougher *
141b899fc316f7eba7a31da12dc0c9b69ada441059plougher * This program is distributed in the hope that it will be useful,
151b899fc316f7eba7a31da12dc0c9b69ada441059plougher * but WITHOUT ANY WARRANTY; without even the implied warranty of
161b899fc316f7eba7a31da12dc0c9b69ada441059plougher * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
171b899fc316f7eba7a31da12dc0c9b69ada441059plougher * GNU General Public License for more details.
181b899fc316f7eba7a31da12dc0c9b69ada441059plougher *
191b899fc316f7eba7a31da12dc0c9b69ada441059plougher * You should have received a copy of the GNU General Public License
201b899fc316f7eba7a31da12dc0c9b69ada441059plougher * along with this program; if not, write to the Free Software
211b899fc316f7eba7a31da12dc0c9b69ada441059plougher * Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
221b899fc316f7eba7a31da12dc0c9b69ada441059plougher *
231b899fc316f7eba7a31da12dc0c9b69ada441059plougher * squashfs_swap.h
241b899fc316f7eba7a31da12dc0c9b69ada441059plougher */
251b899fc316f7eba7a31da12dc0c9b69ada441059plougher
261b899fc316f7eba7a31da12dc0c9b69ada441059plougher/*
27d1afecc17648ca24af6bab587a0b0ddcc035adc3plougher * macros to convert each stucture from big endian to little endian
281b899fc316f7eba7a31da12dc0c9b69ada441059plougher */
291b899fc316f7eba7a31da12dc0c9b69ada441059plougher
30cb76c1835577cdaded339f990f637ceef7c1c3f7plougher#if __BYTE_ORDER == __BIG_ENDIAN
315ec47ee1a582f32b039653ac6fec904afafd465aplougher#include <stddef.h>
325ec47ee1a582f32b039653ac6fec904afafd465aplougherextern void swap_le16(void *, void *);
335ec47ee1a582f32b039653ac6fec904afafd465aplougherextern void swap_le32(void *, void *);
345ec47ee1a582f32b039653ac6fec904afafd465aplougherextern void swap_le64(void *, void *);
355ec47ee1a582f32b039653ac6fec904afafd465aplougherextern void swap_le16_num(void *, void *, int);
365ec47ee1a582f32b039653ac6fec904afafd465aplougherextern void swap_le32_num(void *, void *, int);
375ec47ee1a582f32b039653ac6fec904afafd465aplougherextern void swap_le64_num(void *, void *, int);
38cb76c1835577cdaded339f990f637ceef7c1c3f7plougherextern unsigned short inswap_le16(unsigned short);
39cb76c1835577cdaded339f990f637ceef7c1c3f7plougherextern unsigned int inswap_le32(unsigned int);
40cb76c1835577cdaded339f990f637ceef7c1c3f7plougherextern long long inswap_le64(long long);
41cb76c1835577cdaded339f990f637ceef7c1c3f7plougherextern void inswap_le16_num(unsigned short *, int);
42cb76c1835577cdaded339f990f637ceef7c1c3f7plougherextern void inswap_le32_num(unsigned int *, int);
43cb76c1835577cdaded339f990f637ceef7c1c3f7plougherextern void inswap_le64_num(long long *, int);
441b899fc316f7eba7a31da12dc0c9b69ada441059plougher
450759a654adb0fdc348c448f3569a2dfefa90653cplougher#define _SQUASHFS_SWAP_SUPER_BLOCK(s, d, SWAP_FUNC) {\
4664e83fda63a1b8408ffbfa466e6c67b0de7a8c99plougher	SWAP_FUNC(32, s, d, s_magic, struct squashfs_super_block);\
4764e83fda63a1b8408ffbfa466e6c67b0de7a8c99plougher	SWAP_FUNC(32, s, d, inodes, struct squashfs_super_block);\
4893fce13e13cbbbaa652028c627ce37e96a9679e8Phillip Lougher	SWAP_FUNC##S(32, s, d, mkfs_time, struct squashfs_super_block);\
4964e83fda63a1b8408ffbfa466e6c67b0de7a8c99plougher	SWAP_FUNC(32, s, d, block_size, struct squashfs_super_block);\
5064e83fda63a1b8408ffbfa466e6c67b0de7a8c99plougher	SWAP_FUNC(32, s, d, fragments, struct squashfs_super_block);\
5164e83fda63a1b8408ffbfa466e6c67b0de7a8c99plougher	SWAP_FUNC(16, s, d, compression, struct squashfs_super_block);\
5264e83fda63a1b8408ffbfa466e6c67b0de7a8c99plougher	SWAP_FUNC(16, s, d, block_log, struct squashfs_super_block);\
5364e83fda63a1b8408ffbfa466e6c67b0de7a8c99plougher	SWAP_FUNC(16, s, d, flags, struct squashfs_super_block);\
5464e83fda63a1b8408ffbfa466e6c67b0de7a8c99plougher	SWAP_FUNC(16, s, d, no_ids, struct squashfs_super_block);\
5564e83fda63a1b8408ffbfa466e6c67b0de7a8c99plougher	SWAP_FUNC(16, s, d, s_major, struct squashfs_super_block);\
5664e83fda63a1b8408ffbfa466e6c67b0de7a8c99plougher	SWAP_FUNC(16, s, d, s_minor, struct squashfs_super_block);\
5764e83fda63a1b8408ffbfa466e6c67b0de7a8c99plougher	SWAP_FUNC(64, s, d, root_inode, struct squashfs_super_block);\
5864e83fda63a1b8408ffbfa466e6c67b0de7a8c99plougher	SWAP_FUNC(64, s, d, bytes_used, struct squashfs_super_block);\
5964e83fda63a1b8408ffbfa466e6c67b0de7a8c99plougher	SWAP_FUNC(64, s, d, id_table_start, struct squashfs_super_block);\
6064e83fda63a1b8408ffbfa466e6c67b0de7a8c99plougher	SWAP_FUNC(64, s, d, xattr_id_table_start, struct squashfs_super_block);\
6164e83fda63a1b8408ffbfa466e6c67b0de7a8c99plougher	SWAP_FUNC(64, s, d, inode_table_start, struct squashfs_super_block);\
6264e83fda63a1b8408ffbfa466e6c67b0de7a8c99plougher	SWAP_FUNC(64, s, d, directory_table_start, struct squashfs_super_block);\
6364e83fda63a1b8408ffbfa466e6c67b0de7a8c99plougher	SWAP_FUNC(64, s, d, fragment_table_start, struct squashfs_super_block);\
6464e83fda63a1b8408ffbfa466e6c67b0de7a8c99plougher	SWAP_FUNC(64, s, d, lookup_table_start, struct squashfs_super_block);\
651b899fc316f7eba7a31da12dc0c9b69ada441059plougher}
661b899fc316f7eba7a31da12dc0c9b69ada441059plougher
670759a654adb0fdc348c448f3569a2dfefa90653cplougher#define _SQUASHFS_SWAP_DIR_INDEX(s, d, SWAP_FUNC) {\
682bd2b72b3de5817f9b16e6677a02c217363136f6plougher	SWAP_FUNC(32, s, d, index, struct squashfs_dir_index);\
692bd2b72b3de5817f9b16e6677a02c217363136f6plougher	SWAP_FUNC(32, s, d, start_block, struct squashfs_dir_index);\
702bd2b72b3de5817f9b16e6677a02c217363136f6plougher	SWAP_FUNC(32, s, d, size, struct squashfs_dir_index);\
71d1afecc17648ca24af6bab587a0b0ddcc035adc3plougher}
72d1afecc17648ca24af6bab587a0b0ddcc035adc3plougher
730759a654adb0fdc348c448f3569a2dfefa90653cplougher#define _SQUASHFS_SWAP_BASE_INODE_HEADER(s, d, SWAP_FUNC) {\
74857d0ddc3c94dc889d7dad55f9651963ab5a4ed9plougher	SWAP_FUNC(16, s, d, inode_type, struct squashfs_base_inode_header);\
75857d0ddc3c94dc889d7dad55f9651963ab5a4ed9plougher	SWAP_FUNC(16, s, d, mode, struct squashfs_base_inode_header);\
76857d0ddc3c94dc889d7dad55f9651963ab5a4ed9plougher	SWAP_FUNC(16, s, d, uid, struct squashfs_base_inode_header);\
77857d0ddc3c94dc889d7dad55f9651963ab5a4ed9plougher	SWAP_FUNC(16, s, d, guid, struct squashfs_base_inode_header);\
7893fce13e13cbbbaa652028c627ce37e96a9679e8Phillip Lougher	SWAP_FUNC##S(32, s, d, mtime, struct squashfs_base_inode_header);\
79857d0ddc3c94dc889d7dad55f9651963ab5a4ed9plougher	SWAP_FUNC(32, s, d, inode_number, struct squashfs_base_inode_header);\
801b899fc316f7eba7a31da12dc0c9b69ada441059plougher}
811b899fc316f7eba7a31da12dc0c9b69ada441059plougher
820759a654adb0fdc348c448f3569a2dfefa90653cplougher#define _SQUASHFS_SWAP_IPC_INODE_HEADER(s, d, SWAP_FUNC) {\
83e56b9862d07a7c6202090d74b86d28639ede52caplougher	SWAP_FUNC(16, s, d, inode_type, struct squashfs_ipc_inode_header);\
84e56b9862d07a7c6202090d74b86d28639ede52caplougher	SWAP_FUNC(16, s, d, mode, struct squashfs_ipc_inode_header);\
85e56b9862d07a7c6202090d74b86d28639ede52caplougher	SWAP_FUNC(16, s, d, uid, struct squashfs_ipc_inode_header);\
86e56b9862d07a7c6202090d74b86d28639ede52caplougher	SWAP_FUNC(16, s, d, guid, struct squashfs_ipc_inode_header);\
8793fce13e13cbbbaa652028c627ce37e96a9679e8Phillip Lougher	SWAP_FUNC##S(32, s, d, mtime, struct squashfs_ipc_inode_header);\
88e56b9862d07a7c6202090d74b86d28639ede52caplougher	SWAP_FUNC(32, s, d, inode_number, struct squashfs_ipc_inode_header);\
89e56b9862d07a7c6202090d74b86d28639ede52caplougher	SWAP_FUNC(32, s, d, nlink, struct squashfs_ipc_inode_header);\
901b899fc316f7eba7a31da12dc0c9b69ada441059plougher}
911b899fc316f7eba7a31da12dc0c9b69ada441059plougher
92c5d69328b23c606b3205f84ef0f01d45baa996a5plougher#define _SQUASHFS_SWAP_LIPC_INODE_HEADER(s, d, SWAP_FUNC) {\
93aa0d122348bd8ec500bee33654caf5f34f6644d6plougher	SWAP_FUNC(16, s, d, inode_type, struct squashfs_lipc_inode_header);\
94aa0d122348bd8ec500bee33654caf5f34f6644d6plougher	SWAP_FUNC(16, s, d, mode, struct squashfs_lipc_inode_header);\
95aa0d122348bd8ec500bee33654caf5f34f6644d6plougher	SWAP_FUNC(16, s, d, uid, struct squashfs_lipc_inode_header);\
96aa0d122348bd8ec500bee33654caf5f34f6644d6plougher	SWAP_FUNC(16, s, d, guid, struct squashfs_lipc_inode_header);\
9793fce13e13cbbbaa652028c627ce37e96a9679e8Phillip Lougher	SWAP_FUNC##S(32, s, d, mtime, struct squashfs_lipc_inode_header);\
98aa0d122348bd8ec500bee33654caf5f34f6644d6plougher	SWAP_FUNC(32, s, d, inode_number, struct squashfs_lipc_inode_header);\
99aa0d122348bd8ec500bee33654caf5f34f6644d6plougher	SWAP_FUNC(32, s, d, nlink, struct squashfs_lipc_inode_header);\
100aa0d122348bd8ec500bee33654caf5f34f6644d6plougher	SWAP_FUNC(32, s, d, xattr, struct squashfs_lipc_inode_header);\
101c5d69328b23c606b3205f84ef0f01d45baa996a5plougher}
102c5d69328b23c606b3205f84ef0f01d45baa996a5plougher
1030759a654adb0fdc348c448f3569a2dfefa90653cplougher#define _SQUASHFS_SWAP_DEV_INODE_HEADER(s, d, SWAP_FUNC) {\
104c70c63397c3d8117c9f24ec29fa52ba401ea1608plougher	SWAP_FUNC(16, s, d, inode_type, struct squashfs_dev_inode_header);\
105c70c63397c3d8117c9f24ec29fa52ba401ea1608plougher	SWAP_FUNC(16, s, d, mode, struct squashfs_dev_inode_header);\
106c70c63397c3d8117c9f24ec29fa52ba401ea1608plougher	SWAP_FUNC(16, s, d, uid, struct squashfs_dev_inode_header);\
107c70c63397c3d8117c9f24ec29fa52ba401ea1608plougher	SWAP_FUNC(16, s, d, guid, struct squashfs_dev_inode_header);\
10893fce13e13cbbbaa652028c627ce37e96a9679e8Phillip Lougher	SWAP_FUNC##S(32, s, d, mtime, struct squashfs_dev_inode_header);\
109c70c63397c3d8117c9f24ec29fa52ba401ea1608plougher	SWAP_FUNC(32, s, d, inode_number, struct squashfs_dev_inode_header);\
110c70c63397c3d8117c9f24ec29fa52ba401ea1608plougher	SWAP_FUNC(32, s, d, nlink, struct squashfs_dev_inode_header);\
111c70c63397c3d8117c9f24ec29fa52ba401ea1608plougher	SWAP_FUNC(32, s, d, rdev, struct squashfs_dev_inode_header);\
1121b899fc316f7eba7a31da12dc0c9b69ada441059plougher}
1131b899fc316f7eba7a31da12dc0c9b69ada441059plougher
114e6e0e1bdf98ad6faa63527e5bbdd3bd5e7e97a9eplougher#define _SQUASHFS_SWAP_LDEV_INODE_HEADER(s, d, SWAP_FUNC) {\
1150b4ee5b4b390a9c2c92dfaa3eec9bdee1182e061plougher	SWAP_FUNC(16, s, d, inode_type, struct squashfs_ldev_inode_header);\
1160b4ee5b4b390a9c2c92dfaa3eec9bdee1182e061plougher	SWAP_FUNC(16, s, d, mode, struct squashfs_ldev_inode_header);\
1170b4ee5b4b390a9c2c92dfaa3eec9bdee1182e061plougher	SWAP_FUNC(16, s, d, uid, struct squashfs_ldev_inode_header);\
1180b4ee5b4b390a9c2c92dfaa3eec9bdee1182e061plougher	SWAP_FUNC(16, s, d, guid, struct squashfs_ldev_inode_header);\
11993fce13e13cbbbaa652028c627ce37e96a9679e8Phillip Lougher	SWAP_FUNC##S(32, s, d, mtime, struct squashfs_ldev_inode_header);\
1200b4ee5b4b390a9c2c92dfaa3eec9bdee1182e061plougher	SWAP_FUNC(32, s, d, inode_number, struct squashfs_ldev_inode_header);\
1210b4ee5b4b390a9c2c92dfaa3eec9bdee1182e061plougher	SWAP_FUNC(32, s, d, nlink, struct squashfs_ldev_inode_header);\
1220b4ee5b4b390a9c2c92dfaa3eec9bdee1182e061plougher	SWAP_FUNC(32, s, d, rdev, struct squashfs_ldev_inode_header);\
1230b4ee5b4b390a9c2c92dfaa3eec9bdee1182e061plougher	SWAP_FUNC(32, s, d, xattr, struct squashfs_ldev_inode_header);\
124e6e0e1bdf98ad6faa63527e5bbdd3bd5e7e97a9eplougher}
125e6e0e1bdf98ad6faa63527e5bbdd3bd5e7e97a9eplougher
1260759a654adb0fdc348c448f3569a2dfefa90653cplougher#define _SQUASHFS_SWAP_SYMLINK_INODE_HEADER(s, d, SWAP_FUNC) {\
1275ae6e956cc5d10aee13744cef8c0caa4208a169eplougher	SWAP_FUNC(16, s, d, inode_type, struct squashfs_symlink_inode_header);\
1285ae6e956cc5d10aee13744cef8c0caa4208a169eplougher	SWAP_FUNC(16, s, d, mode, struct squashfs_symlink_inode_header);\
1295ae6e956cc5d10aee13744cef8c0caa4208a169eplougher	SWAP_FUNC(16, s, d, uid, struct squashfs_symlink_inode_header);\
1305ae6e956cc5d10aee13744cef8c0caa4208a169eplougher	SWAP_FUNC(16, s, d, guid, struct squashfs_symlink_inode_header);\
13193fce13e13cbbbaa652028c627ce37e96a9679e8Phillip Lougher	SWAP_FUNC##S(32, s, d, mtime, struct squashfs_symlink_inode_header);\
1325ae6e956cc5d10aee13744cef8c0caa4208a169eplougher	SWAP_FUNC(32, s, d, inode_number, struct squashfs_symlink_inode_header);\
1335ae6e956cc5d10aee13744cef8c0caa4208a169eplougher	SWAP_FUNC(32, s, d, nlink, struct squashfs_symlink_inode_header);\
1345ae6e956cc5d10aee13744cef8c0caa4208a169eplougher	SWAP_FUNC(32, s, d, symlink_size, struct squashfs_symlink_inode_header);\
1351b899fc316f7eba7a31da12dc0c9b69ada441059plougher}
1361b899fc316f7eba7a31da12dc0c9b69ada441059plougher
1370759a654adb0fdc348c448f3569a2dfefa90653cplougher#define _SQUASHFS_SWAP_REG_INODE_HEADER(s, d, SWAP_FUNC) {\
1388701ed64d3241ac3c86db2b6e303769450eac867plougher	SWAP_FUNC(16, s, d, inode_type, struct squashfs_reg_inode_header);\
1398701ed64d3241ac3c86db2b6e303769450eac867plougher	SWAP_FUNC(16, s, d, mode, struct squashfs_reg_inode_header);\
1408701ed64d3241ac3c86db2b6e303769450eac867plougher	SWAP_FUNC(16, s, d, uid, struct squashfs_reg_inode_header);\
1418701ed64d3241ac3c86db2b6e303769450eac867plougher	SWAP_FUNC(16, s, d, guid, struct squashfs_reg_inode_header);\
14293fce13e13cbbbaa652028c627ce37e96a9679e8Phillip Lougher	SWAP_FUNC##S(32, s, d, mtime, struct squashfs_reg_inode_header);\
1438701ed64d3241ac3c86db2b6e303769450eac867plougher	SWAP_FUNC(32, s, d, inode_number, struct squashfs_reg_inode_header);\
1448701ed64d3241ac3c86db2b6e303769450eac867plougher	SWAP_FUNC(32, s, d, start_block, struct squashfs_reg_inode_header);\
1458701ed64d3241ac3c86db2b6e303769450eac867plougher	SWAP_FUNC(32, s, d, fragment, struct squashfs_reg_inode_header);\
1468701ed64d3241ac3c86db2b6e303769450eac867plougher	SWAP_FUNC(32, s, d, offset, struct squashfs_reg_inode_header);\
1478701ed64d3241ac3c86db2b6e303769450eac867plougher	SWAP_FUNC(32, s, d, file_size, struct squashfs_reg_inode_header);\
1481b899fc316f7eba7a31da12dc0c9b69ada441059plougher}
1491b899fc316f7eba7a31da12dc0c9b69ada441059plougher
1500759a654adb0fdc348c448f3569a2dfefa90653cplougher#define _SQUASHFS_SWAP_LREG_INODE_HEADER(s, d, SWAP_FUNC) {\
1511e6ac4a05f89feba7b41571ef0936aa1a3d445dfplougher	SWAP_FUNC(16, s, d, inode_type, struct squashfs_lreg_inode_header);\
1521e6ac4a05f89feba7b41571ef0936aa1a3d445dfplougher	SWAP_FUNC(16, s, d, mode, struct squashfs_lreg_inode_header);\
1531e6ac4a05f89feba7b41571ef0936aa1a3d445dfplougher	SWAP_FUNC(16, s, d, uid, struct squashfs_lreg_inode_header);\
1541e6ac4a05f89feba7b41571ef0936aa1a3d445dfplougher	SWAP_FUNC(16, s, d, guid, struct squashfs_lreg_inode_header);\
15593fce13e13cbbbaa652028c627ce37e96a9679e8Phillip Lougher	SWAP_FUNC##S(32, s, d, mtime, struct squashfs_lreg_inode_header);\
1561e6ac4a05f89feba7b41571ef0936aa1a3d445dfplougher	SWAP_FUNC(32, s, d, inode_number, struct squashfs_lreg_inode_header);\
1571e6ac4a05f89feba7b41571ef0936aa1a3d445dfplougher	SWAP_FUNC(64, s, d, start_block, struct squashfs_lreg_inode_header);\
1581e6ac4a05f89feba7b41571ef0936aa1a3d445dfplougher	SWAP_FUNC(64, s, d, file_size, struct squashfs_lreg_inode_header);\
1591e6ac4a05f89feba7b41571ef0936aa1a3d445dfplougher	SWAP_FUNC(64, s, d, sparse, struct squashfs_lreg_inode_header);\
1601e6ac4a05f89feba7b41571ef0936aa1a3d445dfplougher	SWAP_FUNC(32, s, d, nlink, struct squashfs_lreg_inode_header);\
1611e6ac4a05f89feba7b41571ef0936aa1a3d445dfplougher	SWAP_FUNC(32, s, d, fragment, struct squashfs_lreg_inode_header);\
1621e6ac4a05f89feba7b41571ef0936aa1a3d445dfplougher	SWAP_FUNC(32, s, d, offset, struct squashfs_lreg_inode_header);\
1631e6ac4a05f89feba7b41571ef0936aa1a3d445dfplougher	SWAP_FUNC(32, s, d, xattr, struct squashfs_lreg_inode_header);\
1641b899fc316f7eba7a31da12dc0c9b69ada441059plougher}
1651b899fc316f7eba7a31da12dc0c9b69ada441059plougher
1660759a654adb0fdc348c448f3569a2dfefa90653cplougher#define _SQUASHFS_SWAP_DIR_INODE_HEADER(s, d, SWAP_FUNC) {\
1679d80a6074011ca775b99c2ca2466ef077f6d1157plougher	SWAP_FUNC(16, s, d, inode_type, struct squashfs_dir_inode_header);\
1689d80a6074011ca775b99c2ca2466ef077f6d1157plougher	SWAP_FUNC(16, s, d, mode, struct squashfs_dir_inode_header);\
1699d80a6074011ca775b99c2ca2466ef077f6d1157plougher	SWAP_FUNC(16, s, d, uid, struct squashfs_dir_inode_header);\
1709d80a6074011ca775b99c2ca2466ef077f6d1157plougher	SWAP_FUNC(16, s, d, guid, struct squashfs_dir_inode_header);\
17193fce13e13cbbbaa652028c627ce37e96a9679e8Phillip Lougher	SWAP_FUNC##S(32, s, d, mtime, struct squashfs_dir_inode_header);\
1729d80a6074011ca775b99c2ca2466ef077f6d1157plougher	SWAP_FUNC(32, s, d, inode_number, struct squashfs_dir_inode_header);\
1739d80a6074011ca775b99c2ca2466ef077f6d1157plougher	SWAP_FUNC(32, s, d, start_block, struct squashfs_dir_inode_header);\
1749d80a6074011ca775b99c2ca2466ef077f6d1157plougher	SWAP_FUNC(32, s, d, nlink, struct squashfs_dir_inode_header);\
1759d80a6074011ca775b99c2ca2466ef077f6d1157plougher	SWAP_FUNC(16, s, d, file_size, struct squashfs_dir_inode_header);\
1769d80a6074011ca775b99c2ca2466ef077f6d1157plougher	SWAP_FUNC(16, s, d, offset, struct squashfs_dir_inode_header);\
1779d80a6074011ca775b99c2ca2466ef077f6d1157plougher	SWAP_FUNC(32, s, d, parent_inode, struct squashfs_dir_inode_header);\
1781b899fc316f7eba7a31da12dc0c9b69ada441059plougher}
1791b899fc316f7eba7a31da12dc0c9b69ada441059plougher
1800759a654adb0fdc348c448f3569a2dfefa90653cplougher#define _SQUASHFS_SWAP_LDIR_INODE_HEADER(s, d, SWAP_FUNC) {\
1812611d39a5fcea87d4d5160d3d9bfe1c6aa92729cplougher	SWAP_FUNC(16, s, d, inode_type, struct squashfs_ldir_inode_header);\
1822611d39a5fcea87d4d5160d3d9bfe1c6aa92729cplougher	SWAP_FUNC(16, s, d, mode, struct squashfs_ldir_inode_header);\
1832611d39a5fcea87d4d5160d3d9bfe1c6aa92729cplougher	SWAP_FUNC(16, s, d, uid, struct squashfs_ldir_inode_header);\
1842611d39a5fcea87d4d5160d3d9bfe1c6aa92729cplougher	SWAP_FUNC(16, s, d, guid, struct squashfs_ldir_inode_header);\
18593fce13e13cbbbaa652028c627ce37e96a9679e8Phillip Lougher	SWAP_FUNC##S(32, s, d, mtime, struct squashfs_ldir_inode_header);\
1862611d39a5fcea87d4d5160d3d9bfe1c6aa92729cplougher	SWAP_FUNC(32, s, d, inode_number, struct squashfs_ldir_inode_header);\
1872611d39a5fcea87d4d5160d3d9bfe1c6aa92729cplougher	SWAP_FUNC(32, s, d, nlink, struct squashfs_ldir_inode_header);\
1882611d39a5fcea87d4d5160d3d9bfe1c6aa92729cplougher	SWAP_FUNC(32, s, d, file_size, struct squashfs_ldir_inode_header);\
1892611d39a5fcea87d4d5160d3d9bfe1c6aa92729cplougher	SWAP_FUNC(32, s, d, start_block, struct squashfs_ldir_inode_header);\
1902611d39a5fcea87d4d5160d3d9bfe1c6aa92729cplougher	SWAP_FUNC(32, s, d, parent_inode, struct squashfs_ldir_inode_header);\
1912611d39a5fcea87d4d5160d3d9bfe1c6aa92729cplougher	SWAP_FUNC(16, s, d, i_count, struct squashfs_ldir_inode_header);\
1922611d39a5fcea87d4d5160d3d9bfe1c6aa92729cplougher	SWAP_FUNC(16, s, d, offset, struct squashfs_ldir_inode_header);\
1932611d39a5fcea87d4d5160d3d9bfe1c6aa92729cplougher	SWAP_FUNC(32, s, d, xattr, struct squashfs_ldir_inode_header);\
1941b899fc316f7eba7a31da12dc0c9b69ada441059plougher}
1951b899fc316f7eba7a31da12dc0c9b69ada441059plougher
1960759a654adb0fdc348c448f3569a2dfefa90653cplougher#define _SQUASHFS_SWAP_DIR_ENTRY(s, d, SWAP_FUNC) {\
1979b393553bbca1d7efc755a4b73e64407a526ef11plougher	SWAP_FUNC(16, s, d, offset, struct squashfs_dir_entry);\
1989b393553bbca1d7efc755a4b73e64407a526ef11plougher	SWAP_FUNC##S(16, s, d, inode_number, struct squashfs_dir_entry);\
1999b393553bbca1d7efc755a4b73e64407a526ef11plougher	SWAP_FUNC(16, s, d, type, struct squashfs_dir_entry);\
2009b393553bbca1d7efc755a4b73e64407a526ef11plougher	SWAP_FUNC(16, s, d, size, struct squashfs_dir_entry);\
2011b899fc316f7eba7a31da12dc0c9b69ada441059plougher}
2021b899fc316f7eba7a31da12dc0c9b69ada441059plougher
2030759a654adb0fdc348c448f3569a2dfefa90653cplougher#define _SQUASHFS_SWAP_DIR_HEADER(s, d, SWAP_FUNC) {\
204520e1a144c9a6c957754f93dc8830f884fe5669bplougher	SWAP_FUNC(32, s, d, count, struct squashfs_dir_header);\
205520e1a144c9a6c957754f93dc8830f884fe5669bplougher	SWAP_FUNC(32, s, d, start_block, struct squashfs_dir_header);\
206520e1a144c9a6c957754f93dc8830f884fe5669bplougher	SWAP_FUNC(32, s, d, inode_number, struct squashfs_dir_header);\
2071b899fc316f7eba7a31da12dc0c9b69ada441059plougher}
2081b899fc316f7eba7a31da12dc0c9b69ada441059plougher
2090759a654adb0fdc348c448f3569a2dfefa90653cplougher#define _SQUASHFS_SWAP_FRAGMENT_ENTRY(s, d, SWAP_FUNC) {\
2108ed84b96ca36da8147993935b951918359d8f20aplougher	SWAP_FUNC(64, s, d, start_block, struct squashfs_fragment_entry);\
2118ed84b96ca36da8147993935b951918359d8f20aplougher	SWAP_FUNC(32, s, d, size, struct squashfs_fragment_entry);\
2121b899fc316f7eba7a31da12dc0c9b69ada441059plougher}
2131b899fc316f7eba7a31da12dc0c9b69ada441059plougher
214e6e0e1bdf98ad6faa63527e5bbdd3bd5e7e97a9eplougher#define _SQUASHFS_SWAP_XATTR_ENTRY(s, d, SWAP_FUNC) {\
215f1a367983ca802f43d287270cf8d35d338f7af37plougher	SWAP_FUNC(16, s, d, type, struct squashfs_xattr_entry);\
216f1a367983ca802f43d287270cf8d35d338f7af37plougher	SWAP_FUNC(16, s, d, size, struct squashfs_xattr_entry);\
217e6e0e1bdf98ad6faa63527e5bbdd3bd5e7e97a9eplougher}
218e6e0e1bdf98ad6faa63527e5bbdd3bd5e7e97a9eplougher
219e6e0e1bdf98ad6faa63527e5bbdd3bd5e7e97a9eplougher#define _SQUASHFS_SWAP_XATTR_VAL(s, d, SWAP_FUNC) {\
220f1a367983ca802f43d287270cf8d35d338f7af37plougher	SWAP_FUNC(32, s, d, vsize, struct squashfs_xattr_val);\
221e6e0e1bdf98ad6faa63527e5bbdd3bd5e7e97a9eplougher}
222e6e0e1bdf98ad6faa63527e5bbdd3bd5e7e97a9eplougher
223e6e0e1bdf98ad6faa63527e5bbdd3bd5e7e97a9eplougher#define _SQUASHFS_SWAP_XATTR_ID(s, d, SWAP_FUNC) {\
224f1a367983ca802f43d287270cf8d35d338f7af37plougher	SWAP_FUNC(64, s, d, xattr, struct squashfs_xattr_id);\
225f1a367983ca802f43d287270cf8d35d338f7af37plougher	SWAP_FUNC(32, s, d, count, struct squashfs_xattr_id);\
226f1a367983ca802f43d287270cf8d35d338f7af37plougher	SWAP_FUNC(32, s, d, size, struct squashfs_xattr_id);\
227e6e0e1bdf98ad6faa63527e5bbdd3bd5e7e97a9eplougher}
228e6e0e1bdf98ad6faa63527e5bbdd3bd5e7e97a9eplougher
229e6e0e1bdf98ad6faa63527e5bbdd3bd5e7e97a9eplougher#define _SQUASHFS_SWAP_XATTR_TABLE(s, d, SWAP_FUNC) {\
230f1a367983ca802f43d287270cf8d35d338f7af37plougher	SWAP_FUNC(64, s, d, xattr_table_start, struct squashfs_xattr_table);\
231f1a367983ca802f43d287270cf8d35d338f7af37plougher	SWAP_FUNC(32, s, d, xattr_ids, struct squashfs_xattr_table);\
232e6e0e1bdf98ad6faa63527e5bbdd3bd5e7e97a9eplougher}
233e6e0e1bdf98ad6faa63527e5bbdd3bd5e7e97a9eplougher
2348eb2631bda91a30ed0ecc24a439932c15643f8a8plougher/* big endian architecture copy and swap macros */
235cb76c1835577cdaded339f990f637ceef7c1c3f7plougher#define SQUASHFS_SWAP_SUPER_BLOCK(s, d)	\
236cb76c1835577cdaded339f990f637ceef7c1c3f7plougher			_SQUASHFS_SWAP_SUPER_BLOCK(s, d, SWAP_LE)
237cb76c1835577cdaded339f990f637ceef7c1c3f7plougher#define SQUASHFS_SWAP_DIR_INDEX(s, d) \
238cb76c1835577cdaded339f990f637ceef7c1c3f7plougher			_SQUASHFS_SWAP_DIR_INDEX(s, d, SWAP_LE)
239cb76c1835577cdaded339f990f637ceef7c1c3f7plougher#define SQUASHFS_SWAP_BASE_INODE_HEADER(s, d) \
240cb76c1835577cdaded339f990f637ceef7c1c3f7plougher			_SQUASHFS_SWAP_BASE_INODE_HEADER(s, d, SWAP_LE)
241cb76c1835577cdaded339f990f637ceef7c1c3f7plougher#define SQUASHFS_SWAP_IPC_INODE_HEADER(s, d) \
242cb76c1835577cdaded339f990f637ceef7c1c3f7plougher			_SQUASHFS_SWAP_IPC_INODE_HEADER(s, d, SWAP_LE)
243c5d69328b23c606b3205f84ef0f01d45baa996a5plougher#define SQUASHFS_SWAP_LIPC_INODE_HEADER(s, d) \
244c5d69328b23c606b3205f84ef0f01d45baa996a5plougher			_SQUASHFS_SWAP_LIPC_INODE_HEADER(s, d, SWAP_LE)
245cb76c1835577cdaded339f990f637ceef7c1c3f7plougher#define SQUASHFS_SWAP_DEV_INODE_HEADER(s, d) \
246cb76c1835577cdaded339f990f637ceef7c1c3f7plougher			_SQUASHFS_SWAP_DEV_INODE_HEADER(s, d, SWAP_LE)
247e6e0e1bdf98ad6faa63527e5bbdd3bd5e7e97a9eplougher#define SQUASHFS_SWAP_LDEV_INODE_HEADER(s, d) \
248e6e0e1bdf98ad6faa63527e5bbdd3bd5e7e97a9eplougher			_SQUASHFS_SWAP_LDEV_INODE_HEADER(s, d, SWAP_LE)
249cb76c1835577cdaded339f990f637ceef7c1c3f7plougher#define SQUASHFS_SWAP_SYMLINK_INODE_HEADER(s, d) \
250cb76c1835577cdaded339f990f637ceef7c1c3f7plougher			_SQUASHFS_SWAP_SYMLINK_INODE_HEADER(s, d, SWAP_LE)
251cb76c1835577cdaded339f990f637ceef7c1c3f7plougher#define SQUASHFS_SWAP_REG_INODE_HEADER(s, d) \
252cb76c1835577cdaded339f990f637ceef7c1c3f7plougher			_SQUASHFS_SWAP_REG_INODE_HEADER(s, d, SWAP_LE)
253cb76c1835577cdaded339f990f637ceef7c1c3f7plougher#define SQUASHFS_SWAP_LREG_INODE_HEADER(s, d) \
254cb76c1835577cdaded339f990f637ceef7c1c3f7plougher			_SQUASHFS_SWAP_LREG_INODE_HEADER(s, d, SWAP_LE)
255cb76c1835577cdaded339f990f637ceef7c1c3f7plougher#define SQUASHFS_SWAP_DIR_INODE_HEADER(s, d) \
256cb76c1835577cdaded339f990f637ceef7c1c3f7plougher			_SQUASHFS_SWAP_DIR_INODE_HEADER(s, d, SWAP_LE)
257cb76c1835577cdaded339f990f637ceef7c1c3f7plougher#define SQUASHFS_SWAP_LDIR_INODE_HEADER(s, d) \
258cb76c1835577cdaded339f990f637ceef7c1c3f7plougher			_SQUASHFS_SWAP_LDIR_INODE_HEADER(s, d, SWAP_LE)
259cb76c1835577cdaded339f990f637ceef7c1c3f7plougher#define SQUASHFS_SWAP_DIR_ENTRY(s, d) \
260cb76c1835577cdaded339f990f637ceef7c1c3f7plougher			_SQUASHFS_SWAP_DIR_ENTRY(s, d, SWAP_LE)
261cb76c1835577cdaded339f990f637ceef7c1c3f7plougher#define SQUASHFS_SWAP_DIR_HEADER(s, d) \
262cb76c1835577cdaded339f990f637ceef7c1c3f7plougher			_SQUASHFS_SWAP_DIR_HEADER(s, d, SWAP_LE)
263cb76c1835577cdaded339f990f637ceef7c1c3f7plougher#define SQUASHFS_SWAP_FRAGMENT_ENTRY(s, d) \
264cb76c1835577cdaded339f990f637ceef7c1c3f7plougher			_SQUASHFS_SWAP_FRAGMENT_ENTRY(s, d, SWAP_LE)
265e6e0e1bdf98ad6faa63527e5bbdd3bd5e7e97a9eplougher#define SQUASHFS_SWAP_XATTR_ENTRY(s, d) \
266e6e0e1bdf98ad6faa63527e5bbdd3bd5e7e97a9eplougher			 _SQUASHFS_SWAP_XATTR_ENTRY(s, d, SWAP_LE)
267e6e0e1bdf98ad6faa63527e5bbdd3bd5e7e97a9eplougher#define SQUASHFS_SWAP_XATTR_VAL(s, d) \
268e6e0e1bdf98ad6faa63527e5bbdd3bd5e7e97a9eplougher			_SQUASHFS_SWAP_XATTR_VAL(s, d, SWAP_LE)
269e6e0e1bdf98ad6faa63527e5bbdd3bd5e7e97a9eplougher#define SQUASHFS_SWAP_XATTR_ID(s, d) \
270e6e0e1bdf98ad6faa63527e5bbdd3bd5e7e97a9eplougher			 _SQUASHFS_SWAP_XATTR_ID(s, d, SWAP_LE)
271e6e0e1bdf98ad6faa63527e5bbdd3bd5e7e97a9eplougher#define SQUASHFS_SWAP_XATTR_TABLE(s, d) \
272e6e0e1bdf98ad6faa63527e5bbdd3bd5e7e97a9eplougher			_SQUASHFS_SWAP_XATTR_TABLE(s, d, SWAP_LE)
2735ec47ee1a582f32b039653ac6fec904afafd465aplougher#define SWAP_LE(bits, s, d, field, type) \
2745ec47ee1a582f32b039653ac6fec904afafd465aplougher			SWAP_LE##bits(((void *)(s)) + offsetof(type, field), \
2755ec47ee1a582f32b039653ac6fec904afafd465aplougher				((void *)(d)) + offsetof(type, field))
2765ec47ee1a582f32b039653ac6fec904afafd465aplougher#define SWAP_LES(bits, s, d, field, type) \
2775ec47ee1a582f32b039653ac6fec904afafd465aplougher			SWAP_LE(bits, s, d, field, type)
278cb76c1835577cdaded339f990f637ceef7c1c3f7plougher#define SQUASHFS_SWAP_INODE_T(s, d) SQUASHFS_SWAP_LONG_LONGS(s, d, 1)
2798eb2631bda91a30ed0ecc24a439932c15643f8a8plougher#define SQUASHFS_SWAP_FRAGMENT_INDEXES(s, d, n) \
2808eb2631bda91a30ed0ecc24a439932c15643f8a8plougher			SQUASHFS_SWAP_LONG_LONGS(s, d, n)
281cb76c1835577cdaded339f990f637ceef7c1c3f7plougher#define SQUASHFS_SWAP_LOOKUP_BLOCKS(s, d, n) SQUASHFS_SWAP_LONG_LONGS(s, d, n)
282cb76c1835577cdaded339f990f637ceef7c1c3f7plougher#define SQUASHFS_SWAP_ID_BLOCKS(s, d, n) SQUASHFS_SWAP_LONG_LONGS(s, d, n)
2830759a654adb0fdc348c448f3569a2dfefa90653cplougher
284ef15e43b707f22d64c13e9b2ca0eae8b165a1690Phillip Lougher#define SQUASHFS_SWAP_SHORTS(s, d, n) swap_le16_num(s, d, n)
285ef15e43b707f22d64c13e9b2ca0eae8b165a1690Phillip Lougher#define SQUASHFS_SWAP_INTS(s, d, n) swap_le32_num(s, d, n)
286ef15e43b707f22d64c13e9b2ca0eae8b165a1690Phillip Lougher#define SQUASHFS_SWAP_LONG_LONGS(s, d, n) swap_le64_num(s, d, n)
287ef15e43b707f22d64c13e9b2ca0eae8b165a1690Phillip Lougher
288ef15e43b707f22d64c13e9b2ca0eae8b165a1690Phillip Lougher#define SWAP_LE16(s, d)		swap_le16(s, d)
289ef15e43b707f22d64c13e9b2ca0eae8b165a1690Phillip Lougher#define SWAP_LE32(s, d)		swap_le32(s, d)
290ef15e43b707f22d64c13e9b2ca0eae8b165a1690Phillip Lougher#define SWAP_LE64(s, d)		swap_le64(s, d)
291ef15e43b707f22d64c13e9b2ca0eae8b165a1690Phillip Lougher
2928eb2631bda91a30ed0ecc24a439932c15643f8a8plougher/* big endian architecture swap in-place macros */
293cb76c1835577cdaded339f990f637ceef7c1c3f7plougher#define SQUASHFS_INSWAP_SUPER_BLOCK(s) \
294cb76c1835577cdaded339f990f637ceef7c1c3f7plougher			_SQUASHFS_SWAP_SUPER_BLOCK(s, s, INSWAP_LE)
295cb76c1835577cdaded339f990f637ceef7c1c3f7plougher#define SQUASHFS_INSWAP_DIR_INDEX(s) \
296cb76c1835577cdaded339f990f637ceef7c1c3f7plougher			_SQUASHFS_SWAP_DIR_INDEX(s, s, INSWAP_LE)
297cb76c1835577cdaded339f990f637ceef7c1c3f7plougher#define SQUASHFS_INSWAP_BASE_INODE_HEADER(s) \
298cb76c1835577cdaded339f990f637ceef7c1c3f7plougher			_SQUASHFS_SWAP_BASE_INODE_HEADER(s, s, INSWAP_LE)
299cb76c1835577cdaded339f990f637ceef7c1c3f7plougher#define SQUASHFS_INSWAP_IPC_INODE_HEADER(s) \
300cb76c1835577cdaded339f990f637ceef7c1c3f7plougher			_SQUASHFS_SWAP_IPC_INODE_HEADER(s, s, INSWAP_LE)
301c5d69328b23c606b3205f84ef0f01d45baa996a5plougher#define SQUASHFS_INSWAP_LIPC_INODE_HEADER(s) \
302c5d69328b23c606b3205f84ef0f01d45baa996a5plougher			_SQUASHFS_SWAP_LIPC_INODE_HEADER(s, s, INSWAP_LE)
303cb76c1835577cdaded339f990f637ceef7c1c3f7plougher#define SQUASHFS_INSWAP_DEV_INODE_HEADER(s) \
304cb76c1835577cdaded339f990f637ceef7c1c3f7plougher			_SQUASHFS_SWAP_DEV_INODE_HEADER(s, s, INSWAP_LE)
305e6e0e1bdf98ad6faa63527e5bbdd3bd5e7e97a9eplougher#define SQUASHFS_INSWAP_LDEV_INODE_HEADER(s) \
306e6e0e1bdf98ad6faa63527e5bbdd3bd5e7e97a9eplougher			_SQUASHFS_SWAP_LDEV_INODE_HEADER(s, s, INSWAP_LE)
307cb76c1835577cdaded339f990f637ceef7c1c3f7plougher#define SQUASHFS_INSWAP_SYMLINK_INODE_HEADER(s) \
308cb76c1835577cdaded339f990f637ceef7c1c3f7plougher			_SQUASHFS_SWAP_SYMLINK_INODE_HEADER(s, s, INSWAP_LE)
309cb76c1835577cdaded339f990f637ceef7c1c3f7plougher#define SQUASHFS_INSWAP_REG_INODE_HEADER(s) \
310cb76c1835577cdaded339f990f637ceef7c1c3f7plougher			_SQUASHFS_SWAP_REG_INODE_HEADER(s, s, INSWAP_LE)
311cb76c1835577cdaded339f990f637ceef7c1c3f7plougher#define SQUASHFS_INSWAP_LREG_INODE_HEADER(s) \
312cb76c1835577cdaded339f990f637ceef7c1c3f7plougher			_SQUASHFS_SWAP_LREG_INODE_HEADER(s, s, INSWAP_LE)
313cb76c1835577cdaded339f990f637ceef7c1c3f7plougher#define SQUASHFS_INSWAP_DIR_INODE_HEADER(s) \
314cb76c1835577cdaded339f990f637ceef7c1c3f7plougher			_SQUASHFS_SWAP_DIR_INODE_HEADER(s, s, INSWAP_LE)
315cb76c1835577cdaded339f990f637ceef7c1c3f7plougher#define SQUASHFS_INSWAP_LDIR_INODE_HEADER(s) \
316cb76c1835577cdaded339f990f637ceef7c1c3f7plougher			_SQUASHFS_SWAP_LDIR_INODE_HEADER(s, s, INSWAP_LE)
317cb76c1835577cdaded339f990f637ceef7c1c3f7plougher#define SQUASHFS_INSWAP_DIR_ENTRY(s) \
318cb76c1835577cdaded339f990f637ceef7c1c3f7plougher			_SQUASHFS_SWAP_DIR_ENTRY(s, s, INSWAP_LE)
319cb76c1835577cdaded339f990f637ceef7c1c3f7plougher#define SQUASHFS_INSWAP_DIR_HEADER(s) \
320cb76c1835577cdaded339f990f637ceef7c1c3f7plougher			_SQUASHFS_SWAP_DIR_HEADER(s, s, INSWAP_LE)
321cb76c1835577cdaded339f990f637ceef7c1c3f7plougher#define SQUASHFS_INSWAP_FRAGMENT_ENTRY(s) \
322cb76c1835577cdaded339f990f637ceef7c1c3f7plougher			_SQUASHFS_SWAP_FRAGMENT_ENTRY(s, s, INSWAP_LE)
323e6e0e1bdf98ad6faa63527e5bbdd3bd5e7e97a9eplougher#define SQUASHFS_INSWAP_XATTR_ENTRY(s) \
324e6e0e1bdf98ad6faa63527e5bbdd3bd5e7e97a9eplougher			 _SQUASHFS_SWAP_XATTR_ENTRY(s, s, INSWAP_LE)
325e6e0e1bdf98ad6faa63527e5bbdd3bd5e7e97a9eplougher#define SQUASHFS_INSWAP_XATTR_VAL(s) \
326e6e0e1bdf98ad6faa63527e5bbdd3bd5e7e97a9eplougher			_SQUASHFS_SWAP_XATTR_VAL(s, s, INSWAP_LE)
327e6e0e1bdf98ad6faa63527e5bbdd3bd5e7e97a9eplougher#define SQUASHFS_INSWAP_XATTR_ID(s) \
328e6e0e1bdf98ad6faa63527e5bbdd3bd5e7e97a9eplougher			 _SQUASHFS_SWAP_XATTR_ID(s, s, INSWAP_LE)
329e6e0e1bdf98ad6faa63527e5bbdd3bd5e7e97a9eplougher#define SQUASHFS_INSWAP_XATTR_TABLE(s) \
330e6e0e1bdf98ad6faa63527e5bbdd3bd5e7e97a9eplougher			_SQUASHFS_SWAP_XATTR_TABLE(s, s, INSWAP_LE)
3318eb2631bda91a30ed0ecc24a439932c15643f8a8plougher#define INSWAP_LE(bits, s, d, field, type) \
3328eb2631bda91a30ed0ecc24a439932c15643f8a8plougher			(s)->field = inswap_le##bits((s)->field)
3335ec47ee1a582f32b039653ac6fec904afafd465aplougher#define INSWAP_LES(bits, s, d, field, type) \
33493fce13e13cbbbaa652028c627ce37e96a9679e8Phillip Lougher			(s)->field = INSWAP_LES##bits((s)->field)
33593fce13e13cbbbaa652028c627ce37e96a9679e8Phillip Lougher#define INSWAP_LES16(num) (short) inswap_le16((unsigned short) (num))
33693fce13e13cbbbaa652028c627ce37e96a9679e8Phillip Lougher#define INSWAP_LES32(num) (int) inswap_le32((unsigned int) (num))
337cb76c1835577cdaded339f990f637ceef7c1c3f7plougher#define SQUASHFS_INSWAP_INODE_T(s) s = inswap_le64(s)
338cb76c1835577cdaded339f990f637ceef7c1c3f7plougher#define SQUASHFS_INSWAP_FRAGMENT_INDEXES(s, n) inswap_le64_num(s, n)
339cb76c1835577cdaded339f990f637ceef7c1c3f7plougher#define SQUASHFS_INSWAP_LOOKUP_BLOCKS(s, n) inswap_le64_num(s, n)
340cb76c1835577cdaded339f990f637ceef7c1c3f7plougher#define SQUASHFS_INSWAP_ID_BLOCKS(s, n) inswap_le64_num(s, n)
341cb76c1835577cdaded339f990f637ceef7c1c3f7plougher#define SQUASHFS_INSWAP_SHORTS(s, n) inswap_le16_num(s, n)
342cb76c1835577cdaded339f990f637ceef7c1c3f7plougher#define SQUASHFS_INSWAP_INTS(s, n) inswap_le32_num(s, n)
343cb76c1835577cdaded339f990f637ceef7c1c3f7plougher#define SQUASHFS_INSWAP_LONG_LONGS(s, n) inswap_le64_num(s, n)
344cb76c1835577cdaded339f990f637ceef7c1c3f7plougher#else
3458eb2631bda91a30ed0ecc24a439932c15643f8a8plougher/* little endian architecture, just copy */
346cb76c1835577cdaded339f990f637ceef7c1c3f7plougher#define SQUASHFS_SWAP_SUPER_BLOCK(s, d)	\
347e8be0a63e4674bef6840a43cd8a34bed9c48a255Phillip Lougher		SQUASHFS_MEMCPY(s, d, sizeof(struct squashfs_super_block))
348cb76c1835577cdaded339f990f637ceef7c1c3f7plougher#define SQUASHFS_SWAP_DIR_INDEX(s, d) \
349e8be0a63e4674bef6840a43cd8a34bed9c48a255Phillip Lougher		SQUASHFS_MEMCPY(s, d, sizeof(struct squashfs_dir_index))
350cb76c1835577cdaded339f990f637ceef7c1c3f7plougher#define SQUASHFS_SWAP_BASE_INODE_HEADER(s, d) \
351e8be0a63e4674bef6840a43cd8a34bed9c48a255Phillip Lougher		SQUASHFS_MEMCPY(s, d, sizeof(struct squashfs_base_inode_header))
352cb76c1835577cdaded339f990f637ceef7c1c3f7plougher#define SQUASHFS_SWAP_IPC_INODE_HEADER(s, d) \
353e8be0a63e4674bef6840a43cd8a34bed9c48a255Phillip Lougher		SQUASHFS_MEMCPY(s, d, sizeof(struct squashfs_ipc_inode_header))
354c5d69328b23c606b3205f84ef0f01d45baa996a5plougher#define SQUASHFS_SWAP_LIPC_INODE_HEADER(s, d) \
355e8be0a63e4674bef6840a43cd8a34bed9c48a255Phillip Lougher		SQUASHFS_MEMCPY(s, d, sizeof(struct squashfs_lipc_inode_header))
356cb76c1835577cdaded339f990f637ceef7c1c3f7plougher#define SQUASHFS_SWAP_DEV_INODE_HEADER(s, d) \
357e8be0a63e4674bef6840a43cd8a34bed9c48a255Phillip Lougher		SQUASHFS_MEMCPY(s, d, sizeof(struct squashfs_dev_inode_header))
358e6e0e1bdf98ad6faa63527e5bbdd3bd5e7e97a9eplougher#define SQUASHFS_SWAP_LDEV_INODE_HEADER(s, d) \
359e8be0a63e4674bef6840a43cd8a34bed9c48a255Phillip Lougher		SQUASHFS_MEMCPY(s, d, sizeof(struct squashfs_ldev_inode_header))
360cb76c1835577cdaded339f990f637ceef7c1c3f7plougher#define SQUASHFS_SWAP_SYMLINK_INODE_HEADER(s, d) \
361e8be0a63e4674bef6840a43cd8a34bed9c48a255Phillip Lougher		SQUASHFS_MEMCPY(s, d, sizeof(struct squashfs_symlink_inode_header))
362cb76c1835577cdaded339f990f637ceef7c1c3f7plougher#define SQUASHFS_SWAP_REG_INODE_HEADER(s, d) \
363e8be0a63e4674bef6840a43cd8a34bed9c48a255Phillip Lougher		SQUASHFS_MEMCPY(s, d, sizeof(struct squashfs_reg_inode_header))
364cb76c1835577cdaded339f990f637ceef7c1c3f7plougher#define SQUASHFS_SWAP_LREG_INODE_HEADER(s, d) \
365e8be0a63e4674bef6840a43cd8a34bed9c48a255Phillip Lougher		SQUASHFS_MEMCPY(s, d, sizeof(struct squashfs_lreg_inode_header))
366cb76c1835577cdaded339f990f637ceef7c1c3f7plougher#define SQUASHFS_SWAP_DIR_INODE_HEADER(s, d) \
367e8be0a63e4674bef6840a43cd8a34bed9c48a255Phillip Lougher		SQUASHFS_MEMCPY(s, d, sizeof(struct squashfs_dir_inode_header))
368cb76c1835577cdaded339f990f637ceef7c1c3f7plougher#define SQUASHFS_SWAP_LDIR_INODE_HEADER(s, d) \
369e8be0a63e4674bef6840a43cd8a34bed9c48a255Phillip Lougher		SQUASHFS_MEMCPY(s, d, sizeof(struct squashfs_ldir_inode_header))
370cb76c1835577cdaded339f990f637ceef7c1c3f7plougher#define SQUASHFS_SWAP_DIR_ENTRY(s, d) \
371e8be0a63e4674bef6840a43cd8a34bed9c48a255Phillip Lougher		SQUASHFS_MEMCPY(s, d, sizeof(struct squashfs_dir_entry))
372cb76c1835577cdaded339f990f637ceef7c1c3f7plougher#define SQUASHFS_SWAP_DIR_HEADER(s, d) \
373e8be0a63e4674bef6840a43cd8a34bed9c48a255Phillip Lougher		SQUASHFS_MEMCPY(s, d, sizeof(struct squashfs_dir_header))
374cb76c1835577cdaded339f990f637ceef7c1c3f7plougher#define SQUASHFS_SWAP_FRAGMENT_ENTRY(s, d) \
375e8be0a63e4674bef6840a43cd8a34bed9c48a255Phillip Lougher		SQUASHFS_MEMCPY(s, d, sizeof(struct squashfs_fragment_entry))
376e6e0e1bdf98ad6faa63527e5bbdd3bd5e7e97a9eplougher#define SQUASHFS_SWAP_XATTR_ENTRY(s, d) \
377e8be0a63e4674bef6840a43cd8a34bed9c48a255Phillip Lougher		SQUASHFS_MEMCPY(s, d, sizeof(struct squashfs_xattr_entry))
378e6e0e1bdf98ad6faa63527e5bbdd3bd5e7e97a9eplougher#define SQUASHFS_SWAP_XATTR_VAL(s, d) \
379e8be0a63e4674bef6840a43cd8a34bed9c48a255Phillip Lougher		SQUASHFS_MEMCPY(s, d, sizeof(struct squashfs_xattr_val))
380e6e0e1bdf98ad6faa63527e5bbdd3bd5e7e97a9eplougher#define SQUASHFS_SWAP_XATTR_ID(s, d) \
381e8be0a63e4674bef6840a43cd8a34bed9c48a255Phillip Lougher		SQUASHFS_MEMCPY(s, d, sizeof(struct squashfs_xattr_id))
382e6e0e1bdf98ad6faa63527e5bbdd3bd5e7e97a9eplougher#define SQUASHFS_SWAP_XATTR_TABLE(s, d) \
383e8be0a63e4674bef6840a43cd8a34bed9c48a255Phillip Lougher		SQUASHFS_MEMCPY(s, d, sizeof(struct squashfs_xattr_table))
3841b899fc316f7eba7a31da12dc0c9b69ada441059plougher#define SQUASHFS_SWAP_INODE_T(s, d) SQUASHFS_SWAP_LONG_LONGS(s, d, 1)
3858eb2631bda91a30ed0ecc24a439932c15643f8a8plougher#define SQUASHFS_SWAP_FRAGMENT_INDEXES(s, d, n) \
3868eb2631bda91a30ed0ecc24a439932c15643f8a8plougher			SQUASHFS_SWAP_LONG_LONGS(s, d, n)
3871b899fc316f7eba7a31da12dc0c9b69ada441059plougher#define SQUASHFS_SWAP_LOOKUP_BLOCKS(s, d, n) SQUASHFS_SWAP_LONG_LONGS(s, d, n)
3881b899fc316f7eba7a31da12dc0c9b69ada441059plougher#define SQUASHFS_SWAP_ID_BLOCKS(s, d, n) SQUASHFS_SWAP_LONG_LONGS(s, d, n)
389cb76c1835577cdaded339f990f637ceef7c1c3f7plougher
390ef15e43b707f22d64c13e9b2ca0eae8b165a1690Phillip Lougher#define SQUASHFS_MEMCPY(s, d, n)	memcpy(d, s, n)
391ef15e43b707f22d64c13e9b2ca0eae8b165a1690Phillip Lougher#define SQUASHFS_SWAP_SHORTS(s, d, n)	memcpy(d, s, n * sizeof(short))
392ef15e43b707f22d64c13e9b2ca0eae8b165a1690Phillip Lougher#define SQUASHFS_SWAP_INTS(s, d, n)	memcpy(d, s, n * sizeof(int))
393ef15e43b707f22d64c13e9b2ca0eae8b165a1690Phillip Lougher#define SQUASHFS_SWAP_LONG_LONGS(s, d, n) \
394ef15e43b707f22d64c13e9b2ca0eae8b165a1690Phillip Lougher					memcpy(d, s, n * sizeof(long long))
395ef15e43b707f22d64c13e9b2ca0eae8b165a1690Phillip Lougher
3968eb2631bda91a30ed0ecc24a439932c15643f8a8plougher/* little endian architecture, data already in place so do nothing */
397cb76c1835577cdaded339f990f637ceef7c1c3f7plougher#define SQUASHFS_INSWAP_SUPER_BLOCK(s)
398cb76c1835577cdaded339f990f637ceef7c1c3f7plougher#define SQUASHFS_INSWAP_DIR_INDEX(s)
399cb76c1835577cdaded339f990f637ceef7c1c3f7plougher#define SQUASHFS_INSWAP_BASE_INODE_HEADER(s)
400cb76c1835577cdaded339f990f637ceef7c1c3f7plougher#define SQUASHFS_INSWAP_IPC_INODE_HEADER(s)
401c5d69328b23c606b3205f84ef0f01d45baa996a5plougher#define SQUASHFS_INSWAP_LIPC_INODE_HEADER(s)
402cb76c1835577cdaded339f990f637ceef7c1c3f7plougher#define SQUASHFS_INSWAP_DEV_INODE_HEADER(s)
403e6e0e1bdf98ad6faa63527e5bbdd3bd5e7e97a9eplougher#define SQUASHFS_INSWAP_LDEV_INODE_HEADER(s)
404cb76c1835577cdaded339f990f637ceef7c1c3f7plougher#define SQUASHFS_INSWAP_SYMLINK_INODE_HEADER(s)
405cb76c1835577cdaded339f990f637ceef7c1c3f7plougher#define SQUASHFS_INSWAP_REG_INODE_HEADER(s)
406cb76c1835577cdaded339f990f637ceef7c1c3f7plougher#define SQUASHFS_INSWAP_LREG_INODE_HEADER(s)
407cb76c1835577cdaded339f990f637ceef7c1c3f7plougher#define SQUASHFS_INSWAP_DIR_INODE_HEADER(s)
408cb76c1835577cdaded339f990f637ceef7c1c3f7plougher#define SQUASHFS_INSWAP_LDIR_INODE_HEADER(s)
409cb76c1835577cdaded339f990f637ceef7c1c3f7plougher#define SQUASHFS_INSWAP_DIR_ENTRY(s)
410cb76c1835577cdaded339f990f637ceef7c1c3f7plougher#define SQUASHFS_INSWAP_DIR_HEADER(s)
411cb76c1835577cdaded339f990f637ceef7c1c3f7plougher#define SQUASHFS_INSWAP_FRAGMENT_ENTRY(s)
412e6e0e1bdf98ad6faa63527e5bbdd3bd5e7e97a9eplougher#define SQUASHFS_INSWAP_XATTR_ENTRY(s)
413e6e0e1bdf98ad6faa63527e5bbdd3bd5e7e97a9eplougher#define SQUASHFS_INSWAP_XATTR_VAL(s)
414e6e0e1bdf98ad6faa63527e5bbdd3bd5e7e97a9eplougher#define SQUASHFS_INSWAP_XATTR_ID(s)
415e6e0e1bdf98ad6faa63527e5bbdd3bd5e7e97a9eplougher#define SQUASHFS_INSWAP_XATTR_TABLE(s)
416cb76c1835577cdaded339f990f637ceef7c1c3f7plougher#define SQUASHFS_INSWAP_INODE_T(s)
417cb76c1835577cdaded339f990f637ceef7c1c3f7plougher#define SQUASHFS_INSWAP_FRAGMENT_INDEXES(s, n)
418cb76c1835577cdaded339f990f637ceef7c1c3f7plougher#define SQUASHFS_INSWAP_LOOKUP_BLOCKS(s, n)
419cb76c1835577cdaded339f990f637ceef7c1c3f7plougher#define SQUASHFS_INSWAP_ID_BLOCKS(s, n)
420cb76c1835577cdaded339f990f637ceef7c1c3f7plougher#define SQUASHFS_INSWAP_SHORTS(s, n)
421cb76c1835577cdaded339f990f637ceef7c1c3f7plougher#define SQUASHFS_INSWAP_INTS(s, n)
422cb76c1835577cdaded339f990f637ceef7c1c3f7plougher#define SQUASHFS_INSWAP_LONG_LONGS(s, n)
423cb76c1835577cdaded339f990f637ceef7c1c3f7plougher#endif
4241b899fc316f7eba7a31da12dc0c9b69ada441059plougher#endif
425