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