mirror of
https://github.com/containers/skopeo.git
synced 2025-09-23 19:07:03 +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>
57 lines
1.1 KiB
Go
57 lines
1.1 KiB
Go
//go:build freebsd || openbsd || darwin
|
|
// +build freebsd openbsd darwin
|
|
|
|
package mountinfo
|
|
|
|
import "golang.org/x/sys/unix"
|
|
|
|
// parseMountTable returns information about mounted filesystems
|
|
func parseMountTable(filter FilterFunc) ([]*Info, error) {
|
|
count, err := unix.Getfsstat(nil, unix.MNT_WAIT)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
entries := make([]unix.Statfs_t, count)
|
|
_, err = unix.Getfsstat(entries, unix.MNT_WAIT)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
var out []*Info
|
|
for _, entry := range entries {
|
|
var skip, stop bool
|
|
mountinfo := getMountinfo(&entry)
|
|
|
|
if filter != nil {
|
|
// filter out entries we're not interested in
|
|
skip, stop = filter(mountinfo)
|
|
if skip {
|
|
continue
|
|
}
|
|
}
|
|
|
|
out = append(out, mountinfo)
|
|
if stop {
|
|
break
|
|
}
|
|
}
|
|
return out, nil
|
|
}
|
|
|
|
func mounted(path string) (bool, error) {
|
|
path, err := normalizePath(path)
|
|
if err != nil {
|
|
return false, err
|
|
}
|
|
// Fast path: compare st.st_dev fields.
|
|
// This should always work for FreeBSD and OpenBSD.
|
|
mounted, err := mountedByStat(path)
|
|
if err == nil {
|
|
return mounted, nil
|
|
}
|
|
|
|
// Fallback to parsing mountinfo
|
|
return mountedByMountinfo(path)
|
|
}
|