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:
@@ -36,13 +36,13 @@ type diskManager interface {
|
||||
func diskSetUp(manager diskManager, b iscsiDiskBuilder, volPath string, mounter mount.Interface) error {
|
||||
globalPDPath := manager.MakeGlobalPDName(*b.iscsiDisk)
|
||||
// TODO: handle failed mounts here.
|
||||
mountpoint, err := mounter.IsMountPoint(volPath)
|
||||
notMnt, err := mounter.IsLikelyNotMountPoint(volPath)
|
||||
|
||||
if err != nil && !os.IsNotExist(err) {
|
||||
glog.Errorf("cannot validate mountpoint: %s", volPath)
|
||||
return err
|
||||
}
|
||||
if mountpoint {
|
||||
if !notMnt {
|
||||
return nil
|
||||
}
|
||||
if err := manager.AttachDisk(b); err != nil {
|
||||
@@ -69,12 +69,12 @@ func diskSetUp(manager diskManager, b iscsiDiskBuilder, volPath string, mounter
|
||||
|
||||
// utility to tear down a disk based filesystem
|
||||
func diskTearDown(manager diskManager, c iscsiDiskCleaner, volPath string, mounter mount.Interface) error {
|
||||
mountpoint, err := mounter.IsMountPoint(volPath)
|
||||
notMnt, err := mounter.IsLikelyNotMountPoint(volPath)
|
||||
if err != nil {
|
||||
glog.Errorf("cannot validate mountpoint %s", volPath)
|
||||
return err
|
||||
}
|
||||
if !mountpoint {
|
||||
if notMnt {
|
||||
return os.Remove(volPath)
|
||||
}
|
||||
|
||||
@@ -97,12 +97,12 @@ func diskTearDown(manager diskManager, c iscsiDiskCleaner, volPath string, mount
|
||||
}
|
||||
}
|
||||
|
||||
mountpoint, mntErr := mounter.IsMountPoint(volPath)
|
||||
notMnt, mntErr := mounter.IsLikelyNotMountPoint(volPath)
|
||||
if mntErr != nil {
|
||||
glog.Errorf("isMountpoint check failed: %v", mntErr)
|
||||
glog.Errorf("IsLikelyNotMountPoint check failed: %v", mntErr)
|
||||
return err
|
||||
}
|
||||
if !mountpoint {
|
||||
if notMnt {
|
||||
if err := os.Remove(volPath); err != nil {
|
||||
return err
|
||||
}
|
||||
|
@@ -101,8 +101,8 @@ func (util *ISCSIUtil) AttachDisk(b iscsiDiskBuilder) error {
|
||||
}
|
||||
// mount it
|
||||
globalPDPath := b.manager.MakeGlobalPDName(*b.iscsiDisk)
|
||||
mountpoint, err := b.mounter.IsMountPoint(globalPDPath)
|
||||
if mountpoint {
|
||||
notMnt, err := b.mounter.IsLikelyNotMountPoint(globalPDPath)
|
||||
if !notMnt {
|
||||
glog.Infof("iscsi: %s already mounted", globalPDPath)
|
||||
return nil
|
||||
}
|
||||
|
Reference in New Issue
Block a user