~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/fs/squashfs/squashfs_fs.h

Version: ~ [ linux-5.7-rc7 ] ~ [ linux-5.6.14 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.42 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.124 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.181 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.224 ] ~ [ linux-4.8.17 ] ~ [ linux-4.7.10 ] ~ [ linux-4.6.7 ] ~ [ linux-4.5.7 ] ~ [ linux-4.4.224 ] ~ [ linux-4.3.6 ] ~ [ linux-4.2.8 ] ~ [ linux-4.1.52 ] ~ [ linux-4.0.9 ] ~ [ linux-3.19.8 ] ~ [ linux-3.18.140 ] ~ [ linux-3.17.8 ] ~ [ linux-3.16.84 ] ~ [ linux-3.15.10 ] ~ [ linux-3.14.79 ] ~ [ linux-3.13.11 ] ~ [ linux-3.12.74 ] ~ [ linux-3.11.10 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.5 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

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

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | Wiki (Japanese) | Wiki (English) | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

osdn.jp