system/dispatcher: wrap syscall helper functions
All checks were successful
Test / Create distribution (push) Successful in 34s
Test / Sandbox (push) Successful in 2m6s
Test / Hakurei (push) Successful in 3m22s
Test / Hpkg (push) Successful in 3m49s
Test / Sandbox (race detector) (push) Successful in 5m34s
Test / Hakurei (race detector) (push) Successful in 3m12s
Test / Flake checks (push) Successful in 1m35s

This allows tests to stub all kernel behaviour, like in the container package.

Signed-off-by: Ophestra <cat@gensokyo.uk>
This commit is contained in:
2025-09-04 04:15:25 +09:00
parent 024d2ff782
commit ddfb865e2d
5 changed files with 427 additions and 88 deletions

View File

@@ -31,22 +31,22 @@ type ACLUpdateOp struct {
func (a *ACLUpdateOp) Type() Enablement { return a.et }
func (a *ACLUpdateOp) apply(sys *I) error {
msg.Verbose("applying ACL", a)
return newOpError("acl", acl.Update(a.path, sys.uid, a.perms...), false)
sys.verbose("applying ACL", a)
return newOpError("acl", sys.aclUpdate(a.path, sys.uid, a.perms...), false)
}
func (a *ACLUpdateOp) revert(sys *I, ec *Criteria) error {
if ec.hasType(a.Type()) {
msg.Verbose("stripping ACL", a)
err := acl.Update(a.path, sys.uid)
sys.verbose("stripping ACL", a)
err := sys.aclUpdate(a.path, sys.uid)
if errors.Is(err, os.ErrNotExist) {
// the ACL is effectively stripped if the file no longer exists
msg.Verbosef("target of ACL %s no longer exists", a)
sys.verbosef("target of ACL %s no longer exists", a)
err = nil
}
return newOpError("acl", err, true)
} else {
msg.Verbose("skipping ACL", a)
sys.verbose("skipping ACL", a)
return nil
}
}