aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorOphestra <cat@gensokyo.uk>2025-11-12 23:12:38 +0900
committerOphestra <cat@gensokyo.uk>2025-11-12 23:16:13 +0900
commitf347d44c2281f507e3786aa498f634bfa4c92d84 (patch)
treefe85b41d5f6a5e308b87585f46efd64f90221e2b
parentb5630f6883c874d458d9ae3c666cfb7ae5e3121d (diff)
internal/helper: relocate from helper
This package is ugly and is pending removal only kept alive by xdg-dbus-proxy. Its exported symbols are made available until v0.4.0 where it will be removed for #24. Signed-off-by: Ophestra <cat@gensokyo.uk>
-rw-r--r--helper/deprecated.go73
-rw-r--r--helper/proc/deprecated.go63
-rw-r--r--internal/helper/args.go (renamed from helper/args.go)0
-rw-r--r--internal/helper/args_test.go (renamed from helper/args_test.go)2
-rw-r--r--internal/helper/cmd.go (renamed from helper/cmd.go)2
-rw-r--r--internal/helper/cmd_test.go (renamed from helper/cmd_test.go)2
-rw-r--r--internal/helper/container.go (renamed from helper/container.go)2
-rw-r--r--internal/helper/container_test.go (renamed from helper/container_test.go)2
-rw-r--r--internal/helper/helper.go (renamed from helper/helper.go)2
-rw-r--r--internal/helper/helper_test.go (renamed from helper/helper_test.go)2
-rw-r--r--internal/helper/proc/files.go (renamed from helper/proc/files.go)0
-rw-r--r--internal/helper/proc/pipe.go (renamed from helper/proc/pipe.go)0
-rw-r--r--internal/helper/stub.go (renamed from helper/stub.go)0
-rw-r--r--internal/helper/stub_test.go (renamed from helper/stub_test.go)2
14 files changed, 144 insertions, 8 deletions
diff --git a/helper/deprecated.go b/helper/deprecated.go
new file mode 100644
index 00000000..f09b0c84
--- /dev/null
+++ b/helper/deprecated.go
@@ -0,0 +1,73 @@
+// Package helper exposes the internal/helper package.
+//
+// Deprecated: This package will be removed in 0.4.
+package helper
+
+import (
+ "context"
+ "io"
+ "os"
+ "os/exec"
+ "time"
+ _ "unsafe" // for go:linkname
+
+ "hakurei.app/container"
+ "hakurei.app/container/check"
+ "hakurei.app/internal/helper"
+ "hakurei.app/message"
+)
+
+//go:linkname WaitDelay hakurei.app/internal/helper.WaitDelay
+var WaitDelay time.Duration
+
+const (
+ // HakureiHelper is set to 1 when args fd is enabled and 0 otherwise.
+ HakureiHelper = helper.HakureiHelper
+ // HakureiStatus is set to 1 when stat fd is enabled and 0 otherwise.
+ HakureiStatus = helper.HakureiStatus
+)
+
+type Helper = helper.Helper
+
+// NewCheckedArgs returns a checked null-terminated argument writer for a copy of args.
+//
+//go:linkname NewCheckedArgs hakurei.app/internal/helper.NewCheckedArgs
+func NewCheckedArgs(args ...string) (wt io.WriterTo, err error)
+
+// MustNewCheckedArgs returns a checked null-terminated argument writer for a copy of args.
+// If s contains a NUL byte this function panics instead of returning an error.
+//
+//go:linkname MustNewCheckedArgs hakurei.app/internal/helper.MustNewCheckedArgs
+func MustNewCheckedArgs(args ...string) io.WriterTo
+
+// NewDirect initialises a new direct Helper instance with wt as the null-terminated argument writer.
+// Function argF returns an array of arguments passed directly to the child process.
+//
+//go:linkname NewDirect hakurei.app/internal/helper.NewDirect
+func NewDirect(
+ ctx context.Context,
+ name string,
+ wt io.WriterTo,
+ stat bool,
+ argF func(argsFd, statFd int) []string,
+ cmdF func(cmd *exec.Cmd),
+ extraFiles []*os.File,
+) Helper
+
+// New initialises a Helper instance with wt as the null-terminated argument writer.
+//
+//go:linkname New hakurei.app/internal/helper.New
+func New(
+ ctx context.Context,
+ msg message.Msg,
+ pathname *check.Absolute, name string,
+ wt io.WriterTo,
+ stat bool,
+ argF func(argsFd, statFd int) []string,
+ cmdF func(z *container.Container),
+ extraFiles []*os.File,
+) Helper
+
+// InternalHelperStub is an internal function but exported because it is cross-package;
+// it is part of the implementation of the helper stub.
+func InternalHelperStub() { helper.InternalHelperStub() }
diff --git a/helper/proc/deprecated.go b/helper/proc/deprecated.go
new file mode 100644
index 00000000..91897526
--- /dev/null
+++ b/helper/proc/deprecated.go
@@ -0,0 +1,63 @@
+// Deprecated: This package will be removed in 0.4.
+package proc
+
+import (
+ "context"
+ "io"
+ "os"
+ "os/exec"
+ "time"
+ _ "unsafe" // for go:linkname
+
+ "hakurei.app/internal/helper/proc"
+)
+
+//go:linkname FulfillmentTimeout hakurei.app/internal/helper/proc.FulfillmentTimeout
+var FulfillmentTimeout time.Duration
+
+// A File is an extra file with deferred initialisation.
+type File = proc.File
+
+// ExtraFilesPre is a linked list storing addresses of [os.File].
+type ExtraFilesPre = proc.ExtraFilesPre
+
+// Fulfill calls the [File.Fulfill] method on all files, starts cmd and blocks until all fulfillment completes.
+//
+//go:linkname Fulfill hakurei.app/internal/helper/proc.Fulfill
+func Fulfill(ctx context.Context,
+ v *[]*os.File, start func() error,
+ files []File, extraFiles *ExtraFilesPre,
+) (err error)
+
+// InitFile initialises f as part of the slice extraFiles points to,
+// and returns its final fd value.
+//
+//go:linkname InitFile hakurei.app/internal/helper/proc.InitFile
+func InitFile(f File, extraFiles *ExtraFilesPre) (fd uintptr)
+
+// BaseFile implements the Init method of the File interface and provides indirect access to extra file state.
+type BaseFile = proc.BaseFile
+
+//go:linkname ExtraFile hakurei.app/internal/helper/proc.ExtraFile
+func ExtraFile(cmd *exec.Cmd, f *os.File) (fd uintptr)
+
+//go:linkname ExtraFileSlice hakurei.app/internal/helper/proc.ExtraFileSlice
+func ExtraFileSlice(extraFiles *[]*os.File, f *os.File) (fd uintptr)
+
+// NewWriterTo returns a [File] that receives content from wt on fulfillment.
+//
+//go:linkname NewWriterTo hakurei.app/internal/helper/proc.NewWriterTo
+func NewWriterTo(wt io.WriterTo) File
+
+// NewStat returns a [File] implementing the behaviour
+// of the receiving end of xdg-dbus-proxy stat fd.
+//
+//go:linkname NewStat hakurei.app/internal/helper/proc.NewStat
+func NewStat(s *io.Closer) File
+
+var (
+ //go:linkname ErrStatFault hakurei.app/internal/helper/proc.ErrStatFault
+ ErrStatFault error
+ //go:linkname ErrStatRead hakurei.app/internal/helper/proc.ErrStatRead
+ ErrStatRead error
+)
diff --git a/helper/args.go b/internal/helper/args.go
index 80cd3024..80cd3024 100644
--- a/helper/args.go
+++ b/internal/helper/args.go
diff --git a/helper/args_test.go b/internal/helper/args_test.go
index d6225c3e..c83c6790 100644
--- a/helper/args_test.go
+++ b/internal/helper/args_test.go
@@ -7,7 +7,7 @@ import (
"syscall"
"testing"
- "hakurei.app/helper"
+ "hakurei.app/internal/helper"
)
func TestArgsString(t *testing.T) {
diff --git a/helper/cmd.go b/internal/helper/cmd.go
index 9a5bc3ab..babceb22 100644
--- a/helper/cmd.go
+++ b/internal/helper/cmd.go
@@ -10,7 +10,7 @@ import (
"sync"
"syscall"
- "hakurei.app/helper/proc"
+ "hakurei.app/internal/helper/proc"
)
// NewDirect initialises a new direct Helper instance with wt as the null-terminated argument writer.
diff --git a/helper/cmd_test.go b/internal/helper/cmd_test.go
index 64ac643f..3d29479c 100644
--- a/helper/cmd_test.go
+++ b/internal/helper/cmd_test.go
@@ -9,7 +9,7 @@ import (
"testing"
"hakurei.app/container"
- "hakurei.app/helper"
+ "hakurei.app/internal/helper"
)
func TestCmd(t *testing.T) {
diff --git a/helper/container.go b/internal/helper/container.go
index b85f5859..56a51954 100644
--- a/helper/container.go
+++ b/internal/helper/container.go
@@ -11,7 +11,7 @@ import (
"hakurei.app/container"
"hakurei.app/container/check"
- "hakurei.app/helper/proc"
+ "hakurei.app/internal/helper/proc"
"hakurei.app/message"
)
diff --git a/helper/container_test.go b/internal/helper/container_test.go
index 922d8253..f55da75c 100644
--- a/helper/container_test.go
+++ b/internal/helper/container_test.go
@@ -9,7 +9,7 @@ import (
"hakurei.app/container"
"hakurei.app/container/check"
"hakurei.app/container/fhs"
- "hakurei.app/helper"
+ "hakurei.app/internal/helper"
)
func TestContainer(t *testing.T) {
diff --git a/helper/helper.go b/internal/helper/helper.go
index 60bd7615..378d9471 100644
--- a/helper/helper.go
+++ b/internal/helper/helper.go
@@ -8,7 +8,7 @@ import (
"os"
"time"
- "hakurei.app/helper/proc"
+ "hakurei.app/internal/helper/proc"
)
var WaitDelay = 2 * time.Second
diff --git a/helper/helper_test.go b/internal/helper/helper_test.go
index 4cc36d34..dae098b8 100644
--- a/helper/helper_test.go
+++ b/internal/helper/helper_test.go
@@ -13,7 +13,7 @@ import (
"testing"
"time"
- "hakurei.app/helper"
+ "hakurei.app/internal/helper"
)
var (
diff --git a/helper/proc/files.go b/internal/helper/proc/files.go
index 0612718e..0612718e 100644
--- a/helper/proc/files.go
+++ b/internal/helper/proc/files.go
diff --git a/helper/proc/pipe.go b/internal/helper/proc/pipe.go
index 838c4ae4..838c4ae4 100644
--- a/helper/proc/pipe.go
+++ b/internal/helper/proc/pipe.go
diff --git a/helper/stub.go b/internal/helper/stub.go
index c1f97e63..c1f97e63 100644
--- a/helper/stub.go
+++ b/internal/helper/stub.go
diff --git a/helper/stub_test.go b/internal/helper/stub_test.go
index 58a25383..4b438a5b 100644
--- a/helper/stub_test.go
+++ b/internal/helper/stub_test.go
@@ -5,7 +5,7 @@ import (
"testing"
"hakurei.app/container"
- "hakurei.app/helper"
+ "hakurei.app/internal/helper"
)
func TestMain(m *testing.M) { container.TryArgv0(nil); helper.InternalHelperStub(); os.Exit(m.Run()) }