diff --git a/cgroups/fs/cpuacct.go b/cgroups/fs/cpuacct.go index be180520..7979009c 100644 --- a/cgroups/fs/cpuacct.go +++ b/cgroups/fs/cpuacct.go @@ -12,7 +12,7 @@ import ( "time" "github.com/docker/libcontainer/cgroups" - "github.com/dotcloud/docker/pkg/system" + "github.com/docker/libcontainer/system" ) var ( diff --git a/mount/pivotroot.go b/mount/pivotroot.go index ffd60513..a88ed4a8 100644 --- a/mount/pivotroot.go +++ b/mount/pivotroot.go @@ -8,8 +8,6 @@ import ( "os" "path/filepath" "syscall" - - "github.com/dotcloud/docker/pkg/system" ) func PivotRoot(rootfs string) error { @@ -17,16 +15,20 @@ func PivotRoot(rootfs string) error { if err != nil { return fmt.Errorf("can't create pivot_root dir %s, error %v", pivotDir, err) } - if err := system.Pivotroot(rootfs, pivotDir); err != nil { + + if err := syscall.PivotRoot(rootfs, pivotDir); err != nil { return fmt.Errorf("pivot_root %s", err) } - if err := system.Chdir("/"); err != nil { + + if err := syscall.Chdir("/"); err != nil { return fmt.Errorf("chdir / %s", err) } + // path to pivot dir now changed, update pivotDir = filepath.Join("/", filepath.Base(pivotDir)) - if err := system.Unmount(pivotDir, syscall.MNT_DETACH); err != nil { + if err := syscall.Unmount(pivotDir, syscall.MNT_DETACH); err != nil { return fmt.Errorf("unmount pivot_root dir %s", err) } + return os.Remove(pivotDir) } diff --git a/mount/ptmx.go b/mount/ptmx.go index 32c02520..c316481a 100644 --- a/mount/ptmx.go +++ b/mount/ptmx.go @@ -4,9 +4,10 @@ package mount import ( "fmt" - "github.com/docker/libcontainer/console" "os" "path/filepath" + + "github.com/docker/libcontainer/console" ) func SetupPtmx(rootfs, consolePath, mountLabel string) error { @@ -14,13 +15,16 @@ func SetupPtmx(rootfs, consolePath, mountLabel string) error { if err := os.Remove(ptmx); err != nil && !os.IsNotExist(err) { return err } + if err := os.Symlink("pts/ptmx", ptmx); err != nil { return fmt.Errorf("symlink dev ptmx %s", err) } + if consolePath != "" { if err := console.Setup(rootfs, consolePath, mountLabel); err != nil { return err } } + return nil } diff --git a/mount/readonly.go b/mount/readonly.go index 0658358a..9b4a6f70 100644 --- a/mount/readonly.go +++ b/mount/readonly.go @@ -3,10 +3,9 @@ package mount import ( - "github.com/dotcloud/docker/pkg/system" "syscall" ) func SetReadonly() error { - return system.Mount("/", "/", "bind", syscall.MS_BIND|syscall.MS_REMOUNT|syscall.MS_RDONLY|syscall.MS_REC, "") + return syscall.Mount("/", "/", "bind", syscall.MS_BIND|syscall.MS_REMOUNT|syscall.MS_RDONLY|syscall.MS_REC, "") } diff --git a/mount/remount.go b/mount/remount.go index 3e00509a..99a01209 100644 --- a/mount/remount.go +++ b/mount/remount.go @@ -2,30 +2,30 @@ package mount -import ( - "github.com/dotcloud/docker/pkg/system" - "syscall" -) +import "syscall" func RemountProc() error { - if err := system.Unmount("/proc", syscall.MNT_DETACH); err != nil { + if err := syscall.Unmount("/proc", syscall.MNT_DETACH); err != nil { return err } - if err := system.Mount("proc", "/proc", "proc", uintptr(defaultMountFlags), ""); err != nil { + + if err := syscall.Mount("proc", "/proc", "proc", uintptr(defaultMountFlags), ""); err != nil { return err } + return nil } func RemountSys() error { - if err := system.Unmount("/sys", syscall.MNT_DETACH); err != nil { + if err := syscall.Unmount("/sys", syscall.MNT_DETACH); err != nil { if err != syscall.EINVAL { return err } } else { - if err := system.Mount("sysfs", "/sys", "sysfs", uintptr(defaultMountFlags), ""); err != nil { + if err := syscall.Mount("sysfs", "/sys", "sysfs", uintptr(defaultMountFlags), ""); err != nil { return err } } + return nil } diff --git a/system/sysconfig.go b/system/sysconfig.go new file mode 100644 index 00000000..dcbe6c9c --- /dev/null +++ b/system/sysconfig.go @@ -0,0 +1,13 @@ +// +build linux,cgo + +package system + +/* +#include +int get_hz(void) { return sysconf(_SC_CLK_TCK); } +*/ +import "C" + +func GetClockTicks() int { + return int(C.get_hz()) +}