Skip to content
This repository has been archived by the owner on May 12, 2021. It is now read-only.

Commit

Permalink
Merge pull request #980 from devimc/topic/left_mount_points
Browse files Browse the repository at this point in the history
virtcontainers: set private propagation in rootfs
  • Loading branch information
bergwolf committed Jan 21, 2019
2 parents 150a44f + b029e44 commit 0c09d2b
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion virtcontainers/mount.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 0c09d2b

Please sign in to comment.