system/link: use syscall dispatcher
All checks were successful
Test / Create distribution (push) Successful in 33s
Test / Sandbox (push) Successful in 2m5s
Test / Hakurei (push) Successful in 3m4s
Test / Hpkg (push) Successful in 3m45s
Test / Sandbox (race detector) (push) Successful in 4m26s
Test / Hakurei (race detector) (push) Successful in 5m6s
Test / Flake checks (push) Successful in 1m49s

This enables hardlink op methods to be instrumented.

Signed-off-by: Ophestra <cat@gensokyo.uk>
This commit is contained in:
2025-09-06 19:47:58 +09:00
parent fcd0f2ede7
commit 6cc2b406a4
6 changed files with 116 additions and 48 deletions

View File

@@ -1,6 +1,8 @@
package system
import (
"os"
"hakurei.app/system/acl"
"hakurei.app/system/dbus"
)
@@ -13,6 +15,11 @@ type syscallDispatcher interface {
// just synchronising access is not enough, as this is for test instrumentation.
new(f func(k syscallDispatcher))
// link provides os.Link.
link(oldname, newname string) error
// remove provides os.Remove.
remove(name string) error
// aclUpdate provides [acl.Update].
aclUpdate(name string, uid int, perms ...acl.Perm) error
@@ -37,6 +44,9 @@ type direct struct{}
func (k direct) new(f func(k syscallDispatcher)) { go f(k) }
func (k direct) link(oldname, newname string) error { return os.Link(oldname, newname) }
func (k direct) remove(name string) error { return os.Remove(name) }
func (k direct) aclUpdate(name string, uid int, perms ...acl.Perm) error {
return acl.Update(name, uid, perms...)
}