All checks were successful
Test / Create distribution (push) Successful in 34s
Test / Sandbox (push) Successful in 1m49s
Test / Hakurei (push) Successful in 3m17s
Test / Hpkg (push) Successful in 3m42s
Test / Sandbox (race detector) (push) Successful in 4m10s
Test / Hakurei (race detector) (push) Successful in 5m18s
Test / Flake checks (push) Successful in 1m38s
The mount function now wraps its own errors in a much more descriptive type with proper message formatting. Wrapping them no longer makes any sense. Signed-off-by: Ophestra <cat@gensokyo.uk>
37 lines
1.1 KiB
Go
37 lines
1.1 KiB
Go
package container
|
|
|
|
import (
|
|
"encoding/gob"
|
|
"fmt"
|
|
. "syscall"
|
|
)
|
|
|
|
func init() { gob.Register(new(MountProcOp)) }
|
|
|
|
// Proc appends an [Op] that mounts a private instance of proc.
|
|
func (f *Ops) Proc(target *Absolute) *Ops {
|
|
*f = append(*f, &MountProcOp{target})
|
|
return f
|
|
}
|
|
|
|
// MountProcOp mounts a new instance of [FstypeProc] on container path Target.
|
|
type MountProcOp struct{ Target *Absolute }
|
|
|
|
func (p *MountProcOp) Valid() bool { return p != nil && p.Target != nil }
|
|
func (p *MountProcOp) early(*setupState, syscallDispatcher) error { return nil }
|
|
func (p *MountProcOp) apply(state *setupState, k syscallDispatcher) error {
|
|
target := toSysroot(p.Target.String())
|
|
if err := k.mkdirAll(target, state.ParentPerm); err != nil {
|
|
return wrapErrSelf(err)
|
|
}
|
|
return k.mount(SourceProc, target, FstypeProc, MS_NOSUID|MS_NOEXEC|MS_NODEV, zeroString)
|
|
}
|
|
|
|
func (p *MountProcOp) Is(op Op) bool {
|
|
vp, ok := op.(*MountProcOp)
|
|
return ok && p.Valid() && vp.Valid() &&
|
|
p.Target.Is(vp.Target)
|
|
}
|
|
func (*MountProcOp) prefix() string { return "mounting" }
|
|
func (p *MountProcOp) String() string { return fmt.Sprintf("proc on %q", p.Target) }
|