mirror of
https://github.com/opencontainers/runc.git
synced 2026-07-11 06:03:57 +08:00
Replace config.Privatefs with config.RootPropagation
Right now config.Privatefs is a boolean which determines if / is applied with propagation flag syscall.MS_PRIVATE | syscall.MS_REC or not. Soon we want to represent other propagation states like private, [r]slave, and [r]shared. So either we can introduce more boolean variable or keep track of propagation flags in an integer variable. Keeping an integer variable is more versatile and can allow various kind of propagation flags to be specified. So replace Privatefs with RootPropagation which is an integer. Note, this will require changes in docker. Instead of setting Privatefs to true, they will need to set. config.RootPropagation = syscall.MS_PRIVATE | syscall.MS_REC Signed-off-by: Vivek Goyal <vgoyal@redhat.com>
This commit is contained in:
@@ -92,8 +92,8 @@ type Config struct {
|
|||||||
// bind mounts are writtable.
|
// bind mounts are writtable.
|
||||||
Readonlyfs bool `json:"readonlyfs"`
|
Readonlyfs bool `json:"readonlyfs"`
|
||||||
|
|
||||||
// Privatefs will mount the container's rootfs as private where mount points from the parent will not propogate
|
// Specifies the mount propagation flags to be applied to /.
|
||||||
Privatefs bool `json:"privatefs"`
|
RootPropagation int `json:"rootPropagation"`
|
||||||
|
|
||||||
// Mounts specify additional source and destination paths that will be mounted inside the container's
|
// Mounts specify additional source and destination paths that will be mounted inside the container's
|
||||||
// rootfs and mount namespace if specified
|
// rootfs and mount namespace if specified
|
||||||
|
|||||||
@@ -422,8 +422,8 @@ func mknodDevice(dest string, node *configs.Device) error {
|
|||||||
|
|
||||||
func prepareRoot(config *configs.Config) error {
|
func prepareRoot(config *configs.Config) error {
|
||||||
flag := syscall.MS_SLAVE | syscall.MS_REC
|
flag := syscall.MS_SLAVE | syscall.MS_REC
|
||||||
if config.Privatefs {
|
if config.RootPropagation != 0 {
|
||||||
flag = syscall.MS_PRIVATE | syscall.MS_REC
|
flag = config.RootPropagation
|
||||||
}
|
}
|
||||||
if err := syscall.Mount("", "/", "", uintptr(flag), ""); err != nil {
|
if err := syscall.Mount("", "/", "", uintptr(flag), ""); err != nil {
|
||||||
return err
|
return err
|
||||||
|
|||||||
@@ -329,11 +329,11 @@ func createLibcontainerConfig(cgroupName string, spec *specs.LinuxSpec, rspec *s
|
|||||||
rootfsPath = filepath.Join(cwd, rootfsPath)
|
rootfsPath = filepath.Join(cwd, rootfsPath)
|
||||||
}
|
}
|
||||||
config := &configs.Config{
|
config := &configs.Config{
|
||||||
Rootfs: rootfsPath,
|
Rootfs: rootfsPath,
|
||||||
Capabilities: spec.Linux.Capabilities,
|
Capabilities: spec.Linux.Capabilities,
|
||||||
Readonlyfs: spec.Root.Readonly,
|
Readonlyfs: spec.Root.Readonly,
|
||||||
Hostname: spec.Hostname,
|
Hostname: spec.Hostname,
|
||||||
Privatefs: true,
|
RootPropagation: syscall.MS_PRIVATE | syscall.MS_REC,
|
||||||
}
|
}
|
||||||
for _, ns := range rspec.Linux.Namespaces {
|
for _, ns := range rspec.Linux.Namespaces {
|
||||||
t, exists := namespaceMapping[ns.Type]
|
t, exists := namespaceMapping[ns.Type]
|
||||||
|
|||||||
Reference in New Issue
Block a user