From 01b4c8102b8805fa2e739b5263cddee40f064b23 Mon Sep 17 00:00:00 2001 From: Derek McGowan Date: Mon, 17 Nov 2025 14:54:24 -0800 Subject: [PATCH] Update default erofs block size on macOS during erofs diff Use the Linux default rather than the block size from the local macOS system. The local macOS block size is not relevant as the erofs file will not be mounted directly on macOS. Signed-off-by: Derek McGowan --- plugins/diff/erofs/differ.go | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/plugins/diff/erofs/differ.go b/plugins/diff/erofs/differ.go index c89ad2ddf..a3a1b6df3 100644 --- a/plugins/diff/erofs/differ.go +++ b/plugins/diff/erofs/differ.go @@ -22,6 +22,7 @@ import ( "io" "os" "path" + "runtime" "strings" "time" @@ -82,6 +83,9 @@ func NewErofsDiffer(store content.Store, opts ...DifferOpt) differ { opt(d) } + // Add default block size on darwin if not already specified + d.mkfsExtraOpts = addDefaultMkfsOpts(d.mkfsExtraOpts) + return d } @@ -211,3 +215,21 @@ func (rc *readCounter) Read(p []byte) (n int, err error) { rc.c += int64(n) return } + +// addDefaultMkfsOpts adds default options for mkfs.erofs +func addDefaultMkfsOpts(mkfsExtraOpts []string) []string { + if runtime.GOOS != "darwin" { + return mkfsExtraOpts + } + + // Check if -b argument is already present + for _, opt := range mkfsExtraOpts { + if strings.HasPrefix(opt, "-b") { + return mkfsExtraOpts + } + } + + // Add -b4096 as the first option to prevent unusable block + // size from being used on macOS. + return append([]string{"-b4096"}, mkfsExtraOpts...) +}