Rename IsMountPoint to IsLikelyNotMountPoint
IsLikelyNotMountPoint determines if a directory is not a mountpoint. It is fast but not necessarily ALWAYS correct. If the path is in fact a bind mount from one part of a mount to another it will not be detected. mkdir /tmp/a /tmp/b; mount --bin /tmp/a /tmp/b; IsLikelyNotMountPoint("/tmp/b") will return true. When in fact /tmp/b is a mount point. So this patch renames the function and switches it from a positive to a negative (I could think of a good positive name). This should make future users of this function aware that it isn't quite perfect, but probably good enough.
This commit is contained in:
@@ -144,7 +144,7 @@ func (ed *emptyDir) SetUp() error {
|
||||
|
||||
// SetUpAt creates new directory.
|
||||
func (ed *emptyDir) SetUpAt(dir string) error {
|
||||
isMnt, err := ed.mounter.IsMountPoint(dir)
|
||||
notMnt, err := ed.mounter.IsLikelyNotMountPoint(dir)
|
||||
// Getting an os.IsNotExist err from is a contingency; the directory
|
||||
// may not exist yet, in which case, setup should run.
|
||||
if err != nil && !os.IsNotExist(err) {
|
||||
@@ -156,7 +156,7 @@ func (ed *emptyDir) SetUpAt(dir string) error {
|
||||
// medium is memory, and a mountpoint is present, then the volume is
|
||||
// ready.
|
||||
if volumeutil.IsReady(ed.getMetaDir()) {
|
||||
if ed.medium == api.StorageMediumMemory && isMnt {
|
||||
if ed.medium == api.StorageMediumMemory && !notMnt {
|
||||
return nil
|
||||
} else if ed.medium == api.StorageMediumDefault {
|
||||
return nil
|
||||
|
@@ -37,9 +37,9 @@ type realMountDetector struct {
|
||||
|
||||
func (m *realMountDetector) GetMountMedium(path string) (storageMedium, bool, error) {
|
||||
glog.V(5).Infof("Determining mount medium of %v", path)
|
||||
isMnt, err := m.mounter.IsMountPoint(path)
|
||||
notMnt, err := m.mounter.IsLikelyNotMountPoint(path)
|
||||
if err != nil {
|
||||
return 0, false, fmt.Errorf("IsMountPoint(%q): %v", path, err)
|
||||
return 0, false, fmt.Errorf("IsLikelyNotMountPoint(%q): %v", path, err)
|
||||
}
|
||||
buf := syscall.Statfs_t{}
|
||||
if err := syscall.Statfs(path, &buf); err != nil {
|
||||
@@ -48,9 +48,9 @@ func (m *realMountDetector) GetMountMedium(path string) (storageMedium, bool, er
|
||||
|
||||
glog.V(5).Info("Statfs_t of %v: %+v", path, buf)
|
||||
if buf.Type == linuxTmpfsMagic {
|
||||
return mediumMemory, isMnt, nil
|
||||
return mediumMemory, !notMnt, nil
|
||||
}
|
||||
return mediumUnknown, isMnt, nil
|
||||
return mediumUnknown, !notMnt, nil
|
||||
}
|
||||
|
||||
// selinuxEnabled determines whether SELinux is enabled.
|
||||
|
Reference in New Issue
Block a user