1
diff -Nru klibc-1.1.1/utils/fstype.c klibc-squashfs/utils/fstype.c
2
--- klibc-1.1.1/utils/fstype.c 2005-09-06 22:49:34.000000000 +0200
3
+++ klibc-squashfs/utils/fstype.c 2005-12-16 14:26:34.000000000 +0100
8
+#include "squashfs_fs.h"
11
* reiserfs_fs.h is too sick to include directly.
16
+static int squashfs_image(const unsigned char *buf, unsigned long *blocks)
18
+ const struct squashfs_super_block *sb =
19
+ (const struct squashfs_super_block *)buf;
21
+ if (sb->s_magic == SQUASHFS_MAGIC ||
22
+ sb->s_magic == SQUASHFS_MAGIC_SWAP) {
23
+ *blocks = 0; /* We don't know the size of squashfs images */
33
{ 0, "cramfs", cramfs_image },
34
{ 0, "romfs", romfs_image },
35
{ 0, "xfs", xfs_image },
36
+ { 0, "squashfs", squashfs_image },
37
{ 1, "minix", minix_image },
38
{ 1, "ext3", ext3_image },
39
{ 1, "ext2", ext2_image },
40
diff -Nru klibc-1.1.1/utils/squashfs_fs.h klibc-squashfs/utils/squashfs_fs.h
41
--- klibc-1.1.1/utils/squashfs_fs.h 1970-01-01 01:00:00.000000000 +0100
42
+++ klibc-squashfs/utils/squashfs_fs.h 2005-12-15 21:22:44.000000000 +0100
50
+ * Copyright (c) 2002, 2003, 2004, 2005
51
+ * Phillip Lougher <phillip@lougher.demon.co.uk>
53
+ * This program is free software; you can redistribute it and/or
54
+ * modify it under the terms of the GNU General Public License
55
+ * as published by the Free Software Foundation; either version 2,
56
+ * or (at your option) any later version.
58
+ * This program is distributed in the hope that it will be useful,
59
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
60
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
61
+ * GNU General Public License for more details.
63
+ * You should have received a copy of the GNU General Public License
64
+ * along with this program; if not, write to the Free Software
65
+ * Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
70
+#define SQUASHFS_MAJOR 2
71
+#define SQUASHFS_MINOR 1
72
+#define SQUASHFS_MAGIC 0x73717368
73
+#define SQUASHFS_MAGIC_SWAP 0x68737173
74
+#define SQUASHFS_START 0
76
+/* size of metadata (inode and directory) blocks */
77
+#define SQUASHFS_METADATA_SIZE 8192
78
+#define SQUASHFS_METADATA_LOG 13
80
+/* default size of data blocks */
81
+#define SQUASHFS_FILE_SIZE 65536
82
+#define SQUASHFS_FILE_LOG 16
84
+#define SQUASHFS_FILE_MAX_SIZE 65536
86
+/* Max number of uids and gids */
87
+#define SQUASHFS_UIDS 256
88
+#define SQUASHFS_GUIDS 255
90
+/* Max length of filename (not 255) */
91
+#define SQUASHFS_NAME_LEN 256
93
+#define SQUASHFS_INVALID ((long long) 0xffffffffffff)
94
+#define SQUASHFS_INVALID_BLK ((long long) 0xffffffff)
95
+#define SQUASHFS_USED_BLK ((long long) 0xfffffffe)
97
+/* Filesystem flags */
98
+#define SQUASHFS_NOI 0
99
+#define SQUASHFS_NOD 1
100
+#define SQUASHFS_CHECK 2
101
+#define SQUASHFS_NOF 3
102
+#define SQUASHFS_NO_FRAG 4
103
+#define SQUASHFS_ALWAYS_FRAG 5
104
+#define SQUASHFS_DUPLICATE 6
106
+#define SQUASHFS_BIT(flag, bit) ((flag >> bit) & 1)
108
+#define SQUASHFS_UNCOMPRESSED_INODES(flags) SQUASHFS_BIT(flags, \
111
+#define SQUASHFS_UNCOMPRESSED_DATA(flags) SQUASHFS_BIT(flags, \
114
+#define SQUASHFS_UNCOMPRESSED_FRAGMENTS(flags) SQUASHFS_BIT(flags, \
117
+#define SQUASHFS_NO_FRAGMENTS(flags) SQUASHFS_BIT(flags, \
120
+#define SQUASHFS_ALWAYS_FRAGMENTS(flags) SQUASHFS_BIT(flags, \
121
+ SQUASHFS_ALWAYS_FRAG)
123
+#define SQUASHFS_DUPLICATES(flags) SQUASHFS_BIT(flags, \
124
+ SQUASHFS_DUPLICATE)
126
+#define SQUASHFS_CHECK_DATA(flags) SQUASHFS_BIT(flags, \
129
+#define SQUASHFS_MKFLAGS(noi, nod, check_data, nof, no_frag, always_frag, \
130
+ duplicate_checking) (noi | (nod << 1) | (check_data << 2) \
131
+ | (nof << 3) | (no_frag << 4) | (always_frag << 5) | \
132
+ (duplicate_checking << 6))
134
+/* Max number of types and file types */
135
+#define SQUASHFS_DIR_TYPE 1
136
+#define SQUASHFS_FILE_TYPE 2
137
+#define SQUASHFS_SYMLINK_TYPE 3
138
+#define SQUASHFS_BLKDEV_TYPE 4
139
+#define SQUASHFS_CHRDEV_TYPE 5
140
+#define SQUASHFS_FIFO_TYPE 6
141
+#define SQUASHFS_SOCKET_TYPE 7
142
+#define SQUASHFS_LDIR_TYPE 8
144
+/* 1.0 filesystem type definitions */
145
+#define SQUASHFS_TYPES 5
146
+#define SQUASHFS_IPC_TYPE 0
148
+/* Flag whether block is compressed or uncompressed, bit is set if block is
150
+#define SQUASHFS_COMPRESSED_BIT (1 << 15)
152
+#define SQUASHFS_COMPRESSED_SIZE(B) (((B) & ~SQUASHFS_COMPRESSED_BIT) ? \
153
+ (B) & ~SQUASHFS_COMPRESSED_BIT : SQUASHFS_COMPRESSED_BIT)
155
+#define SQUASHFS_COMPRESSED(B) (!((B) & SQUASHFS_COMPRESSED_BIT))
157
+#define SQUASHFS_COMPRESSED_BIT_BLOCK (1 << 24)
159
+#define SQUASHFS_COMPRESSED_SIZE_BLOCK(B) (((B) & \
160
+ ~SQUASHFS_COMPRESSED_BIT_BLOCK) ? (B) & \
161
+ ~SQUASHFS_COMPRESSED_BIT_BLOCK : SQUASHFS_COMPRESSED_BIT_BLOCK)
163
+#define SQUASHFS_COMPRESSED_BLOCK(B) (!((B) & SQUASHFS_COMPRESSED_BIT_BLOCK))
166
+ * Inode number ops. Inodes consist of a compressed block number, and an
167
+ * uncompressed offset within that block
169
+#define SQUASHFS_INODE_BLK(a) ((unsigned int) ((a) >> 16))
171
+#define SQUASHFS_INODE_OFFSET(a) ((unsigned int) ((a) & 0xffff))
173
+#define SQUASHFS_MKINODE(A, B) ((squashfs_inode_t)(((squashfs_inode_t) (A)\
176
+/* Compute 32 bit VFS inode number from squashfs inode number */
177
+#define SQUASHFS_MK_VFS_INODE(a, b) ((unsigned int) (((a) << 8) + \
180
+/* Translate between VFS mode and squashfs mode */
181
+#define SQUASHFS_MODE(a) ((a) & 0xfff)
183
+/* fragment and fragment table defines */
184
+#define SQUASHFS_FRAGMENT_BYTES(A) (A * sizeof(struct squashfs_fragment_entry))
186
+#define SQUASHFS_FRAGMENT_INDEX(A) (SQUASHFS_FRAGMENT_BYTES(A) / \
187
+ SQUASHFS_METADATA_SIZE)
189
+#define SQUASHFS_FRAGMENT_INDEX_OFFSET(A) (SQUASHFS_FRAGMENT_BYTES(A) % \
190
+ SQUASHFS_METADATA_SIZE)
192
+#define SQUASHFS_FRAGMENT_INDEXES(A) ((SQUASHFS_FRAGMENT_BYTES(A) + \
193
+ SQUASHFS_METADATA_SIZE - 1) / \
194
+ SQUASHFS_METADATA_SIZE)
196
+#define SQUASHFS_FRAGMENT_INDEX_BYTES(A) (SQUASHFS_FRAGMENT_INDEXES(A) *\
197
+ sizeof(unsigned int))
199
+#define SQUASHFS_CACHED_FRAGMENTS 3
201
+/* cached data constants for filesystem */
202
+#define SQUASHFS_CACHED_BLKS 8
204
+#define SQUASHFS_MAX_FILE_SIZE_LOG 32
206
+#define SQUASHFS_MAX_FILE_SIZE ((long long) 1 << \
207
+ (SQUASHFS_MAX_FILE_SIZE_LOG - 1))
209
+#define SQUASHFS_MARKER_BYTE 0xff
213
+ * definitions for structures on disk
216
+typedef unsigned int squashfs_block_t;
217
+typedef long long squashfs_inode_t;
219
+struct squashfs_super_block {
220
+ unsigned int s_magic;
221
+ unsigned int inodes;
222
+ unsigned int bytes_used;
223
+ unsigned int uid_start;
224
+ unsigned int guid_start;
225
+ unsigned int inode_table_start;
226
+ unsigned int directory_table_start;
227
+ unsigned int s_major:16;
228
+ unsigned int s_minor:16;
229
+ unsigned int block_size_1:16;
230
+ unsigned int block_log:16;
231
+ unsigned int flags:8;
232
+ unsigned int no_uids:8;
233
+ unsigned int no_guids:8;
234
+ unsigned int mkfs_time /* time of filesystem creation */;
235
+ squashfs_inode_t root_inode;
236
+ unsigned int block_size;
237
+ unsigned int fragments;
238
+ unsigned int fragment_table_start;
239
+} __attribute__ ((packed));
241
+struct squashfs_dir_index {
242
+ unsigned int index:27;
243
+ unsigned int start_block:29;
244
+ unsigned char size;
245
+ unsigned char name[0];
246
+} __attribute__ ((packed));
248
+struct squashfs_base_inode_header {
249
+ unsigned int inode_type:4;
250
+ unsigned int mode:12; /* protection */
251
+ unsigned int uid:8; /* index into uid table */
252
+ unsigned int guid:8; /* index into guid table */
253
+} __attribute__ ((packed));
255
+struct squashfs_ipc_inode_header {
256
+ unsigned int inode_type:4;
257
+ unsigned int mode:12; /* protection */
258
+ unsigned int uid:8; /* index into uid table */
259
+ unsigned int guid:8; /* index into guid table */
260
+} __attribute__ ((packed));
262
+struct squashfs_dev_inode_header {
263
+ unsigned int inode_type:4;
264
+ unsigned int mode:12; /* protection */
265
+ unsigned int uid:8; /* index into uid table */
266
+ unsigned int guid:8; /* index into guid table */
267
+ unsigned short rdev;
268
+} __attribute__ ((packed));
270
+struct squashfs_symlink_inode_header {
271
+ unsigned int inode_type:4;
272
+ unsigned int mode:12; /* protection */
273
+ unsigned int uid:8; /* index into uid table */
274
+ unsigned int guid:8; /* index into guid table */
275
+ unsigned short symlink_size;
277
+} __attribute__ ((packed));
279
+struct squashfs_reg_inode_header {
280
+ unsigned int inode_type:4;
281
+ unsigned int mode:12; /* protection */
282
+ unsigned int uid:8; /* index into uid table */
283
+ unsigned int guid:8; /* index into guid table */
284
+ unsigned int mtime;
285
+ squashfs_block_t start_block;
286
+ unsigned int fragment;
287
+ unsigned int offset;
288
+ unsigned int file_size:SQUASHFS_MAX_FILE_SIZE_LOG;
289
+ unsigned short block_list[0];
290
+} __attribute__ ((packed));
292
+struct squashfs_dir_inode_header {
293
+ unsigned int inode_type:4;
294
+ unsigned int mode:12; /* protection */
295
+ unsigned int uid:8; /* index into uid table */
296
+ unsigned int guid:8; /* index into guid table */
297
+ unsigned int file_size:19;
298
+ unsigned int offset:13;
299
+ unsigned int mtime;
300
+ unsigned int start_block:24;
301
+} __attribute__ ((packed));
303
+struct squashfs_ldir_inode_header {
304
+ unsigned int inode_type:4;
305
+ unsigned int mode:12; /* protection */
306
+ unsigned int uid:8; /* index into uid table */
307
+ unsigned int guid:8; /* index into guid table */
308
+ unsigned int file_size:27;
309
+ unsigned int offset:13;
310
+ unsigned int mtime;
311
+ unsigned int start_block:24;
312
+ unsigned int i_count:16;
313
+ struct squashfs_dir_index index[0];
314
+} __attribute__ ((packed));
316
+union squashfs_inode_header {
317
+ struct squashfs_base_inode_header base;
318
+ struct squashfs_dev_inode_header dev;
319
+ struct squashfs_symlink_inode_header symlink;
320
+ struct squashfs_reg_inode_header reg;
321
+ struct squashfs_dir_inode_header dir;
322
+ struct squashfs_ldir_inode_header ldir;
323
+ struct squashfs_ipc_inode_header ipc;
326
+struct squashfs_dir_entry {
327
+ unsigned int offset:13;
328
+ unsigned int type:3;
329
+ unsigned int size:8;
331
+} __attribute__ ((packed));
333
+struct squashfs_dir_header {
334
+ unsigned int count:8;
335
+ unsigned int start_block:24;
336
+} __attribute__ ((packed));
338
+struct squashfs_fragment_entry {
339
+ unsigned int start_block;
341
+} __attribute__ ((packed));
343
+extern int squashfs_uncompress_block(void *d, int dstlen, void *s, int srclen);
344
+extern int squashfs_uncompress_init(void);
345
+extern int squashfs_uncompress_exit(void);
348
+ * macros to convert each packed bitfield structure from little endian to big
349
+ * endian and vice versa. These are needed when creating or using a filesystem
350
+ * on a machine with different byte ordering to the target architecture.
354
+#define SQUASHFS_SWAP_START \
357
+ unsigned long long val;\
361
+#define SQUASHFS_SWAP_SUPER_BLOCK(s, d) {\
362
+ SQUASHFS_SWAP_START\
363
+ SQUASHFS_MEMSET(s, d, sizeof(struct squashfs_super_block));\
364
+ SQUASHFS_SWAP((s)->s_magic, d, 0, 32);\
365
+ SQUASHFS_SWAP((s)->inodes, d, 32, 32);\
366
+ SQUASHFS_SWAP((s)->bytes_used, d, 64, 32);\
367
+ SQUASHFS_SWAP((s)->uid_start, d, 96, 32);\
368
+ SQUASHFS_SWAP((s)->guid_start, d, 128, 32);\
369
+ SQUASHFS_SWAP((s)->inode_table_start, d, 160, 32);\
370
+ SQUASHFS_SWAP((s)->directory_table_start, d, 192, 32);\
371
+ SQUASHFS_SWAP((s)->s_major, d, 224, 16);\
372
+ SQUASHFS_SWAP((s)->s_minor, d, 240, 16);\
373
+ SQUASHFS_SWAP((s)->block_size_1, d, 256, 16);\
374
+ SQUASHFS_SWAP((s)->block_log, d, 272, 16);\
375
+ SQUASHFS_SWAP((s)->flags, d, 288, 8);\
376
+ SQUASHFS_SWAP((s)->no_uids, d, 296, 8);\
377
+ SQUASHFS_SWAP((s)->no_guids, d, 304, 8);\
378
+ SQUASHFS_SWAP((s)->mkfs_time, d, 312, 32);\
379
+ SQUASHFS_SWAP((s)->root_inode, d, 344, 64);\
380
+ SQUASHFS_SWAP((s)->block_size, d, 408, 32);\
381
+ SQUASHFS_SWAP((s)->fragments, d, 440, 32);\
382
+ SQUASHFS_SWAP((s)->fragment_table_start, d, 472, 32);\
385
+#define SQUASHFS_SWAP_BASE_INODE_CORE(s, d, n)\
386
+ SQUASHFS_MEMSET(s, d, n);\
387
+ SQUASHFS_SWAP((s)->inode_type, d, 0, 4);\
388
+ SQUASHFS_SWAP((s)->mode, d, 4, 12);\
389
+ SQUASHFS_SWAP((s)->uid, d, 16, 8);\
390
+ SQUASHFS_SWAP((s)->guid, d, 24, 8);\
392
+#define SQUASHFS_SWAP_BASE_INODE_HEADER(s, d, n) {\
393
+ SQUASHFS_SWAP_START\
394
+ SQUASHFS_SWAP_BASE_INODE_CORE(s, d, n)\
397
+#define SQUASHFS_SWAP_IPC_INODE_HEADER(s, d) \
398
+ SQUASHFS_SWAP_BASE_INODE_HEADER(s, d, sizeof(struct squashfs_ipc_inode_header))
400
+#define SQUASHFS_SWAP_DEV_INODE_HEADER(s, d) {\
401
+ SQUASHFS_SWAP_START\
402
+ SQUASHFS_SWAP_BASE_INODE_CORE(s, d, \
403
+ sizeof(struct squashfs_dev_inode_header)); \
404
+ SQUASHFS_SWAP((s)->rdev, d, 32, 16);\
407
+#define SQUASHFS_SWAP_SYMLINK_INODE_HEADER(s, d) {\
408
+ SQUASHFS_SWAP_START\
409
+ SQUASHFS_SWAP_BASE_INODE_CORE(s, d, \
410
+ sizeof(struct squashfs_symlink_inode_header));\
411
+ SQUASHFS_SWAP((s)->symlink_size, d, 32, 16);\
414
+#define SQUASHFS_SWAP_REG_INODE_HEADER(s, d) {\
415
+ SQUASHFS_SWAP_START\
416
+ SQUASHFS_SWAP_BASE_INODE_CORE(s, d, \
417
+ sizeof(struct squashfs_reg_inode_header));\
418
+ SQUASHFS_SWAP((s)->mtime, d, 32, 32);\
419
+ SQUASHFS_SWAP((s)->start_block, d, 64, 32);\
420
+ SQUASHFS_SWAP((s)->fragment, d, 96, 32);\
421
+ SQUASHFS_SWAP((s)->offset, d, 128, 32);\
422
+ SQUASHFS_SWAP((s)->file_size, d, 160, SQUASHFS_MAX_FILE_SIZE_LOG);\
425
+#define SQUASHFS_SWAP_DIR_INODE_HEADER(s, d) {\
426
+ SQUASHFS_SWAP_START\
427
+ SQUASHFS_SWAP_BASE_INODE_CORE(s, d, \
428
+ sizeof(struct squashfs_dir_inode_header));\
429
+ SQUASHFS_SWAP((s)->file_size, d, 32, 19);\
430
+ SQUASHFS_SWAP((s)->offset, d, 51, 13);\
431
+ SQUASHFS_SWAP((s)->mtime, d, 64, 32);\
432
+ SQUASHFS_SWAP((s)->start_block, d, 96, 24);\
435
+#define SQUASHFS_SWAP_LDIR_INODE_HEADER(s, d) {\
436
+ SQUASHFS_SWAP_START\
437
+ SQUASHFS_SWAP_BASE_INODE_CORE(s, d, \
438
+ sizeof(struct squashfs_ldir_inode_header));\
439
+ SQUASHFS_SWAP((s)->file_size, d, 32, 27);\
440
+ SQUASHFS_SWAP((s)->offset, d, 59, 13);\
441
+ SQUASHFS_SWAP((s)->mtime, d, 72, 32);\
442
+ SQUASHFS_SWAP((s)->start_block, d, 104, 24);\
443
+ SQUASHFS_SWAP((s)->i_count, d, 128, 16);\
446
+#define SQUASHFS_SWAP_DIR_INDEX(s, d) {\
447
+ SQUASHFS_SWAP_START\
448
+ SQUASHFS_MEMSET(s, d, sizeof(struct squashfs_dir_index));\
449
+ SQUASHFS_SWAP((s)->index, d, 0, 27);\
450
+ SQUASHFS_SWAP((s)->start_block, d, 27, 29);\
451
+ SQUASHFS_SWAP((s)->size, d, 56, 8);\
454
+#define SQUASHFS_SWAP_DIR_HEADER(s, d) {\
455
+ SQUASHFS_SWAP_START\
456
+ SQUASHFS_MEMSET(s, d, sizeof(struct squashfs_dir_header));\
457
+ SQUASHFS_SWAP((s)->count, d, 0, 8);\
458
+ SQUASHFS_SWAP((s)->start_block, d, 8, 24);\
461
+#define SQUASHFS_SWAP_DIR_ENTRY(s, d) {\
462
+ SQUASHFS_SWAP_START\
463
+ SQUASHFS_MEMSET(s, d, sizeof(struct squashfs_dir_entry));\
464
+ SQUASHFS_SWAP((s)->offset, d, 0, 13);\
465
+ SQUASHFS_SWAP((s)->type, d, 13, 3);\
466
+ SQUASHFS_SWAP((s)->size, d, 16, 8);\
469
+#define SQUASHFS_SWAP_FRAGMENT_ENTRY(s, d) {\
470
+ SQUASHFS_SWAP_START\
471
+ SQUASHFS_MEMSET(s, d, sizeof(struct squashfs_fragment_entry));\
472
+ SQUASHFS_SWAP((s)->start_block, d, 0, 32);\
473
+ SQUASHFS_SWAP((s)->size, d, 32, 32);\
476
+#define SQUASHFS_SWAP_SHORTS(s, d, n) {\
479
+ SQUASHFS_SWAP_START\
480
+ SQUASHFS_MEMSET(s, d, n * 2);\
481
+ for(entry = 0, bit_position = 0; entry < n; entry++, bit_position += \
483
+ SQUASHFS_SWAP(s[entry], d, bit_position, 16);\
486
+#define SQUASHFS_SWAP_INTS(s, d, n) {\
489
+ SQUASHFS_SWAP_START\
490
+ SQUASHFS_MEMSET(s, d, n * 4);\
491
+ for(entry = 0, bit_position = 0; entry < n; entry++, bit_position += \
493
+ SQUASHFS_SWAP(s[entry], d, bit_position, 32);\
496
+#define SQUASHFS_SWAP_DATA(s, d, n, bits) {\
499
+ SQUASHFS_SWAP_START\
500
+ SQUASHFS_MEMSET(s, d, n * bits / 8);\
501
+ for(entry = 0, bit_position = 0; entry < n; entry++, bit_position += \
503
+ SQUASHFS_SWAP(s[entry], d, bit_position, bits);\
506
+#define SQUASHFS_SWAP_FRAGMENT_INDEXES(s, d, n) SQUASHFS_SWAP_INTS(s, d, n)
508
+#ifdef CONFIG_SQUASHFS_1_0_COMPATIBILITY
510
+struct squashfs_base_inode_header_1 {
511
+ unsigned int inode_type:4;
512
+ unsigned int mode:12; /* protection */
513
+ unsigned int uid:4; /* index into uid table */
514
+ unsigned int guid:4; /* index into guid table */
515
+} __attribute__ ((packed));
517
+struct squashfs_ipc_inode_header_1 {
518
+ unsigned int inode_type:4;
519
+ unsigned int mode:12; /* protection */
520
+ unsigned int uid:4; /* index into uid table */
521
+ unsigned int guid:4; /* index into guid table */
522
+ unsigned int type:4;
523
+ unsigned int offset:4;
524
+} __attribute__ ((packed));
526
+struct squashfs_dev_inode_header_1 {
527
+ unsigned int inode_type:4;
528
+ unsigned int mode:12; /* protection */
529
+ unsigned int uid:4; /* index into uid table */
530
+ unsigned int guid:4; /* index into guid table */
531
+ unsigned short rdev;
532
+} __attribute__ ((packed));
534
+struct squashfs_symlink_inode_header_1 {
535
+ unsigned int inode_type:4;
536
+ unsigned int mode:12; /* protection */
537
+ unsigned int uid:4; /* index into uid table */
538
+ unsigned int guid:4; /* index into guid table */
539
+ unsigned short symlink_size;
541
+} __attribute__ ((packed));
543
+struct squashfs_reg_inode_header_1 {
544
+ unsigned int inode_type:4;
545
+ unsigned int mode:12; /* protection */
546
+ unsigned int uid:4; /* index into uid table */
547
+ unsigned int guid:4; /* index into guid table */
548
+ unsigned int mtime;
549
+ squashfs_block_t start_block;
550
+ unsigned int file_size:SQUASHFS_MAX_FILE_SIZE_LOG;
551
+ unsigned short block_list[0];
552
+} __attribute__ ((packed));
554
+struct squashfs_dir_inode_header_1 {
555
+ unsigned int inode_type:4;
556
+ unsigned int mode:12; /* protection */
557
+ unsigned int uid:4; /* index into uid table */
558
+ unsigned int guid:4; /* index into guid table */
559
+ unsigned int file_size:19;
560
+ unsigned int offset:13;
561
+ unsigned int mtime;
562
+ unsigned int start_block:24;
563
+} __attribute__ ((packed));
565
+#define SQUASHFS_SWAP_BASE_INODE_CORE_1(s, d, n) \
566
+ SQUASHFS_MEMSET(s, d, n);\
567
+ SQUASHFS_SWAP((s)->inode_type, d, 0, 4);\
568
+ SQUASHFS_SWAP((s)->mode, d, 4, 12);\
569
+ SQUASHFS_SWAP((s)->uid, d, 16, 4);\
570
+ SQUASHFS_SWAP((s)->guid, d, 20, 4);
572
+#define SQUASHFS_SWAP_BASE_INODE_HEADER_1(s, d, n) {\
573
+ SQUASHFS_SWAP_START\
574
+ SQUASHFS_SWAP_BASE_INODE_CORE_1(s, d, n)\
577
+#define SQUASHFS_SWAP_IPC_INODE_HEADER_1(s, d) {\
578
+ SQUASHFS_SWAP_START\
579
+ SQUASHFS_SWAP_BASE_INODE_CORE_1(s, d, \
580
+ sizeof(struct squashfs_ipc_inode_header_1));\
581
+ SQUASHFS_SWAP((s)->type, d, 24, 4);\
582
+ SQUASHFS_SWAP((s)->offset, d, 28, 4);\
585
+#define SQUASHFS_SWAP_DEV_INODE_HEADER_1(s, d) {\
586
+ SQUASHFS_SWAP_START\
587
+ SQUASHFS_SWAP_BASE_INODE_CORE_1(s, d, \
588
+ sizeof(struct squashfs_dev_inode_header_1));\
589
+ SQUASHFS_SWAP((s)->rdev, d, 24, 16);\
592
+#define SQUASHFS_SWAP_SYMLINK_INODE_HEADER_1(s, d) {\
593
+ SQUASHFS_SWAP_START\
594
+ SQUASHFS_SWAP_BASE_INODE_CORE(s, d, \
595
+ sizeof(struct squashfs_symlink_inode_header_1));\
596
+ SQUASHFS_SWAP((s)->symlink_size, d, 24, 16);\
599
+#define SQUASHFS_SWAP_REG_INODE_HEADER_1(s, d) {\
600
+ SQUASHFS_SWAP_START\
601
+ SQUASHFS_SWAP_BASE_INODE_CORE(s, d, \
602
+ sizeof(struct squashfs_reg_inode_header_1));\
603
+ SQUASHFS_SWAP((s)->mtime, d, 24, 32);\
604
+ SQUASHFS_SWAP((s)->start_block, d, 56, 32);\
605
+ SQUASHFS_SWAP((s)->file_size, d, 88, SQUASHFS_MAX_FILE_SIZE_LOG);\
608
+#define SQUASHFS_SWAP_DIR_INODE_HEADER_1(s, d) {\
609
+ SQUASHFS_SWAP_START\
610
+ SQUASHFS_SWAP_BASE_INODE_CORE(s, d, \
611
+ sizeof(struct squashfs_dir_inode_header_1));\
612
+ SQUASHFS_SWAP((s)->file_size, d, 24, 19);\
613
+ SQUASHFS_SWAP((s)->offset, d, 43, 13);\
614
+ SQUASHFS_SWAP((s)->mtime, d, 56, 32);\
615
+ SQUASHFS_SWAP((s)->start_block, d, 88, 24);\
622
+ * macros used to swap each structure entry, taking into account
623
+ * bitfields and different bitfield placing conventions on differing
627
+#include <asm/byteorder.h>
630
+ /* convert from little endian to big endian */
631
+#define SQUASHFS_SWAP(value, p, pos, tbits) _SQUASHFS_SWAP(value, p, pos, \
634
+ /* convert from big endian to little endian */
635
+#define SQUASHFS_SWAP(value, p, pos, tbits) _SQUASHFS_SWAP(value, p, pos, \
636
+ tbits, 64 - tbits - b_pos)
639
+#define _SQUASHFS_SWAP(value, p, pos, tbits, SHIFT) {\
642
+ s = (unsigned char *)p + (pos / 8);\
643
+ d = ((unsigned char *) &val) + 7;\
644
+ for(bits = 0; bits < (tbits + b_pos); bits += 8) \
646
+ value = (val >> (SHIFT))/* & ((1 << tbits) - 1)*/;\
649
+#define SQUASHFS_MEMSET(s, d, n) memset(s, 0, n);