aboutsummaryrefslogtreecommitdiffhomepage
path: root/container/path.go
diff options
context:
space:
mode:
authorOphestra <cat@gensokyo.uk>2025-08-11 02:52:32 +0900
committerOphestra <cat@gensokyo.uk>2025-08-11 04:56:42 +0900
commite99d7affb0c128fa82722f9b3d79c99b5e5918cd (patch)
tree387e08d6c4363d8b9e0462f069c140fbdb15c917 /container/path.go
parent41ac2be9658b49c68cb793f3a6f0c5932d82e1c2 (diff)
container: use absolute for pathname
This is simultaneously more efficient and less error-prone. This change caused minor API changes in multiple other packages. Signed-off-by: Ophestra <cat@gensokyo.uk>
Diffstat (limited to 'container/path.go')
-rw-r--r--container/path.go34
1 files changed, 34 insertions, 0 deletions
diff --git a/container/path.go b/container/path.go
index 28a56a13..fe6d6d4c 100644
--- a/container/path.go
+++ b/container/path.go
@@ -13,6 +13,8 @@ import (
"hakurei.app/container/vfs"
)
+/* constants in this file bypass abs check, be extremely careful when changing them! */
+
const (
// FHSRoot points to the file system root.
FHSRoot = "/"
@@ -49,6 +51,38 @@ const (
FHSSys = "/sys/"
)
+var (
+ // AbsFHSRoot is [FHSRoot] as [Absolute].
+ AbsFHSRoot = &Absolute{FHSRoot}
+ // AbsFHSEtc is [FHSEtc] as [Absolute].
+ AbsFHSEtc = &Absolute{FHSEtc}
+ // AbsFHSTmp is [FHSTmp] as [Absolute].
+ AbsFHSTmp = &Absolute{FHSTmp}
+
+ // AbsFHSRun is [FHSRun] as [Absolute].
+ AbsFHSRun = &Absolute{FHSRun}
+ // AbsFHSRunUser is [FHSRunUser] as [Absolute].
+ AbsFHSRunUser = &Absolute{FHSRunUser}
+
+ // AbsFHSUsrBin is [FHSUsrBin] as [Absolute].
+ AbsFHSUsrBin = &Absolute{FHSUsrBin}
+
+ // AbsFHSVar is [FHSVar] as [Absolute].
+ AbsFHSVar = &Absolute{FHSVar}
+ // AbsFHSVarLib is [FHSVarLib] as [Absolute].
+ AbsFHSVarLib = &Absolute{FHSVarLib}
+
+ // AbsFHSDev is [FHSDev] as [Absolute].
+ AbsFHSDev = &Absolute{FHSDev}
+ // AbsFHSProc is [FHSProc] as [Absolute].
+ AbsFHSProc = &Absolute{FHSProc}
+ // AbsFHSSys is [FHSSys] as [Absolute].
+ AbsFHSSys = &Absolute{FHSSys}
+
+ // AbsNonexistent is [Nonexistent] as [Absolute].
+ AbsNonexistent = &Absolute{Nonexistent}
+)
+
const (
// Nonexistent is a path that cannot exist.
// /proc is chosen because a system with covered /proc is unsupported by this package.