]> git.kernelconcepts.de Git - karo-tx-uboot.git/blob - fs/ubifs/ubifs-media.h
Merge branch 'master' of git://www.denx.de/git/u-boot-imx
[karo-tx-uboot.git] / fs / ubifs / ubifs-media.h
1 /*
2  * This file is part of UBIFS.
3  *
4  * Copyright (C) 2006-2008 Nokia Corporation.
5  *
6  * SPDX-License-Identifier:     GPL-2.0+
7  *
8  * Authors: Artem Bityutskiy (Битюцкий Артём)
9  *          Adrian Hunter
10  */
11
12 /*
13  * This file describes UBIFS on-flash format and contains definitions of all the
14  * relevant data structures and constants.
15  *
16  * All UBIFS on-flash objects are stored in the form of nodes. All nodes start
17  * with the UBIFS node magic number and have the same common header. Nodes
18  * always sit at 8-byte aligned positions on the media and node header sizes are
19  * also 8-byte aligned (except for the indexing node and the padding node).
20  */
21
22 #ifndef __UBIFS_MEDIA_H__
23 #define __UBIFS_MEDIA_H__
24
25 /* UBIFS node magic number (must not have the padding byte first or last) */
26 #define UBIFS_NODE_MAGIC  0x06101831
27
28 /*
29  * UBIFS on-flash format version. This version is increased when the on-flash
30  * format is changing. If this happens, UBIFS is will support older versions as
31  * well. But older UBIFS code will not support newer formats. Format changes
32  * will be rare and only when absolutely necessary, e.g. to fix a bug or to add
33  * a new feature.
34  *
35  * UBIFS went into mainline kernel with format version 4. The older formats
36  * were development formats.
37  */
38 #define UBIFS_FORMAT_VERSION 4
39
40 /*
41  * Read-only compatibility version. If the UBIFS format is changed, older UBIFS
42  * implementations will not be able to mount newer formats in read-write mode.
43  * However, depending on the change, it may be possible to mount newer formats
44  * in R/O mode. This is indicated by the R/O compatibility version which is
45  * stored in the super-block.
46  *
47  * This is needed to support boot-loaders which only need R/O mounting. With
48  * this flag it is possible to do UBIFS format changes without a need to update
49  * boot-loaders.
50  */
51 #define UBIFS_RO_COMPAT_VERSION 0
52
53 /* Minimum logical eraseblock size in bytes */
54 #define UBIFS_MIN_LEB_SZ (15*1024)
55
56 /* Initial CRC32 value used when calculating CRC checksums */
57 #define UBIFS_CRC32_INIT 0xFFFFFFFFU
58
59 /*
60  * UBIFS does not try to compress data if its length is less than the below
61  * constant.
62  */
63 #define UBIFS_MIN_COMPR_LEN 128
64
65 /*
66  * If compressed data length is less than %UBIFS_MIN_COMPRESS_DIFF bytes
67  * shorter than uncompressed data length, UBIFS prefers to leave this data
68  * node uncompress, because it'll be read faster.
69  */
70 #define UBIFS_MIN_COMPRESS_DIFF 64
71
72 /* Root inode number */
73 #define UBIFS_ROOT_INO 1
74
75 /* Lowest inode number used for regular inodes (not UBIFS-only internal ones) */
76 #define UBIFS_FIRST_INO 64
77
78 /*
79  * Maximum file name and extended attribute length (must be a multiple of 8,
80  * minus 1).
81  */
82 #define UBIFS_MAX_NLEN 255
83
84 /* Maximum number of data journal heads */
85 #define UBIFS_MAX_JHEADS 1
86
87 /*
88  * Size of UBIFS data block. Note, UBIFS is not a block oriented file-system,
89  * which means that it does not treat the underlying media as consisting of
90  * blocks like in case of hard drives. Do not be confused. UBIFS block is just
91  * the maximum amount of data which one data node can have or which can be
92  * attached to an inode node.
93  */
94 #define UBIFS_BLOCK_SIZE  4096
95 #define UBIFS_BLOCK_SHIFT 12
96
97 /* UBIFS padding byte pattern (must not be first or last byte of node magic) */
98 #define UBIFS_PADDING_BYTE 0xCE
99
100 /* Maximum possible key length */
101 #define UBIFS_MAX_KEY_LEN 16
102
103 /* Key length ("simple" format) */
104 #define UBIFS_SK_LEN 8
105
106 /* Minimum index tree fanout */
107 #define UBIFS_MIN_FANOUT 3
108
109 /* Maximum number of levels in UBIFS indexing B-tree */
110 #define UBIFS_MAX_LEVELS 512
111
112 /* Maximum amount of data attached to an inode in bytes */
113 #define UBIFS_MAX_INO_DATA UBIFS_BLOCK_SIZE
114
115 /* LEB Properties Tree fanout (must be power of 2) and fanout shift */
116 #define UBIFS_LPT_FANOUT 4
117 #define UBIFS_LPT_FANOUT_SHIFT 2
118
119 /* LEB Properties Tree bit field sizes */
120 #define UBIFS_LPT_CRC_BITS 16
121 #define UBIFS_LPT_CRC_BYTES 2
122 #define UBIFS_LPT_TYPE_BITS 4
123
124 /* The key is always at the same position in all keyed nodes */
125 #define UBIFS_KEY_OFFSET offsetof(struct ubifs_ino_node, key)
126
127 /* Garbage collector journal head number */
128 #define UBIFS_GC_HEAD   0
129 /* Base journal head number */
130 #define UBIFS_BASE_HEAD 1
131 /* Data journal head number */
132 #define UBIFS_DATA_HEAD 2
133
134 /*
135  * LEB Properties Tree node types.
136  *
137  * UBIFS_LPT_PNODE: LPT leaf node (contains LEB properties)
138  * UBIFS_LPT_NNODE: LPT internal node
139  * UBIFS_LPT_LTAB: LPT's own lprops table
140  * UBIFS_LPT_LSAVE: LPT's save table (big model only)
141  * UBIFS_LPT_NODE_CNT: count of LPT node types
142  * UBIFS_LPT_NOT_A_NODE: all ones (15 for 4 bits) is never a valid node type
143  */
144 enum {
145         UBIFS_LPT_PNODE,
146         UBIFS_LPT_NNODE,
147         UBIFS_LPT_LTAB,
148         UBIFS_LPT_LSAVE,
149         UBIFS_LPT_NODE_CNT,
150         UBIFS_LPT_NOT_A_NODE = (1 << UBIFS_LPT_TYPE_BITS) - 1,
151 };
152
153 /*
154  * UBIFS inode types.
155  *
156  * UBIFS_ITYPE_REG: regular file
157  * UBIFS_ITYPE_DIR: directory
158  * UBIFS_ITYPE_LNK: soft link
159  * UBIFS_ITYPE_BLK: block device node
160  * UBIFS_ITYPE_CHR: character device node
161  * UBIFS_ITYPE_FIFO: fifo
162  * UBIFS_ITYPE_SOCK: socket
163  * UBIFS_ITYPES_CNT: count of supported file types
164  */
165 enum {
166         UBIFS_ITYPE_REG,
167         UBIFS_ITYPE_DIR,
168         UBIFS_ITYPE_LNK,
169         UBIFS_ITYPE_BLK,
170         UBIFS_ITYPE_CHR,
171         UBIFS_ITYPE_FIFO,
172         UBIFS_ITYPE_SOCK,
173         UBIFS_ITYPES_CNT,
174 };
175
176 /*
177  * Supported key hash functions.
178  *
179  * UBIFS_KEY_HASH_R5: R5 hash
180  * UBIFS_KEY_HASH_TEST: test hash which just returns first 4 bytes of the name
181  */
182 enum {
183         UBIFS_KEY_HASH_R5,
184         UBIFS_KEY_HASH_TEST,
185 };
186
187 /*
188  * Supported key formats.
189  *
190  * UBIFS_SIMPLE_KEY_FMT: simple key format
191  */
192 enum {
193         UBIFS_SIMPLE_KEY_FMT,
194 };
195
196 /*
197  * The simple key format uses 29 bits for storing UBIFS block number and hash
198  * value.
199  */
200 #define UBIFS_S_KEY_BLOCK_BITS 29
201 #define UBIFS_S_KEY_BLOCK_MASK 0x1FFFFFFF
202 #define UBIFS_S_KEY_HASH_BITS  UBIFS_S_KEY_BLOCK_BITS
203 #define UBIFS_S_KEY_HASH_MASK  UBIFS_S_KEY_BLOCK_MASK
204
205 /*
206  * Key types.
207  *
208  * UBIFS_INO_KEY: inode node key
209  * UBIFS_DATA_KEY: data node key
210  * UBIFS_DENT_KEY: directory entry node key
211  * UBIFS_XENT_KEY: extended attribute entry key
212  * UBIFS_KEY_TYPES_CNT: number of supported key types
213  */
214 enum {
215         UBIFS_INO_KEY,
216         UBIFS_DATA_KEY,
217         UBIFS_DENT_KEY,
218         UBIFS_XENT_KEY,
219         UBIFS_KEY_TYPES_CNT,
220 };
221
222 /* Count of LEBs reserved for the superblock area */
223 #define UBIFS_SB_LEBS 1
224 /* Count of LEBs reserved for the master area */
225 #define UBIFS_MST_LEBS 2
226
227 /* First LEB of the superblock area */
228 #define UBIFS_SB_LNUM 0
229 /* First LEB of the master area */
230 #define UBIFS_MST_LNUM (UBIFS_SB_LNUM + UBIFS_SB_LEBS)
231 /* First LEB of the log area */
232 #define UBIFS_LOG_LNUM (UBIFS_MST_LNUM + UBIFS_MST_LEBS)
233
234 /*
235  * The below constants define the absolute minimum values for various UBIFS
236  * media areas. Many of them actually depend of flash geometry and the FS
237  * configuration (number of journal heads, orphan LEBs, etc). This means that
238  * the smallest volume size which can be used for UBIFS cannot be pre-defined
239  * by these constants. The file-system that meets the below limitation will not
240  * necessarily mount. UBIFS does run-time calculations and validates the FS
241  * size.
242  */
243
244 /* Minimum number of logical eraseblocks in the log */
245 #define UBIFS_MIN_LOG_LEBS 2
246 /* Minimum number of bud logical eraseblocks (one for each head) */
247 #define UBIFS_MIN_BUD_LEBS 3
248 /* Minimum number of journal logical eraseblocks */
249 #define UBIFS_MIN_JNL_LEBS (UBIFS_MIN_LOG_LEBS + UBIFS_MIN_BUD_LEBS)
250 /* Minimum number of LPT area logical eraseblocks */
251 #define UBIFS_MIN_LPT_LEBS 2
252 /* Minimum number of orphan area logical eraseblocks */
253 #define UBIFS_MIN_ORPH_LEBS 1
254 /*
255  * Minimum number of main area logical eraseblocks (buds, 3 for the index, 1
256  * for GC, 1 for deletions, and at least 1 for committed data).
257  */
258 #define UBIFS_MIN_MAIN_LEBS (UBIFS_MIN_BUD_LEBS + 6)
259
260 /* Minimum number of logical eraseblocks */
261 #define UBIFS_MIN_LEB_CNT (UBIFS_SB_LEBS + UBIFS_MST_LEBS + \
262                            UBIFS_MIN_LOG_LEBS + UBIFS_MIN_LPT_LEBS + \
263                            UBIFS_MIN_ORPH_LEBS + UBIFS_MIN_MAIN_LEBS)
264
265 /* Node sizes (N.B. these are guaranteed to be multiples of 8) */
266 #define UBIFS_CH_SZ        sizeof(struct ubifs_ch)
267 #define UBIFS_INO_NODE_SZ  sizeof(struct ubifs_ino_node)
268 #define UBIFS_DATA_NODE_SZ sizeof(struct ubifs_data_node)
269 #define UBIFS_DENT_NODE_SZ sizeof(struct ubifs_dent_node)
270 #define UBIFS_TRUN_NODE_SZ sizeof(struct ubifs_trun_node)
271 #define UBIFS_PAD_NODE_SZ  sizeof(struct ubifs_pad_node)
272 #define UBIFS_SB_NODE_SZ   sizeof(struct ubifs_sb_node)
273 #define UBIFS_MST_NODE_SZ  sizeof(struct ubifs_mst_node)
274 #define UBIFS_REF_NODE_SZ  sizeof(struct ubifs_ref_node)
275 #define UBIFS_IDX_NODE_SZ  sizeof(struct ubifs_idx_node)
276 #define UBIFS_CS_NODE_SZ   sizeof(struct ubifs_cs_node)
277 #define UBIFS_ORPH_NODE_SZ sizeof(struct ubifs_orph_node)
278 /* Extended attribute entry nodes are identical to directory entry nodes */
279 #define UBIFS_XENT_NODE_SZ UBIFS_DENT_NODE_SZ
280 /* Only this does not have to be multiple of 8 bytes */
281 #define UBIFS_BRANCH_SZ    sizeof(struct ubifs_branch)
282
283 /* Maximum node sizes (N.B. these are guaranteed to be multiples of 8) */
284 #define UBIFS_MAX_DATA_NODE_SZ  (UBIFS_DATA_NODE_SZ + UBIFS_BLOCK_SIZE)
285 #define UBIFS_MAX_INO_NODE_SZ   (UBIFS_INO_NODE_SZ + UBIFS_MAX_INO_DATA)
286 #define UBIFS_MAX_DENT_NODE_SZ  (UBIFS_DENT_NODE_SZ + UBIFS_MAX_NLEN + 1)
287 #define UBIFS_MAX_XENT_NODE_SZ  UBIFS_MAX_DENT_NODE_SZ
288
289 /* The largest UBIFS node */
290 #define UBIFS_MAX_NODE_SZ UBIFS_MAX_INO_NODE_SZ
291
292 /*
293  * On-flash inode flags.
294  *
295  * UBIFS_COMPR_FL: use compression for this inode
296  * UBIFS_SYNC_FL:  I/O on this inode has to be synchronous
297  * UBIFS_IMMUTABLE_FL: inode is immutable
298  * UBIFS_APPEND_FL: writes to the inode may only append data
299  * UBIFS_DIRSYNC_FL: I/O on this directory inode has to be synchronous
300  * UBIFS_XATTR_FL: this inode is the inode for an extended attribute value
301  *
302  * Note, these are on-flash flags which correspond to ioctl flags
303  * (@FS_COMPR_FL, etc). They have the same values now, but generally, do not
304  * have to be the same.
305  */
306 enum {
307         UBIFS_COMPR_FL     = 0x01,
308         UBIFS_SYNC_FL      = 0x02,
309         UBIFS_IMMUTABLE_FL = 0x04,
310         UBIFS_APPEND_FL    = 0x08,
311         UBIFS_DIRSYNC_FL   = 0x10,
312         UBIFS_XATTR_FL     = 0x20,
313 };
314
315 /* Inode flag bits used by UBIFS */
316 #define UBIFS_FL_MASK 0x0000001F
317
318 /*
319  * UBIFS compression algorithms.
320  *
321  * UBIFS_COMPR_NONE: no compression
322  * UBIFS_COMPR_LZO: LZO compression
323  * UBIFS_COMPR_ZLIB: ZLIB compression
324  * UBIFS_COMPR_TYPES_CNT: count of supported compression types
325  */
326 enum {
327         UBIFS_COMPR_NONE,
328         UBIFS_COMPR_LZO,
329         UBIFS_COMPR_ZLIB,
330         UBIFS_COMPR_TYPES_CNT,
331 };
332
333 /*
334  * UBIFS node types.
335  *
336  * UBIFS_INO_NODE: inode node
337  * UBIFS_DATA_NODE: data node
338  * UBIFS_DENT_NODE: directory entry node
339  * UBIFS_XENT_NODE: extended attribute node
340  * UBIFS_TRUN_NODE: truncation node
341  * UBIFS_PAD_NODE: padding node
342  * UBIFS_SB_NODE: superblock node
343  * UBIFS_MST_NODE: master node
344  * UBIFS_REF_NODE: LEB reference node
345  * UBIFS_IDX_NODE: index node
346  * UBIFS_CS_NODE: commit start node
347  * UBIFS_ORPH_NODE: orphan node
348  * UBIFS_NODE_TYPES_CNT: count of supported node types
349  *
350  * Note, we index arrays by these numbers, so keep them low and contiguous.
351  * Node type constants for inodes, direntries and so on have to be the same as
352  * corresponding key type constants.
353  */
354 enum {
355         UBIFS_INO_NODE,
356         UBIFS_DATA_NODE,
357         UBIFS_DENT_NODE,
358         UBIFS_XENT_NODE,
359         UBIFS_TRUN_NODE,
360         UBIFS_PAD_NODE,
361         UBIFS_SB_NODE,
362         UBIFS_MST_NODE,
363         UBIFS_REF_NODE,
364         UBIFS_IDX_NODE,
365         UBIFS_CS_NODE,
366         UBIFS_ORPH_NODE,
367         UBIFS_NODE_TYPES_CNT,
368 };
369
370 /*
371  * Master node flags.
372  *
373  * UBIFS_MST_DIRTY: rebooted uncleanly - master node is dirty
374  * UBIFS_MST_NO_ORPHS: no orphan inodes present
375  * UBIFS_MST_RCVRY: written by recovery
376  */
377 enum {
378         UBIFS_MST_DIRTY = 1,
379         UBIFS_MST_NO_ORPHS = 2,
380         UBIFS_MST_RCVRY = 4,
381 };
382
383 /*
384  * Node group type (used by recovery to recover whole group or none).
385  *
386  * UBIFS_NO_NODE_GROUP: this node is not part of a group
387  * UBIFS_IN_NODE_GROUP: this node is a part of a group
388  * UBIFS_LAST_OF_NODE_GROUP: this node is the last in a group
389  */
390 enum {
391         UBIFS_NO_NODE_GROUP = 0,
392         UBIFS_IN_NODE_GROUP,
393         UBIFS_LAST_OF_NODE_GROUP,
394 };
395
396 /*
397  * Superblock flags.
398  *
399  * UBIFS_FLG_BIGLPT: if "big" LPT model is used if set
400  * UBIFS_FLG_SPACE_FIXUP: first-mount "fixup" of free space within LEBs needed
401  */
402 enum {
403         UBIFS_FLG_BIGLPT = 0x02,
404         UBIFS_FLG_SPACE_FIXUP = 0x04,
405 };
406
407 /**
408  * struct ubifs_ch - common header node.
409  * @magic: UBIFS node magic number (%UBIFS_NODE_MAGIC)
410  * @crc: CRC-32 checksum of the node header
411  * @sqnum: sequence number
412  * @len: full node length
413  * @node_type: node type
414  * @group_type: node group type
415  * @padding: reserved for future, zeroes
416  *
417  * Every UBIFS node starts with this common part. If the node has a key, the
418  * key always goes next.
419  */
420 struct ubifs_ch {
421         __le32 magic;
422         __le32 crc;
423         __le64 sqnum;
424         __le32 len;
425         __u8 node_type;
426         __u8 group_type;
427         __u8 padding[2];
428 } __packed;
429
430 /**
431  * union ubifs_dev_desc - device node descriptor.
432  * @new: new type device descriptor
433  * @huge: huge type device descriptor
434  *
435  * This data structure describes major/minor numbers of a device node. In an
436  * inode is a device node then its data contains an object of this type. UBIFS
437  * uses standard Linux "new" and "huge" device node encodings.
438  */
439 union ubifs_dev_desc {
440         __le32 new;
441         __le64 huge;
442 } __packed;
443
444 /**
445  * struct ubifs_ino_node - inode node.
446  * @ch: common header
447  * @key: node key
448  * @creat_sqnum: sequence number at time of creation
449  * @size: inode size in bytes (amount of uncompressed data)
450  * @atime_sec: access time seconds
451  * @ctime_sec: creation time seconds
452  * @mtime_sec: modification time seconds
453  * @atime_nsec: access time nanoseconds
454  * @ctime_nsec: creation time nanoseconds
455  * @mtime_nsec: modification time nanoseconds
456  * @nlink: number of hard links
457  * @uid: owner ID
458  * @gid: group ID
459  * @mode: access flags
460  * @flags: per-inode flags (%UBIFS_COMPR_FL, %UBIFS_SYNC_FL, etc)
461  * @data_len: inode data length
462  * @xattr_cnt: count of extended attributes this inode has
463  * @xattr_size: summarized size of all extended attributes in bytes
464  * @padding1: reserved for future, zeroes
465  * @xattr_names: sum of lengths of all extended attribute names belonging to
466  *               this inode
467  * @compr_type: compression type used for this inode
468  * @padding2: reserved for future, zeroes
469  * @data: data attached to the inode
470  *
471  * Note, even though inode compression type is defined by @compr_type, some
472  * nodes of this inode may be compressed with different compressor - this
473  * happens if compression type is changed while the inode already has data
474  * nodes. But @compr_type will be use for further writes to the inode.
475  *
476  * Note, do not forget to amend 'zero_ino_node_unused()' function when changing
477  * the padding fields.
478  */
479 struct ubifs_ino_node {
480         struct ubifs_ch ch;
481         __u8 key[UBIFS_MAX_KEY_LEN];
482         __le64 creat_sqnum;
483         __le64 size;
484         __le64 atime_sec;
485         __le64 ctime_sec;
486         __le64 mtime_sec;
487         __le32 atime_nsec;
488         __le32 ctime_nsec;
489         __le32 mtime_nsec;
490         __le32 nlink;
491         __le32 uid;
492         __le32 gid;
493         __le32 mode;
494         __le32 flags;
495         __le32 data_len;
496         __le32 xattr_cnt;
497         __le32 xattr_size;
498         __u8 padding1[4]; /* Watch 'zero_ino_node_unused()' if changing! */
499         __le32 xattr_names;
500         __le16 compr_type;
501         __u8 padding2[26]; /* Watch 'zero_ino_node_unused()' if changing! */
502         __u8 data[];
503 } __packed;
504
505 /**
506  * struct ubifs_dent_node - directory entry node.
507  * @ch: common header
508  * @key: node key
509  * @inum: target inode number
510  * @padding1: reserved for future, zeroes
511  * @type: type of the target inode (%UBIFS_ITYPE_REG, %UBIFS_ITYPE_DIR, etc)
512  * @nlen: name length
513  * @padding2: reserved for future, zeroes
514  * @name: zero-terminated name
515  *
516  * Note, do not forget to amend 'zero_dent_node_unused()' function when
517  * changing the padding fields.
518  */
519 struct ubifs_dent_node {
520         struct ubifs_ch ch;
521         __u8 key[UBIFS_MAX_KEY_LEN];
522         __le64 inum;
523         __u8 padding1;
524         __u8 type;
525         __le16 nlen;
526         __u8 padding2[4]; /* Watch 'zero_dent_node_unused()' if changing! */
527 #ifndef __UBOOT__
528         __u8 name[];
529 #else
530         char name[];
531 #endif
532 } __packed;
533
534 /**
535  * struct ubifs_data_node - data node.
536  * @ch: common header
537  * @key: node key
538  * @size: uncompressed data size in bytes
539  * @compr_type: compression type (%UBIFS_COMPR_NONE, %UBIFS_COMPR_LZO, etc)
540  * @padding: reserved for future, zeroes
541  * @data: data
542  *
543  * Note, do not forget to amend 'zero_data_node_unused()' function when
544  * changing the padding fields.
545  */
546 struct ubifs_data_node {
547         struct ubifs_ch ch;
548         __u8 key[UBIFS_MAX_KEY_LEN];
549         __le32 size;
550         __le16 compr_type;
551         __u8 padding[2]; /* Watch 'zero_data_node_unused()' if changing! */
552         __u8 data[];
553 } __packed;
554
555 /**
556  * struct ubifs_trun_node - truncation node.
557  * @ch: common header
558  * @inum: truncated inode number
559  * @padding: reserved for future, zeroes
560  * @old_size: size before truncation
561  * @new_size: size after truncation
562  *
563  * This node exists only in the journal and never goes to the main area. Note,
564  * do not forget to amend 'zero_trun_node_unused()' function when changing the
565  * padding fields.
566  */
567 struct ubifs_trun_node {
568         struct ubifs_ch ch;
569         __le32 inum;
570         __u8 padding[12]; /* Watch 'zero_trun_node_unused()' if changing! */
571         __le64 old_size;
572         __le64 new_size;
573 } __packed;
574
575 /**
576  * struct ubifs_pad_node - padding node.
577  * @ch: common header
578  * @pad_len: how many bytes after this node are unused (because padded)
579  * @padding: reserved for future, zeroes
580  */
581 struct ubifs_pad_node {
582         struct ubifs_ch ch;
583         __le32 pad_len;
584 } __packed;
585
586 /**
587  * struct ubifs_sb_node - superblock node.
588  * @ch: common header
589  * @padding: reserved for future, zeroes
590  * @key_hash: type of hash function used in keys
591  * @key_fmt: format of the key
592  * @flags: file-system flags (%UBIFS_FLG_BIGLPT, etc)
593  * @min_io_size: minimal input/output unit size
594  * @leb_size: logical eraseblock size in bytes
595  * @leb_cnt: count of LEBs used by file-system
596  * @max_leb_cnt: maximum count of LEBs used by file-system
597  * @max_bud_bytes: maximum amount of data stored in buds
598  * @log_lebs: log size in logical eraseblocks
599  * @lpt_lebs: number of LEBs used for lprops table
600  * @orph_lebs: number of LEBs used for recording orphans
601  * @jhead_cnt: count of journal heads
602  * @fanout: tree fanout (max. number of links per indexing node)
603  * @lsave_cnt: number of LEB numbers in LPT's save table
604  * @fmt_version: UBIFS on-flash format version
605  * @default_compr: default compression algorithm (%UBIFS_COMPR_LZO, etc)
606  * @padding1: reserved for future, zeroes
607  * @rp_uid: reserve pool UID
608  * @rp_gid: reserve pool GID
609  * @rp_size: size of the reserved pool in bytes
610  * @padding2: reserved for future, zeroes
611  * @time_gran: time granularity in nanoseconds
612  * @uuid: UUID generated when the file system image was created
613  * @ro_compat_version: UBIFS R/O compatibility version
614  */
615 struct ubifs_sb_node {
616         struct ubifs_ch ch;
617         __u8 padding[2];
618         __u8 key_hash;
619         __u8 key_fmt;
620         __le32 flags;
621         __le32 min_io_size;
622         __le32 leb_size;
623         __le32 leb_cnt;
624         __le32 max_leb_cnt;
625         __le64 max_bud_bytes;
626         __le32 log_lebs;
627         __le32 lpt_lebs;
628         __le32 orph_lebs;
629         __le32 jhead_cnt;
630         __le32 fanout;
631         __le32 lsave_cnt;
632         __le32 fmt_version;
633         __le16 default_compr;
634         __u8 padding1[2];
635         __le32 rp_uid;
636         __le32 rp_gid;
637         __le64 rp_size;
638         __le32 time_gran;
639         __u8 uuid[16];
640         __le32 ro_compat_version;
641         __u8 padding2[3968];
642 } __packed;
643
644 /**
645  * struct ubifs_mst_node - master node.
646  * @ch: common header
647  * @highest_inum: highest inode number in the committed index
648  * @cmt_no: commit number
649  * @flags: various flags (%UBIFS_MST_DIRTY, etc)
650  * @log_lnum: start of the log
651  * @root_lnum: LEB number of the root indexing node
652  * @root_offs: offset within @root_lnum
653  * @root_len: root indexing node length
654  * @gc_lnum: LEB reserved for garbage collection (%-1 value means the LEB was
655  * not reserved and should be reserved on mount)
656  * @ihead_lnum: LEB number of index head
657  * @ihead_offs: offset of index head
658  * @index_size: size of index on flash
659  * @total_free: total free space in bytes
660  * @total_dirty: total dirty space in bytes
661  * @total_used: total used space in bytes (includes only data LEBs)
662  * @total_dead: total dead space in bytes (includes only data LEBs)
663  * @total_dark: total dark space in bytes (includes only data LEBs)
664  * @lpt_lnum: LEB number of LPT root nnode
665  * @lpt_offs: offset of LPT root nnode
666  * @nhead_lnum: LEB number of LPT head
667  * @nhead_offs: offset of LPT head
668  * @ltab_lnum: LEB number of LPT's own lprops table
669  * @ltab_offs: offset of LPT's own lprops table
670  * @lsave_lnum: LEB number of LPT's save table (big model only)
671  * @lsave_offs: offset of LPT's save table (big model only)
672  * @lscan_lnum: LEB number of last LPT scan
673  * @empty_lebs: number of empty logical eraseblocks
674  * @idx_lebs: number of indexing logical eraseblocks
675  * @leb_cnt: count of LEBs used by file-system
676  * @padding: reserved for future, zeroes
677  */
678 struct ubifs_mst_node {
679         struct ubifs_ch ch;
680         __le64 highest_inum;
681         __le64 cmt_no;
682         __le32 flags;
683         __le32 log_lnum;
684         __le32 root_lnum;
685         __le32 root_offs;
686         __le32 root_len;
687         __le32 gc_lnum;
688         __le32 ihead_lnum;
689         __le32 ihead_offs;
690         __le64 index_size;
691         __le64 total_free;
692         __le64 total_dirty;
693         __le64 total_used;
694         __le64 total_dead;
695         __le64 total_dark;
696         __le32 lpt_lnum;
697         __le32 lpt_offs;
698         __le32 nhead_lnum;
699         __le32 nhead_offs;
700         __le32 ltab_lnum;
701         __le32 ltab_offs;
702         __le32 lsave_lnum;
703         __le32 lsave_offs;
704         __le32 lscan_lnum;
705         __le32 empty_lebs;
706         __le32 idx_lebs;
707         __le32 leb_cnt;
708         __u8 padding[344];
709 } __packed;
710
711 /**
712  * struct ubifs_ref_node - logical eraseblock reference node.
713  * @ch: common header
714  * @lnum: the referred logical eraseblock number
715  * @offs: start offset in the referred LEB
716  * @jhead: journal head number
717  * @padding: reserved for future, zeroes
718  */
719 struct ubifs_ref_node {
720         struct ubifs_ch ch;
721         __le32 lnum;
722         __le32 offs;
723         __le32 jhead;
724         __u8 padding[28];
725 } __packed;
726
727 /**
728  * struct ubifs_branch - key/reference/length branch
729  * @lnum: LEB number of the target node
730  * @offs: offset within @lnum
731  * @len: target node length
732  * @key: key
733  */
734 struct ubifs_branch {
735         __le32 lnum;
736         __le32 offs;
737         __le32 len;
738 #ifndef __UBOOT__
739         __u8 key[];
740 #else
741         char key[];
742 #endif
743 } __packed;
744
745 /**
746  * struct ubifs_idx_node - indexing node.
747  * @ch: common header
748  * @child_cnt: number of child index nodes
749  * @level: tree level
750  * @branches: LEB number / offset / length / key branches
751  */
752 struct ubifs_idx_node {
753         struct ubifs_ch ch;
754         __le16 child_cnt;
755         __le16 level;
756 #ifndef __UBOOT__
757         __u8 branches[];
758 #else
759         char branches[];
760 #endif
761 } __packed;
762
763 /**
764  * struct ubifs_cs_node - commit start node.
765  * @ch: common header
766  * @cmt_no: commit number
767  */
768 struct ubifs_cs_node {
769         struct ubifs_ch ch;
770         __le64 cmt_no;
771 } __packed;
772
773 /**
774  * struct ubifs_orph_node - orphan node.
775  * @ch: common header
776  * @cmt_no: commit number (also top bit is set on the last node of the commit)
777  * @inos: inode numbers of orphans
778  */
779 struct ubifs_orph_node {
780         struct ubifs_ch ch;
781         __le64 cmt_no;
782         __le64 inos[];
783 } __packed;
784
785 #endif /* __UBIFS_MEDIA_H__ */