diff --git a/mount/init.go b/mount/init.go index bef83885..53e88051 100644 --- a/mount/init.go +++ b/mount/init.go @@ -27,12 +27,12 @@ type mount struct { // InitializeMountNamespace setups up the devices, mount points, and filesystems for use inside a // new mount namepsace -func InitializeMountNamespace(rootfs, console string, MountSpec *MountSpec) error { +func InitializeMountNamespace(rootfs, console string, MountConfig *MountConfig) error { var ( err error flag = syscall.MS_PRIVATE ) - if MountSpec.NoPivotRoot { + if MountConfig.NoPivotRoot { flag = syscall.MS_SLAVE } if err := system.Mount("", "/", "", uintptr(flag|syscall.MS_REC), ""); err != nil { @@ -41,16 +41,16 @@ func InitializeMountNamespace(rootfs, console string, MountSpec *MountSpec) erro if err := system.Mount(rootfs, rootfs, "bind", syscall.MS_BIND|syscall.MS_REC, ""); err != nil { return fmt.Errorf("mouting %s as bind %s", rootfs, err) } - if err := mountSystem(rootfs, MountSpec); err != nil { + if err := mountSystem(rootfs, MountConfig); err != nil { return fmt.Errorf("mount system %s", err) } - if err := setupBindmounts(rootfs, MountSpec.Mounts); err != nil { + if err := setupBindmounts(rootfs, MountConfig.Mounts); err != nil { return fmt.Errorf("bind mounts %s", err) } - if err := nodes.CreateDeviceNodes(rootfs, MountSpec.DeviceNodes); err != nil { + if err := nodes.CreateDeviceNodes(rootfs, MountConfig.DeviceNodes); err != nil { return fmt.Errorf("create device nodes %s", err) } - if err := SetupPtmx(rootfs, console, MountSpec.MountLabel); err != nil { + if err := SetupPtmx(rootfs, console, MountConfig.MountLabel); err != nil { return err } if err := setupDevSymlinks(rootfs); err != nil { @@ -60,7 +60,7 @@ func InitializeMountNamespace(rootfs, console string, MountSpec *MountSpec) erro return fmt.Errorf("chdir into %s %s", rootfs, err) } - if MountSpec.NoPivotRoot { + if MountConfig.NoPivotRoot { err = MsMoveRoot(rootfs) } else { err = PivotRoot(rootfs) @@ -69,7 +69,7 @@ func InitializeMountNamespace(rootfs, console string, MountSpec *MountSpec) erro return err } - if MountSpec.ReadonlyFs { + if MountConfig.ReadonlyFs { if err := SetReadonly(); err != nil { return fmt.Errorf("set readonly %s", err) } @@ -82,8 +82,8 @@ func InitializeMountNamespace(rootfs, console string, MountSpec *MountSpec) erro // mountSystem sets up linux specific system mounts like sys, proc, shm, and devpts // inside the mount namespace -func mountSystem(rootfs string, MountSpec *MountSpec) error { - for _, m := range newSystemMounts(rootfs, MountSpec.MountLabel, MountSpec.Mounts) { +func mountSystem(rootfs string, MountConfig *MountConfig) error { + for _, m := range newSystemMounts(rootfs, MountConfig.MountLabel, MountConfig.Mounts) { if err := os.MkdirAll(m.path, 0755); err != nil && !os.IsExist(err) { return fmt.Errorf("mkdirall %s %s", m.path, err) } diff --git a/mount/types.go b/mount/types.go index 3234c753..54586e7e 100644 --- a/mount/types.go +++ b/mount/types.go @@ -5,7 +5,7 @@ import ( "github.com/docker/libcontainer/devices" ) -type MountSpec struct { +type MountConfig struct { // NoPivotRoot will use MS_MOVE and a chroot to jail the process into the container's rootfs // This is a common option when the container is running in ramdisk NoPivotRoot bool `json:"no_pivot_root,omitempty"` diff --git a/namespaces/init.go b/namespaces/init.go index 61a545f5..5b97b1cb 100644 --- a/namespaces/init.go +++ b/namespaces/init.go @@ -69,7 +69,7 @@ func Init(container *libcontainer.Container, uncleanRootfs, consolePath string, label.Init() - if err := mount.InitializeMountNamespace(rootfs, consolePath, libcontainer.GetInternalMountSpec(container)); err != nil { + if err := mount.InitializeMountNamespace(rootfs, consolePath, libcontainer.GetInternalMountConfig(container)); err != nil { return fmt.Errorf("setup mount namespace %s", err) } if container.Hostname != "" { diff --git a/utils.go b/utils.go index cc7b6b5d..d9c65c58 100644 --- a/utils.go +++ b/utils.go @@ -6,8 +6,8 @@ import ( "github.com/docker/libcontainer/security/capabilities" ) -func GetInternalMountSpec(container *Container) *mount.MountSpec { - out := &mount.MountSpec{ +func GetInternalMountConfig(container *Container) *mount.MountConfig { + out := &mount.MountConfig{ NoPivotRoot: container.NoPivotRoot, ReadonlyFs: container.ReadonlyFs, DeviceNodes: container.DeviceNodes,