aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorOphestra <cat@gensokyo.uk>2025-08-01 23:32:38 +0900
committerOphestra <cat@gensokyo.uk>2025-08-01 23:32:38 +0900
commit1dc780bca737610196ed58644b3ba61edc8acc48 (patch)
tree3768d928282b5aa8a98e920bfce8a07b1a098568
parentec33061c925f0f02897158db2b21a7ebfee71cc6 (diff)
container/mount: separate remount from bind
Remount turns out to be useful in other places. Signed-off-by: Ophestra <cat@gensokyo.uk>
-rw-r--r--container/mount.go7
1 files changed, 7 insertions, 0 deletions
diff --git a/container/mount.go b/container/mount.go
index 12093d47..024b9829 100644
--- a/container/mount.go
+++ b/container/mount.go
@@ -10,6 +10,7 @@ import (
"hakurei.app/container/vfs"
)
+// bindMount mounts source on target and recursively applies flags if MS_REC is set.
func (p *procPaths) bindMount(source, target string, flags uintptr, eq bool) error {
if eq {
msg.Verbosef("resolved %q flags %#x", target, flags)
@@ -22,6 +23,11 @@ func (p *procPaths) bindMount(source, target string, flags uintptr, eq bool) err
fmt.Sprintf("cannot mount %q on %q:", source, target))
}
+ return p.remount(target, flags)
+}
+
+// remount applies flags on target, recursively if MS_REC is set.
+func (p *procPaths) remount(target string, flags uintptr) error {
var targetFinal string
if v, err := filepath.EvalSymlinks(target); err != nil {
return wrapErrSelf(err)
@@ -83,6 +89,7 @@ func (p *procPaths) bindMount(source, target string, flags uintptr, eq bool) err
})
}
+// remountWithFlags remounts mount point described by [vfs.MountInfoNode].
func remountWithFlags(n *vfs.MountInfoNode, mf uintptr) error {
kf, unmatched := n.Flags()
if len(unmatched) != 0 {