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:
@@ -215,12 +215,12 @@ func (util *RBDUtil) AttachDisk(b rbdBuilder) error {
|
||||
}
|
||||
// mount it
|
||||
globalPDPath := b.manager.MakeGlobalPDName(*b.rbd)
|
||||
mountpoint, err := b.mounter.IsMountPoint(globalPDPath)
|
||||
// in the first time, the path shouldn't exist and IsMountPoint is expected to get NotExist
|
||||
notMnt, err := b.mounter.IsLikelyNotMountPoint(globalPDPath)
|
||||
// in the first time, the path shouldn't exist and IsLikelyNotMountPoint is expected to get NotExist
|
||||
if err != nil && !os.IsNotExist(err) {
|
||||
return fmt.Errorf("rbd: %s failed to check mountpoint", globalPDPath)
|
||||
}
|
||||
if mountpoint {
|
||||
if !notMnt {
|
||||
return nil
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user