diff options
| author | Ophestra <cat@gensokyo.uk> | 2025-08-20 01:26:41 +0900 |
|---|---|---|
| committer | Ophestra <cat@gensokyo.uk> | 2025-08-20 01:28:31 +0900 |
| commit | c81c9a9d75f179988cf858b85fe2de71bf9c2ff4 (patch) | |
| tree | 157723a3f9a6f8a456fc939a1ef56e8e597d70f3 /container/initremount.go | |
| parent | 339e4080dce73d372f6111773066b9c84308b6b7 (diff) | |
container/init: split setup ops into individual files
This significantly increases readability.
Signed-off-by: Ophestra <cat@gensokyo.uk>
Diffstat (limited to 'container/initremount.go')
| -rw-r--r-- | container/initremount.go | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/container/initremount.go b/container/initremount.go new file mode 100644 index 00000000..2b290af0 --- /dev/null +++ b/container/initremount.go @@ -0,0 +1,34 @@ +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 == *vr } +func (*RemountOp) prefix() string { return "remounting" } +func (r *RemountOp) String() string { return fmt.Sprintf("%q flags %#x", r.Target, r.Flags) } |
