erofs-utils: Set mkfs default blocksize based on current platform
authorSandeep Dhavale <dhavale@google.com>
Wed, 30 Aug 2023 23:16:06 +0000 (16:16 -0700)
committerGao Xiang <hsiangkao@linux.alibaba.com>
Thu, 31 Aug 2023 14:46:00 +0000 (22:46 +0800)
Set mkfs default blocksize to current platform pagesize.
This means mkfs with default options will work on current
platform. If we are building image for a platform for a different
blocksize, we can override default with -b option up to
EROFS_MAX_BLOCK_SIZE.

Signed-off-by: Sandeep Dhavale <dhavale@google.com>
Link: https://lore.kernel.org/r/20230830231606.3783734-2-dhavale@google.com
[ Gao Xiang: compare with EROFS_MAX_BLOCK_SIZE for safety. ]
Signed-off-by: Gao Xiang <hsiangkao@linux.alibaba.com>
mkfs/main.c

index 7225c400f4889710b595d1df3e84692a5e17748b..16da9c0af3967d3e06bd36b4adea54a76561d9ca 100644 (file)
@@ -705,7 +705,7 @@ static void erofs_mkfs_default_options(void)
        cfg.c_showprogress = true;
        cfg.c_legacy_compress = false;
        cfg.c_xattr_name_filter = true;
-       sbi.blkszbits = ilog2(EROFS_MAX_BLOCK_SIZE);
+       sbi.blkszbits = ilog2(min_t(u32, getpagesize(), EROFS_MAX_BLOCK_SIZE));
        sbi.feature_incompat = EROFS_FEATURE_INCOMPAT_ZERO_PADDING;
        sbi.feature_compat = EROFS_FEATURE_COMPAT_SB_CHKSUM |
                             EROFS_FEATURE_COMPAT_MTIME;