Rename MountSpec to MountConfig.

Docker-DCO-1.1-Signed-off-by: Vishnu Kannan <vishnuk@google.com> (github: vishh)
This commit is contained in:
Vishnu Kannan 2014-06-23 18:09:36 +00:00
parent b50266335e
commit 4c55db7d58
4 changed files with 14 additions and 14 deletions

View File

@ -27,12 +27,12 @@ type mount struct {
// InitializeMountNamespace setups up the devices, mount points, and filesystems for use inside a // InitializeMountNamespace setups up the devices, mount points, and filesystems for use inside a
// new mount namepsace // new mount namepsace
func InitializeMountNamespace(rootfs, console string, MountSpec *MountSpec) error { func InitializeMountNamespace(rootfs, console string, MountConfig *MountConfig) error {
var ( var (
err error err error
flag = syscall.MS_PRIVATE flag = syscall.MS_PRIVATE
) )
if MountSpec.NoPivotRoot { if MountConfig.NoPivotRoot {
flag = syscall.MS_SLAVE flag = syscall.MS_SLAVE
} }
if err := system.Mount("", "/", "", uintptr(flag|syscall.MS_REC), ""); err != nil { 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 { 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) 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) 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) 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) 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 return err
} }
if err := setupDevSymlinks(rootfs); err != nil { 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) return fmt.Errorf("chdir into %s %s", rootfs, err)
} }
if MountSpec.NoPivotRoot { if MountConfig.NoPivotRoot {
err = MsMoveRoot(rootfs) err = MsMoveRoot(rootfs)
} else { } else {
err = PivotRoot(rootfs) err = PivotRoot(rootfs)
@ -69,7 +69,7 @@ func InitializeMountNamespace(rootfs, console string, MountSpec *MountSpec) erro
return err return err
} }
if MountSpec.ReadonlyFs { if MountConfig.ReadonlyFs {
if err := SetReadonly(); err != nil { if err := SetReadonly(); err != nil {
return fmt.Errorf("set readonly %s", err) 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 // mountSystem sets up linux specific system mounts like sys, proc, shm, and devpts
// inside the mount namespace // inside the mount namespace
func mountSystem(rootfs string, MountSpec *MountSpec) error { func mountSystem(rootfs string, MountConfig *MountConfig) error {
for _, m := range newSystemMounts(rootfs, MountSpec.MountLabel, MountSpec.Mounts) { for _, m := range newSystemMounts(rootfs, MountConfig.MountLabel, MountConfig.Mounts) {
if err := os.MkdirAll(m.path, 0755); err != nil && !os.IsExist(err) { if err := os.MkdirAll(m.path, 0755); err != nil && !os.IsExist(err) {
return fmt.Errorf("mkdirall %s %s", m.path, err) return fmt.Errorf("mkdirall %s %s", m.path, err)
} }

View File

@ -5,7 +5,7 @@ import (
"github.com/docker/libcontainer/devices" "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 // 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 // This is a common option when the container is running in ramdisk
NoPivotRoot bool `json:"no_pivot_root,omitempty"` NoPivotRoot bool `json:"no_pivot_root,omitempty"`

View File

@ -69,7 +69,7 @@ func Init(container *libcontainer.Container, uncleanRootfs, consolePath string,
label.Init() 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) return fmt.Errorf("setup mount namespace %s", err)
} }
if container.Hostname != "" { if container.Hostname != "" {

View File

@ -6,8 +6,8 @@ import (
"github.com/docker/libcontainer/security/capabilities" "github.com/docker/libcontainer/security/capabilities"
) )
func GetInternalMountSpec(container *Container) *mount.MountSpec { func GetInternalMountConfig(container *Container) *mount.MountConfig {
out := &mount.MountSpec{ out := &mount.MountConfig{
NoPivotRoot: container.NoPivotRoot, NoPivotRoot: container.NoPivotRoot,
ReadonlyFs: container.ReadonlyFs, ReadonlyFs: container.ReadonlyFs,
DeviceNodes: container.DeviceNodes, DeviceNodes: container.DeviceNodes,