[PATCH 1/9] erofs-utils: lib: sync up with the latest erofs_fs.h

Gao Xiang hsiangkao at linux.alibaba.com
Thu Feb 6 23:50:26 AEDT 2025


Mainly commit 745ed7d77834 ("erofs: cleanup i_format-related stuffs")
and commit 7c3ca1838a78 ("erofs: restrict pcluster size limitations")

Signed-off-by: Gao Xiang <hsiangkao at linux.alibaba.com>
---
 include/erofs/internal.h | 16 ++++------------
 include/erofs_fs.h       | 15 ++++++++-------
 2 files changed, 12 insertions(+), 19 deletions(-)

diff --git a/include/erofs/internal.h b/include/erofs/internal.h
index eb665e2..7f01782 100644
--- a/include/erofs/internal.h
+++ b/include/erofs/internal.h
@@ -292,22 +292,14 @@ static inline bool is_inode_layout_compression(struct erofs_inode *inode)
 	return erofs_inode_is_data_compressed(inode->datalayout);
 }
 
-static inline unsigned int erofs_bitrange(unsigned int value, unsigned int bit,
-					  unsigned int bits)
+static inline unsigned int erofs_inode_version(unsigned int ifmt)
 {
-	return (value >> bit) & ((1 << bits) - 1);
+	return (ifmt >> EROFS_I_VERSION_BIT) & EROFS_I_VERSION_MASK;
 }
 
-static inline unsigned int erofs_inode_version(unsigned int value)
+static inline unsigned int erofs_inode_datalayout(unsigned int ifmt)
 {
-	return erofs_bitrange(value, EROFS_I_VERSION_BIT,
-			      EROFS_I_VERSION_BITS);
-}
-
-static inline unsigned int erofs_inode_datalayout(unsigned int value)
-{
-	return erofs_bitrange(value, EROFS_I_DATALAYOUT_BIT,
-			      EROFS_I_DATALAYOUT_BITS);
+	return (ifmt >> EROFS_I_DATALAYOUT_BIT) & EROFS_I_DATALAYOUT_MASK;
 }
 
 static inline struct erofs_inode *erofs_parent_inode(struct erofs_inode *inode)
diff --git a/include/erofs_fs.h b/include/erofs_fs.h
index 9c69aac..5672c99 100644
--- a/include/erofs_fs.h
+++ b/include/erofs_fs.h
@@ -10,6 +10,7 @@
 #define __EROFS_FS_H
 
 #define EROFS_SUPER_MAGIC_V1    0xE0F5E1E2
+/* to allow for x86 boot sectors and other oddities. */
 #define EROFS_SUPER_OFFSET      1024
 
 #define EROFS_FEATURE_COMPAT_SB_CHKSUM          0x00000001
@@ -55,7 +56,7 @@ struct erofs_deviceslot {
 /* erofs on-disk super block (currently 128 bytes) */
 struct erofs_super_block {
 	__le32 magic;           /* file system magic number */
-	__le32 checksum;        /* crc32c(super_block) */
+	__le32 checksum;        /* crc32c to avoid unexpected on-disk overlap */
 	__le32 feature_compat;
 	__u8 blkszbits;         /* filesystem block size in bit shift */
 	__u8 sb_extslots;	/* superblock size = 128 + sb_extslots * 16 */
@@ -112,14 +113,14 @@ static inline bool erofs_inode_is_data_compressed(unsigned int datamode)
 }
 
 /* bit definitions of inode i_format */
-#define EROFS_I_VERSION_BITS            1
-#define EROFS_I_DATALAYOUT_BITS         3
+#define EROFS_I_VERSION_MASK            0x01
+#define EROFS_I_DATALAYOUT_MASK         0x07
 
 #define EROFS_I_VERSION_BIT             0
 #define EROFS_I_DATALAYOUT_BIT          1
+#define EROFS_I_ALL_BIT			4
 
-#define EROFS_I_ALL	\
-	((1 << (EROFS_I_DATALAYOUT_BIT + EROFS_I_DATALAYOUT_BITS)) - 1)
+#define EROFS_I_ALL	((1 << EROFS_I_ALL_BIT) - 1)
 
 /* indicate chunk blkbits, thus 'chunksize = blocksize << chunk blkbits' */
 #define EROFS_CHUNK_FORMAT_BLKBITS_MASK		0x001F
@@ -334,11 +335,11 @@ struct z_erofs_deflate_cfgs {
 /* 6 bytes (+ length field = 8 bytes) */
 struct z_erofs_zstd_cfgs {
 	u8 format;
-	u8 windowlog;		/* windowLog - ZSTD_WINDOWLOG_ABSOLUTEMIN(10) */
+	u8 windowlog;           /* windowLog - ZSTD_WINDOWLOG_ABSOLUTEMIN(10) */
 	u8 reserved[4];
 } __packed;
 
-#define Z_EROFS_ZSTD_MAX_DICT_SIZE	Z_EROFS_PCLUSTER_MAX_SIZE
+#define Z_EROFS_ZSTD_MAX_DICT_SIZE      Z_EROFS_PCLUSTER_MAX_SIZE
 
 /*
  * bit 0 : COMPACTED_2B indexes (0 - off; 1 - on)
-- 
2.43.5



More information about the Linux-erofs mailing list