diff options
author | Gao Xiang <hsiangkao@redhat.com> | 2020-10-30 20:30:19 +0800 |
---|---|---|
committer | Gao Xiang <hsiangkao@redhat.com> | 2020-11-01 23:44:29 +0800 |
commit | 9d90d5a34718a003edcfaceac1b80617fdbb87b0 (patch) | |
tree | 4c020814e8c93cb9ef7132c1a37dbffcdff2d8c4 | |
parent | 4d109df7f04264eb17892ad0fd2928a1d2bc4542 (diff) |
mkfs: introduce erofs_mkfs_default_options()
Gather all default settings, and generate UUID before
parse_options_cfg(), therefore the UUID can be overridden
later by command line for reproducible images.
Link: https://lore.kernel.org/r/20201030123020.133084-3-hsiangkao@redhat.com
Reviewed-by: Li Guifu <bluce.lee@aliyun.com>
Signed-off-by: Gao Xiang <hsiangkao@redhat.com>
-rw-r--r-- | mkfs/main.c | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/mkfs/main.c b/mkfs/main.c index 5c41fc0..0e17314 100644 --- a/mkfs/main.c +++ b/mkfs/main.c @@ -368,18 +368,18 @@ static int erofs_mkfs_superblock_csum_set(void) return 0; } -static void erofs_mkfs_generate_uuid(void) +static void erofs_mkfs_default_options(void) { - char uuid_str[37] = "not available"; + cfg.c_legacy_compress = false; + sbi.feature_incompat = EROFS_FEATURE_INCOMPAT_LZ4_0PADDING; + sbi.feature_compat = EROFS_FEATURE_COMPAT_SB_CHKSUM; + /* generate a default uuid first */ #ifdef HAVE_LIBUUID do { uuid_generate(sbi.uuid); } while (uuid_is_null(sbi.uuid)); - - uuid_unparse_lower(sbi.uuid, uuid_str); #endif - erofs_info("filesystem UUID: %s", uuid_str); } /* https://reproducible-builds.org/specs/source-date-epoch/ for more details */ @@ -418,13 +418,12 @@ int main(int argc, char **argv) struct stat64 st; erofs_blk_t nblocks; struct timeval t; + char uuid_str[37] = "not available"; erofs_init_configure(); fprintf(stderr, "%s %s\n", basename(argv[0]), cfg.c_version); - cfg.c_legacy_compress = false; - sbi.feature_incompat = EROFS_FEATURE_INCOMPAT_LZ4_0PADDING; - sbi.feature_compat = EROFS_FEATURE_COMPAT_SB_CHKSUM; + erofs_mkfs_default_options(); err = mkfs_parse_options_cfg(argc, argv); if (err) { @@ -495,7 +494,11 @@ int main(int argc, char **argv) goto exit; } - erofs_mkfs_generate_uuid(); +#ifdef HAVE_LIBUUID + uuid_unparse_lower(sbi.uuid, uuid_str); +#endif + erofs_info("filesystem UUID: %s", uuid_str); + erofs_inode_manager_init(); err = erofs_build_shared_xattrs_from_path(cfg.c_src_path); |