diff options
| author | Ophestra <cat@gensokyo.uk> | 2025-09-28 21:51:10 +0900 |
|---|---|---|
| committer | Ophestra <cat@gensokyo.uk> | 2025-09-28 21:51:10 +0900 |
| commit | e55822c62f7287698a683e6e7e40aa9a992b5585 (patch) | |
| tree | 19f5e8e2614c86c9a79f8264b49a2b48e13fabee /container/autoroot.go | |
| parent | 802e6afa34de7f6124157153b0bde4ac25d7b363 (diff) | |
container/init: reduce verbose noise
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>
Diffstat (limited to 'container/autoroot.go')
| -rw-r--r-- | container/autoroot.go | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/container/autoroot.go b/container/autoroot.go index 9d456099..c37e49bc 100644 --- a/container/autoroot.go +++ b/container/autoroot.go @@ -22,7 +22,7 @@ type AutoRootOp struct { // obtained during early; // these wrap the underlying Op because BindMountOp is relatively complex, // so duplicating that code would be unwise - resolved []Op + resolved []*BindMountOp } func (r *AutoRootOp) Valid() bool { return r != nil && r.Host != nil } @@ -31,10 +31,11 @@ func (r *AutoRootOp) early(state *setupState, k syscallDispatcher) error { if d, err := k.readdir(r.Host.String()); err != nil { return err } else { - r.resolved = make([]Op, 0, len(d)) + r.resolved = make([]*BindMountOp, 0, len(d)) for _, ent := range d { name := ent.Name() if IsAutoRootBindable(name) { + // careful: the Valid method is skipped, make sure this is always valid op := &BindMountOp{ Source: r.Host.Append(name), Target: AbsFHSRoot.Append(name), @@ -57,7 +58,7 @@ func (r *AutoRootOp) apply(state *setupState, k syscallDispatcher) error { state.nonrepeatable |= nrAutoRoot for _, op := range r.resolved { - k.verbosef("%s %s", op.prefix(), op) + // these are exclusively BindMountOp, do not attempt to print identifying message if err := op.apply(state, k); err != nil { return err } @@ -71,7 +72,7 @@ func (r *AutoRootOp) Is(op Op) bool { r.Host.Is(vr.Host) && r.Flags == vr.Flags } -func (*AutoRootOp) prefix() string { return "setting up" } +func (*AutoRootOp) prefix() (string, bool) { return "setting up", true } func (r *AutoRootOp) String() string { return fmt.Sprintf("auto root %q flags %#x", r.Host, r.Flags) } |
