From e99d7affb0c128fa82722f9b3d79c99b5e5918cd Mon Sep 17 00:00:00 2001 From: Ophestra Date: Mon, 11 Aug 2025 02:52:32 +0900 Subject: 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 --- container/path.go | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) (limited to 'container/path.go') 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. -- cgit v1.3.1