Skip to content

Commit 08d99a2

Browse files
committed
libcontainer/specconv/spec_linux: Support empty 'type' for bind mounts
From the "Creating a bind mount" section of mount(2) [1]: > If mountflags includes MS_BIND (available since Linux 2.4), then > perform a bind mount... > > The filesystemtype and data arguments are ignored. This commit adds support for configurations that leave the OPTIONAL type [2] unset for bind mounts. There's a related spec-example change in flight with [3], although my personal preference would be a more explicit spec for the whole mount structure [4]. [1]: http://man7.org/linux/man-pages/man2/mount.2.html [2]: https://github.com/opencontainers/runtime-spec/blame/v1.0.1/config.md#L102 [3]: opencontainers/runtime-spec#954 [4]: opencontainers/runtime-spec#771 Signed-off-by: W. Trevor King <[email protected]>
1 parent f29a591 commit 08d99a2

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

libcontainer/specconv/spec_linux.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -269,13 +269,17 @@ func CreateLibcontainerConfig(opts *CreateOpts) (*configs.Config, error) {
269269
func createLibcontainerMount(cwd string, m specs.Mount) *configs.Mount {
270270
flags, pgflags, data, ext := parseMountOptions(m.Options)
271271
source := m.Source
272-
if m.Type == "bind" {
272+
device := m.Type
273+
if flags|unix.MS_BIND != 0 {
274+
if device == "" {
275+
device = "bind"
276+
}
273277
if !filepath.IsAbs(source) {
274278
source = filepath.Join(cwd, m.Source)
275279
}
276280
}
277281
return &configs.Mount{
278-
Device: m.Type,
282+
Device: device,
279283
Source: source,
280284
Destination: m.Destination,
281285
Data: data,

0 commit comments

Comments
 (0)