aboutsummaryrefslogtreecommitdiffhomepage
path: root/cmd/app/lock.go
diff options
context:
space:
mode:
authorOphestra <cat@gensokyo.uk>2026-09-17 02:30:10 +0900
committerOphestra <cat@gensokyo.uk>2026-09-17 02:30:10 +0900
commit4078289cdadb4def6ae28428ce8bf3c7907f66f1 (patch)
treefd7c9dd9192cc4bb9aeb94c1efb7411687535231 /cmd/app/lock.go
parent3fbdf138bb7ce07319d2c9e3d89b3a3892e139d2 (diff)
cmd/app: alternative merged template layout
This implements an optional, alternative template layout to accommodate ZFS and equivalent setups where each template occupies a different filesystem. In such a setup, the default, separate workdir is unusable as overlayfs requires the workdir to reside on the same filesystem as the writable upperdir. The "merge" build tag enables this alternative behaviour. Signed-off-by: Ophestra <cat@gensokyo.uk>
Diffstat (limited to 'cmd/app/lock.go')
-rw-r--r--cmd/app/lock.go19
1 files changed, 9 insertions, 10 deletions
diff --git a/cmd/app/lock.go b/cmd/app/lock.go
index 88068381..2a419ea1 100644
--- a/cmd/app/lock.go
+++ b/cmd/app/lock.go
@@ -8,7 +8,6 @@ import (
"strings"
"syscall"
- "hakurei.app/check"
"hakurei.app/fhs"
"hakurei.app/hst"
"hakurei.app/internal/env"
@@ -24,15 +23,15 @@ func (e MutationConflictError) Error() string {
}
// informTemplate guards intention of a template or its derivatives.
-func informTemplate(base *check.Absolute, name string, mutable bool) (func() error, error) {
- mu := lockedfile.MutexAt(base.Append("lock", name).String())
+func informTemplate(b *base, name string, mutable bool) (func() error, error) {
+ mu := lockedfile.MutexAt(b.append("lock", name).String())
if unlock, err := mu.Lock(); err != nil {
return nil, err
} else {
defer unlock()
}
- marker := base.Append("lock", "."+name)
+ marker := b.append("lock", "."+name)
if p, err := os.ReadFile(marker.String()); err == nil {
if _, err = os.Stat(fhs.AbsProc.Append(string(p)).String()); err == nil {
return nil, MutationConflictError(p)
@@ -72,8 +71,8 @@ func informTemplate(base *check.Absolute, name string, mutable bool) (func() err
if !root.Target.Is(fhs.AbsRoot) ||
len(root.Lower) != 1 ||
- !root.Lower[0].Is(base.Append("initial")) ||
- !root.Upper.Is(base.Append("template", name)) ||
+ !root.Lower[0].Is(b.initial()) ||
+ !root.Upper.Is(b.template(name)) ||
root.Work != nil {
continue
}
@@ -102,12 +101,12 @@ func informTemplate(base *check.Absolute, name string, mutable bool) (func() err
}
// acquireTemplate obtains exclusivity of a template.
-func acquireTemplate(base *check.Absolute, name string) (remove func() error, err error) {
- return informTemplate(base, name, true)
+func acquireTemplate(b *base, name string) (remove func() error, err error) {
+ return informTemplate(b, name, true)
}
// enterTemplate checks against exclusivity of a template.
-func enterTemplate(base *check.Absolute, name string) error {
- _, err := informTemplate(base, name, false)
+func enterTemplate(b *base, name string) error {
+ _, err := informTemplate(b, name, false)
return err
}