Skip to content
This repository was archived by the owner on Dec 13, 2018. It is now read-only.
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions rootfs_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,10 @@ func mountToRootfs(m *configs.Mount, rootfs, mountLabel string) error {
if err := syscall.Mount("", dest, "none", uintptr(syscall.MS_PRIVATE), ""); err != nil {
return err
}
} else {
if err := syscall.Mount("", dest, "none", uintptr(syscall.MS_SLAVE), ""); err != nil {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you explain this chunk?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the mount was not specified as PRIVATE ,then we default to SLAVE.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can I specify syscall.MS_SHARED? If yes, should we handle it?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not yet, there is a separate pull request being worked on for handling all three requests.

You really want that on a container by container basis. The problem we have now is the entire host OS is being setup Private, which means no mount points can ever be made SHARED or SLAVE.

This change is just to make ROOTFS PRIVATE allowing mountpoints outside of ROOTFS to be mounted as PRIVATE. If this works and does not cause the problem @crosbymichael pulled the previous patch for, we can continue working on allowing users to specify differnet mount propogation rules on a container by container basis.

return err
}
}
case "cgroup":
mounts, err := cgroups.GetCgroupMounts()
Expand Down Expand Up @@ -338,14 +342,15 @@ func mknodDevice(dest string, node *configs.Device) error {
}

func prepareRoot(config *configs.Config) error {
if err := syscall.Mount(config.Rootfs, config.Rootfs, "bind", syscall.MS_BIND|syscall.MS_REC, ""); err != nil {
return err
}

flag := syscall.MS_SLAVE | syscall.MS_REC
if config.Privatefs {
flag = syscall.MS_PRIVATE | syscall.MS_REC
}
if err := syscall.Mount("", "/", "", uintptr(flag), ""); err != nil {
return err
}
return syscall.Mount(config.Rootfs, config.Rootfs, "bind", syscall.MS_BIND|syscall.MS_REC, "")
return syscall.Mount("", config.Rootfs, "", uintptr(flag), "")
}

func setReadonly() error {
Expand Down