-
Notifications
You must be signed in to change notification settings - Fork 0
/
squashfs_swap.h
312 lines (294 loc) · 11.4 KB
/
squashfs_swap.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
#ifndef SQUASHFS_SWAP_H
#define SQUASHFS_SWAP_H
/*
* Squashfs
*
* Copyright (c) 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009
* Phillip Lougher <[email protected]>
*
* 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,
* 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, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* squashfs_swap.h
*/
/*
* macros to convert each stucture from big endian to little endian
*/
#if __BYTE_ORDER == __BIG_ENDIAN
extern void swap_le16(unsigned short *, unsigned short *);
extern void swap_le32(unsigned int *, unsigned int *);
extern void swap_le64(long long *, long long *);
extern void swap_le16_num(unsigned short *, unsigned short *, int);
extern void swap_le32_num(unsigned int *, unsigned int *, int);
extern void swap_le64_num(long long *, long long *, int);
extern unsigned short inswap_le16(unsigned short);
extern unsigned int inswap_le32(unsigned int);
extern long long inswap_le64(long long);
extern void inswap_le16_num(unsigned short *, int);
extern void inswap_le32_num(unsigned int *, int);
extern void inswap_le64_num(long long *, int);
#define _SQUASHFS_SWAP_SUPER_BLOCK(s, d, SWAP_FUNC) {\
SWAP_FUNC##32(s, d, s_magic);\
SWAP_FUNC##32(s, d, inodes);\
SWAP_FUNC##32(s, d, mkfs_time);\
SWAP_FUNC##32(s, d, block_size);\
SWAP_FUNC##32(s, d, fragments);\
SWAP_FUNC##16(s, d, compression);\
SWAP_FUNC##16(s, d, block_log);\
SWAP_FUNC##16(s, d, flags);\
SWAP_FUNC##16(s, d, no_ids);\
SWAP_FUNC##16(s, d, s_major);\
SWAP_FUNC##16(s, d, s_minor);\
SWAP_FUNC##64(s, d, root_inode);\
SWAP_FUNC##64(s, d, bytes_used);\
SWAP_FUNC##64(s, d, id_table_start);\
SWAP_FUNC##64(s, d, xattr_table_start);\
SWAP_FUNC##64(s, d, inode_table_start);\
SWAP_FUNC##64(s, d, directory_table_start);\
SWAP_FUNC##64(s, d, fragment_table_start);\
SWAP_FUNC##64(s, d, lookup_table_start);\
}
#define _SQUASHFS_SWAP_DIR_INDEX(s, d, SWAP_FUNC) {\
SWAP_FUNC##32(s, d, index);\
SWAP_FUNC##32(s, d, start_block);\
SWAP_FUNC##32(s, d, size);\
}
#define _SQUASHFS_SWAP_BASE_INODE_HEADER(s, d, SWAP_FUNC) {\
SWAP_FUNC##16(s, d, inode_type);\
SWAP_FUNC##16(s, d, mode);\
SWAP_FUNC##16(s, d, uid);\
SWAP_FUNC##16(s, d, guid);\
SWAP_FUNC##32(s, d, mtime);\
SWAP_FUNC##32(s, d, inode_number);\
}
#define _SQUASHFS_SWAP_IPC_INODE_HEADER(s, d, SWAP_FUNC) {\
SWAP_FUNC##16(s, d, inode_type);\
SWAP_FUNC##16(s, d, mode);\
SWAP_FUNC##16(s, d, uid);\
SWAP_FUNC##16(s, d, guid);\
SWAP_FUNC##32(s, d, mtime);\
SWAP_FUNC##32(s, d, inode_number);\
SWAP_FUNC##32(s, d, nlink);\
}
#define _SQUASHFS_SWAP_DEV_INODE_HEADER(s, d, SWAP_FUNC) {\
SWAP_FUNC##16(s, d, inode_type);\
SWAP_FUNC##16(s, d, mode);\
SWAP_FUNC##16(s, d, uid);\
SWAP_FUNC##16(s, d, guid);\
SWAP_FUNC##32(s, d, mtime);\
SWAP_FUNC##32(s, d, inode_number);\
SWAP_FUNC##32(s, d, nlink);\
SWAP_FUNC##32(s, d, rdev);\
}
#define _SQUASHFS_SWAP_SYMLINK_INODE_HEADER(s, d, SWAP_FUNC) {\
SWAP_FUNC##16(s, d, inode_type);\
SWAP_FUNC##16(s, d, mode);\
SWAP_FUNC##16(s, d, uid);\
SWAP_FUNC##16(s, d, guid);\
SWAP_FUNC##32(s, d, mtime);\
SWAP_FUNC##32(s, d, inode_number);\
SWAP_FUNC##32(s, d, nlink);\
SWAP_FUNC##32(s, d, symlink_size);\
}
#define _SQUASHFS_SWAP_REG_INODE_HEADER(s, d, SWAP_FUNC) {\
SWAP_FUNC##16(s, d, inode_type);\
SWAP_FUNC##16(s, d, mode);\
SWAP_FUNC##16(s, d, uid);\
SWAP_FUNC##16(s, d, guid);\
SWAP_FUNC##32(s, d, mtime);\
SWAP_FUNC##32(s, d, inode_number);\
SWAP_FUNC##32(s, d, start_block);\
SWAP_FUNC##32(s, d, fragment);\
SWAP_FUNC##32(s, d, offset);\
SWAP_FUNC##32(s, d, file_size);\
}
#define _SQUASHFS_SWAP_LREG_INODE_HEADER(s, d, SWAP_FUNC) {\
SWAP_FUNC##16(s, d, inode_type);\
SWAP_FUNC##16(s, d, mode);\
SWAP_FUNC##16(s, d, uid);\
SWAP_FUNC##16(s, d, guid);\
SWAP_FUNC##32(s, d, mtime);\
SWAP_FUNC##32(s, d, inode_number);\
SWAP_FUNC##64(s, d, start_block);\
SWAP_FUNC##64(s, d, file_size);\
SWAP_FUNC##64(s, d, sparse);\
SWAP_FUNC##32(s, d, nlink);\
SWAP_FUNC##32(s, d, fragment);\
SWAP_FUNC##32(s, d, offset);\
SWAP_FUNC##32(s, d, xattr);\
}
#define _SQUASHFS_SWAP_DIR_INODE_HEADER(s, d, SWAP_FUNC) {\
SWAP_FUNC##16(s, d, inode_type);\
SWAP_FUNC##16(s, d, mode);\
SWAP_FUNC##16(s, d, uid);\
SWAP_FUNC##16(s, d, guid);\
SWAP_FUNC##32(s, d, mtime);\
SWAP_FUNC##32(s, d, inode_number);\
SWAP_FUNC##32(s, d, start_block);\
SWAP_FUNC##32(s, d, nlink);\
SWAP_FUNC##16(s, d, file_size);\
SWAP_FUNC##16(s, d, offset);\
SWAP_FUNC##32(s, d, parent_inode);\
}
#define _SQUASHFS_SWAP_LDIR_INODE_HEADER(s, d, SWAP_FUNC) {\
SWAP_FUNC##16(s, d, inode_type);\
SWAP_FUNC##16(s, d, mode);\
SWAP_FUNC##16(s, d, uid);\
SWAP_FUNC##16(s, d, guid);\
SWAP_FUNC##32(s, d, mtime);\
SWAP_FUNC##32(s, d, inode_number);\
SWAP_FUNC##32(s, d, nlink);\
SWAP_FUNC##32(s, d, file_size);\
SWAP_FUNC##32(s, d, start_block);\
SWAP_FUNC##32(s, d, parent_inode);\
SWAP_FUNC##16(s, d, i_count);\
SWAP_FUNC##16(s, d, offset);\
SWAP_FUNC##32(s, d, xattr);\
}
#define _SQUASHFS_SWAP_DIR_ENTRY(s, d, SWAP_FUNC) {\
SWAP_FUNC##16(s, d, offset);\
SWAP_FUNC##S16(s, d, inode_number);\
SWAP_FUNC##16(s, d, type);\
SWAP_FUNC##16(s, d, size);\
}
#define _SQUASHFS_SWAP_DIR_HEADER(s, d, SWAP_FUNC) {\
SWAP_FUNC##32(s, d, count);\
SWAP_FUNC##32(s, d, start_block);\
SWAP_FUNC##32(s, d, inode_number);\
}
#define _SQUASHFS_SWAP_FRAGMENT_ENTRY(s, d, SWAP_FUNC) {\
SWAP_FUNC##64(s, d, start_block);\
SWAP_FUNC##32(s, d, size);\
}
#define SQUASHFS_SWAP_SUPER_BLOCK(s, d) \
_SQUASHFS_SWAP_SUPER_BLOCK(s, d, SWAP_LE)
#define SQUASHFS_SWAP_DIR_INDEX(s, d) \
_SQUASHFS_SWAP_DIR_INDEX(s, d, SWAP_LE)
#define SQUASHFS_SWAP_BASE_INODE_HEADER(s, d) \
_SQUASHFS_SWAP_BASE_INODE_HEADER(s, d, SWAP_LE)
#define SQUASHFS_SWAP_IPC_INODE_HEADER(s, d) \
_SQUASHFS_SWAP_IPC_INODE_HEADER(s, d, SWAP_LE)
#define SQUASHFS_SWAP_DEV_INODE_HEADER(s, d) \
_SQUASHFS_SWAP_DEV_INODE_HEADER(s, d, SWAP_LE)
#define SQUASHFS_SWAP_SYMLINK_INODE_HEADER(s, d) \
_SQUASHFS_SWAP_SYMLINK_INODE_HEADER(s, d, SWAP_LE)
#define SQUASHFS_SWAP_REG_INODE_HEADER(s, d) \
_SQUASHFS_SWAP_REG_INODE_HEADER(s, d, SWAP_LE)
#define SQUASHFS_SWAP_LREG_INODE_HEADER(s, d) \
_SQUASHFS_SWAP_LREG_INODE_HEADER(s, d, SWAP_LE)
#define SQUASHFS_SWAP_DIR_INODE_HEADER(s, d) \
_SQUASHFS_SWAP_DIR_INODE_HEADER(s, d, SWAP_LE)
#define SQUASHFS_SWAP_LDIR_INODE_HEADER(s, d) \
_SQUASHFS_SWAP_LDIR_INODE_HEADER(s, d, SWAP_LE)
#define SQUASHFS_SWAP_DIR_ENTRY(s, d) \
_SQUASHFS_SWAP_DIR_ENTRY(s, d, SWAP_LE)
#define SQUASHFS_SWAP_DIR_HEADER(s, d) \
_SQUASHFS_SWAP_DIR_HEADER(s, d, SWAP_LE)
#define SQUASHFS_SWAP_FRAGMENT_ENTRY(s, d) \
_SQUASHFS_SWAP_FRAGMENT_ENTRY(s, d, SWAP_LE)
#define SQUASHFS_SWAP_INODE_T(s, d) SQUASHFS_SWAP_LONG_LONGS(s, d, 1)
#define SQUASHFS_SWAP_FRAGMENT_INDEXES(s, d, n) SQUASHFS_SWAP_LONG_LONGS(s, d, n)
#define SQUASHFS_SWAP_LOOKUP_BLOCKS(s, d, n) SQUASHFS_SWAP_LONG_LONGS(s, d, n)
#define SQUASHFS_SWAP_ID_BLOCKS(s, d, n) SQUASHFS_SWAP_LONG_LONGS(s, d, n)
#define SQUASHFS_INSWAP_SUPER_BLOCK(s) \
_SQUASHFS_SWAP_SUPER_BLOCK(s, s, INSWAP_LE)
#define SQUASHFS_INSWAP_DIR_INDEX(s) \
_SQUASHFS_SWAP_DIR_INDEX(s, s, INSWAP_LE)
#define SQUASHFS_INSWAP_BASE_INODE_HEADER(s) \
_SQUASHFS_SWAP_BASE_INODE_HEADER(s, s, INSWAP_LE)
#define SQUASHFS_INSWAP_IPC_INODE_HEADER(s) \
_SQUASHFS_SWAP_IPC_INODE_HEADER(s, s, INSWAP_LE)
#define SQUASHFS_INSWAP_DEV_INODE_HEADER(s) \
_SQUASHFS_SWAP_DEV_INODE_HEADER(s, s, INSWAP_LE)
#define SQUASHFS_INSWAP_SYMLINK_INODE_HEADER(s) \
_SQUASHFS_SWAP_SYMLINK_INODE_HEADER(s, s, INSWAP_LE)
#define SQUASHFS_INSWAP_REG_INODE_HEADER(s) \
_SQUASHFS_SWAP_REG_INODE_HEADER(s, s, INSWAP_LE)
#define SQUASHFS_INSWAP_LREG_INODE_HEADER(s) \
_SQUASHFS_SWAP_LREG_INODE_HEADER(s, s, INSWAP_LE)
#define SQUASHFS_INSWAP_DIR_INODE_HEADER(s) \
_SQUASHFS_SWAP_DIR_INODE_HEADER(s, s, INSWAP_LE)
#define SQUASHFS_INSWAP_LDIR_INODE_HEADER(s) \
_SQUASHFS_SWAP_LDIR_INODE_HEADER(s, s, INSWAP_LE)
#define SQUASHFS_INSWAP_DIR_ENTRY(s) \
_SQUASHFS_SWAP_DIR_ENTRY(s, s, INSWAP_LE)
#define SQUASHFS_INSWAP_DIR_HEADER(s) \
_SQUASHFS_SWAP_DIR_HEADER(s, s, INSWAP_LE)
#define SQUASHFS_INSWAP_FRAGMENT_ENTRY(s) \
_SQUASHFS_SWAP_FRAGMENT_ENTRY(s, s, INSWAP_LE)
#define INSWAP_LE16(s, d, field) (s)->field = inswap_le16((s)->field)
#define INSWAP_LE32(s, d, field) (s)->field = inswap_le32((s)->field)
#define INSWAP_LE64(s, d, field) (s)->field = inswap_le64((s)->field)
#define INSWAP_LES16(s, d, field) \
(s)->field = (short) inswap_le16((unsigned short) (s)->field)
#define SQUASHFS_INSWAP_INODE_T(s) s = inswap_le64(s)
#define SQUASHFS_INSWAP_FRAGMENT_INDEXES(s, n) inswap_le64_num(s, n)
#define SQUASHFS_INSWAP_LOOKUP_BLOCKS(s, n) inswap_le64_num(s, n)
#define SQUASHFS_INSWAP_ID_BLOCKS(s, n) inswap_le64_num(s, n)
#define SQUASHFS_INSWAP_SHORTS(s, n) inswap_le16_num(s, n)
#define SQUASHFS_INSWAP_INTS(s, n) inswap_le32_num(s, n)
#define SQUASHFS_INSWAP_LONG_LONGS(s, n) inswap_le64_num(s, n)
#else
#define SQUASHFS_SWAP_SUPER_BLOCK(s, d) \
SQUASHFS_MEMCPY(s, d, sizeof(*(s)))
#define SQUASHFS_SWAP_DIR_INDEX(s, d) \
SQUASHFS_MEMCPY(s, d, sizeof(*(s)))
#define SQUASHFS_SWAP_BASE_INODE_HEADER(s, d) \
SQUASHFS_MEMCPY(s, d, sizeof(*(s)))
#define SQUASHFS_SWAP_IPC_INODE_HEADER(s, d) \
SQUASHFS_MEMCPY(s, d, sizeof(*(s)))
#define SQUASHFS_SWAP_DEV_INODE_HEADER(s, d) \
SQUASHFS_MEMCPY(s, d, sizeof(*(s)))
#define SQUASHFS_SWAP_SYMLINK_INODE_HEADER(s, d) \
SQUASHFS_MEMCPY(s, d, sizeof(*(s)))
#define SQUASHFS_SWAP_REG_INODE_HEADER(s, d) \
SQUASHFS_MEMCPY(s, d, sizeof(*(s)))
#define SQUASHFS_SWAP_LREG_INODE_HEADER(s, d) \
SQUASHFS_MEMCPY(s, d, sizeof(*(s)))
#define SQUASHFS_SWAP_DIR_INODE_HEADER(s, d) \
SQUASHFS_MEMCPY(s, d, sizeof(*(s)))
#define SQUASHFS_SWAP_LDIR_INODE_HEADER(s, d) \
SQUASHFS_MEMCPY(s, d, sizeof(*(s)))
#define SQUASHFS_SWAP_DIR_ENTRY(s, d) \
SQUASHFS_MEMCPY(s, d, sizeof(*(s)))
#define SQUASHFS_SWAP_DIR_HEADER(s, d) \
SQUASHFS_MEMCPY(s, d, sizeof(*(s)))
#define SQUASHFS_SWAP_FRAGMENT_ENTRY(s, d) \
SQUASHFS_MEMCPY(s, d, sizeof(*(s)))
#define SQUASHFS_SWAP_INODE_T(s, d) SQUASHFS_SWAP_LONG_LONGS(s, d, 1)
#define SQUASHFS_SWAP_FRAGMENT_INDEXES(s, d, n) SQUASHFS_SWAP_LONG_LONGS(s, d, n)
#define SQUASHFS_SWAP_LOOKUP_BLOCKS(s, d, n) SQUASHFS_SWAP_LONG_LONGS(s, d, n)
#define SQUASHFS_SWAP_ID_BLOCKS(s, d, n) SQUASHFS_SWAP_LONG_LONGS(s, d, n)
#define SQUASHFS_INSWAP_SUPER_BLOCK(s)
#define SQUASHFS_INSWAP_DIR_INDEX(s)
#define SQUASHFS_INSWAP_BASE_INODE_HEADER(s)
#define SQUASHFS_INSWAP_IPC_INODE_HEADER(s)
#define SQUASHFS_INSWAP_DEV_INODE_HEADER(s)
#define SQUASHFS_INSWAP_SYMLINK_INODE_HEADER(s)
#define SQUASHFS_INSWAP_REG_INODE_HEADER(s)
#define SQUASHFS_INSWAP_LREG_INODE_HEADER(s)
#define SQUASHFS_INSWAP_DIR_INODE_HEADER(s)
#define SQUASHFS_INSWAP_LDIR_INODE_HEADER(s)
#define SQUASHFS_INSWAP_DIR_ENTRY(s)
#define SQUASHFS_INSWAP_DIR_HEADER(s)
#define SQUASHFS_INSWAP_FRAGMENT_ENTRY(s)
#define SQUASHFS_INSWAP_INODE_T(s)
#define SQUASHFS_INSWAP_FRAGMENT_INDEXES(s, n)
#define SQUASHFS_INSWAP_LOOKUP_BLOCKS(s, n)
#define SQUASHFS_INSWAP_ID_BLOCKS(s, n)
#define SQUASHFS_INSWAP_SHORTS(s, n)
#define SQUASHFS_INSWAP_INTS(s, n)
#define SQUASHFS_INSWAP_LONG_LONGS(s, n)
#endif
#endif