Skip to content

Commit

Permalink
Rename MountSpec to MountConfig.
Browse files Browse the repository at this point in the history
Docker-DCO-1.1-Signed-off-by: Vishnu Kannan <vishnuk@google.com> (github: vishh)
  • Loading branch information
vishh committed Jun 23, 2014
1 parent b502663 commit 4c55db7
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 14 deletions.
20 changes: 10 additions & 10 deletions mount/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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 {
Expand All @@ -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)
Expand All @@ -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)
}
Expand All @@ -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)
}
Expand Down
2 changes: 1 addition & 1 deletion mount/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
Expand Down
2 changes: 1 addition & 1 deletion namespaces/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 != "" {
Expand Down
4 changes: 2 additions & 2 deletions utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 4c55db7

Please sign in to comment.