6 * Copyright (c) 2002, 2003, 2004, 2005 Phillip Lougher <phillip@lougher.demon.co.uk>
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License
10 * as published by the Free Software Foundation; either version 2,
11 * or (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
25 #ifdef CONFIG_SQUASHFS_VMALLOC
26 #define SQUASHFS_ALLOC(a) vmalloc(a)
27 #define SQUASHFS_FREE(a) vfree(a)
29 #define SQUASHFS_ALLOC(a) kmalloc(a, GFP_KERNEL)
30 #define SQUASHFS_FREE(a) kfree(a)
32 #define SQUASHFS_CACHED_FRAGMENTS CONFIG_SQUASHFS_FRAGMENT_CACHE_SIZE
33 #define SQUASHFS_MAJOR 2
34 #define SQUASHFS_MINOR 1
35 #define SQUASHFS_MAGIC 0x73717368
36 #define SQUASHFS_MAGIC_SWAP 0x68737173
37 #define SQUASHFS_START 0
39 /* size of metadata (inode and directory) blocks */
40 #define SQUASHFS_METADATA_SIZE 8192
41 #define SQUASHFS_METADATA_LOG 13
43 /* default size of data blocks */
44 #define SQUASHFS_FILE_SIZE 65536
45 #define SQUASHFS_FILE_LOG 16
47 #define SQUASHFS_FILE_MAX_SIZE 65536
49 /* Max number of uids and gids */
50 #define SQUASHFS_UIDS 256
51 #define SQUASHFS_GUIDS 255
53 /* Max length of filename (not 255) */
54 #define SQUASHFS_NAME_LEN 256
56 #define SQUASHFS_INVALID ((long long) 0xffffffffffff)
57 #define SQUASHFS_INVALID_BLK ((long long) 0xffffffff)
58 #define SQUASHFS_USED_BLK ((long long) 0xfffffffe)
60 /* Filesystem flags */
61 #define SQUASHFS_NOI 0
62 #define SQUASHFS_NOD 1
63 #define SQUASHFS_CHECK 2
64 #define SQUASHFS_NOF 3
65 #define SQUASHFS_NO_FRAG 4
66 #define SQUASHFS_ALWAYS_FRAG 5
67 #define SQUASHFS_DUPLICATE 6
68 #define SQUASHFS_BIT(flag, bit) ((flag >> bit) & 1)
69 #define SQUASHFS_UNCOMPRESSED_INODES(flags) SQUASHFS_BIT(flags, SQUASHFS_NOI)
70 #define SQUASHFS_UNCOMPRESSED_DATA(flags) SQUASHFS_BIT(flags, SQUASHFS_NOD)
71 #define SQUASHFS_UNCOMPRESSED_FRAGMENTS(flags) SQUASHFS_BIT(flags, SQUASHFS_NOF)
72 #define SQUASHFS_NO_FRAGMENTS(flags) SQUASHFS_BIT(flags, SQUASHFS_NO_FRAG)
73 #define SQUASHFS_ALWAYS_FRAGMENTS(flags) SQUASHFS_BIT(flags, SQUASHFS_ALWAYS_FRAG)
74 #define SQUASHFS_DUPLICATES(flags) SQUASHFS_BIT(flags, SQUASHFS_DUPLICATE)
75 #define SQUASHFS_CHECK_DATA(flags) SQUASHFS_BIT(flags, SQUASHFS_CHECK)
76 #define SQUASHFS_MKFLAGS(noi, nod, check_data, nof, no_frag, always_frag, duplicate_checking) (noi | (nod << 1) | (check_data << 2) | (nof << 3) | (no_frag << 4) | (always_frag << 5) | (duplicate_checking << 6))
78 /* Max number of types and file types */
79 #define SQUASHFS_DIR_TYPE 1
80 #define SQUASHFS_FILE_TYPE 2
81 #define SQUASHFS_SYMLINK_TYPE 3
82 #define SQUASHFS_BLKDEV_TYPE 4
83 #define SQUASHFS_CHRDEV_TYPE 5
84 #define SQUASHFS_FIFO_TYPE 6
85 #define SQUASHFS_SOCKET_TYPE 7
86 #define SQUASHFS_LDIR_TYPE 8
88 /* 1.0 filesystem type definitions */
89 #define SQUASHFS_TYPES 5
90 #define SQUASHFS_IPC_TYPE 0
92 /* Flag whether block is compressed or uncompressed, bit is set if block is uncompressed */
93 #define SQUASHFS_COMPRESSED_BIT (1 << 15)
94 #define SQUASHFS_COMPRESSED_SIZE(B) (((B) & ~SQUASHFS_COMPRESSED_BIT) ? \
95 (B) & ~SQUASHFS_COMPRESSED_BIT : SQUASHFS_COMPRESSED_BIT)
97 #define SQUASHFS_COMPRESSED(B) (!((B) & SQUASHFS_COMPRESSED_BIT))
99 #define SQUASHFS_COMPRESSED_BIT_BLOCK (1 << 24)
100 #define SQUASHFS_COMPRESSED_SIZE_BLOCK(B) (((B) & ~SQUASHFS_COMPRESSED_BIT_BLOCK) ? \
101 (B) & ~SQUASHFS_COMPRESSED_BIT_BLOCK : SQUASHFS_COMPRESSED_BIT_BLOCK)
103 #define SQUASHFS_COMPRESSED_BLOCK(B) (!((B) & SQUASHFS_COMPRESSED_BIT_BLOCK))
106 * Inode number ops. Inodes consist of a compressed block number, and an uncompressed
107 * offset within that block
109 #define SQUASHFS_INODE_BLK(a) ((unsigned int) ((a) >> 16))
110 #define SQUASHFS_INODE_OFFSET(a) ((unsigned int) ((a) & 0xffff))
111 #define SQUASHFS_MKINODE(A, B) ((squashfs_inode)(((squashfs_inode) (A) << 16)\
114 /* Compute 32 bit VFS inode number from squashfs inode number */
115 #define SQUASHFS_MK_VFS_INODE(a, b) ((unsigned int) (((a) << 8) + ((b) >> 2) + 1))
117 /* Translate between VFS mode and squashfs mode */
118 #define SQUASHFS_MODE(a) ((a) & 0xfff)
120 /* fragment and fragment table defines */
121 typedef unsigned int squashfs_fragment_index
;
122 #define SQUASHFS_FRAGMENT_BYTES(A) (A * sizeof(squashfs_fragment_entry))
123 #define SQUASHFS_FRAGMENT_INDEX(A) (SQUASHFS_FRAGMENT_BYTES(A) / SQUASHFS_METADATA_SIZE)
124 #define SQUASHFS_FRAGMENT_INDEX_OFFSET(A) (SQUASHFS_FRAGMENT_BYTES(A) % SQUASHFS_METADATA_SIZE)
125 #define SQUASHFS_FRAGMENT_INDEXES(A) ((SQUASHFS_FRAGMENT_BYTES(A) + SQUASHFS_METADATA_SIZE - 1) / SQUASHFS_METADATA_SIZE)
126 #define SQUASHFS_FRAGMENT_INDEX_BYTES(A) (SQUASHFS_FRAGMENT_INDEXES(A) * sizeof(squashfs_fragment_index))
128 /* cached data constants for filesystem */
129 #define SQUASHFS_CACHED_BLKS 8
131 #define SQUASHFS_MAX_FILE_SIZE_LOG 32
132 #define SQUASHFS_MAX_FILE_SIZE ((long long) 1 << (SQUASHFS_MAX_FILE_SIZE_LOG - 1))
134 #define SQUASHFS_MARKER_BYTE 0xff
138 * definitions for structures on disk
141 typedef unsigned int squashfs_block
;
142 typedef long long squashfs_inode
;
144 typedef unsigned int squashfs_uid
;
146 typedef struct squashfs_super_block
{
147 #ifdef CONFIG_SQUASHFS_CRAMFS_MAGIC
148 unsigned char cramfs_magic
[4];
149 unsigned char cramfs_size
[4];
151 unsigned int s_magic
;
153 unsigned int bytes_used
;
154 unsigned int uid_start
;
155 unsigned int guid_start
;
156 unsigned int inode_table_start
;
157 unsigned int directory_table_start
;
158 unsigned int s_major
:16;
159 unsigned int s_minor
:16;
160 unsigned int block_size_1
:16;
161 unsigned int block_log
:16;
162 unsigned int flags
:8;
163 unsigned int no_uids
:8;
164 unsigned int no_guids
:8;
165 unsigned int mkfs_time
/* time of filesystem creation */;
166 squashfs_inode root_inode
;
167 unsigned int block_size
;
168 unsigned int fragments
;
169 unsigned int fragment_table_start
;
170 } __attribute__ ((packed
)) squashfs_super_block
;
173 unsigned int index
:27;
174 unsigned int start_block
:29;
176 unsigned char name
[0];
177 } __attribute__ ((packed
)) squashfs_dir_index
;
180 unsigned int inode_type
:4;
181 unsigned int mode
:12; /* protection */
182 unsigned int uid
:8; /* index into uid table */
183 unsigned int guid
:8; /* index into guid table */
184 } __attribute__ ((packed
)) squashfs_base_inode_header
;
186 typedef squashfs_base_inode_header squashfs_ipc_inode_header
;
189 unsigned int inode_type
:4;
190 unsigned int mode
:12; /* protection */
191 unsigned int uid
:8; /* index into uid table */
192 unsigned int guid
:8; /* index into guid table */
194 } __attribute__ ((packed
)) squashfs_dev_inode_header
;
197 unsigned int inode_type
:4;
198 unsigned int mode
:12; /* protection */
199 unsigned int uid
:8; /* index into uid table */
200 unsigned int guid
:8; /* index into guid table */
201 unsigned short symlink_size
;
203 } __attribute__ ((packed
)) squashfs_symlink_inode_header
;
206 unsigned int inode_type
:4;
207 unsigned int mode
:12; /* protection */
208 unsigned int uid
:8; /* index into uid table */
209 unsigned int guid
:8; /* index into guid table */
211 squashfs_block start_block
;
212 unsigned int fragment
;
214 unsigned int file_size
:SQUASHFS_MAX_FILE_SIZE_LOG
;
215 unsigned short block_list
[0];
216 } __attribute__ ((packed
)) squashfs_reg_inode_header
;
219 unsigned int inode_type
:4;
220 unsigned int mode
:12; /* protection */
221 unsigned int uid
:8; /* index into uid table */
222 unsigned int guid
:8; /* index into guid table */
223 unsigned int file_size
:19;
224 unsigned int offset
:13;
226 unsigned int start_block
:24;
227 } __attribute__ ((packed
)) squashfs_dir_inode_header
;
230 unsigned int inode_type
:4;
231 unsigned int mode
:12; /* protection */
232 unsigned int uid
:8; /* index into uid table */
233 unsigned int guid
:8; /* index into guid table */
234 unsigned int file_size
:27;
235 unsigned int offset
:13;
237 unsigned int start_block
:24;
238 unsigned int i_count
:16;
239 squashfs_dir_index index
[0];
240 } __attribute__ ((packed
)) squashfs_ldir_inode_header
;
243 squashfs_base_inode_header base
;
244 squashfs_dev_inode_header dev
;
245 squashfs_symlink_inode_header symlink
;
246 squashfs_reg_inode_header reg
;
247 squashfs_dir_inode_header dir
;
248 squashfs_ldir_inode_header ldir
;
249 squashfs_ipc_inode_header ipc
;
250 } squashfs_inode_header
;
253 unsigned int offset
:13;
257 } __attribute__ ((packed
)) squashfs_dir_entry
;
260 unsigned int count
:8;
261 unsigned int start_block
:24;
262 } __attribute__ ((packed
)) squashfs_dir_header
;
265 unsigned int start_block
;
267 } __attribute__ ((packed
)) squashfs_fragment_entry
;
269 extern int squashfs_uncompress_block(void *d
, int dstlen
, void *s
, int srclen
);
270 extern int squashfs_uncompress_init(void);
271 extern int squashfs_uncompress_exit(void);
274 * macros to convert each packed bitfield structure from little endian to big
275 * endian and vice versa. These are needed when creating or using a filesystem on a
276 * machine with different byte ordering to the target architecture.
280 #define SQUASHFS_SWAP_SUPER_BLOCK(s, d) {\
281 SQUASHFS_MEMSET(s, d, sizeof(squashfs_super_block));\
282 SQUASHFS_SWAP((s)->s_magic, d, 0, 32);\
283 SQUASHFS_SWAP((s)->inodes, d, 32, 32);\
284 SQUASHFS_SWAP((s)->bytes_used, d, 64, 32);\
285 SQUASHFS_SWAP((s)->uid_start, d, 96, 32);\
286 SQUASHFS_SWAP((s)->guid_start, d, 128, 32);\
287 SQUASHFS_SWAP((s)->inode_table_start, d, 160, 32);\
288 SQUASHFS_SWAP((s)->directory_table_start, d, 192, 32);\
289 SQUASHFS_SWAP((s)->s_major, d, 224, 16);\
290 SQUASHFS_SWAP((s)->s_minor, d, 240, 16);\
291 SQUASHFS_SWAP((s)->block_size_1, d, 256, 16);\
292 SQUASHFS_SWAP((s)->block_log, d, 272, 16);\
293 SQUASHFS_SWAP((s)->flags, d, 288, 8);\
294 SQUASHFS_SWAP((s)->no_uids, d, 296, 8);\
295 SQUASHFS_SWAP((s)->no_guids, d, 304, 8);\
296 SQUASHFS_SWAP((s)->mkfs_time, d, 312, 32);\
297 SQUASHFS_SWAP((s)->root_inode, d, 344, 64);\
298 SQUASHFS_SWAP((s)->block_size, d, 408, 32);\
299 SQUASHFS_SWAP((s)->fragments, d, 440, 32);\
300 SQUASHFS_SWAP((s)->fragment_table_start, d, 472, 32);\
303 #define SQUASHFS_SWAP_BASE_INODE_HEADER(s, d, n) {\
304 SQUASHFS_MEMSET(s, d, n);\
305 SQUASHFS_SWAP((s)->inode_type, d, 0, 4);\
306 SQUASHFS_SWAP((s)->mode, d, 4, 12);\
307 SQUASHFS_SWAP((s)->uid, d, 16, 8);\
308 SQUASHFS_SWAP((s)->guid, d, 24, 8);\
311 #define SQUASHFS_SWAP_IPC_INODE_HEADER(s, d) SQUASHFS_SWAP_BASE_INODE_HEADER(s, d, sizeof(squashfs_ipc_inode_header))
313 #define SQUASHFS_SWAP_DEV_INODE_HEADER(s, d) {\
314 SQUASHFS_SWAP_BASE_INODE_HEADER(s, d, sizeof(squashfs_dev_inode_header));\
315 SQUASHFS_SWAP((s)->rdev, d, 32, 16);\
318 #define SQUASHFS_SWAP_SYMLINK_INODE_HEADER(s, d) {\
319 SQUASHFS_SWAP_BASE_INODE_HEADER(s, d, sizeof(squashfs_symlink_inode_header));\
320 SQUASHFS_SWAP((s)->symlink_size, d, 32, 16);\
323 #define SQUASHFS_SWAP_REG_INODE_HEADER(s, d) {\
324 SQUASHFS_SWAP_BASE_INODE_HEADER(s, d, sizeof(squashfs_reg_inode_header));\
325 SQUASHFS_SWAP((s)->mtime, d, 32, 32);\
326 SQUASHFS_SWAP((s)->start_block, d, 64, 32);\
327 SQUASHFS_SWAP((s)->fragment, d, 96, 32);\
328 SQUASHFS_SWAP((s)->offset, d, 128, 32);\
329 SQUASHFS_SWAP((s)->file_size, d, 160, SQUASHFS_MAX_FILE_SIZE_LOG);\
332 #define SQUASHFS_SWAP_DIR_INODE_HEADER(s, d) {\
333 SQUASHFS_SWAP_BASE_INODE_HEADER(s, d, sizeof(squashfs_dir_inode_header));\
334 SQUASHFS_SWAP((s)->file_size, d, 32, 19);\
335 SQUASHFS_SWAP((s)->offset, d, 51, 13);\
336 SQUASHFS_SWAP((s)->mtime, d, 64, 32);\
337 SQUASHFS_SWAP((s)->start_block, d, 96, 24);\
340 #define SQUASHFS_SWAP_LDIR_INODE_HEADER(s, d) {\
341 SQUASHFS_SWAP_BASE_INODE_HEADER(s, d, sizeof(squashfs_ldir_inode_header));\
342 SQUASHFS_SWAP((s)->file_size, d, 32, 27);\
343 SQUASHFS_SWAP((s)->offset, d, 59, 13);\
344 SQUASHFS_SWAP((s)->mtime, d, 72, 32);\
345 SQUASHFS_SWAP((s)->start_block, d, 104, 24);\
346 SQUASHFS_SWAP((s)->i_count, d, 128, 16);\
349 #define SQUASHFS_SWAP_DIR_INDEX(s, d) {\
350 SQUASHFS_MEMSET(s, d, sizeof(squashfs_dir_index));\
351 SQUASHFS_SWAP((s)->index, d, 0, 27);\
352 SQUASHFS_SWAP((s)->start_block, d, 27, 29);\
353 SQUASHFS_SWAP((s)->size, d, 56, 8);\
356 #define SQUASHFS_SWAP_DIR_HEADER(s, d) {\
357 SQUASHFS_MEMSET(s, d, sizeof(squashfs_dir_header));\
358 SQUASHFS_SWAP((s)->count, d, 0, 8);\
359 SQUASHFS_SWAP((s)->start_block, d, 8, 24);\
362 #define SQUASHFS_SWAP_DIR_ENTRY(s, d) {\
363 SQUASHFS_MEMSET(s, d, sizeof(squashfs_dir_entry));\
364 SQUASHFS_SWAP((s)->offset, d, 0, 13);\
365 SQUASHFS_SWAP((s)->type, d, 13, 3);\
366 SQUASHFS_SWAP((s)->size, d, 16, 8);\
369 #define SQUASHFS_SWAP_FRAGMENT_ENTRY(s, d) {\
370 SQUASHFS_MEMSET(s, d, sizeof(squashfs_fragment_entry));\
371 SQUASHFS_SWAP((s)->start_block, d, 0, 32);\
372 SQUASHFS_SWAP((s)->size, d, 32, 32);\
375 #define SQUASHFS_SWAP_SHORTS(s, d, n) {\
378 SQUASHFS_MEMSET(s, d, n * 2);\
379 for(entry = 0, bit_position = 0; entry < n; entry++, bit_position += 16)\
380 SQUASHFS_SWAP(s[entry], d, bit_position, 16);\
383 #define SQUASHFS_SWAP_INTS(s, d, n) {\
386 SQUASHFS_MEMSET(s, d, n * 4);\
387 for(entry = 0, bit_position = 0; entry < n; entry++, bit_position += 32)\
388 SQUASHFS_SWAP(s[entry], d, bit_position, 32);\
391 #define SQUASHFS_SWAP_DATA(s, d, n, bits) {\
394 SQUASHFS_MEMSET(s, d, n * bits / 8);\
395 for(entry = 0, bit_position = 0; entry < n; entry++, bit_position += bits)\
396 SQUASHFS_SWAP(s[entry], d, bit_position, bits);\
399 #define SQUASHFS_SWAP_FRAGMENT_INDEXES(s, d, n) SQUASHFS_SWAP_INTS(s, d, n)
401 #ifdef SQUASHFS_1_0_COMPATIBILITY
403 unsigned int inode_type
:4;
404 unsigned int mode
:12; /* protection */
405 unsigned int uid
:4; /* index into uid table */
406 unsigned int guid
:4; /* index into guid table */
407 } __attribute__ ((packed
)) squashfs_base_inode_header_1
;
410 unsigned int inode_type
:4;
411 unsigned int mode
:12; /* protection */
412 unsigned int uid
:4; /* index into uid table */
413 unsigned int guid
:4; /* index into guid table */
415 unsigned int offset
:4;
416 } __attribute__ ((packed
)) squashfs_ipc_inode_header_1
;
419 unsigned int inode_type
:4;
420 unsigned int mode
:12; /* protection */
421 unsigned int uid
:4; /* index into uid table */
422 unsigned int guid
:4; /* index into guid table */
424 } __attribute__ ((packed
)) squashfs_dev_inode_header_1
;
427 unsigned int inode_type
:4;
428 unsigned int mode
:12; /* protection */
429 unsigned int uid
:4; /* index into uid table */
430 unsigned int guid
:4; /* index into guid table */
431 unsigned short symlink_size
;
433 } __attribute__ ((packed
)) squashfs_symlink_inode_header_1
;
436 unsigned int inode_type
:4;
437 unsigned int mode
:12; /* protection */
438 unsigned int uid
:4; /* index into uid table */
439 unsigned int guid
:4; /* index into guid table */
441 squashfs_block start_block
;
442 unsigned int file_size
:SQUASHFS_MAX_FILE_SIZE_LOG
;
443 unsigned short block_list
[0];
444 } __attribute__ ((packed
)) squashfs_reg_inode_header_1
;
447 unsigned int inode_type
:4;
448 unsigned int mode
:12; /* protection */
449 unsigned int uid
:4; /* index into uid table */
450 unsigned int guid
:4; /* index into guid table */
451 unsigned int file_size
:19;
452 unsigned int offset
:13;
454 unsigned int start_block
:24;
455 } __attribute__ ((packed
)) squashfs_dir_inode_header_1
;
457 #define SQUASHFS_SWAP_BASE_INODE_HEADER_1(s, d, n) {\
458 SQUASHFS_MEMSET(s, d, n);\
459 SQUASHFS_SWAP((s)->inode_type, d, 0, 4);\
460 SQUASHFS_SWAP((s)->mode, d, 4, 12);\
461 SQUASHFS_SWAP((s)->uid, d, 16, 4);\
462 SQUASHFS_SWAP((s)->guid, d, 20, 4);\
465 #define SQUASHFS_SWAP_IPC_INODE_HEADER_1(s, d) {\
466 SQUASHFS_SWAP_BASE_INODE_HEADER_1(s, d, sizeof(squashfs_ipc_inode_header_1));\
467 SQUASHFS_SWAP((s)->type, d, 24, 4);\
468 SQUASHFS_SWAP((s)->offset, d, 28, 4);\
471 #define SQUASHFS_SWAP_DEV_INODE_HEADER_1(s, d) {\
472 SQUASHFS_SWAP_BASE_INODE_HEADER_1(s, d, sizeof(squashfs_dev_inode_header_1));\
473 SQUASHFS_SWAP((s)->rdev, d, 24, 16);\
476 #define SQUASHFS_SWAP_SYMLINK_INODE_HEADER_1(s, d) {\
477 SQUASHFS_SWAP_BASE_INODE_HEADER(s, d, sizeof(squashfs_symlink_inode_header_1));\
478 SQUASHFS_SWAP((s)->symlink_size, d, 24, 16);\
481 #define SQUASHFS_SWAP_REG_INODE_HEADER_1(s, d) {\
482 SQUASHFS_SWAP_BASE_INODE_HEADER(s, d, sizeof(squashfs_reg_inode_header_1));\
483 SQUASHFS_SWAP((s)->mtime, d, 24, 32);\
484 SQUASHFS_SWAP((s)->start_block, d, 56, 32);\
485 SQUASHFS_SWAP((s)->file_size, d, 88, SQUASHFS_MAX_FILE_SIZE_LOG);\
488 #define SQUASHFS_SWAP_DIR_INODE_HEADER_1(s, d) {\
489 SQUASHFS_SWAP_BASE_INODE_HEADER(s, d, sizeof(squashfs_dir_inode_header_1));\
490 SQUASHFS_SWAP((s)->file_size, d, 24, 19);\
491 SQUASHFS_SWAP((s)->offset, d, 43, 13);\
492 SQUASHFS_SWAP((s)->mtime, d, 56, 32);\
493 SQUASHFS_SWAP((s)->start_block, d, 88, 24);\
499 * macros used to swap each structure entry, taking into account
500 * bitfields and different bitfield placing conventions on differing architectures
502 #include <asm/byteorder.h>
504 /* convert from little endian to big endian */
505 #define SQUASHFS_SWAP(value, p, pos, tbits) _SQUASHFS_SWAP(value, p, pos, tbits, b_pos)
507 /* convert from big endian to little endian */
508 #define SQUASHFS_SWAP(value, p, pos, tbits) _SQUASHFS_SWAP(value, p, pos, tbits, 64 - tbits - b_pos)
511 #define _SQUASHFS_SWAP(value, p, pos, tbits, SHIFT) {\
513 int b_pos = pos % 8;\
514 unsigned long long val = 0;\
515 unsigned char *s = (unsigned char *)p + (pos / 8);\
516 unsigned char *d = ((unsigned char *) &val) + 7;\
517 for(bits = 0; bits < (tbits + b_pos); bits += 8) \
519 value = (val >> (SHIFT))/* & ((1 << tbits) - 1)*/;\
521 #define SQUASHFS_MEMSET(s, d, n) memset(s, 0, n);