open-nomad/helper/mount/mount_linux.go
Seth Hoenig 4650e97d29 deps: upgrade docker and runc
This PR upgrades
 - docker dependency to the latest tagged release (v20.10.12)
 - runc dependency to the latest tagged release (v1.0.3)

Docker does not abide by [semver](https://github.com/moby/moby/issues/39302), so it is marked +incompatible,
and transitive dependencies are upgrade manually.

Runc made three relevant breaking changes

 * cgroup manager .Set changed to accept Resources instead of Cgroup
   3f65946756

 * config.Device moved to devices.Device
   https://github.com/opencontainers/runc/pull/2679

 * mountinfo.Mounted now returns an error if the specified path does not exist
   https://github.com/moby/sys/blob/mountinfo/v0.5.0/mountinfo/mountinfo.go#L16
2022-01-18 08:35:26 -06:00

34 lines
950 B
Go

//go:build linux
// +build linux
package mount
import (
"github.com/moby/sys/mount"
"github.com/moby/sys/mountinfo"
)
// mounter provides the default implementation of mount.Mounter
// for the linux platform.
// Currently it delegates to the docker `mount` package.
type mounter struct {
}
// New returns a Mounter for the current system.
func New() Mounter {
return &mounter{}
}
// IsNotAMountPoint determines if a directory is not a mountpoint.
// It does this by checking the path against the contents of /proc/self/mountinfo
func (m *mounter) IsNotAMountPoint(path string) (bool, error) {
isMount, err := mountinfo.Mounted(path)
return !isMount, err
}
func (m *mounter) Mount(device, target, mountType, options string) error {
// Defer to the docker implementation of `Mount`, it's correct enough for our
// usecase and avoids us needing to shell out to the `mount` utility.
return mount.Mount(device, target, mountType, options)
}