mirror of
https://github.com/containers/skopeo.git
synced 2025-09-28 21:46:48 +00:00
Vendor in latest containers storage
We want to get support into skopeo for handling override_kernel_checks so that we can use overlay backend on RHEL. Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
This commit is contained in:
44
vendor/github.com/containers/storage/pkg/mount/mount.go
generated
vendored
44
vendor/github.com/containers/storage/pkg/mount/mount.go
generated
vendored
@@ -1,7 +1,11 @@
|
||||
package mount
|
||||
|
||||
import (
|
||||
"sort"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/containers/storage/pkg/fileutils"
|
||||
)
|
||||
|
||||
// GetMounts retrieves a list of mounts for the current running process.
|
||||
@@ -17,6 +21,10 @@ func Mounted(mountpoint string) (bool, error) {
|
||||
return false, err
|
||||
}
|
||||
|
||||
mountpoint, err = fileutils.ReadSymlinkedDirectory(mountpoint)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
// Search the table for the mountpoint
|
||||
for _, e := range entries {
|
||||
if e.Mountpoint == mountpoint {
|
||||
@@ -46,13 +54,11 @@ func Mount(device, target, mType, options string) error {
|
||||
// flags.go for supported option flags.
|
||||
func ForceMount(device, target, mType, options string) error {
|
||||
flag, data := parseOptions(options)
|
||||
if err := mount(device, target, mType, uintptr(flag), data); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
return mount(device, target, mType, uintptr(flag), data)
|
||||
}
|
||||
|
||||
// Unmount will unmount the target filesystem, so long as it is mounted.
|
||||
// Unmount lazily unmounts a filesystem on supported platforms, otherwise
|
||||
// does a normal unmount.
|
||||
func Unmount(target string) error {
|
||||
if mounted, err := Mounted(target); err != nil || !mounted {
|
||||
return err
|
||||
@@ -60,6 +66,32 @@ func Unmount(target string) error {
|
||||
return ForceUnmount(target)
|
||||
}
|
||||
|
||||
// RecursiveUnmount unmounts the target and all mounts underneath, starting with
|
||||
// the deepsest mount first.
|
||||
func RecursiveUnmount(target string) error {
|
||||
mounts, err := GetMounts()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// Make the deepest mount be first
|
||||
sort.Sort(sort.Reverse(byMountpoint(mounts)))
|
||||
|
||||
for i, m := range mounts {
|
||||
if !strings.HasPrefix(m.Mountpoint, target) {
|
||||
continue
|
||||
}
|
||||
if err := Unmount(m.Mountpoint); err != nil && i == len(mounts)-1 {
|
||||
if mounted, err := Mounted(m.Mountpoint); err != nil || mounted {
|
||||
return err
|
||||
}
|
||||
// Ignore errors for submounts and continue trying to unmount others
|
||||
// The final unmount should fail if there ane any submounts remaining
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// ForceUnmount will force an unmount of the target filesystem, regardless if
|
||||
// it is mounted or not.
|
||||
func ForceUnmount(target string) (err error) {
|
||||
@@ -70,5 +102,5 @@ func ForceUnmount(target string) (err error) {
|
||||
}
|
||||
time.Sleep(100 * time.Millisecond)
|
||||
}
|
||||
return
|
||||
return nil
|
||||
}
|
||||
|
Reference in New Issue
Block a user