container/path: use syscall dispatcher
All checks were successful
Test / Create distribution (push) Successful in 34s
Test / Sandbox (push) Successful in 2m8s
Test / Hakurei (push) Successful in 3m14s
Test / Hpkg (push) Successful in 4m8s
Test / Sandbox (race detector) (push) Successful in 4m26s
Test / Hakurei (race detector) (push) Successful in 43s
Test / Flake checks (push) Successful in 1m39s

This allows path and mount functions to be instrumented.

Signed-off-by: Ophestra <cat@gensokyo.uk>
This commit is contained in:
2025-08-22 22:00:40 +09:00
parent 09d2844981
commit afe23600d2
6 changed files with 353 additions and 33 deletions

View File

@@ -131,13 +131,14 @@ func ensureFile(name string, perm, pperm os.FileMode) error {
return err
}
var hostProc = newProcPaths(hostPath)
var hostProc = newProcPaths(direct{}, hostPath)
func newProcPaths(prefix string) *procPaths {
return &procPaths{prefix + "/proc", prefix + "/proc/self"}
func newProcPaths(k syscallDispatcher, prefix string) *procPaths {
return &procPaths{k, prefix + "/proc", prefix + "/proc/self"}
}
type procPaths struct {
k syscallDispatcher
prefix string
self string
}
@@ -145,7 +146,7 @@ type procPaths struct {
func (p *procPaths) stdout() string { return p.self + "/fd/1" }
func (p *procPaths) fd(fd int) string { return p.self + "/fd/" + strconv.Itoa(fd) }
func (p *procPaths) mountinfo(f func(d *vfs.MountInfoDecoder) error) error {
if r, err := os.Open(p.self + "/mountinfo"); err != nil {
if r, err := p.k.openNew(p.self + "/mountinfo"); err != nil {
return wrapErrSelf(err)
} else {
d := vfs.NewMountInfoDecoder(r)