Use mount.Target to specify subdirectory of rootfs mount

- Add Target to mount.Mount.
- Add UnmountMounts to unmount a list of mounts in reverse order.
- Add UnmountRecursive to unmount deepest mount first for a given target, using
moby/sys/mountinfo.

Signed-off-by: Edgar Lee <edgarhinshunlee@gmail.com>
This commit is contained in:
Edgar Lee
2023-01-23 13:36:28 -05:00
parent 753bfd6575
commit 34d5878185
26 changed files with 282 additions and 65 deletions

View File

@@ -22,6 +22,7 @@ import (
"fmt"
"io"
"os"
"path/filepath"
"strings"
"text/tabwriter"
"time"
@@ -640,6 +641,6 @@ func printNode(name string, tree *snapshotTree, level int) {
func printMounts(target string, mounts []mount.Mount) {
// FIXME: This is specific to Unix
for _, m := range mounts {
fmt.Printf("mount -t %s %s %s -o %s\n", m.Type, m.Source, target, strings.Join(m.Options, ","))
fmt.Printf("mount -t %s %s %s -o %s\n", m.Type, m.Source, filepath.Join(target, m.Target), strings.Join(m.Options, ","))
}
}