mirror of
https://github.com/containers/skopeo.git
synced 2025-09-24 03:17:17 +00:00
Bumps [github.com/containers/storage](https://github.com/containers/storage) from 1.41.0 to 1.42.0. - [Release notes](https://github.com/containers/storage/releases) - [Changelog](https://github.com/containers/storage/blob/main/docs/containers-storage-changes.md) - [Commits](https://github.com/containers/storage/compare/v1.41.0...v1.42.0) --- updated-dependencies: - dependency-name: github.com/containers/storage dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com>
54 lines
1.2 KiB
Go
54 lines
1.2 KiB
Go
//go:build linux || freebsd || openbsd || darwin
|
|
// +build linux freebsd openbsd darwin
|
|
|
|
package mountinfo
|
|
|
|
import (
|
|
"os"
|
|
"path/filepath"
|
|
|
|
"golang.org/x/sys/unix"
|
|
)
|
|
|
|
func mountedByStat(path string) (bool, error) {
|
|
var st unix.Stat_t
|
|
|
|
if err := unix.Lstat(path, &st); err != nil {
|
|
return false, &os.PathError{Op: "stat", Path: path, Err: err}
|
|
}
|
|
dev := st.Dev
|
|
parent := filepath.Dir(path)
|
|
if err := unix.Lstat(parent, &st); err != nil {
|
|
return false, &os.PathError{Op: "stat", Path: parent, Err: err}
|
|
}
|
|
if dev != st.Dev {
|
|
// Device differs from that of parent,
|
|
// so definitely a mount point.
|
|
return true, nil
|
|
}
|
|
// NB: this does not detect bind mounts on Linux.
|
|
return false, nil
|
|
}
|
|
|
|
func normalizePath(path string) (realPath string, err error) {
|
|
if realPath, err = filepath.Abs(path); err != nil {
|
|
return "", err
|
|
}
|
|
if realPath, err = filepath.EvalSymlinks(realPath); err != nil {
|
|
return "", err
|
|
}
|
|
if _, err := os.Stat(realPath); err != nil {
|
|
return "", err
|
|
}
|
|
return realPath, nil
|
|
}
|
|
|
|
func mountedByMountinfo(path string) (bool, error) {
|
|
entries, err := GetMounts(SingleEntryFilter(path))
|
|
if err != nil {
|
|
return false, err
|
|
}
|
|
|
|
return len(entries) > 0, nil
|
|
}
|