From 98287edb4994c977e41ff1fd78de4169ed87f4bf Mon Sep 17 00:00:00 2001 From: Akihiro Suda Date: Wed, 16 Sep 2020 18:56:31 +0900 Subject: [PATCH] allow bind mount w/o explicit "bind" opt but w/ explicit "bind" type Previously, {"type":"bind"} without {"options": ["bind"]} was failing with ENODEV. See https://github.com/containers/podman/issues/7652 Signed-off-by: Akihiro Suda --- libcontainer/specconv/spec_linux.go | 3 +++ tests/integration/mounts.bats | 9 +++++++++ 2 files changed, 12 insertions(+) diff --git a/libcontainer/specconv/spec_linux.go b/libcontainer/specconv/spec_linux.go index 11235acc432..f731387ab86 100644 --- a/libcontainer/specconv/spec_linux.go +++ b/libcontainer/specconv/spec_linux.go @@ -329,6 +329,9 @@ func CreateLibcontainerConfig(opts *CreateOpts) (*configs.Config, error) { func createLibcontainerMount(cwd string, m specs.Mount) *configs.Mount { flags, pgflags, data, ext := parseMountOptions(m.Options) + if m.Type == "bind" { + flags |= unix.MS_BIND + } source := m.Source device := m.Type if flags&unix.MS_BIND != 0 { diff --git a/tests/integration/mounts.bats b/tests/integration/mounts.bats index bd41dc6ea77..4e4a01f04bd 100644 --- a/tests/integration/mounts.bats +++ b/tests/integration/mounts.bats @@ -19,3 +19,12 @@ function teardown() { [ "$status" -eq 0 ] [[ "${lines[0]}" == *'/tmp/bind/config.json'* ]] } + +@test "runc run [bind mount w/o explicit \"bind\" opt but w/ explicit \"bind\" type]" { + update_config ' .mounts += [{"source": ".", "destination": "/tmp/bind", "type":"bind"}] + | .process.args |= ["ls", "/tmp/bind/config.json"]' + + runc run test_bind_mount + [ "$status" -eq 0 ] + [[ "${lines[0]}" == *'/tmp/bind/config.json'* ]] +}