From 15170735badf9c8c8f13840efcb70bf7ba192b4d Mon Sep 17 00:00:00 2001 From: Ophestra Date: Sun, 3 Aug 2025 18:06:41 +0900 Subject: container/mount: move tmpfs sysroot prefixing to caller The mountTmpfs helper is a relatively low level function that is not exposed as part of the API. Prefixing sysroot here not only introduces overhead but is also quite error-prone. Signed-off-by: Ophestra --- container/mount.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'container/mount.go') diff --git a/container/mount.go b/container/mount.go index fc0e177f..30ef7008 100644 --- a/container/mount.go +++ b/container/mount.go @@ -160,8 +160,9 @@ func remountWithFlags(n *vfs.MountInfoNode, mf uintptr) error { return nil } -func mountTmpfs(fsname, name string, flags uintptr, size int, perm os.FileMode) error { - target := toSysroot(name) +// mountTmpfs mounts tmpfs on target; +// callers who wish to mount to sysroot must pass the return value of toSysroot. +func mountTmpfs(fsname, target string, flags uintptr, size int, perm os.FileMode) error { if err := os.MkdirAll(target, parentPerm(perm)); err != nil { return wrapErrSelf(err) } @@ -171,7 +172,7 @@ func mountTmpfs(fsname, name string, flags uintptr, size int, perm os.FileMode) } return wrapErrSuffix( Mount(fsname, target, FstypeTmpfs, flags, opt), - fmt.Sprintf("cannot mount tmpfs on %q:", name)) + fmt.Sprintf("cannot mount tmpfs on %q:", target)) } func parentPerm(perm os.FileMode) os.FileMode { -- cgit v1.3.1