diff options
| author | Ophestra <cat@gensokyo.uk> | 2025-09-02 04:54:34 +0900 |
|---|---|---|
| committer | Ophestra <cat@gensokyo.uk> | 2025-09-02 04:54:34 +0900 |
| commit | 6f719bc3c19d56279d2d76d3bcf8fb66ace2d2fb (patch) | |
| tree | 6e9e84fd6f382fa823c87a70a0df0284dc127250 /internal/app | |
| parent | 1b5d20a39b2c5720d83a8eaf3d2227deb46a7c0d (diff) | |
system: update doc commands and remove mutex
The mutex is not really doing anything, none of these methods make sense when called concurrently anyway. The copylocks analysis is still satisfied by the noCopy struct.
Signed-off-by: Ophestra <cat@gensokyo.uk>
Diffstat (limited to 'internal/app')
| -rw-r--r-- | internal/app/app_nixos_linux_test.go | 3 | ||||
| -rw-r--r-- | internal/app/app_pd_linux_test.go | 5 | ||||
| -rw-r--r-- | internal/app/app_test.go | 2 | ||||
| -rw-r--r-- | internal/app/export_test.go | 9 | ||||
| -rw-r--r-- | internal/app/process.go | 2 | ||||
| -rw-r--r-- | internal/app/seal.go | 7 |
6 files changed, 16 insertions, 12 deletions
diff --git a/internal/app/app_nixos_linux_test.go b/internal/app/app_nixos_linux_test.go index e2aa5a40..b6f5e44f 100644 --- a/internal/app/app_nixos_linux_test.go +++ b/internal/app/app_nixos_linux_test.go @@ -1,6 +1,7 @@ package app_test import ( + "context" "syscall" "hakurei.app/container" @@ -74,7 +75,7 @@ var testCasesNixos = []sealTestCase{ 0x4c, 0xf0, 0x73, 0xbd, 0xb4, 0x6e, 0xb5, 0xc1, }, - system.New(1000001). + system.New(context.TODO(), 1000001). Ensure("/tmp/hakurei.1971", 0711). Ensure("/tmp/hakurei.1971/runtime", 0700).UpdatePermType(system.User, "/tmp/hakurei.1971/runtime", acl.Execute). Ensure("/tmp/hakurei.1971/runtime/1", 0700).UpdatePermType(system.User, "/tmp/hakurei.1971/runtime/1", acl.Read, acl.Write, acl.Execute). diff --git a/internal/app/app_pd_linux_test.go b/internal/app/app_pd_linux_test.go index 384f5a0e..7bc94734 100644 --- a/internal/app/app_pd_linux_test.go +++ b/internal/app/app_pd_linux_test.go @@ -1,6 +1,7 @@ package app_test import ( + "context" "os" "syscall" @@ -23,7 +24,7 @@ var testCasesPd = []sealTestCase{ 0xbd, 0x01, 0x78, 0x0e, 0xb9, 0xa6, 0x07, 0xac, }, - system.New(1000000). + system.New(context.TODO(), 1000000). Ensure("/tmp/hakurei.1971", 0711). Ensure("/tmp/hakurei.1971/runtime", 0700).UpdatePermType(system.User, "/tmp/hakurei.1971/runtime", acl.Execute). Ensure("/tmp/hakurei.1971/runtime/0", 0700).UpdatePermType(system.User, "/tmp/hakurei.1971/runtime/0", acl.Read, acl.Write, acl.Execute). @@ -115,7 +116,7 @@ var testCasesPd = []sealTestCase{ 0x82, 0xd4, 0x13, 0x36, 0x9b, 0x64, 0xce, 0x7c, }, - system.New(1000009). + system.New(context.TODO(), 1000009). Ensure("/tmp/hakurei.1971", 0711). Ensure("/tmp/hakurei.1971/runtime", 0700).UpdatePermType(system.User, "/tmp/hakurei.1971/runtime", acl.Execute). Ensure("/tmp/hakurei.1971/runtime/9", 0700).UpdatePermType(system.User, "/tmp/hakurei.1971/runtime/9", acl.Read, acl.Write, acl.Execute). diff --git a/internal/app/app_test.go b/internal/app/app_test.go index 8b96cfba..ab94b1ca 100644 --- a/internal/app/app_test.go +++ b/internal/app/app_test.go @@ -30,7 +30,7 @@ func TestApp(t *testing.T) { for _, tc := range testCases { t.Run(tc.name, func(t *testing.T) { - a := app.NewWithID(tc.id, tc.os) + a := app.NewWithID(t.Context(), tc.id, tc.os) var ( gotSys *system.I gotContainer *container.Params diff --git a/internal/app/export_test.go b/internal/app/export_test.go index b7ee7f73..3e5db9fb 100644 --- a/internal/app/export_test.go +++ b/internal/app/export_test.go @@ -1,17 +1,16 @@ package app import ( + "context" + "hakurei.app/container" "hakurei.app/internal/app/state" "hakurei.app/internal/sys" "hakurei.app/system" ) -func NewWithID(id state.ID, os sys.State) *App { - a := new(App) - a.id = newID(&id) - a.sys = os - return a +func NewWithID(ctx context.Context, id state.ID, os sys.State) *App { + return &App{id: newID(&id), sys: os, ctx: ctx} } func AppIParams(a *App, seal *Outcome) (*system.I, *container.Params) { diff --git a/internal/app/process.go b/internal/app/process.go index 44355699..b89f0fc4 100644 --- a/internal/app/process.go +++ b/internal/app/process.go @@ -61,7 +61,7 @@ func (seal *Outcome) Run(rs *RunState) error { // read comp value early to allow for early failure hsuPath := internal.MustHsuPath() - if err := seal.sys.Commit(seal.ctx); err != nil { + if err := seal.sys.Commit(); err != nil { return err } store := state.NewMulti(seal.runDirPath.String()) diff --git a/internal/app/seal.go b/internal/app/seal.go index ec42dc2d..047c3a74 100644 --- a/internal/app/seal.go +++ b/internal/app/seal.go @@ -146,8 +146,11 @@ type hsuUser struct { } func (seal *Outcome) finalise(ctx context.Context, sys sys.State, config *hst.Config) error { + if ctx == nil { + panic("invalid call to finalise") + } if seal.ctx != nil { - panic("finalise called twice") + panic("attempting to finalise twice") } seal.ctx = ctx @@ -306,7 +309,7 @@ func (seal *Outcome) finalise(ctx context.Context, sys sys.State, config *hst.Co share := &shareHost{seal: seal, sc: sys.Paths()} seal.runDirPath = share.sc.RunDirPath - seal.sys = system.New(seal.user.uid.unwrap()) + seal.sys = system.New(seal.ctx, seal.user.uid.unwrap()) seal.sys.Ensure(share.sc.SharePath.String(), 0711) { |
