All checks were successful
Test / Create distribution (push) Successful in 35s
Test / Sandbox (push) Successful in 2m11s
Test / Hakurei (push) Successful in 3m5s
Test / Hpkg (push) Successful in 4m6s
Test / Sandbox (race detector) (push) Successful in 4m24s
Test / Hakurei (race detector) (push) Successful in 5m3s
Test / Flake checks (push) Successful in 1m19s
Fixes regression introduced while integrating Absolute. Signed-off-by: Ophestra <cat@gensokyo.uk>
40 lines
1.0 KiB
Go
40 lines
1.0 KiB
Go
package container
|
|
|
|
import (
|
|
"encoding/gob"
|
|
"fmt"
|
|
"syscall"
|
|
)
|
|
|
|
func init() { gob.Register(new(RemountOp)) }
|
|
|
|
// Remount appends an [Op] that applies [RemountOp.Flags] on container path [RemountOp.Target].
|
|
func (f *Ops) Remount(target *Absolute, flags uintptr) *Ops {
|
|
*f = append(*f, &RemountOp{target, flags})
|
|
return f
|
|
}
|
|
|
|
// RemountOp remounts Target with Flags.
|
|
type RemountOp struct {
|
|
Target *Absolute
|
|
Flags uintptr
|
|
}
|
|
|
|
func (*RemountOp) early(*setupState) error { return nil }
|
|
func (r *RemountOp) apply(*setupState) error {
|
|
if r.Target == nil {
|
|
return syscall.EBADE
|
|
}
|
|
return wrapErrSuffix(hostProc.remount(toSysroot(r.Target.String()), r.Flags),
|
|
fmt.Sprintf("cannot remount %q:", r.Target))
|
|
}
|
|
|
|
func (r *RemountOp) Is(op Op) bool {
|
|
vr, ok := op.(*RemountOp)
|
|
return ok && ((r == nil && vr == nil) ||
|
|
(r.Target != nil && vr.Target != nil && r.Target.Is(vr.Target)) &&
|
|
r.Flags == vr.Flags)
|
|
}
|
|
func (*RemountOp) prefix() string { return "remounting" }
|
|
func (r *RemountOp) String() string { return fmt.Sprintf("%q flags %#x", r.Target, r.Flags) }
|