All checks were successful
Test / Create distribution (push) Successful in 56s
Test / Sandbox (push) Successful in 2m38s
Test / Hakurei (push) Successful in 3m45s
Test / Hpkg (push) Successful in 4m36s
Test / Sandbox (race detector) (push) Successful in 4m45s
Test / Hakurei (race detector) (push) Successful in 5m43s
Test / Flake checks (push) Successful in 1m41s
This makes it possible to optionally omit the identifying verbose message, for when the Op implementation can provide a much more useful message in its case, using information not yet available to the String method. 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 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, bool) { return "mounting", true }
|
|
func (p *MountProcOp) String() string { return fmt.Sprintf("proc on %q", p.Target) }
|