Skip to content

Commit a30ba61

Browse files
committed
Internalize mount.Interface.IsMountPointMatch
IsMountPointMatch() had no callers outside of the mount package, and has internal implementation details. This patch makes it no longer be public.
1 parent 038e5fa commit a30ba61

File tree

9 files changed

+14
-33
lines changed

9 files changed

+14
-33
lines changed

pkg/util/mount/fake.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -137,11 +137,6 @@ func (f *FakeMounter) List() ([]MountPoint, error) {
137137
return f.MountPoints, nil
138138
}
139139

140-
// IsMountPointMatch tests if dir and mp are the same path
141-
func (f *FakeMounter) IsMountPointMatch(mp MountPoint, dir string) bool {
142-
return mp.Path == dir
143-
}
144-
145140
// IsLikelyNotMountPoint determines whether a path is a mountpoint by checking
146141
// if the absolute path to file is in the in-memory mountpoints
147142
func (f *FakeMounter) IsLikelyNotMountPoint(file string) (bool, error) {

pkg/util/mount/mount.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,6 @@ type Interface interface {
4141
// consistent (i.e. it could change between chunked reads). This is guaranteed
4242
// to be consistent.
4343
List() ([]MountPoint, error)
44-
// IsMountPointMatch determines if the mountpoint matches the dir.
45-
IsMountPointMatch(mp MountPoint, dir string) bool
4644
// IsLikelyNotMountPoint uses heuristics to determine if a directory
4745
// is not a mountpoint.
4846
// It should return ErrNotExist when the directory does not exist.
@@ -162,7 +160,7 @@ func GetDeviceNameFromMount(mounter Interface, mountPath string) (string, int, e
162160
// IsNotMountPoint detects bind mounts in linux.
163161
// IsNotMountPoint enumerates all the mountpoints using List() and
164162
// the list of mountpoints may be large, then it uses
165-
// IsMountPointMatch to evaluate whether the directory is a mountpoint.
163+
// isMountPointMatch to evaluate whether the directory is a mountpoint.
166164
func IsNotMountPoint(mounter Interface, file string) (bool, error) {
167165
// IsLikelyNotMountPoint provides a quick check
168166
// to determine whether file IS A mountpoint.
@@ -195,7 +193,7 @@ func IsNotMountPoint(mounter Interface, file string) (bool, error) {
195193
return notMnt, mountPointsErr
196194
}
197195
for _, mp := range mountPoints {
198-
if mounter.IsMountPointMatch(mp, resolvedFile) {
196+
if isMountPointMatch(mp, resolvedFile) {
199197
notMnt = false
200198
break
201199
}

pkg/util/mount/mount_helper_unix.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,3 +131,10 @@ func parseMountInfo(filename string) ([]mountInfo, error) {
131131
}
132132
return infos, nil
133133
}
134+
135+
// isMountPointMatch returns true if the path in mp is the same as dir.
136+
// Handles case where mountpoint dir has been renamed due to stale NFS mount.
137+
func isMountPointMatch(mp MountPoint, dir string) bool {
138+
deletedDir := fmt.Sprintf("%s\\040(deleted)", dir)
139+
return ((mp.Path == dir) || (mp.Path == deletedDir))
140+
}

pkg/util/mount/mount_helper_windows.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,3 +91,8 @@ func ValidateDiskNumber(disk string) error {
9191

9292
return nil
9393
}
94+
95+
// isMountPointMatch determines if the mountpoint matches the dir
96+
func isMountPointMatch(mp MountPoint, dir string) bool {
97+
return mp.Path == dir
98+
}

pkg/util/mount/mount_linux.go

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -213,12 +213,6 @@ func (*Mounter) List() ([]MountPoint, error) {
213213
return ListProcMounts(procMountsPath)
214214
}
215215

216-
// IsMountPointMatch returns true if the path in mp is the same as dir
217-
func (mounter *Mounter) IsMountPointMatch(mp MountPoint, dir string) bool {
218-
deletedDir := fmt.Sprintf("%s\\040(deleted)", dir)
219-
return ((mp.Path == dir) || (mp.Path == deletedDir))
220-
}
221-
222216
// IsLikelyNotMountPoint determines if a directory is not a mountpoint.
223217
// It is fast but not necessarily ALWAYS correct. If the path is in fact
224218
// a bind mount from one part of a mount to another it will not be detected.

pkg/util/mount/mount_unsupported.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,6 @@ func (mounter *Mounter) List() ([]MountPoint, error) {
5353
return []MountPoint{}, errUnsupported
5454
}
5555

56-
// IsMountPointMatch returns true if the path in mp is the same as dir
57-
func (mounter *Mounter) IsMountPointMatch(mp MountPoint, dir string) bool {
58-
return (mp.Path == dir)
59-
}
60-
6156
// IsLikelyNotMountPoint always returns an error on unsupported platforms
6257
func (mounter *Mounter) IsLikelyNotMountPoint(file string) (bool, error) {
6358
return true, errUnsupported

pkg/util/mount/mount_windows.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -164,11 +164,6 @@ func (mounter *Mounter) List() ([]MountPoint, error) {
164164
return []MountPoint{}, nil
165165
}
166166

167-
// IsMountPointMatch determines if the mountpoint matches the dir
168-
func (mounter *Mounter) IsMountPointMatch(mp MountPoint, dir string) bool {
169-
return mp.Path == dir
170-
}
171-
172167
// IsLikelyNotMountPoint determines if a directory is not a mountpoint.
173168
func (mounter *Mounter) IsLikelyNotMountPoint(file string) (bool, error) {
174169
stat, err := os.Lstat(file)

pkg/volume/util/exec/exec_mount.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -91,10 +91,6 @@ func (m *execMounter) List() ([]mount.MountPoint, error) {
9191
return m.wrappedMounter.List()
9292
}
9393

94-
func (m *execMounter) IsMountPointMatch(mp mount.MountPoint, dir string) bool {
95-
return m.wrappedMounter.IsMountPointMatch(mp, dir)
96-
}
97-
9894
// IsLikelyNotMountPoint determines whether a path is a mountpoint.
9995
func (m *execMounter) IsLikelyNotMountPoint(file string) (bool, error) {
10096
return m.wrappedMounter.IsLikelyNotMountPoint(file)

pkg/volume/util/exec/exec_mount_unsupported.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,6 @@ func (mounter *execMounter) List() ([]mount.MountPoint, error) {
4646
return []mount.MountPoint{}, nil
4747
}
4848

49-
func (mounter *execMounter) IsMountPointMatch(mp mount.MountPoint, dir string) bool {
50-
return (mp.Path == dir)
51-
}
52-
5349
func (mounter *execMounter) IsLikelyNotMountPoint(file string) (bool, error) {
5450
return true, nil
5551
}

0 commit comments

Comments
 (0)