Merge pull request #980 from devimc/topic/left_mount_points

virtcontainers: set private propagation in rootfs
This commit is contained in:
Peng Tao 2019-01-21 13:28:23 +08:00 committed by GitHub
commit 0c09d2bf9a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -248,10 +248,16 @@ func bindMount(ctx context.Context, source, destination string, readonly bool) e
if err := ensureDestinationExists(absSource, destination); err != nil {
return fmt.Errorf("Could not create destination mount point %v: %v", destination, err)
} else if err := syscall.Mount(absSource, destination, "bind", syscall.MS_BIND, ""); err != nil {
}
if err := syscall.Mount(absSource, destination, "bind", syscall.MS_BIND, ""); err != nil {
return fmt.Errorf("Could not bind mount %v to %v: %v", absSource, destination, err)
}
if err := syscall.Mount("none", destination, "", syscall.MS_PRIVATE, ""); err != nil {
return fmt.Errorf("Could not make mount point %v private: %v", destination, err)
}
// For readonly bind mounts, we need to remount with the readonly flag.
// This is needed as only very recent versions of libmount/util-linux support "bind,ro"
if readonly {