mirror of
https://github.com/containerd/containerd.git
synced 2026-08-04 15:10:45 +00:00
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 <derek@mcg.dev>
This commit is contained in:
@@ -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...)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user