2014-01-31 05:16:42 -05:00
|
|
|
// +build linux,amd64
|
2013-11-27 22:12:51 -05:00
|
|
|
|
2013-11-07 17:37:33 -05:00
|
|
|
package devmapper
|
|
|
|
|
|
|
|
import (
|
2014-05-16 08:10:02 -04:00
|
|
|
"os"
|
2013-11-07 17:37:33 -05:00
|
|
|
"path/filepath"
|
2014-05-16 08:10:02 -04:00
|
|
|
"syscall"
|
2013-11-07 17:37:33 -05:00
|
|
|
)
|
|
|
|
|
|
|
|
// FIXME: this is copy-pasted from the aufs driver.
|
|
|
|
// It should be moved into the core.
|
|
|
|
|
2014-05-16 08:10:02 -04:00
|
|
|
func Mounted(mountpoint string) (bool, error) {
|
|
|
|
mntpoint, err := os.Stat(mountpoint)
|
2013-11-07 17:37:33 -05:00
|
|
|
if err != nil {
|
2014-05-16 08:10:02 -04:00
|
|
|
if os.IsNotExist(err) {
|
2013-11-07 17:37:33 -05:00
|
|
|
return false, nil
|
|
|
|
}
|
|
|
|
return false, err
|
|
|
|
}
|
2014-05-16 08:10:02 -04:00
|
|
|
parent, err := os.Stat(filepath.Join(mountpoint, ".."))
|
2013-11-07 17:37:33 -05:00
|
|
|
if err != nil {
|
|
|
|
return false, err
|
|
|
|
}
|
2014-05-16 08:10:02 -04:00
|
|
|
mntpointSt := mntpoint.Sys().(*syscall.Stat_t)
|
|
|
|
parentSt := parent.Sys().(*syscall.Stat_t)
|
2013-11-07 17:37:33 -05:00
|
|
|
return mntpointSt.Dev != parentSt.Dev, nil
|
|
|
|
}
|