aboutsummaryrefslogtreecommitdiffhomepage
path: root/container/init.go
diff options
context:
space:
mode:
authorOphestra <cat@gensokyo.uk>2025-08-17 01:29:54 +0900
committerOphestra <cat@gensokyo.uk>2025-08-17 01:32:07 +0900
commit8aa65f28c68815db9dd1f246ee2656759574c3bb (patch)
tree5bd72d78f6a77defb5cda3767016f97a7f1c2adc /container/init.go
parentf9edec7e4169ecda63ba15762f12e64803b9984d (diff)
container: allow additional state between ops
This is useful for ops that need to be aware of previous instances of themselves. Signed-off-by: Ophestra <cat@gensokyo.uk>
Diffstat (limited to 'container/init.go')
-rw-r--r--container/init.go6
1 files changed, 4 insertions, 2 deletions
diff --git a/container/init.go b/container/init.go
index 03ec8836..f162de26 100644
--- a/container/init.go
+++ b/container/init.go
@@ -121,6 +121,8 @@ func Init(prepare func(prefix string), setVerbose func(verbose bool)) {
log.Fatalf("cannot make / rslave: %v", err)
}
+ state := &setupState{Params: &params.Params}
+
/* early is called right before pivot_root into intermediate root;
this step is mostly for gathering information that would otherwise be difficult to obtain
via library functions after pivot_root, and implementations are expected to avoid changing
@@ -130,7 +132,7 @@ func Init(prepare func(prefix string), setVerbose func(verbose bool)) {
log.Fatalf("invalid op %d", i)
}
- if err := op.early(&params.Params); err != nil {
+ if err := op.early(state); err != nil {
msg.PrintBaseErr(err,
fmt.Sprintf("cannot prepare op %d:", i))
msg.BeforeExit()
@@ -170,7 +172,7 @@ func Init(prepare func(prefix string), setVerbose func(verbose bool)) {
for i, op := range *params.Ops {
// ops already checked during early setup
msg.Verbosef("%s %s", op.prefix(), op)
- if err := op.apply(&params.Params); err != nil {
+ if err := op.apply(state); err != nil {
msg.PrintBaseErr(err,
fmt.Sprintf("cannot apply op %d:", i))
msg.BeforeExit()