Gao Xiang | 29b24f6 | 2019-07-31 23:57:31 +0800 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-only OR Apache-2.0 */ |
| 2 | /* |
Gao Xiang | ea559e7 | 2019-09-04 10:08:57 +0800 | [diff] [blame] | 3 | * EROFS (Enhanced ROM File System) on-disk format definition |
| 4 | * |
Gao Xiang | aea1286 | 2018-07-26 20:21:44 +0800 | [diff] [blame] | 5 | * Copyright (C) 2017-2018 HUAWEI, Inc. |
| 6 | * http://www.huawei.com/ |
| 7 | * Created by Gao Xiang <gaoxiang25@huawei.com> |
Gao Xiang | aea1286 | 2018-07-26 20:21:44 +0800 | [diff] [blame] | 8 | */ |
| 9 | #ifndef __EROFS_FS_H |
| 10 | #define __EROFS_FS_H |
| 11 | |
Gao Xiang | aea1286 | 2018-07-26 20:21:44 +0800 | [diff] [blame] | 12 | #define EROFS_SUPER_OFFSET 1024 |
| 13 | |
Gao Xiang | 5efe513 | 2019-06-13 16:35:41 +0800 | [diff] [blame] | 14 | /* |
Gao Xiang | 426a930 | 2019-09-04 10:08:53 +0800 | [diff] [blame] | 15 | * Any bits that aren't in EROFS_ALL_FEATURE_INCOMPAT should |
| 16 | * be incompatible with this kernel version. |
Gao Xiang | 5efe513 | 2019-06-13 16:35:41 +0800 | [diff] [blame] | 17 | */ |
Gao Xiang | 426a930 | 2019-09-04 10:08:53 +0800 | [diff] [blame] | 18 | #define EROFS_FEATURE_INCOMPAT_LZ4_0PADDING 0x00000001 |
| 19 | #define EROFS_ALL_FEATURE_INCOMPAT EROFS_FEATURE_INCOMPAT_LZ4_0PADDING |
Gao Xiang | 5efe513 | 2019-06-13 16:35:41 +0800 | [diff] [blame] | 20 | |
Gao Xiang | 4b66eb5 | 2019-09-04 10:08:48 +0800 | [diff] [blame] | 21 | /* 128-byte erofs on-disk super block */ |
Gao Xiang | aea1286 | 2018-07-26 20:21:44 +0800 | [diff] [blame] | 22 | struct erofs_super_block { |
Gao Xiang | 4b66eb5 | 2019-09-04 10:08:48 +0800 | [diff] [blame] | 23 | __le32 magic; /* file system magic number */ |
| 24 | __le32 checksum; /* crc32c(super_block) */ |
Gao Xiang | 426a930 | 2019-09-04 10:08:53 +0800 | [diff] [blame] | 25 | __le32 feature_compat; |
Gao Xiang | 4b66eb5 | 2019-09-04 10:08:48 +0800 | [diff] [blame] | 26 | __u8 blkszbits; /* support block_size == PAGE_SIZE only */ |
| 27 | __u8 reserved; |
Gao Xiang | aea1286 | 2018-07-26 20:21:44 +0800 | [diff] [blame] | 28 | |
Gao Xiang | 4b66eb5 | 2019-09-04 10:08:48 +0800 | [diff] [blame] | 29 | __le16 root_nid; /* nid of root directory */ |
| 30 | __le64 inos; /* total valid ino # (== f_files - f_favail) */ |
Gao Xiang | aea1286 | 2018-07-26 20:21:44 +0800 | [diff] [blame] | 31 | |
Gao Xiang | 4b66eb5 | 2019-09-04 10:08:48 +0800 | [diff] [blame] | 32 | __le64 build_time; /* inode v1 time derivation */ |
| 33 | __le32 build_time_nsec; /* inode v1 time derivation in nano scale */ |
| 34 | __le32 blocks; /* used for statfs */ |
| 35 | __le32 meta_blkaddr; /* start block address of metadata area */ |
| 36 | __le32 xattr_blkaddr; /* start block address of shared xattr area */ |
| 37 | __u8 uuid[16]; /* 128-bit uuid for volume */ |
| 38 | __u8 volume_name[16]; /* volume name */ |
Gao Xiang | 426a930 | 2019-09-04 10:08:53 +0800 | [diff] [blame] | 39 | __le32 feature_incompat; |
Gao Xiang | aea1286 | 2018-07-26 20:21:44 +0800 | [diff] [blame] | 40 | |
Gao Xiang | 4b66eb5 | 2019-09-04 10:08:48 +0800 | [diff] [blame] | 41 | __u8 reserved2[44]; |
Gao Xiang | ed34aa4 | 2019-09-04 10:08:51 +0800 | [diff] [blame] | 42 | }; |
Gao Xiang | aea1286 | 2018-07-26 20:21:44 +0800 | [diff] [blame] | 43 | |
Gao Xiang | aea1286 | 2018-07-26 20:21:44 +0800 | [diff] [blame] | 44 | /* |
Gao Xiang | ea559e7 | 2019-09-04 10:08:57 +0800 | [diff] [blame] | 45 | * erofs inode datalayout (i_format in on-disk inode): |
Gao Xiang | aea1286 | 2018-07-26 20:21:44 +0800 | [diff] [blame] | 46 | * 0 - inode plain without inline data A: |
| 47 | * inode, [xattrs], ... | ... | no-holed data |
Gao Xiang | ec8c244 | 2019-06-24 15:22:51 +0800 | [diff] [blame] | 48 | * 1 - inode VLE compression B (legacy): |
Gao Xiang | aea1286 | 2018-07-26 20:21:44 +0800 | [diff] [blame] | 49 | * inode, [xattrs], extents ... | ... |
| 50 | * 2 - inode plain with inline data C: |
| 51 | * inode, [xattrs], last_inline_data, ... | ... | no-holed data |
Gao Xiang | ec8c244 | 2019-06-24 15:22:51 +0800 | [diff] [blame] | 52 | * 3 - inode compression D: |
| 53 | * inode, [xattrs], map_header, extents ... | ... |
| 54 | * 4~7 - reserved |
Gao Xiang | aea1286 | 2018-07-26 20:21:44 +0800 | [diff] [blame] | 55 | */ |
| 56 | enum { |
Gao Xiang | 60a49ba | 2019-09-04 10:08:49 +0800 | [diff] [blame] | 57 | EROFS_INODE_FLAT_PLAIN = 0, |
| 58 | EROFS_INODE_FLAT_COMPRESSION_LEGACY = 1, |
| 59 | EROFS_INODE_FLAT_INLINE = 2, |
| 60 | EROFS_INODE_FLAT_COMPRESSION = 3, |
Gao Xiang | 8a76568 | 2019-09-04 10:08:54 +0800 | [diff] [blame] | 61 | EROFS_INODE_DATALAYOUT_MAX |
Gao Xiang | aea1286 | 2018-07-26 20:21:44 +0800 | [diff] [blame] | 62 | }; |
Gao Xiang | ccd9c19 | 2018-12-12 01:57:30 +0800 | [diff] [blame] | 63 | |
Gao Xiang | 3d2969f | 2019-08-13 10:30:52 +0800 | [diff] [blame] | 64 | static inline bool erofs_inode_is_data_compressed(unsigned int datamode) |
Gao Xiang | ec8c244 | 2019-06-24 15:22:51 +0800 | [diff] [blame] | 65 | { |
Gao Xiang | c39747f | 2019-09-04 10:08:52 +0800 | [diff] [blame] | 66 | return datamode == EROFS_INODE_FLAT_COMPRESSION || |
| 67 | datamode == EROFS_INODE_FLAT_COMPRESSION_LEGACY; |
Gao Xiang | ec8c244 | 2019-06-24 15:22:51 +0800 | [diff] [blame] | 68 | } |
| 69 | |
Gao Xiang | ccd9c19 | 2018-12-12 01:57:30 +0800 | [diff] [blame] | 70 | /* bit definitions of inode i_advise */ |
Gao Xiang | aea1286 | 2018-07-26 20:21:44 +0800 | [diff] [blame] | 71 | #define EROFS_I_VERSION_BITS 1 |
Gao Xiang | 8a76568 | 2019-09-04 10:08:54 +0800 | [diff] [blame] | 72 | #define EROFS_I_DATALAYOUT_BITS 3 |
Gao Xiang | aea1286 | 2018-07-26 20:21:44 +0800 | [diff] [blame] | 73 | |
| 74 | #define EROFS_I_VERSION_BIT 0 |
Gao Xiang | 8a76568 | 2019-09-04 10:08:54 +0800 | [diff] [blame] | 75 | #define EROFS_I_DATALAYOUT_BIT 1 |
Gao Xiang | aea1286 | 2018-07-26 20:21:44 +0800 | [diff] [blame] | 76 | |
Gao Xiang | 4b66eb5 | 2019-09-04 10:08:48 +0800 | [diff] [blame] | 77 | /* 32-byte reduced form of an ondisk inode */ |
Gao Xiang | 8a76568 | 2019-09-04 10:08:54 +0800 | [diff] [blame] | 78 | struct erofs_inode_compact { |
| 79 | __le16 i_format; /* inode format hints */ |
Gao Xiang | aea1286 | 2018-07-26 20:21:44 +0800 | [diff] [blame] | 80 | |
| 81 | /* 1 header + n-1 * 4 bytes inline xattr to keep continuity */ |
Gao Xiang | 4b66eb5 | 2019-09-04 10:08:48 +0800 | [diff] [blame] | 82 | __le16 i_xattr_icount; |
| 83 | __le16 i_mode; |
| 84 | __le16 i_nlink; |
| 85 | __le32 i_size; |
| 86 | __le32 i_reserved; |
| 87 | union { |
Gao Xiang | aea1286 | 2018-07-26 20:21:44 +0800 | [diff] [blame] | 88 | /* file total compressed blocks for data mapping 1 */ |
| 89 | __le32 compressed_blocks; |
| 90 | __le32 raw_blkaddr; |
| 91 | |
| 92 | /* for device files, used to indicate old/new device # */ |
| 93 | __le32 rdev; |
Gao Xiang | ed34aa4 | 2019-09-04 10:08:51 +0800 | [diff] [blame] | 94 | } i_u; |
Gao Xiang | 4b66eb5 | 2019-09-04 10:08:48 +0800 | [diff] [blame] | 95 | __le32 i_ino; /* only used for 32-bit stat compatibility */ |
| 96 | __le16 i_uid; |
| 97 | __le16 i_gid; |
| 98 | __le32 i_reserved2; |
Gao Xiang | ed34aa4 | 2019-09-04 10:08:51 +0800 | [diff] [blame] | 99 | }; |
Gao Xiang | aea1286 | 2018-07-26 20:21:44 +0800 | [diff] [blame] | 100 | |
| 101 | /* 32 bytes on-disk inode */ |
Gao Xiang | 8a76568 | 2019-09-04 10:08:54 +0800 | [diff] [blame] | 102 | #define EROFS_INODE_LAYOUT_COMPACT 0 |
Gao Xiang | aea1286 | 2018-07-26 20:21:44 +0800 | [diff] [blame] | 103 | /* 64 bytes on-disk inode */ |
Gao Xiang | 8a76568 | 2019-09-04 10:08:54 +0800 | [diff] [blame] | 104 | #define EROFS_INODE_LAYOUT_EXTENDED 1 |
Gao Xiang | aea1286 | 2018-07-26 20:21:44 +0800 | [diff] [blame] | 105 | |
Gao Xiang | 4b66eb5 | 2019-09-04 10:08:48 +0800 | [diff] [blame] | 106 | /* 64-byte complete form of an ondisk inode */ |
Gao Xiang | 8a76568 | 2019-09-04 10:08:54 +0800 | [diff] [blame] | 107 | struct erofs_inode_extended { |
| 108 | __le16 i_format; /* inode format hints */ |
Gao Xiang | aea1286 | 2018-07-26 20:21:44 +0800 | [diff] [blame] | 109 | |
Gao Xiang | cead56f | 2019-07-31 23:57:34 +0800 | [diff] [blame] | 110 | /* 1 header + n-1 * 4 bytes inline xattr to keep continuity */ |
Gao Xiang | 4b66eb5 | 2019-09-04 10:08:48 +0800 | [diff] [blame] | 111 | __le16 i_xattr_icount; |
| 112 | __le16 i_mode; |
| 113 | __le16 i_reserved; |
| 114 | __le64 i_size; |
| 115 | union { |
Gao Xiang | aea1286 | 2018-07-26 20:21:44 +0800 | [diff] [blame] | 116 | /* file total compressed blocks for data mapping 1 */ |
| 117 | __le32 compressed_blocks; |
| 118 | __le32 raw_blkaddr; |
| 119 | |
| 120 | /* for device files, used to indicate old/new device # */ |
| 121 | __le32 rdev; |
Gao Xiang | ed34aa4 | 2019-09-04 10:08:51 +0800 | [diff] [blame] | 122 | } i_u; |
Gao Xiang | aea1286 | 2018-07-26 20:21:44 +0800 | [diff] [blame] | 123 | |
| 124 | /* only used for 32-bit stat compatibility */ |
Gao Xiang | 4b66eb5 | 2019-09-04 10:08:48 +0800 | [diff] [blame] | 125 | __le32 i_ino; |
Gao Xiang | aea1286 | 2018-07-26 20:21:44 +0800 | [diff] [blame] | 126 | |
Gao Xiang | 4b66eb5 | 2019-09-04 10:08:48 +0800 | [diff] [blame] | 127 | __le32 i_uid; |
| 128 | __le32 i_gid; |
| 129 | __le64 i_ctime; |
| 130 | __le32 i_ctime_nsec; |
| 131 | __le32 i_nlink; |
| 132 | __u8 i_reserved2[16]; |
Gao Xiang | ed34aa4 | 2019-09-04 10:08:51 +0800 | [diff] [blame] | 133 | }; |
Gao Xiang | aea1286 | 2018-07-26 20:21:44 +0800 | [diff] [blame] | 134 | |
| 135 | #define EROFS_MAX_SHARED_XATTRS (128) |
| 136 | /* h_shared_count between 129 ... 255 are special # */ |
| 137 | #define EROFS_SHARED_XATTR_EXTENT (255) |
| 138 | |
| 139 | /* |
| 140 | * inline xattrs (n == i_xattr_icount): |
| 141 | * erofs_xattr_ibody_header(1) + (n - 1) * 4 bytes |
| 142 | * 12 bytes / \ |
| 143 | * / \ |
| 144 | * /-----------------------\ |
| 145 | * | erofs_xattr_entries+ | |
| 146 | * +-----------------------+ |
| 147 | * inline xattrs must starts in erofs_xattr_ibody_header, |
| 148 | * for read-only fs, no need to introduce h_refcount |
| 149 | */ |
| 150 | struct erofs_xattr_ibody_header { |
Gao Xiang | cead56f | 2019-07-31 23:57:34 +0800 | [diff] [blame] | 151 | __le32 h_reserved; |
Gao Xiang | aea1286 | 2018-07-26 20:21:44 +0800 | [diff] [blame] | 152 | __u8 h_shared_count; |
Gao Xiang | cead56f | 2019-07-31 23:57:34 +0800 | [diff] [blame] | 153 | __u8 h_reserved2[7]; |
Gao Xiang | aea1286 | 2018-07-26 20:21:44 +0800 | [diff] [blame] | 154 | __le32 h_shared_xattrs[0]; /* shared xattr id array */ |
Gao Xiang | ed34aa4 | 2019-09-04 10:08:51 +0800 | [diff] [blame] | 155 | }; |
Gao Xiang | aea1286 | 2018-07-26 20:21:44 +0800 | [diff] [blame] | 156 | |
| 157 | /* Name indexes */ |
| 158 | #define EROFS_XATTR_INDEX_USER 1 |
| 159 | #define EROFS_XATTR_INDEX_POSIX_ACL_ACCESS 2 |
| 160 | #define EROFS_XATTR_INDEX_POSIX_ACL_DEFAULT 3 |
| 161 | #define EROFS_XATTR_INDEX_TRUSTED 4 |
| 162 | #define EROFS_XATTR_INDEX_LUSTRE 5 |
| 163 | #define EROFS_XATTR_INDEX_SECURITY 6 |
| 164 | |
| 165 | /* xattr entry (for both inline & shared xattrs) */ |
| 166 | struct erofs_xattr_entry { |
| 167 | __u8 e_name_len; /* length of name */ |
| 168 | __u8 e_name_index; /* attribute name index */ |
| 169 | __le16 e_value_size; /* size of attribute value */ |
| 170 | /* followed by e_name and e_value */ |
| 171 | char e_name[0]; /* attribute name */ |
Gao Xiang | ed34aa4 | 2019-09-04 10:08:51 +0800 | [diff] [blame] | 172 | }; |
Gao Xiang | aea1286 | 2018-07-26 20:21:44 +0800 | [diff] [blame] | 173 | |
Gao Xiang | b6796ab | 2019-09-04 10:08:50 +0800 | [diff] [blame] | 174 | static inline unsigned int erofs_xattr_ibody_size(__le16 i_xattr_icount) |
| 175 | { |
| 176 | if (!i_xattr_icount) |
| 177 | return 0; |
| 178 | |
| 179 | return sizeof(struct erofs_xattr_ibody_header) + |
| 180 | sizeof(__u32) * (le16_to_cpu(i_xattr_icount) - 1); |
| 181 | } |
Gao Xiang | aea1286 | 2018-07-26 20:21:44 +0800 | [diff] [blame] | 182 | |
| 183 | #define EROFS_XATTR_ALIGN(size) round_up(size, sizeof(struct erofs_xattr_entry)) |
Gao Xiang | b6796ab | 2019-09-04 10:08:50 +0800 | [diff] [blame] | 184 | |
| 185 | static inline unsigned int erofs_xattr_entry_size(struct erofs_xattr_entry *e) |
| 186 | { |
| 187 | return EROFS_XATTR_ALIGN(sizeof(struct erofs_xattr_entry) + |
| 188 | e->e_name_len + le16_to_cpu(e->e_value_size)); |
| 189 | } |
Gao Xiang | aea1286 | 2018-07-26 20:21:44 +0800 | [diff] [blame] | 190 | |
Gao Xiang | ea559e7 | 2019-09-04 10:08:57 +0800 | [diff] [blame] | 191 | /* available compression algorithm types (for h_algorithmtype) */ |
Gao Xiang | ec8c244 | 2019-06-24 15:22:51 +0800 | [diff] [blame] | 192 | enum { |
Gao Xiang | 60a49ba | 2019-09-04 10:08:49 +0800 | [diff] [blame] | 193 | Z_EROFS_COMPRESSION_LZ4 = 0, |
Gao Xiang | ec8c244 | 2019-06-24 15:22:51 +0800 | [diff] [blame] | 194 | Z_EROFS_COMPRESSION_MAX |
| 195 | }; |
| 196 | |
| 197 | /* |
| 198 | * bit 0 : COMPACTED_2B indexes (0 - off; 1 - on) |
| 199 | * e.g. for 4k logical cluster size, 4B if compacted 2B is off; |
| 200 | * (4B) + 2B + (4B) if compacted 2B is on. |
| 201 | */ |
| 202 | #define Z_EROFS_ADVISE_COMPACTED_2B_BIT 0 |
| 203 | |
| 204 | #define Z_EROFS_ADVISE_COMPACTED_2B (1 << Z_EROFS_ADVISE_COMPACTED_2B_BIT) |
| 205 | |
| 206 | struct z_erofs_map_header { |
| 207 | __le32 h_reserved1; |
| 208 | __le16 h_advise; |
| 209 | /* |
| 210 | * bit 0-3 : algorithm type of head 1 (logical cluster type 01); |
| 211 | * bit 4-7 : algorithm type of head 2 (logical cluster type 11). |
| 212 | */ |
| 213 | __u8 h_algorithmtype; |
| 214 | /* |
| 215 | * bit 0-2 : logical cluster bits - 12, e.g. 0 for 4096; |
| 216 | * bit 3-4 : (physical - logical) cluster bits of head 1: |
| 217 | * For example, if logical clustersize = 4096, 1 for 8192. |
| 218 | * bit 5-7 : (physical - logical) cluster bits of head 2. |
| 219 | */ |
| 220 | __u8 h_clusterbits; |
| 221 | }; |
| 222 | |
| 223 | #define Z_EROFS_VLE_LEGACY_HEADER_PADDING 8 |
Gao Xiang | aea1286 | 2018-07-26 20:21:44 +0800 | [diff] [blame] | 224 | |
| 225 | /* |
Gao Xiang | ea559e7 | 2019-09-04 10:08:57 +0800 | [diff] [blame] | 226 | * Fixed-sized output compression ondisk Logical Extent cluster type: |
Gao Xiang | aea1286 | 2018-07-26 20:21:44 +0800 | [diff] [blame] | 227 | * 0 - literal (uncompressed) cluster |
| 228 | * 1 - compressed cluster (for the head logical cluster) |
| 229 | * 2 - compressed cluster (for the other logical clusters) |
| 230 | * |
| 231 | * In detail, |
| 232 | * 0 - literal (uncompressed) cluster, |
| 233 | * di_advise = 0 |
| 234 | * di_clusterofs = the literal data offset of the cluster |
| 235 | * di_blkaddr = the blkaddr of the literal cluster |
| 236 | * |
| 237 | * 1 - compressed cluster (for the head logical cluster) |
| 238 | * di_advise = 1 |
| 239 | * di_clusterofs = the decompressed data offset of the cluster |
| 240 | * di_blkaddr = the blkaddr of the compressed cluster |
| 241 | * |
| 242 | * 2 - compressed cluster (for the other logical clusters) |
| 243 | * di_advise = 2 |
| 244 | * di_clusterofs = |
| 245 | * the decompressed data offset in its own head cluster |
| 246 | * di_u.delta[0] = distance to its corresponding head cluster |
| 247 | * di_u.delta[1] = distance to its corresponding tail cluster |
| 248 | * (di_advise could be 0, 1 or 2) |
| 249 | */ |
Gao Xiang | 99691b4 | 2018-08-21 22:49:33 +0800 | [diff] [blame] | 250 | enum { |
Gao Xiang | 60a49ba | 2019-09-04 10:08:49 +0800 | [diff] [blame] | 251 | Z_EROFS_VLE_CLUSTER_TYPE_PLAIN = 0, |
| 252 | Z_EROFS_VLE_CLUSTER_TYPE_HEAD = 1, |
| 253 | Z_EROFS_VLE_CLUSTER_TYPE_NONHEAD = 2, |
| 254 | Z_EROFS_VLE_CLUSTER_TYPE_RESERVED = 3, |
Gao Xiang | 99691b4 | 2018-08-21 22:49:33 +0800 | [diff] [blame] | 255 | Z_EROFS_VLE_CLUSTER_TYPE_MAX |
| 256 | }; |
| 257 | |
Gao Xiang | aea1286 | 2018-07-26 20:21:44 +0800 | [diff] [blame] | 258 | #define Z_EROFS_VLE_DI_CLUSTER_TYPE_BITS 2 |
| 259 | #define Z_EROFS_VLE_DI_CLUSTER_TYPE_BIT 0 |
| 260 | |
| 261 | struct z_erofs_vle_decompressed_index { |
| 262 | __le16 di_advise; |
| 263 | /* where to decompress in the head cluster */ |
| 264 | __le16 di_clusterofs; |
| 265 | |
| 266 | union { |
| 267 | /* for the head cluster */ |
| 268 | __le32 blkaddr; |
| 269 | /* |
| 270 | * for the rest clusters |
| 271 | * eg. for 4k page-sized cluster, maximum 4K*64k = 256M) |
| 272 | * [0] - pointing to the head cluster |
| 273 | * [1] - pointing to the tail cluster |
| 274 | */ |
| 275 | __le16 delta[2]; |
Gao Xiang | ed34aa4 | 2019-09-04 10:08:51 +0800 | [diff] [blame] | 276 | } di_u; |
| 277 | }; |
Gao Xiang | aea1286 | 2018-07-26 20:21:44 +0800 | [diff] [blame] | 278 | |
Gao Xiang | ec8c244 | 2019-06-24 15:22:51 +0800 | [diff] [blame] | 279 | #define Z_EROFS_VLE_LEGACY_INDEX_ALIGN(size) \ |
| 280 | (round_up(size, sizeof(struct z_erofs_vle_decompressed_index)) + \ |
| 281 | sizeof(struct z_erofs_map_header) + Z_EROFS_VLE_LEGACY_HEADER_PADDING) |
Gao Xiang | aea1286 | 2018-07-26 20:21:44 +0800 | [diff] [blame] | 282 | |
| 283 | /* dirent sorts in alphabet order, thus we can do binary search */ |
| 284 | struct erofs_dirent { |
Gao Xiang | 4b66eb5 | 2019-09-04 10:08:48 +0800 | [diff] [blame] | 285 | __le64 nid; /* node number */ |
| 286 | __le16 nameoff; /* start offset of file name */ |
| 287 | __u8 file_type; /* file type */ |
| 288 | __u8 reserved; /* reserved */ |
Gao Xiang | aea1286 | 2018-07-26 20:21:44 +0800 | [diff] [blame] | 289 | } __packed; |
| 290 | |
Gao Xiang | 1d819c5 | 2019-08-16 15:11:42 +0800 | [diff] [blame] | 291 | /* |
| 292 | * EROFS file types should match generic FT_* types and |
| 293 | * it seems no need to add BUILD_BUG_ONs since potential |
| 294 | * unmatchness will break other fses as well... |
| 295 | */ |
Gao Xiang | aea1286 | 2018-07-26 20:21:44 +0800 | [diff] [blame] | 296 | |
| 297 | #define EROFS_NAME_LEN 255 |
| 298 | |
| 299 | /* check the EROFS on-disk layout strictly at compile time */ |
| 300 | static inline void erofs_check_ondisk_layout_definitions(void) |
| 301 | { |
| 302 | BUILD_BUG_ON(sizeof(struct erofs_super_block) != 128); |
Gao Xiang | 8a76568 | 2019-09-04 10:08:54 +0800 | [diff] [blame] | 303 | BUILD_BUG_ON(sizeof(struct erofs_inode_compact) != 32); |
| 304 | BUILD_BUG_ON(sizeof(struct erofs_inode_extended) != 64); |
Gao Xiang | aea1286 | 2018-07-26 20:21:44 +0800 | [diff] [blame] | 305 | BUILD_BUG_ON(sizeof(struct erofs_xattr_ibody_header) != 12); |
| 306 | BUILD_BUG_ON(sizeof(struct erofs_xattr_entry) != 4); |
Gao Xiang | ec8c244 | 2019-06-24 15:22:51 +0800 | [diff] [blame] | 307 | BUILD_BUG_ON(sizeof(struct z_erofs_map_header) != 8); |
Gao Xiang | aea1286 | 2018-07-26 20:21:44 +0800 | [diff] [blame] | 308 | BUILD_BUG_ON(sizeof(struct z_erofs_vle_decompressed_index) != 8); |
| 309 | BUILD_BUG_ON(sizeof(struct erofs_dirent) != 12); |
Gao Xiang | 99691b4 | 2018-08-21 22:49:33 +0800 | [diff] [blame] | 310 | |
| 311 | BUILD_BUG_ON(BIT(Z_EROFS_VLE_DI_CLUSTER_TYPE_BITS) < |
| 312 | Z_EROFS_VLE_CLUSTER_TYPE_MAX - 1); |
Gao Xiang | aea1286 | 2018-07-26 20:21:44 +0800 | [diff] [blame] | 313 | } |
| 314 | |
| 315 | #endif |
| 316 | |