From a092b042abca15ce3ba9def9b502d8a7cb889c1b Mon Sep 17 00:00:00 2001 From: Ophestra Date: Fri, 14 Mar 2025 02:11:38 +0900 Subject: [PATCH] sandbox: pass params to setup ops Signed-off-by: Ophestra --- internal/sandbox/container.go | 2 +- internal/sandbox/init.go | 2 +- internal/sandbox/sequential.go | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/internal/sandbox/container.go b/internal/sandbox/container.go index 91db06e..4f8be1d 100644 --- a/internal/sandbox/container.go +++ b/internal/sandbox/container.go @@ -90,7 +90,7 @@ type ( Ops []Op Op interface { - apply() error + apply(params *InitParams) error Is(op Op) bool fmt.Stringer diff --git a/internal/sandbox/init.go b/internal/sandbox/init.go index 1b9bbf8..83bb168 100644 --- a/internal/sandbox/init.go +++ b/internal/sandbox/init.go @@ -126,7 +126,7 @@ func Init(exit func(code int)) { for i, op := range *params.Ops { fmsg.Verbosef("mounting %s", op) - if err := op.apply(); err != nil { + if err := op.apply(¶ms.InitParams); err != nil { fmsg.PrintBaseError(err, fmt.Sprintf("cannot apply op %d:", i)) exit(1) diff --git a/internal/sandbox/sequential.go b/internal/sandbox/sequential.go index 445ae8f..75d6268 100644 --- a/internal/sandbox/sequential.go +++ b/internal/sandbox/sequential.go @@ -20,7 +20,7 @@ type BindMount struct { Flags int } -func (b *BindMount) apply() error { +func (b *BindMount) apply(*InitParams) error { if !path.IsAbs(b.Source) || !path.IsAbs(b.Target) { return fmsg.WrapError(syscall.EBADE, "path is not absolute") @@ -47,7 +47,7 @@ type MountProc struct { Path string } -func (p *MountProc) apply() error { +func (p *MountProc) apply(*InitParams) error { if !path.IsAbs(p.Path) { return fmsg.WrapError(syscall.EBADE, fmt.Sprintf("path %q is not absolute", p.Path)) @@ -78,7 +78,7 @@ type MountTmpfs struct { Perm os.FileMode } -func (t *MountTmpfs) apply() error { +func (t *MountTmpfs) apply(*InitParams) error { if !path.IsAbs(t.Path) { return fmsg.WrapError(syscall.EBADE, fmt.Sprintf("path %q is not absolute", t.Path))