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