diff options
| author | Ophestra <cat@gensokyo.uk> | 2025-08-21 00:18:50 +0900 |
|---|---|---|
| committer | Ophestra <cat@gensokyo.uk> | 2025-08-21 00:18:50 +0900 |
| commit | 5d8a2199b6c8dc5f75b529a39d196c6cb14c98c2 (patch) | |
| tree | 5ad693466483081342b24df929365490015b4efa /container/initremount.go | |
| parent | a1482ecdd0f98728f4b97137cd7b2fa17f67bb89 (diff) | |
container/init: op interface valid method
Check ops early and eliminate duplicate checks.
Signed-off-by: Ophestra <cat@gensokyo.uk>
Diffstat (limited to 'container/initremount.go')
| -rw-r--r-- | container/initremount.go | 11 |
1 files changed, 4 insertions, 7 deletions
diff --git a/container/initremount.go b/container/initremount.go index 77efc21d..74bea097 100644 --- a/container/initremount.go +++ b/container/initremount.go @@ -3,7 +3,6 @@ package container import ( "encoding/gob" "fmt" - "syscall" ) func init() { gob.Register(new(RemountOp)) } @@ -20,20 +19,18 @@ type RemountOp struct { Flags uintptr } +func (r *RemountOp) Valid() bool { return r != nil && r.Target != nil } 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) + return ok && r.Valid() && vr.Valid() && + 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) } |
