diff options
| author | Robert Marko | 2026-05-20 19:59:10 +0000 |
|---|---|---|
| committer | Robert Marko | 2026-05-23 15:44:55 +0000 |
| commit | 7df188543e26e70b179e649ec227a1dbe8489338 (patch) | |
| tree | b2cced7b718660d70d4d0bec9d807b30cdc824b7 | |
| parent | e600d842ce81b776dc8e2c7aaf39bb923e446c45 (diff) | |
| download | fstools-7df188543e26e70b179e649ec227a1dbe8489338.tar.gz | |
libfstools: enable f2fs overlay compression formatting
When fstools_overlay_compression_type is provided, format f2fs overlays
with the extra_attr and compression feature bits enabled so the
filesystem can later be mounted with compression options.
Log when f2fs overlay compression formatting is enabled to make the
selected path visible during first boot formatting.
Signed-off-by: Robert Marko <robert.marko@sartura.hr>
| -rw-r--r-- | libfstools/common.c | 26 |
1 files changed, 22 insertions, 4 deletions
diff --git a/libfstools/common.c b/libfstools/common.c index 1492793..a948321 100644 --- a/libfstools/common.c +++ b/libfstools/common.c @@ -154,10 +154,21 @@ static bool use_f2fs(struct volume *v, uint64_t offset, const char *bdev) return ret; } +static bool use_f2fs_compression(void) +{ + char typeparam[BUFLEN]; + + if (!get_var_from_file("/proc/cmdline", "fstools_overlay_compression_type", + typeparam, sizeof(typeparam))) + return false; + + return typeparam[0] && strcmp(typeparam, "none"); +} + int block_volume_format(struct volume *v, uint64_t offset, const char *bdev) { int ret = 0; - char str[128]; + char str[256]; unsigned int skip_blocks = 0; int fd; __u32 deadc0de; @@ -205,10 +216,17 @@ int block_volume_format(struct volume *v, uint64_t offset, const char *bdev) } do_format: ULOG_INFO("overlay filesystem in %s has not been formatted yet\n", v->blk); - if (use_f2fs(v, offset, bdev)) - snprintf(str, sizeof(str), "mkfs.f2fs -q -f -l rootfs_data %s", v->blk); - else + if (use_f2fs(v, offset, bdev)) { + if (use_f2fs_compression()) { + ULOG_INFO("f2fs overlay compression enabled\n"); + snprintf(str, sizeof(str), + "mkfs.f2fs -q -f -O extra_attr,compression -l rootfs_data %s", v->blk); + } else { + snprintf(str, sizeof(str), "mkfs.f2fs -q -f -l rootfs_data %s", v->blk); + } + } else { snprintf(str, sizeof(str), "mkfs.ext4 -q -F -L rootfs_data %s", v->blk); + } ret = system(str); break; |