This source file includes following definitions.
- squashfs_block_size
1
2 #ifndef SQUASHFS_FS
3 #define SQUASHFS_FS
4
5
6
7
8
9
10
11
12
13 #define SQUASHFS_CACHED_FRAGMENTS CONFIG_SQUASHFS_FRAGMENT_CACHE_SIZE
14 #define SQUASHFS_MAJOR 4
15 #define SQUASHFS_MINOR 0
16 #define SQUASHFS_START 0
17
18
19 #define SQUASHFS_METADATA_SIZE 8192
20
21
22 #ifdef CONFIG_SQUASHFS_4K_DEVBLK_SIZE
23 #define SQUASHFS_DEVBLK_SIZE 4096
24 #else
25 #define SQUASHFS_DEVBLK_SIZE 1024
26 #endif
27
28 #define SQUASHFS_FILE_MAX_SIZE 1048576
29 #define SQUASHFS_FILE_MAX_LOG 20
30
31
32 #define SQUASHFS_NAME_LEN 256
33
34
35 #define SQUASHFS_DIR_COUNT 256
36
37 #define SQUASHFS_INVALID_FRAG (0xffffffffU)
38 #define SQUASHFS_INVALID_XATTR (0xffffffffU)
39 #define SQUASHFS_INVALID_BLK (-1LL)
40
41
42 #define SQUASHFS_NOI 0
43 #define SQUASHFS_NOD 1
44 #define SQUASHFS_NOF 3
45 #define SQUASHFS_NO_FRAG 4
46 #define SQUASHFS_ALWAYS_FRAG 5
47 #define SQUASHFS_DUPLICATE 6
48 #define SQUASHFS_EXPORT 7
49 #define SQUASHFS_COMP_OPT 10
50
51 #define SQUASHFS_BIT(flag, bit) ((flag >> bit) & 1)
52
53 #define SQUASHFS_UNCOMPRESSED_INODES(flags) SQUASHFS_BIT(flags, \
54 SQUASHFS_NOI)
55
56 #define SQUASHFS_UNCOMPRESSED_DATA(flags) SQUASHFS_BIT(flags, \
57 SQUASHFS_NOD)
58
59 #define SQUASHFS_UNCOMPRESSED_FRAGMENTS(flags) SQUASHFS_BIT(flags, \
60 SQUASHFS_NOF)
61
62 #define SQUASHFS_NO_FRAGMENTS(flags) SQUASHFS_BIT(flags, \
63 SQUASHFS_NO_FRAG)
64
65 #define SQUASHFS_ALWAYS_FRAGMENTS(flags) SQUASHFS_BIT(flags, \
66 SQUASHFS_ALWAYS_FRAG)
67
68 #define SQUASHFS_DUPLICATES(flags) SQUASHFS_BIT(flags, \
69 SQUASHFS_DUPLICATE)
70
71 #define SQUASHFS_EXPORTABLE(flags) SQUASHFS_BIT(flags, \
72 SQUASHFS_EXPORT)
73
74 #define SQUASHFS_COMP_OPTS(flags) SQUASHFS_BIT(flags, \
75 SQUASHFS_COMP_OPT)
76
77
78 #define SQUASHFS_DIR_TYPE 1
79 #define SQUASHFS_REG_TYPE 2
80 #define SQUASHFS_SYMLINK_TYPE 3
81 #define SQUASHFS_BLKDEV_TYPE 4
82 #define SQUASHFS_CHRDEV_TYPE 5
83 #define SQUASHFS_FIFO_TYPE 6
84 #define SQUASHFS_SOCKET_TYPE 7
85 #define SQUASHFS_LDIR_TYPE 8
86 #define SQUASHFS_LREG_TYPE 9
87 #define SQUASHFS_LSYMLINK_TYPE 10
88 #define SQUASHFS_LBLKDEV_TYPE 11
89 #define SQUASHFS_LCHRDEV_TYPE 12
90 #define SQUASHFS_LFIFO_TYPE 13
91 #define SQUASHFS_LSOCKET_TYPE 14
92
93
94 #define SQUASHFS_MAX_DIR_TYPE 7
95
96
97 #define SQUASHFS_XATTR_USER 0
98 #define SQUASHFS_XATTR_TRUSTED 1
99 #define SQUASHFS_XATTR_SECURITY 2
100 #define SQUASHFS_XATTR_VALUE_OOL 256
101 #define SQUASHFS_XATTR_PREFIX_MASK 0xff
102
103
104
105 #define SQUASHFS_COMPRESSED_BIT (1 << 15)
106
107 #define SQUASHFS_COMPRESSED_SIZE(B) (((B) & ~SQUASHFS_COMPRESSED_BIT) ? \
108 (B) & ~SQUASHFS_COMPRESSED_BIT : SQUASHFS_COMPRESSED_BIT)
109
110 #define SQUASHFS_COMPRESSED(B) (!((B) & SQUASHFS_COMPRESSED_BIT))
111
112 #define SQUASHFS_COMPRESSED_BIT_BLOCK (1 << 24)
113
114 #define SQUASHFS_COMPRESSED_SIZE_BLOCK(B) ((B) & \
115 ~SQUASHFS_COMPRESSED_BIT_BLOCK)
116
117 #define SQUASHFS_COMPRESSED_BLOCK(B) (!((B) & SQUASHFS_COMPRESSED_BIT_BLOCK))
118
119 static inline int squashfs_block_size(__le32 raw)
120 {
121 u32 size = le32_to_cpu(raw);
122 return (size >> 25) ? -EIO : size;
123 }
124
125
126
127
128
129 #define SQUASHFS_INODE_BLK(A) ((unsigned int) ((A) >> 16))
130
131 #define SQUASHFS_INODE_OFFSET(A) ((unsigned int) ((A) & 0xffff))
132
133 #define SQUASHFS_MKINODE(A, B) ((long long)(((long long) (A)\
134 << 16) + (B)))
135
136
137 #define SQUASHFS_FRAGMENT_BYTES(A) \
138 ((A) * sizeof(struct squashfs_fragment_entry))
139
140 #define SQUASHFS_FRAGMENT_INDEX(A) (SQUASHFS_FRAGMENT_BYTES(A) / \
141 SQUASHFS_METADATA_SIZE)
142
143 #define SQUASHFS_FRAGMENT_INDEX_OFFSET(A) (SQUASHFS_FRAGMENT_BYTES(A) % \
144 SQUASHFS_METADATA_SIZE)
145
146 #define SQUASHFS_FRAGMENT_INDEXES(A) ((SQUASHFS_FRAGMENT_BYTES(A) + \
147 SQUASHFS_METADATA_SIZE - 1) / \
148 SQUASHFS_METADATA_SIZE)
149
150 #define SQUASHFS_FRAGMENT_INDEX_BYTES(A) (SQUASHFS_FRAGMENT_INDEXES(A) *\
151 sizeof(u64))
152
153
154 #define SQUASHFS_LOOKUP_BYTES(A) ((A) * sizeof(u64))
155
156 #define SQUASHFS_LOOKUP_BLOCK(A) (SQUASHFS_LOOKUP_BYTES(A) / \
157 SQUASHFS_METADATA_SIZE)
158
159 #define SQUASHFS_LOOKUP_BLOCK_OFFSET(A) (SQUASHFS_LOOKUP_BYTES(A) % \
160 SQUASHFS_METADATA_SIZE)
161
162 #define SQUASHFS_LOOKUP_BLOCKS(A) ((SQUASHFS_LOOKUP_BYTES(A) + \
163 SQUASHFS_METADATA_SIZE - 1) / \
164 SQUASHFS_METADATA_SIZE)
165
166 #define SQUASHFS_LOOKUP_BLOCK_BYTES(A) (SQUASHFS_LOOKUP_BLOCKS(A) *\
167 sizeof(u64))
168
169
170 #define SQUASHFS_ID_BYTES(A) ((A) * sizeof(unsigned int))
171
172 #define SQUASHFS_ID_BLOCK(A) (SQUASHFS_ID_BYTES(A) / \
173 SQUASHFS_METADATA_SIZE)
174
175 #define SQUASHFS_ID_BLOCK_OFFSET(A) (SQUASHFS_ID_BYTES(A) % \
176 SQUASHFS_METADATA_SIZE)
177
178 #define SQUASHFS_ID_BLOCKS(A) ((SQUASHFS_ID_BYTES(A) + \
179 SQUASHFS_METADATA_SIZE - 1) / \
180 SQUASHFS_METADATA_SIZE)
181
182 #define SQUASHFS_ID_BLOCK_BYTES(A) (SQUASHFS_ID_BLOCKS(A) *\
183 sizeof(u64))
184
185 #define SQUASHFS_XATTR_BYTES(A) ((A) * sizeof(struct squashfs_xattr_id))
186
187 #define SQUASHFS_XATTR_BLOCK(A) (SQUASHFS_XATTR_BYTES(A) / \
188 SQUASHFS_METADATA_SIZE)
189
190 #define SQUASHFS_XATTR_BLOCK_OFFSET(A) (SQUASHFS_XATTR_BYTES(A) % \
191 SQUASHFS_METADATA_SIZE)
192
193 #define SQUASHFS_XATTR_BLOCKS(A) ((SQUASHFS_XATTR_BYTES(A) + \
194 SQUASHFS_METADATA_SIZE - 1) / \
195 SQUASHFS_METADATA_SIZE)
196
197 #define SQUASHFS_XATTR_BLOCK_BYTES(A) (SQUASHFS_XATTR_BLOCKS(A) *\
198 sizeof(u64))
199 #define SQUASHFS_XATTR_BLK(A) ((unsigned int) ((A) >> 16))
200
201 #define SQUASHFS_XATTR_OFFSET(A) ((unsigned int) ((A) & 0xffff))
202
203
204 #define SQUASHFS_CACHED_BLKS 8
205
206
207 #define SQUASHFS_META_INDEXES (SQUASHFS_METADATA_SIZE / sizeof(unsigned int))
208 #define SQUASHFS_META_ENTRIES 127
209 #define SQUASHFS_META_SLOTS 8
210
211 struct meta_entry {
212 u64 data_block;
213 unsigned int index_block;
214 unsigned short offset;
215 unsigned short pad;
216 };
217
218 struct meta_index {
219 unsigned int inode_number;
220 unsigned int offset;
221 unsigned short entries;
222 unsigned short skip;
223 unsigned short locked;
224 unsigned short pad;
225 struct meta_entry meta_entry[SQUASHFS_META_ENTRIES];
226 };
227
228
229
230
231
232 #define ZLIB_COMPRESSION 1
233 #define LZMA_COMPRESSION 2
234 #define LZO_COMPRESSION 3
235 #define XZ_COMPRESSION 4
236 #define LZ4_COMPRESSION 5
237 #define ZSTD_COMPRESSION 6
238
239 struct squashfs_super_block {
240 __le32 s_magic;
241 __le32 inodes;
242 __le32 mkfs_time;
243 __le32 block_size;
244 __le32 fragments;
245 __le16 compression;
246 __le16 block_log;
247 __le16 flags;
248 __le16 no_ids;
249 __le16 s_major;
250 __le16 s_minor;
251 __le64 root_inode;
252 __le64 bytes_used;
253 __le64 id_table_start;
254 __le64 xattr_id_table_start;
255 __le64 inode_table_start;
256 __le64 directory_table_start;
257 __le64 fragment_table_start;
258 __le64 lookup_table_start;
259 };
260
261 struct squashfs_dir_index {
262 __le32 index;
263 __le32 start_block;
264 __le32 size;
265 unsigned char name[0];
266 };
267
268 struct squashfs_base_inode {
269 __le16 inode_type;
270 __le16 mode;
271 __le16 uid;
272 __le16 guid;
273 __le32 mtime;
274 __le32 inode_number;
275 };
276
277 struct squashfs_ipc_inode {
278 __le16 inode_type;
279 __le16 mode;
280 __le16 uid;
281 __le16 guid;
282 __le32 mtime;
283 __le32 inode_number;
284 __le32 nlink;
285 };
286
287 struct squashfs_lipc_inode {
288 __le16 inode_type;
289 __le16 mode;
290 __le16 uid;
291 __le16 guid;
292 __le32 mtime;
293 __le32 inode_number;
294 __le32 nlink;
295 __le32 xattr;
296 };
297
298 struct squashfs_dev_inode {
299 __le16 inode_type;
300 __le16 mode;
301 __le16 uid;
302 __le16 guid;
303 __le32 mtime;
304 __le32 inode_number;
305 __le32 nlink;
306 __le32 rdev;
307 };
308
309 struct squashfs_ldev_inode {
310 __le16 inode_type;
311 __le16 mode;
312 __le16 uid;
313 __le16 guid;
314 __le32 mtime;
315 __le32 inode_number;
316 __le32 nlink;
317 __le32 rdev;
318 __le32 xattr;
319 };
320
321 struct squashfs_symlink_inode {
322 __le16 inode_type;
323 __le16 mode;
324 __le16 uid;
325 __le16 guid;
326 __le32 mtime;
327 __le32 inode_number;
328 __le32 nlink;
329 __le32 symlink_size;
330 char symlink[0];
331 };
332
333 struct squashfs_reg_inode {
334 __le16 inode_type;
335 __le16 mode;
336 __le16 uid;
337 __le16 guid;
338 __le32 mtime;
339 __le32 inode_number;
340 __le32 start_block;
341 __le32 fragment;
342 __le32 offset;
343 __le32 file_size;
344 __le16 block_list[0];
345 };
346
347 struct squashfs_lreg_inode {
348 __le16 inode_type;
349 __le16 mode;
350 __le16 uid;
351 __le16 guid;
352 __le32 mtime;
353 __le32 inode_number;
354 __le64 start_block;
355 __le64 file_size;
356 __le64 sparse;
357 __le32 nlink;
358 __le32 fragment;
359 __le32 offset;
360 __le32 xattr;
361 __le16 block_list[0];
362 };
363
364 struct squashfs_dir_inode {
365 __le16 inode_type;
366 __le16 mode;
367 __le16 uid;
368 __le16 guid;
369 __le32 mtime;
370 __le32 inode_number;
371 __le32 start_block;
372 __le32 nlink;
373 __le16 file_size;
374 __le16 offset;
375 __le32 parent_inode;
376 };
377
378 struct squashfs_ldir_inode {
379 __le16 inode_type;
380 __le16 mode;
381 __le16 uid;
382 __le16 guid;
383 __le32 mtime;
384 __le32 inode_number;
385 __le32 nlink;
386 __le32 file_size;
387 __le32 start_block;
388 __le32 parent_inode;
389 __le16 i_count;
390 __le16 offset;
391 __le32 xattr;
392 struct squashfs_dir_index index[0];
393 };
394
395 union squashfs_inode {
396 struct squashfs_base_inode base;
397 struct squashfs_dev_inode dev;
398 struct squashfs_ldev_inode ldev;
399 struct squashfs_symlink_inode symlink;
400 struct squashfs_reg_inode reg;
401 struct squashfs_lreg_inode lreg;
402 struct squashfs_dir_inode dir;
403 struct squashfs_ldir_inode ldir;
404 struct squashfs_ipc_inode ipc;
405 struct squashfs_lipc_inode lipc;
406 };
407
408 struct squashfs_dir_entry {
409 __le16 offset;
410 __le16 inode_number;
411 __le16 type;
412 __le16 size;
413 char name[0];
414 };
415
416 struct squashfs_dir_header {
417 __le32 count;
418 __le32 start_block;
419 __le32 inode_number;
420 };
421
422 struct squashfs_fragment_entry {
423 __le64 start_block;
424 __le32 size;
425 unsigned int unused;
426 };
427
428 struct squashfs_xattr_entry {
429 __le16 type;
430 __le16 size;
431 char data[0];
432 };
433
434 struct squashfs_xattr_val {
435 __le32 vsize;
436 char value[0];
437 };
438
439 struct squashfs_xattr_id {
440 __le64 xattr;
441 __le32 count;
442 __le32 size;
443 };
444
445 struct squashfs_xattr_id_table {
446 __le64 xattr_table_start;
447 __le32 xattr_ids;
448 __le32 unused;
449 };
450
451 #endif