Skip to content

Commit eeb0f88

Browse files
dmcgowank8s-infra-cherrypick-robot
authored andcommitted
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 <[email protected]>
1 parent efd86f2 commit eeb0f88

1 file changed

Lines changed: 22 additions & 0 deletions

File tree

plugins/diff/erofs/differ.go

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import (
2222
"io"
2323
"os"
2424
"path"
25+
"runtime"
2526
"strings"
2627
"time"
2728

@@ -82,6 +83,9 @@ func NewErofsDiffer(store content.Store, opts ...DifferOpt) differ {
8283
opt(d)
8384
}
8485

86+
// Add default block size on darwin if not already specified
87+
d.mkfsExtraOpts = addDefaultMkfsOpts(d.mkfsExtraOpts)
88+
8589
return d
8690
}
8791

@@ -211,3 +215,21 @@ func (rc *readCounter) Read(p []byte) (n int, err error) {
211215
rc.c += int64(n)
212216
return
213217
}
218+
219+
// addDefaultMkfsOpts adds default options for mkfs.erofs
220+
func addDefaultMkfsOpts(mkfsExtraOpts []string) []string {
221+
if runtime.GOOS != "darwin" {
222+
return mkfsExtraOpts
223+
}
224+
225+
// Check if -b argument is already present
226+
for _, opt := range mkfsExtraOpts {
227+
if strings.HasPrefix(opt, "-b") {
228+
return mkfsExtraOpts
229+
}
230+
}
231+
232+
// Add -b4096 as the first option to prevent unusable block
233+
// size from being used on macOS.
234+
return append([]string{"-b4096"}, mkfsExtraOpts...)
235+
}

0 commit comments

Comments
 (0)