Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions libcontainer/specconv/spec_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
9 changes: 9 additions & 0 deletions tests/integration/mounts.bats
Original file line number Diff line number Diff line change
Expand Up @@ -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'* ]]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this will also match something like "ls: /tmp/bind/config.json: no such file or directory" which is not good.

I think we should list the directory instead, and check the file is present in the output.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We check the status code, so it won't match ls: /tmp/bind/config.json: no such file or directory

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

well in this case it does not make sense to check the output, since ls will definitely return the error if the file is not there, so this check is redundant

Copy link
Contributor

@kolyshkin kolyshkin Sep 21, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So I guess either

  • list the directory, check the exit code, check the output to contain file name

or

  • list the file, check the exit code

}