aboutsummaryrefslogtreecommitdiffhomepage
path: root/container/autoetc.go
diff options
context:
space:
mode:
authorOphestra <cat@gensokyo.uk>2025-08-11 02:52:32 +0900
committerOphestra <cat@gensokyo.uk>2025-08-11 04:56:42 +0900
commite99d7affb0c128fa82722f9b3d79c99b5e5918cd (patch)
tree387e08d6c4363d8b9e0462f069c140fbdb15c917 /container/autoetc.go
parent41ac2be9658b49c68cb793f3a6f0c5932d82e1c2 (diff)
container: use absolute for pathname
This is simultaneously more efficient and less error-prone. This change caused minor API changes in multiple other packages. Signed-off-by: Ophestra <cat@gensokyo.uk>
Diffstat (limited to 'container/autoetc.go')
-rw-r--r--container/autoetc.go12
1 files changed, 7 insertions, 5 deletions
diff --git a/container/autoetc.go b/container/autoetc.go
index 3e23c160..56879125 100644
--- a/container/autoetc.go
+++ b/container/autoetc.go
@@ -10,9 +10,9 @@ func init() { gob.Register(new(AutoEtcOp)) }
// Etc appends an [Op] that expands host /etc into a toplevel symlink mirror with /etc semantics.
// This is not a generic setup op. It is implemented here to reduce ipc overhead.
-func (f *Ops) Etc(host, prefix string) *Ops {
+func (f *Ops) Etc(host *Absolute, prefix string) *Ops {
e := &AutoEtcOp{prefix}
- f.Mkdir(FHSEtc, 0755)
+ f.Mkdir(AbsFHSEtc, 0755)
f.Bind(host, e.hostPath(), 0)
*f = append(*f, e)
return f
@@ -28,7 +28,7 @@ func (e *AutoEtcOp) apply(*Params) error {
if err := os.MkdirAll(target, 0755); err != nil {
return wrapErrSelf(err)
}
- if d, err := os.ReadDir(toSysroot(e.hostPath())); err != nil {
+ if d, err := os.ReadDir(toSysroot(e.hostPath().String())); err != nil {
return wrapErrSelf(err)
} else {
for _, ent := range d {
@@ -54,8 +54,10 @@ func (e *AutoEtcOp) apply(*Params) error {
return nil
}
-func (e *AutoEtcOp) hostPath() string { return FHSEtc + e.hostRel() }
-func (e *AutoEtcOp) hostRel() string { return ".host/" + e.Prefix }
+
+// bypasses abs check, use with caution!
+func (e *AutoEtcOp) hostPath() *Absolute { return &Absolute{FHSEtc + e.hostRel()} }
+func (e *AutoEtcOp) hostRel() string { return ".host/" + e.Prefix }
func (e *AutoEtcOp) Is(op Op) bool {
ve, ok := op.(*AutoEtcOp)