2014-04-11 23:06:56 +08:00
|
|
|
// +build linux
|
|
|
|
|
|
|
|
package mount
|
|
|
|
|
2014-07-15 08:00:05 +08:00
|
|
|
import "syscall"
|
2014-04-11 23:06:56 +08:00
|
|
|
|
|
|
|
func RemountProc() error {
|
2014-07-15 08:00:05 +08:00
|
|
|
if err := syscall.Unmount("/proc", syscall.MNT_DETACH); err != nil {
|
2014-04-11 23:06:56 +08:00
|
|
|
return err
|
|
|
|
}
|
2014-07-15 08:00:05 +08:00
|
|
|
|
|
|
|
if err := syscall.Mount("proc", "/proc", "proc", uintptr(defaultMountFlags), ""); err != nil {
|
2014-04-11 23:06:56 +08:00
|
|
|
return err
|
|
|
|
}
|
2014-07-15 08:00:05 +08:00
|
|
|
|
2014-04-11 23:06:56 +08:00
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func RemountSys() error {
|
2014-07-15 08:00:05 +08:00
|
|
|
if err := syscall.Unmount("/sys", syscall.MNT_DETACH); err != nil {
|
2014-04-11 23:06:56 +08:00
|
|
|
if err != syscall.EINVAL {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
} else {
|
2014-07-15 08:00:05 +08:00
|
|
|
if err := syscall.Mount("sysfs", "/sys", "sysfs", uintptr(defaultMountFlags), ""); err != nil {
|
2014-04-11 23:06:56 +08:00
|
|
|
return err
|
|
|
|
}
|
|
|
|
}
|
2014-07-15 08:00:05 +08:00
|
|
|
|
2014-04-11 23:06:56 +08:00
|
|
|
return nil
|
|
|
|
}
|