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 #123 from sboeuf/fix_k8s
Browse files Browse the repository at this point in the history
virtcontainers: Don't ignore container mounts based on their path
  • Loading branch information
chavafg authored Mar 28, 2018
2 parents 01f7e46 + 80996b3 commit c4f922d
Show file tree
Hide file tree
Showing 4 changed files with 1 addition and 39 deletions.
2 changes: 1 addition & 1 deletion virtcontainers/container.go
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ func (c *Container) createContainersDirs() error {
func (c *Container) mountSharedDirMounts(hostSharedDir, guestSharedDir string) ([]Mount, error) {
var sharedDirMounts []Mount
for idx, m := range c.mounts {
if isSystemMount(m.Destination) || m.Type != "bind" {
if m.Type != "bind" {
continue
}

Expand Down
2 changes: 0 additions & 2 deletions virtcontainers/kata_agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -570,8 +570,6 @@ func constraintGRPCSpec(grpcSpec *grpc.Spec) {
grpcSpec.Mounts[idx].Type = "tmpfs"
grpcSpec.Mounts[idx].Source = "shm"
grpcSpec.Mounts[idx].Options = []string{"noexec", "nosuid", "nodev", "mode=1777", "size=65536k"}

break
}
}
}
Expand Down
12 changes: 0 additions & 12 deletions virtcontainers/mount.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,18 +29,6 @@ import (

var rootfsDir = "rootfs"

var systemMountPrefixes = []string{"/proc", "/dev", "/sys"}

func isSystemMount(m string) bool {
for _, p := range systemMountPrefixes {
if m == p || strings.HasPrefix(m, p+"/") {
return true
}
}

return false
}

func major(dev uint64) int {
return int((dev >> 8) & 0xfff)
}
Expand Down
24 changes: 0 additions & 24 deletions virtcontainers/mount_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,30 +29,6 @@ import (
"testing"
)

func TestIsSystemMount(t *testing.T) {
tests := []struct {
mnt string
expected bool
}{
{"/sys", true},
{"/sys/", true},
{"/sys//", true},
{"/sys/fs", true},
{"/sys/fs/", true},
{"/sys/fs/cgroup", true},
{"/sysfoo", false},
{"/home", false},
{"/dev/block/", true},
}

for _, test := range tests {
result := isSystemMount(test.mnt)
if result != test.expected {
t.Fatalf("Expected result for path %s : %v, got %v", test.mnt, test.expected, result)
}
}
}

func TestMajorMinorNumber(t *testing.T) {
devices := []string{"/dev/zero", "/dev/net/tun"}

Expand Down

0 comments on commit c4f922d

Please sign in to comment.