![]() |
|
|||
0001 /* SPDX-License-Identifier: GPL-2.0-only */ 0002 /* 0003 * This file is part of UBIFS. 0004 * 0005 * Copyright (C) 2006-2008 Nokia Corporation. 0006 * 0007 * Authors: Artem Bityutskiy (Битюцкий Артём) 0008 * Adrian Hunter 0009 */ 0010 0011 /* 0012 * This file describes UBIFS on-flash format and contains definitions of all the 0013 * relevant data structures and constants. 0014 * 0015 * All UBIFS on-flash objects are stored in the form of nodes. All nodes start 0016 * with the UBIFS node magic number and have the same common header. Nodes 0017 * always sit at 8-byte aligned positions on the media and node header sizes are 0018 * also 8-byte aligned (except for the indexing node and the padding node). 0019 */ 0020 0021 #ifndef __UBIFS_MEDIA_H__ 0022 #define __UBIFS_MEDIA_H__ 0023 0024 /* UBIFS node magic number (must not have the padding byte first or last) */ 0025 #define UBIFS_NODE_MAGIC 0x06101831 0026 0027 /* 0028 * UBIFS on-flash format version. This version is increased when the on-flash 0029 * format is changing. If this happens, UBIFS is will support older versions as 0030 * well. But older UBIFS code will not support newer formats. Format changes 0031 * will be rare and only when absolutely necessary, e.g. to fix a bug or to add 0032 * a new feature. 0033 * 0034 * UBIFS went into mainline kernel with format version 4. The older formats 0035 * were development formats. 0036 */ 0037 #define UBIFS_FORMAT_VERSION 5 0038 0039 /* 0040 * Read-only compatibility version. If the UBIFS format is changed, older UBIFS 0041 * implementations will not be able to mount newer formats in read-write mode. 0042 * However, depending on the change, it may be possible to mount newer formats 0043 * in R/O mode. This is indicated by the R/O compatibility version which is 0044 * stored in the super-block. 0045 * 0046 * This is needed to support boot-loaders which only need R/O mounting. With 0047 * this flag it is possible to do UBIFS format changes without a need to update 0048 * boot-loaders. 0049 */ 0050 #define UBIFS_RO_COMPAT_VERSION 0 0051 0052 /* Minimum logical eraseblock size in bytes */ 0053 #define UBIFS_MIN_LEB_SZ (15*1024) 0054 0055 /* Initial CRC32 value used when calculating CRC checksums */ 0056 #define UBIFS_CRC32_INIT 0xFFFFFFFFU 0057 0058 /* 0059 * UBIFS does not try to compress data if its length is less than the below 0060 * constant. 0061 */ 0062 #define UBIFS_MIN_COMPR_LEN 128 0063 0064 /* 0065 * If compressed data length is less than %UBIFS_MIN_COMPRESS_DIFF bytes 0066 * shorter than uncompressed data length, UBIFS prefers to leave this data 0067 * node uncompress, because it'll be read faster. 0068 */ 0069 #define UBIFS_MIN_COMPRESS_DIFF 64 0070 0071 /* Root inode number */ 0072 #define UBIFS_ROOT_INO 1 0073 0074 /* Lowest inode number used for regular inodes (not UBIFS-only internal ones) */ 0075 #define UBIFS_FIRST_INO 64 0076 0077 /* 0078 * Maximum file name and extended attribute length (must be a multiple of 8, 0079 * minus 1). 0080 */ 0081 #define UBIFS_MAX_NLEN 255 0082 0083 /* Maximum number of data journal heads */ 0084 #define UBIFS_MAX_JHEADS 1 0085 0086 /* 0087 * Size of UBIFS data block. Note, UBIFS is not a block oriented file-system, 0088 * which means that it does not treat the underlying media as consisting of 0089 * blocks like in case of hard drives. Do not be confused. UBIFS block is just 0090 * the maximum amount of data which one data node can have or which can be 0091 * attached to an inode node. 0092 */ 0093 #define UBIFS_BLOCK_SIZE 4096 0094 #define UBIFS_BLOCK_SHIFT 12 0095 0096 /* UBIFS padding byte pattern (must not be first or last byte of node magic) */ 0097 #define UBIFS_PADDING_BYTE 0xCE 0098 0099 /* Maximum possible key length */ 0100 #define UBIFS_MAX_KEY_LEN 16 0101 0102 /* Key length ("simple" format) */ 0103 #define UBIFS_SK_LEN 8 0104 0105 /* Minimum index tree fanout */ 0106 #define UBIFS_MIN_FANOUT 3 0107 0108 /* Maximum number of levels in UBIFS indexing B-tree */ 0109 #define UBIFS_MAX_LEVELS 512 0110 0111 /* Maximum amount of data attached to an inode in bytes */ 0112 #define UBIFS_MAX_INO_DATA UBIFS_BLOCK_SIZE 0113 0114 /* LEB Properties Tree fanout (must be power of 2) and fanout shift */ 0115 #define UBIFS_LPT_FANOUT 4 0116 #define UBIFS_LPT_FANOUT_SHIFT 2 0117 0118 /* LEB Properties Tree bit field sizes */ 0119 #define UBIFS_LPT_CRC_BITS 16 0120 #define UBIFS_LPT_CRC_BYTES 2 0121 #define UBIFS_LPT_TYPE_BITS 4 0122 0123 /* The key is always at the same position in all keyed nodes */ 0124 #define UBIFS_KEY_OFFSET offsetof(struct ubifs_ino_node, key) 0125 0126 /* Garbage collector journal head number */ 0127 #define UBIFS_GC_HEAD 0 0128 /* Base journal head number */ 0129 #define UBIFS_BASE_HEAD 1 0130 /* Data journal head number */ 0131 #define UBIFS_DATA_HEAD 2 0132 0133 /* 0134 * LEB Properties Tree node types. 0135 * 0136 * UBIFS_LPT_PNODE: LPT leaf node (contains LEB properties) 0137 * UBIFS_LPT_NNODE: LPT internal node 0138 * UBIFS_LPT_LTAB: LPT's own lprops table 0139 * UBIFS_LPT_LSAVE: LPT's save table (big model only) 0140 * UBIFS_LPT_NODE_CNT: count of LPT node types 0141 * UBIFS_LPT_NOT_A_NODE: all ones (15 for 4 bits) is never a valid node type 0142 */ 0143 enum { 0144 UBIFS_LPT_PNODE, 0145 UBIFS_LPT_NNODE, 0146 UBIFS_LPT_LTAB, 0147 UBIFS_LPT_LSAVE, 0148 UBIFS_LPT_NODE_CNT, 0149 UBIFS_LPT_NOT_A_NODE = (1 << UBIFS_LPT_TYPE_BITS) - 1, 0150 }; 0151 0152 /* 0153 * UBIFS inode types. 0154 * 0155 * UBIFS_ITYPE_REG: regular file 0156 * UBIFS_ITYPE_DIR: directory 0157 * UBIFS_ITYPE_LNK: soft link 0158 * UBIFS_ITYPE_BLK: block device node 0159 * UBIFS_ITYPE_CHR: character device node 0160 * UBIFS_ITYPE_FIFO: fifo 0161 * UBIFS_ITYPE_SOCK: socket 0162 * UBIFS_ITYPES_CNT: count of supported file types 0163 */ 0164 enum { 0165 UBIFS_ITYPE_REG, 0166 UBIFS_ITYPE_DIR, 0167 UBIFS_ITYPE_LNK, 0168 UBIFS_ITYPE_BLK, 0169 UBIFS_ITYPE_CHR, 0170 UBIFS_ITYPE_FIFO, 0171 UBIFS_ITYPE_SOCK, 0172 UBIFS_ITYPES_CNT, 0173 }; 0174 0175 /* 0176 * Supported key hash functions. 0177 * 0178 * UBIFS_KEY_HASH_R5: R5 hash 0179 * UBIFS_KEY_HASH_TEST: test hash which just returns first 4 bytes of the name 0180 */ 0181 enum { 0182 UBIFS_KEY_HASH_R5, 0183 UBIFS_KEY_HASH_TEST, 0184 }; 0185 0186 /* 0187 * Supported key formats. 0188 * 0189 * UBIFS_SIMPLE_KEY_FMT: simple key format 0190 */ 0191 enum { 0192 UBIFS_SIMPLE_KEY_FMT, 0193 }; 0194 0195 /* 0196 * The simple key format uses 29 bits for storing UBIFS block number and hash 0197 * value. 0198 */ 0199 #define UBIFS_S_KEY_BLOCK_BITS 29 0200 #define UBIFS_S_KEY_BLOCK_MASK 0x1FFFFFFF 0201 #define UBIFS_S_KEY_HASH_BITS UBIFS_S_KEY_BLOCK_BITS 0202 #define UBIFS_S_KEY_HASH_MASK UBIFS_S_KEY_BLOCK_MASK 0203 0204 /* 0205 * Key types. 0206 * 0207 * UBIFS_INO_KEY: inode node key 0208 * UBIFS_DATA_KEY: data node key 0209 * UBIFS_DENT_KEY: directory entry node key 0210 * UBIFS_XENT_KEY: extended attribute entry key 0211 * UBIFS_KEY_TYPES_CNT: number of supported key types 0212 */ 0213 enum { 0214 UBIFS_INO_KEY, 0215 UBIFS_DATA_KEY, 0216 UBIFS_DENT_KEY, 0217 UBIFS_XENT_KEY, 0218 UBIFS_KEY_TYPES_CNT, 0219 }; 0220 0221 /* Count of LEBs reserved for the superblock area */ 0222 #define UBIFS_SB_LEBS 1 0223 /* Count of LEBs reserved for the master area */ 0224 #define UBIFS_MST_LEBS 2 0225 0226 /* First LEB of the superblock area */ 0227 #define UBIFS_SB_LNUM 0 0228 /* First LEB of the master area */ 0229 #define UBIFS_MST_LNUM (UBIFS_SB_LNUM + UBIFS_SB_LEBS) 0230 /* First LEB of the log area */ 0231 #define UBIFS_LOG_LNUM (UBIFS_MST_LNUM + UBIFS_MST_LEBS) 0232 0233 /* 0234 * The below constants define the absolute minimum values for various UBIFS 0235 * media areas. Many of them actually depend of flash geometry and the FS 0236 * configuration (number of journal heads, orphan LEBs, etc). This means that 0237 * the smallest volume size which can be used for UBIFS cannot be pre-defined 0238 * by these constants. The file-system that meets the below limitation will not 0239 * necessarily mount. UBIFS does run-time calculations and validates the FS 0240 * size. 0241 */ 0242 0243 /* Minimum number of logical eraseblocks in the log */ 0244 #define UBIFS_MIN_LOG_LEBS 2 0245 /* Minimum number of bud logical eraseblocks (one for each head) */ 0246 #define UBIFS_MIN_BUD_LEBS 3 0247 /* Minimum number of journal logical eraseblocks */ 0248 #define UBIFS_MIN_JNL_LEBS (UBIFS_MIN_LOG_LEBS + UBIFS_MIN_BUD_LEBS) 0249 /* Minimum number of LPT area logical eraseblocks */ 0250 #define UBIFS_MIN_LPT_LEBS 2 0251 /* Minimum number of orphan area logical eraseblocks */ 0252 #define UBIFS_MIN_ORPH_LEBS 1 0253 /* 0254 * Minimum number of main area logical eraseblocks (buds, 3 for the index, 1 0255 * for GC, 1 for deletions, and at least 1 for committed data). 0256 */ 0257 #define UBIFS_MIN_MAIN_LEBS (UBIFS_MIN_BUD_LEBS + 6) 0258 0259 /* Minimum number of logical eraseblocks */ 0260 #define UBIFS_MIN_LEB_CNT (UBIFS_SB_LEBS + UBIFS_MST_LEBS + \ 0261 UBIFS_MIN_LOG_LEBS + UBIFS_MIN_LPT_LEBS + \ 0262 UBIFS_MIN_ORPH_LEBS + UBIFS_MIN_MAIN_LEBS) 0263 0264 /* Node sizes (N.B. these are guaranteed to be multiples of 8) */ 0265 #define UBIFS_CH_SZ sizeof(struct ubifs_ch) 0266 #define UBIFS_INO_NODE_SZ sizeof(struct ubifs_ino_node) 0267 #define UBIFS_DATA_NODE_SZ sizeof(struct ubifs_data_node) 0268 #define UBIFS_DENT_NODE_SZ sizeof(struct ubifs_dent_node) 0269 #define UBIFS_TRUN_NODE_SZ sizeof(struct ubifs_trun_node) 0270 #define UBIFS_PAD_NODE_SZ sizeof(struct ubifs_pad_node) 0271 #define UBIFS_SB_NODE_SZ sizeof(struct ubifs_sb_node) 0272 #define UBIFS_MST_NODE_SZ sizeof(struct ubifs_mst_node) 0273 #define UBIFS_REF_NODE_SZ sizeof(struct ubifs_ref_node) 0274 #define UBIFS_IDX_NODE_SZ sizeof(struct ubifs_idx_node) 0275 #define UBIFS_CS_NODE_SZ sizeof(struct ubifs_cs_node) 0276 #define UBIFS_ORPH_NODE_SZ sizeof(struct ubifs_orph_node) 0277 #define UBIFS_AUTH_NODE_SZ sizeof(struct ubifs_auth_node) 0278 #define UBIFS_SIG_NODE_SZ sizeof(struct ubifs_sig_node) 0279 0280 /* Extended attribute entry nodes are identical to directory entry nodes */ 0281 #define UBIFS_XENT_NODE_SZ UBIFS_DENT_NODE_SZ 0282 /* Only this does not have to be multiple of 8 bytes */ 0283 #define UBIFS_BRANCH_SZ sizeof(struct ubifs_branch) 0284 0285 /* Maximum node sizes (N.B. these are guaranteed to be multiples of 8) */ 0286 #define UBIFS_MAX_DATA_NODE_SZ (UBIFS_DATA_NODE_SZ + UBIFS_BLOCK_SIZE) 0287 #define UBIFS_MAX_INO_NODE_SZ (UBIFS_INO_NODE_SZ + UBIFS_MAX_INO_DATA) 0288 #define UBIFS_MAX_DENT_NODE_SZ (UBIFS_DENT_NODE_SZ + UBIFS_MAX_NLEN + 1) 0289 #define UBIFS_MAX_XENT_NODE_SZ UBIFS_MAX_DENT_NODE_SZ 0290 0291 /* The largest UBIFS node */ 0292 #define UBIFS_MAX_NODE_SZ UBIFS_MAX_INO_NODE_SZ 0293 0294 /* The maxmimum size of a hash, enough for sha512 */ 0295 #define UBIFS_MAX_HASH_LEN 64 0296 0297 /* The maxmimum size of a hmac, enough for hmac(sha512) */ 0298 #define UBIFS_MAX_HMAC_LEN 64 0299 0300 /* 0301 * xattr name of UBIFS encryption context, we don't use a prefix 0302 * nor a long name to not waste space on the flash. 0303 */ 0304 #define UBIFS_XATTR_NAME_ENCRYPTION_CONTEXT "c" 0305 0306 /* Type field in ubifs_sig_node */ 0307 #define UBIFS_SIGNATURE_TYPE_PKCS7 1 0308 0309 /* 0310 * On-flash inode flags. 0311 * 0312 * UBIFS_COMPR_FL: use compression for this inode 0313 * UBIFS_SYNC_FL: I/O on this inode has to be synchronous 0314 * UBIFS_IMMUTABLE_FL: inode is immutable 0315 * UBIFS_APPEND_FL: writes to the inode may only append data 0316 * UBIFS_DIRSYNC_FL: I/O on this directory inode has to be synchronous 0317 * UBIFS_XATTR_FL: this inode is the inode for an extended attribute value 0318 * UBIFS_CRYPT_FL: use encryption for this inode 0319 * 0320 * Note, these are on-flash flags which correspond to ioctl flags 0321 * (@FS_COMPR_FL, etc). They have the same values now, but generally, do not 0322 * have to be the same. 0323 */ 0324 enum { 0325 UBIFS_COMPR_FL = 0x01, 0326 UBIFS_SYNC_FL = 0x02, 0327 UBIFS_IMMUTABLE_FL = 0x04, 0328 UBIFS_APPEND_FL = 0x08, 0329 UBIFS_DIRSYNC_FL = 0x10, 0330 UBIFS_XATTR_FL = 0x20, 0331 UBIFS_CRYPT_FL = 0x40, 0332 }; 0333 0334 /* Inode flag bits used by UBIFS */ 0335 #define UBIFS_FL_MASK 0x0000001F 0336 0337 /* 0338 * UBIFS compression algorithms. 0339 * 0340 * UBIFS_COMPR_NONE: no compression 0341 * UBIFS_COMPR_LZO: LZO compression 0342 * UBIFS_COMPR_ZLIB: ZLIB compression 0343 * UBIFS_COMPR_ZSTD: ZSTD compression 0344 * UBIFS_COMPR_TYPES_CNT: count of supported compression types 0345 */ 0346 enum { 0347 UBIFS_COMPR_NONE, 0348 UBIFS_COMPR_LZO, 0349 UBIFS_COMPR_ZLIB, 0350 UBIFS_COMPR_ZSTD, 0351 UBIFS_COMPR_TYPES_CNT, 0352 }; 0353 0354 /* 0355 * UBIFS node types. 0356 * 0357 * UBIFS_INO_NODE: inode node 0358 * UBIFS_DATA_NODE: data node 0359 * UBIFS_DENT_NODE: directory entry node 0360 * UBIFS_XENT_NODE: extended attribute node 0361 * UBIFS_TRUN_NODE: truncation node 0362 * UBIFS_PAD_NODE: padding node 0363 * UBIFS_SB_NODE: superblock node 0364 * UBIFS_MST_NODE: master node 0365 * UBIFS_REF_NODE: LEB reference node 0366 * UBIFS_IDX_NODE: index node 0367 * UBIFS_CS_NODE: commit start node 0368 * UBIFS_ORPH_NODE: orphan node 0369 * UBIFS_AUTH_NODE: authentication node 0370 * UBIFS_SIG_NODE: signature node 0371 * UBIFS_NODE_TYPES_CNT: count of supported node types 0372 * 0373 * Note, we index arrays by these numbers, so keep them low and contiguous. 0374 * Node type constants for inodes, direntries and so on have to be the same as 0375 * corresponding key type constants. 0376 */ 0377 enum { 0378 UBIFS_INO_NODE, 0379 UBIFS_DATA_NODE, 0380 UBIFS_DENT_NODE, 0381 UBIFS_XENT_NODE, 0382 UBIFS_TRUN_NODE, 0383 UBIFS_PAD_NODE, 0384 UBIFS_SB_NODE, 0385 UBIFS_MST_NODE, 0386 UBIFS_REF_NODE, 0387 UBIFS_IDX_NODE, 0388 UBIFS_CS_NODE, 0389 UBIFS_ORPH_NODE, 0390 UBIFS_AUTH_NODE, 0391 UBIFS_SIG_NODE, 0392 UBIFS_NODE_TYPES_CNT, 0393 }; 0394 0395 /* 0396 * Master node flags. 0397 * 0398 * UBIFS_MST_DIRTY: rebooted uncleanly - master node is dirty 0399 * UBIFS_MST_NO_ORPHS: no orphan inodes present 0400 * UBIFS_MST_RCVRY: written by recovery 0401 */ 0402 enum { 0403 UBIFS_MST_DIRTY = 1, 0404 UBIFS_MST_NO_ORPHS = 2, 0405 UBIFS_MST_RCVRY = 4, 0406 }; 0407 0408 /* 0409 * Node group type (used by recovery to recover whole group or none). 0410 * 0411 * UBIFS_NO_NODE_GROUP: this node is not part of a group 0412 * UBIFS_IN_NODE_GROUP: this node is a part of a group 0413 * UBIFS_LAST_OF_NODE_GROUP: this node is the last in a group 0414 */ 0415 enum { 0416 UBIFS_NO_NODE_GROUP = 0, 0417 UBIFS_IN_NODE_GROUP, 0418 UBIFS_LAST_OF_NODE_GROUP, 0419 }; 0420 0421 /* 0422 * Superblock flags. 0423 * 0424 * UBIFS_FLG_BIGLPT: if "big" LPT model is used if set 0425 * UBIFS_FLG_SPACE_FIXUP: first-mount "fixup" of free space within LEBs needed 0426 * UBIFS_FLG_DOUBLE_HASH: store a 32bit cookie in directory entry nodes to 0427 * support 64bit cookies for lookups by hash 0428 * UBIFS_FLG_ENCRYPTION: this filesystem contains encrypted files 0429 * UBIFS_FLG_AUTHENTICATION: this filesystem contains hashes for authentication 0430 */ 0431 enum { 0432 UBIFS_FLG_BIGLPT = 0x02, 0433 UBIFS_FLG_SPACE_FIXUP = 0x04, 0434 UBIFS_FLG_DOUBLE_HASH = 0x08, 0435 UBIFS_FLG_ENCRYPTION = 0x10, 0436 UBIFS_FLG_AUTHENTICATION = 0x20, 0437 }; 0438 0439 #define UBIFS_FLG_MASK (UBIFS_FLG_BIGLPT | UBIFS_FLG_SPACE_FIXUP | \ 0440 UBIFS_FLG_DOUBLE_HASH | UBIFS_FLG_ENCRYPTION | \ 0441 UBIFS_FLG_AUTHENTICATION) 0442 0443 /** 0444 * struct ubifs_ch - common header node. 0445 * @magic: UBIFS node magic number (%UBIFS_NODE_MAGIC) 0446 * @crc: CRC-32 checksum of the node header 0447 * @sqnum: sequence number 0448 * @len: full node length 0449 * @node_type: node type 0450 * @group_type: node group type 0451 * @padding: reserved for future, zeroes 0452 * 0453 * Every UBIFS node starts with this common part. If the node has a key, the 0454 * key always goes next. 0455 */ 0456 struct ubifs_ch { 0457 __le32 magic; 0458 __le32 crc; 0459 __le64 sqnum; 0460 __le32 len; 0461 __u8 node_type; 0462 __u8 group_type; 0463 __u8 padding[2]; 0464 } __packed; 0465 0466 /** 0467 * union ubifs_dev_desc - device node descriptor. 0468 * @new: new type device descriptor 0469 * @huge: huge type device descriptor 0470 * 0471 * This data structure describes major/minor numbers of a device node. In an 0472 * inode is a device node then its data contains an object of this type. UBIFS 0473 * uses standard Linux "new" and "huge" device node encodings. 0474 */ 0475 union ubifs_dev_desc { 0476 __le32 new; 0477 __le64 huge; 0478 } __packed; 0479 0480 /** 0481 * struct ubifs_ino_node - inode node. 0482 * @ch: common header 0483 * @key: node key 0484 * @creat_sqnum: sequence number at time of creation 0485 * @size: inode size in bytes (amount of uncompressed data) 0486 * @atime_sec: access time seconds 0487 * @ctime_sec: creation time seconds 0488 * @mtime_sec: modification time seconds 0489 * @atime_nsec: access time nanoseconds 0490 * @ctime_nsec: creation time nanoseconds 0491 * @mtime_nsec: modification time nanoseconds 0492 * @nlink: number of hard links 0493 * @uid: owner ID 0494 * @gid: group ID 0495 * @mode: access flags 0496 * @flags: per-inode flags (%UBIFS_COMPR_FL, %UBIFS_SYNC_FL, etc) 0497 * @data_len: inode data length 0498 * @xattr_cnt: count of extended attributes this inode has 0499 * @xattr_size: summarized size of all extended attributes in bytes 0500 * @padding1: reserved for future, zeroes 0501 * @xattr_names: sum of lengths of all extended attribute names belonging to 0502 * this inode 0503 * @compr_type: compression type used for this inode 0504 * @padding2: reserved for future, zeroes 0505 * @data: data attached to the inode 0506 * 0507 * Note, even though inode compression type is defined by @compr_type, some 0508 * nodes of this inode may be compressed with different compressor - this 0509 * happens if compression type is changed while the inode already has data 0510 * nodes. But @compr_type will be use for further writes to the inode. 0511 * 0512 * Note, do not forget to amend 'zero_ino_node_unused()' function when changing 0513 * the padding fields. 0514 */ 0515 struct ubifs_ino_node { 0516 struct ubifs_ch ch; 0517 __u8 key[UBIFS_MAX_KEY_LEN]; 0518 __le64 creat_sqnum; 0519 __le64 size; 0520 __le64 atime_sec; 0521 __le64 ctime_sec; 0522 __le64 mtime_sec; 0523 __le32 atime_nsec; 0524 __le32 ctime_nsec; 0525 __le32 mtime_nsec; 0526 __le32 nlink; 0527 __le32 uid; 0528 __le32 gid; 0529 __le32 mode; 0530 __le32 flags; 0531 __le32 data_len; 0532 __le32 xattr_cnt; 0533 __le32 xattr_size; 0534 __u8 padding1[4]; /* Watch 'zero_ino_node_unused()' if changing! */ 0535 __le32 xattr_names; 0536 __le16 compr_type; 0537 __u8 padding2[26]; /* Watch 'zero_ino_node_unused()' if changing! */ 0538 __u8 data[]; 0539 } __packed; 0540 0541 /** 0542 * struct ubifs_dent_node - directory entry node. 0543 * @ch: common header 0544 * @key: node key 0545 * @inum: target inode number 0546 * @padding1: reserved for future, zeroes 0547 * @type: type of the target inode (%UBIFS_ITYPE_REG, %UBIFS_ITYPE_DIR, etc) 0548 * @nlen: name length 0549 * @cookie: A 32bits random number, used to construct a 64bits 0550 * identifier. 0551 * @name: zero-terminated name 0552 * 0553 * Note, do not forget to amend 'zero_dent_node_unused()' function when 0554 * changing the padding fields. 0555 */ 0556 struct ubifs_dent_node { 0557 struct ubifs_ch ch; 0558 __u8 key[UBIFS_MAX_KEY_LEN]; 0559 __le64 inum; 0560 __u8 padding1; 0561 __u8 type; 0562 __le16 nlen; 0563 __le32 cookie; 0564 __u8 name[]; 0565 } __packed; 0566 0567 /** 0568 * struct ubifs_data_node - data node. 0569 * @ch: common header 0570 * @key: node key 0571 * @size: uncompressed data size in bytes 0572 * @compr_type: compression type (%UBIFS_COMPR_NONE, %UBIFS_COMPR_LZO, etc) 0573 * @compr_size: compressed data size in bytes, only valid when data is encrypted 0574 * @data: data 0575 * 0576 */ 0577 struct ubifs_data_node { 0578 struct ubifs_ch ch; 0579 __u8 key[UBIFS_MAX_KEY_LEN]; 0580 __le32 size; 0581 __le16 compr_type; 0582 __le16 compr_size; 0583 __u8 data[]; 0584 } __packed; 0585 0586 /** 0587 * struct ubifs_trun_node - truncation node. 0588 * @ch: common header 0589 * @inum: truncated inode number 0590 * @padding: reserved for future, zeroes 0591 * @old_size: size before truncation 0592 * @new_size: size after truncation 0593 * 0594 * This node exists only in the journal and never goes to the main area. Note, 0595 * do not forget to amend 'zero_trun_node_unused()' function when changing the 0596 * padding fields. 0597 */ 0598 struct ubifs_trun_node { 0599 struct ubifs_ch ch; 0600 __le32 inum; 0601 __u8 padding[12]; /* Watch 'zero_trun_node_unused()' if changing! */ 0602 __le64 old_size; 0603 __le64 new_size; 0604 } __packed; 0605 0606 /** 0607 * struct ubifs_pad_node - padding node. 0608 * @ch: common header 0609 * @pad_len: how many bytes after this node are unused (because padded) 0610 * @padding: reserved for future, zeroes 0611 */ 0612 struct ubifs_pad_node { 0613 struct ubifs_ch ch; 0614 __le32 pad_len; 0615 } __packed; 0616 0617 /** 0618 * struct ubifs_sb_node - superblock node. 0619 * @ch: common header 0620 * @padding: reserved for future, zeroes 0621 * @key_hash: type of hash function used in keys 0622 * @key_fmt: format of the key 0623 * @flags: file-system flags (%UBIFS_FLG_BIGLPT, etc) 0624 * @min_io_size: minimal input/output unit size 0625 * @leb_size: logical eraseblock size in bytes 0626 * @leb_cnt: count of LEBs used by file-system 0627 * @max_leb_cnt: maximum count of LEBs used by file-system 0628 * @max_bud_bytes: maximum amount of data stored in buds 0629 * @log_lebs: log size in logical eraseblocks 0630 * @lpt_lebs: number of LEBs used for lprops table 0631 * @orph_lebs: number of LEBs used for recording orphans 0632 * @jhead_cnt: count of journal heads 0633 * @fanout: tree fanout (max. number of links per indexing node) 0634 * @lsave_cnt: number of LEB numbers in LPT's save table 0635 * @fmt_version: UBIFS on-flash format version 0636 * @default_compr: default compression algorithm (%UBIFS_COMPR_LZO, etc) 0637 * @padding1: reserved for future, zeroes 0638 * @rp_uid: reserve pool UID 0639 * @rp_gid: reserve pool GID 0640 * @rp_size: size of the reserved pool in bytes 0641 * @padding2: reserved for future, zeroes 0642 * @time_gran: time granularity in nanoseconds 0643 * @uuid: UUID generated when the file system image was created 0644 * @ro_compat_version: UBIFS R/O compatibility version 0645 * @hmac: HMAC to authenticate the superblock node 0646 * @hmac_wkm: HMAC of a well known message (the string "UBIFS") as a convenience 0647 * to the user to check if the correct key is passed. 0648 * @hash_algo: The hash algo used for this filesystem (one of enum hash_algo) 0649 * @hash_mst: hash of the master node, only valid for signed images in which the 0650 * master node does not contain a hmac 0651 */ 0652 struct ubifs_sb_node { 0653 struct ubifs_ch ch; 0654 __u8 padding[2]; 0655 __u8 key_hash; 0656 __u8 key_fmt; 0657 __le32 flags; 0658 __le32 min_io_size; 0659 __le32 leb_size; 0660 __le32 leb_cnt; 0661 __le32 max_leb_cnt; 0662 __le64 max_bud_bytes; 0663 __le32 log_lebs; 0664 __le32 lpt_lebs; 0665 __le32 orph_lebs; 0666 __le32 jhead_cnt; 0667 __le32 fanout; 0668 __le32 lsave_cnt; 0669 __le32 fmt_version; 0670 __le16 default_compr; 0671 __u8 padding1[2]; 0672 __le32 rp_uid; 0673 __le32 rp_gid; 0674 __le64 rp_size; 0675 __le32 time_gran; 0676 __u8 uuid[16]; 0677 __le32 ro_compat_version; 0678 __u8 hmac[UBIFS_MAX_HMAC_LEN]; 0679 __u8 hmac_wkm[UBIFS_MAX_HMAC_LEN]; 0680 __le16 hash_algo; 0681 __u8 hash_mst[UBIFS_MAX_HASH_LEN]; 0682 __u8 padding2[3774]; 0683 } __packed; 0684 0685 /** 0686 * struct ubifs_mst_node - master node. 0687 * @ch: common header 0688 * @highest_inum: highest inode number in the committed index 0689 * @cmt_no: commit number 0690 * @flags: various flags (%UBIFS_MST_DIRTY, etc) 0691 * @log_lnum: start of the log 0692 * @root_lnum: LEB number of the root indexing node 0693 * @root_offs: offset within @root_lnum 0694 * @root_len: root indexing node length 0695 * @gc_lnum: LEB reserved for garbage collection (%-1 value means the LEB was 0696 * not reserved and should be reserved on mount) 0697 * @ihead_lnum: LEB number of index head 0698 * @ihead_offs: offset of index head 0699 * @index_size: size of index on flash 0700 * @total_free: total free space in bytes 0701 * @total_dirty: total dirty space in bytes 0702 * @total_used: total used space in bytes (includes only data LEBs) 0703 * @total_dead: total dead space in bytes (includes only data LEBs) 0704 * @total_dark: total dark space in bytes (includes only data LEBs) 0705 * @lpt_lnum: LEB number of LPT root nnode 0706 * @lpt_offs: offset of LPT root nnode 0707 * @nhead_lnum: LEB number of LPT head 0708 * @nhead_offs: offset of LPT head 0709 * @ltab_lnum: LEB number of LPT's own lprops table 0710 * @ltab_offs: offset of LPT's own lprops table 0711 * @lsave_lnum: LEB number of LPT's save table (big model only) 0712 * @lsave_offs: offset of LPT's save table (big model only) 0713 * @lscan_lnum: LEB number of last LPT scan 0714 * @empty_lebs: number of empty logical eraseblocks 0715 * @idx_lebs: number of indexing logical eraseblocks 0716 * @leb_cnt: count of LEBs used by file-system 0717 * @hash_root_idx: the hash of the root index node 0718 * @hash_lpt: the hash of the LPT 0719 * @hmac: HMAC to authenticate the master node 0720 * @padding: reserved for future, zeroes 0721 */ 0722 struct ubifs_mst_node { 0723 struct ubifs_ch ch; 0724 __le64 highest_inum; 0725 __le64 cmt_no; 0726 __le32 flags; 0727 __le32 log_lnum; 0728 __le32 root_lnum; 0729 __le32 root_offs; 0730 __le32 root_len; 0731 __le32 gc_lnum; 0732 __le32 ihead_lnum; 0733 __le32 ihead_offs; 0734 __le64 index_size; 0735 __le64 total_free; 0736 __le64 total_dirty; 0737 __le64 total_used; 0738 __le64 total_dead; 0739 __le64 total_dark; 0740 __le32 lpt_lnum; 0741 __le32 lpt_offs; 0742 __le32 nhead_lnum; 0743 __le32 nhead_offs; 0744 __le32 ltab_lnum; 0745 __le32 ltab_offs; 0746 __le32 lsave_lnum; 0747 __le32 lsave_offs; 0748 __le32 lscan_lnum; 0749 __le32 empty_lebs; 0750 __le32 idx_lebs; 0751 __le32 leb_cnt; 0752 __u8 hash_root_idx[UBIFS_MAX_HASH_LEN]; 0753 __u8 hash_lpt[UBIFS_MAX_HASH_LEN]; 0754 __u8 hmac[UBIFS_MAX_HMAC_LEN]; 0755 __u8 padding[152]; 0756 } __packed; 0757 0758 /** 0759 * struct ubifs_ref_node - logical eraseblock reference node. 0760 * @ch: common header 0761 * @lnum: the referred logical eraseblock number 0762 * @offs: start offset in the referred LEB 0763 * @jhead: journal head number 0764 * @padding: reserved for future, zeroes 0765 */ 0766 struct ubifs_ref_node { 0767 struct ubifs_ch ch; 0768 __le32 lnum; 0769 __le32 offs; 0770 __le32 jhead; 0771 __u8 padding[28]; 0772 } __packed; 0773 0774 /** 0775 * struct ubifs_auth_node - node for authenticating other nodes 0776 * @ch: common header 0777 * @hmac: The HMAC 0778 */ 0779 struct ubifs_auth_node { 0780 struct ubifs_ch ch; 0781 __u8 hmac[]; 0782 } __packed; 0783 0784 /** 0785 * struct ubifs_sig_node - node for signing other nodes 0786 * @ch: common header 0787 * @type: type of the signature, currently only UBIFS_SIGNATURE_TYPE_PKCS7 0788 * supported 0789 * @len: The length of the signature data 0790 * @padding: reserved for future, zeroes 0791 * @sig: The signature data 0792 */ 0793 struct ubifs_sig_node { 0794 struct ubifs_ch ch; 0795 __le32 type; 0796 __le32 len; 0797 __u8 padding[32]; 0798 __u8 sig[]; 0799 } __packed; 0800 0801 /** 0802 * struct ubifs_branch - key/reference/length branch 0803 * @lnum: LEB number of the target node 0804 * @offs: offset within @lnum 0805 * @len: target node length 0806 * @key: key 0807 * 0808 * In an authenticated UBIFS we have the hash of the referenced node after @key. 0809 * This can't be added to the struct type definition because @key is a 0810 * dynamically sized element already. 0811 */ 0812 struct ubifs_branch { 0813 __le32 lnum; 0814 __le32 offs; 0815 __le32 len; 0816 __u8 key[]; 0817 } __packed; 0818 0819 /** 0820 * struct ubifs_idx_node - indexing node. 0821 * @ch: common header 0822 * @child_cnt: number of child index nodes 0823 * @level: tree level 0824 * @branches: LEB number / offset / length / key branches 0825 */ 0826 struct ubifs_idx_node { 0827 struct ubifs_ch ch; 0828 __le16 child_cnt; 0829 __le16 level; 0830 __u8 branches[]; 0831 } __packed; 0832 0833 /** 0834 * struct ubifs_cs_node - commit start node. 0835 * @ch: common header 0836 * @cmt_no: commit number 0837 */ 0838 struct ubifs_cs_node { 0839 struct ubifs_ch ch; 0840 __le64 cmt_no; 0841 } __packed; 0842 0843 /** 0844 * struct ubifs_orph_node - orphan node. 0845 * @ch: common header 0846 * @cmt_no: commit number (also top bit is set on the last node of the commit) 0847 * @inos: inode numbers of orphans 0848 */ 0849 struct ubifs_orph_node { 0850 struct ubifs_ch ch; 0851 __le64 cmt_no; 0852 __le64 inos[]; 0853 } __packed; 0854 0855 #endif /* __UBIFS_MEDIA_H__ */
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.1.0 LXR engine. The LXR team |
![]() ![]() |