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