mirror of https://github.com/k3s-io/k3s
Merge pull request #72391 from cofyc/fix72387
Deprecate mount.IsNotMountPoint in favor of mounter.IsNotMountPointpull/564/head
commit
5b4b40cfe0
|
@ -48,7 +48,7 @@ func (mounter *execMounter) IsMountPointMatch(mp MountPoint, dir string) bool {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (mounter *execMounter) IsNotMountPoint(dir string) (bool, error) {
|
func (mounter *execMounter) IsNotMountPoint(dir string) (bool, error) {
|
||||||
return IsNotMountPoint(mounter, dir)
|
return isNotMountPoint(mounter, dir)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (mounter *execMounter) IsLikelyNotMountPoint(file string) (bool, error) {
|
func (mounter *execMounter) IsLikelyNotMountPoint(file string) (bool, error) {
|
||||||
|
|
|
@ -137,7 +137,7 @@ func (f *FakeMounter) IsMountPointMatch(mp MountPoint, dir string) bool {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f *FakeMounter) IsNotMountPoint(dir string) (bool, error) {
|
func (f *FakeMounter) IsNotMountPoint(dir string) (bool, error) {
|
||||||
return IsNotMountPoint(f, dir)
|
return isNotMountPoint(f, dir)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f *FakeMounter) IsLikelyNotMountPoint(file string) (bool, error) {
|
func (f *FakeMounter) IsLikelyNotMountPoint(file string) (bool, error) {
|
||||||
|
|
|
@ -245,12 +245,9 @@ func GetDeviceNameFromMount(mounter Interface, mountPath string) (string, int, e
|
||||||
return device, refCount, nil
|
return device, refCount, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// IsNotMountPoint determines if a directory is a mountpoint.
|
// isNotMountPoint implements Mounter.IsNotMountPoint and is shared by mounter
|
||||||
// It should return ErrNotExist when the directory does not exist.
|
// implementations.
|
||||||
// This method uses the List() of all mountpoints
|
func isNotMountPoint(mounter Interface, file string) (bool, error) {
|
||||||
// It is more extensive than IsLikelyNotMountPoint
|
|
||||||
// and it detects bind mounts in linux
|
|
||||||
func IsNotMountPoint(mounter Interface, file string) (bool, error) {
|
|
||||||
// IsLikelyNotMountPoint provides a quick check
|
// IsLikelyNotMountPoint provides a quick check
|
||||||
// to determine whether file IS A mountpoint
|
// to determine whether file IS A mountpoint
|
||||||
notMnt, notMntErr := mounter.IsLikelyNotMountPoint(file)
|
notMnt, notMntErr := mounter.IsLikelyNotMountPoint(file)
|
||||||
|
|
|
@ -56,7 +56,7 @@ func doCleanupMountPoint(mountPath string, mounter Interface, extensiveMountPoin
|
||||||
var notMnt bool
|
var notMnt bool
|
||||||
var err error
|
var err error
|
||||||
if extensiveMountPointCheck {
|
if extensiveMountPointCheck {
|
||||||
notMnt, err = IsNotMountPoint(mounter, mountPath)
|
notMnt, err = mounter.IsNotMountPoint(mountPath)
|
||||||
} else {
|
} else {
|
||||||
notMnt, err = mounter.IsLikelyNotMountPoint(mountPath)
|
notMnt, err = mounter.IsLikelyNotMountPoint(mountPath)
|
||||||
}
|
}
|
||||||
|
|
|
@ -229,7 +229,7 @@ func (mounter *Mounter) IsMountPointMatch(mp MountPoint, dir string) bool {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (mounter *Mounter) IsNotMountPoint(dir string) (bool, error) {
|
func (mounter *Mounter) IsNotMountPoint(dir string) (bool, error) {
|
||||||
return IsNotMountPoint(mounter, dir)
|
return isNotMountPoint(mounter, dir)
|
||||||
}
|
}
|
||||||
|
|
||||||
// IsLikelyNotMountPoint determines if a directory is not a mountpoint.
|
// IsLikelyNotMountPoint determines if a directory is not a mountpoint.
|
||||||
|
@ -757,7 +757,7 @@ func safeOpenSubPath(mounter Interface, subpath Subpath) (int, error) {
|
||||||
func prepareSubpathTarget(mounter Interface, subpath Subpath) (bool, string, error) {
|
func prepareSubpathTarget(mounter Interface, subpath Subpath) (bool, string, error) {
|
||||||
// Early check for already bind-mounted subpath.
|
// Early check for already bind-mounted subpath.
|
||||||
bindPathTarget := getSubpathBindTarget(subpath)
|
bindPathTarget := getSubpathBindTarget(subpath)
|
||||||
notMount, err := IsNotMountPoint(mounter, bindPathTarget)
|
notMount, err := mounter.IsNotMountPoint(bindPathTarget)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if !os.IsNotExist(err) {
|
if !os.IsNotExist(err) {
|
||||||
return false, "", fmt.Errorf("error checking path %s for mount: %s", bindPathTarget, err)
|
return false, "", fmt.Errorf("error checking path %s for mount: %s", bindPathTarget, err)
|
||||||
|
|
|
@ -55,7 +55,7 @@ func (mounter *Mounter) IsMountPointMatch(mp MountPoint, dir string) bool {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (mounter *Mounter) IsNotMountPoint(dir string) (bool, error) {
|
func (mounter *Mounter) IsNotMountPoint(dir string) (bool, error) {
|
||||||
return IsNotMountPoint(mounter, dir)
|
return isNotMountPoint(mounter, dir)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (mounter *Mounter) IsLikelyNotMountPoint(file string) (bool, error) {
|
func (mounter *Mounter) IsLikelyNotMountPoint(file string) (bool, error) {
|
||||||
|
|
|
@ -132,7 +132,7 @@ func (mounter *Mounter) IsMountPointMatch(mp MountPoint, dir string) bool {
|
||||||
|
|
||||||
// IsNotMountPoint determines if a directory is a mountpoint.
|
// IsNotMountPoint determines if a directory is a mountpoint.
|
||||||
func (mounter *Mounter) IsNotMountPoint(dir string) (bool, error) {
|
func (mounter *Mounter) IsNotMountPoint(dir string) (bool, error) {
|
||||||
return IsNotMountPoint(mounter, dir)
|
return isNotMountPoint(mounter, dir)
|
||||||
}
|
}
|
||||||
|
|
||||||
// IsLikelyNotMountPoint determines if a directory is not a mountpoint.
|
// IsLikelyNotMountPoint determines if a directory is not a mountpoint.
|
||||||
|
|
|
@ -145,7 +145,7 @@ func (*NsenterMounter) List() ([]MountPoint, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *NsenterMounter) IsNotMountPoint(dir string) (bool, error) {
|
func (m *NsenterMounter) IsNotMountPoint(dir string) (bool, error) {
|
||||||
return IsNotMountPoint(m, dir)
|
return isNotMountPoint(m, dir)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (*NsenterMounter) IsMountPointMatch(mp MountPoint, dir string) bool {
|
func (*NsenterMounter) IsMountPointMatch(mp MountPoint, dir string) bool {
|
||||||
|
|
|
@ -46,7 +46,7 @@ func (*NsenterMounter) List() ([]MountPoint, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *NsenterMounter) IsNotMountPoint(dir string) (bool, error) {
|
func (m *NsenterMounter) IsNotMountPoint(dir string) (bool, error) {
|
||||||
return IsNotMountPoint(m, dir)
|
return isNotMountPoint(m, dir)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (*NsenterMounter) IsMountPointMatch(mp MountPoint, dir string) bool {
|
func (*NsenterMounter) IsMountPointMatch(mp MountPoint, dir string) bool {
|
||||||
|
|
Loading…
Reference in New Issue