1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00
moby--moby/graphdriver/aufs/mount.go

38 lines
788 B
Go
Raw Normal View History

package aufs
import (
2013-06-04 14:30:47 -04:00
"github.com/dotcloud/docker/utils"
"os"
2013-06-04 14:30:47 -04:00
"os/exec"
"path/filepath"
"syscall"
)
func Unmount(target string) error {
2013-06-04 14:30:47 -04:00
if err := exec.Command("auplink", target, "flush").Run(); err != nil {
utils.Errorf("[warning]: couldn't run auplink before unmount: %s", err)
2013-06-04 14:30:47 -04:00
}
if err := syscall.Unmount(target, 0); err != nil {
return err
}
2013-11-08 13:17:51 -05:00
return nil
}
func Mounted(mountpoint string) (bool, error) {
mntpoint, err := os.Stat(mountpoint)
if err != nil {
if os.IsNotExist(err) {
return false, nil
}
return false, err
}
parent, err := os.Stat(filepath.Join(mountpoint, ".."))
if err != nil {
return false, err
}
mntpointSt := mntpoint.Sys().(*syscall.Stat_t)
parentSt := parent.Sys().(*syscall.Stat_t)
return mntpointSt.Dev != parentSt.Dev, nil
}