diff options
author | moricho <ikeda.morito@gmail.com> | 2020-04-20 16:46:22 +0900 |
---|---|---|
committer | moricho <ikeda.morito@gmail.com> | 2020-04-25 22:04:39 +0900 |
commit | 93e510e26fca90a90e10a550ce6ca8d7dfa0b55c (patch) | |
tree | ef9e307a6911c0674c02024b8c23c75cc340b357 /runsc | |
parent | c9199bab927e901947c1647de248433aa3d439fb (diff) |
fix behavior of `getMountNameAndOptions` when options include either bind or rbind
Signed-off-by: moricho <ikeda.morito@gmail.com>
Diffstat (limited to 'runsc')
-rw-r--r-- | runsc/boot/fs.go | 31 |
1 files changed, 24 insertions, 7 deletions
diff --git a/runsc/boot/fs.go b/runsc/boot/fs.go index 98cce60af..e1519673c 100644 --- a/runsc/boot/fs.go +++ b/runsc/boot/fs.go @@ -756,6 +756,15 @@ func (c *containerMounter) createRootMount(ctx context.Context, conf *Config) (* return rootInode, nil } +func (c *containerMounter) getBindMountNameAndOptions(conf *Config, m specs.Mount) (string, []string, bool) { + fd := c.fds.remove() + fsName = "9p" + opts = p9MountOptions(fd, c.getMountAccessType(m)) + // If configured, add overlay to all writable mounts. + useOverlay = conf.Overlay && !mountFlags(m.Options).ReadOnly + return fsName, opts, useOverlay +} + // getMountNameAndOptions retrieves the fsName, opts, and useOverlay values // used for mounts. func (c *containerMounter) getMountNameAndOptions(conf *Config, m specs.Mount) (string, []string, bool, error) { @@ -769,6 +778,13 @@ func (c *containerMounter) getMountNameAndOptions(conf *Config, m specs.Mount) ( case devpts, devtmpfs, proc, sysfs: fsName = m.Type case nonefs: + for _, opt := range m.Options { + if opt == "bind" || opt == "rbind" { + fsName, opts, useOverlay = c.getBindMountNameAndOptions(conf, m) + return fsName, opts, useOverlay, nil + } + } + fsName = sysfs case tmpfs: fsName = m.Type @@ -778,15 +794,16 @@ func (c *containerMounter) getMountNameAndOptions(conf *Config, m specs.Mount) ( if err != nil { return "", nil, false, err } - case bind: - fd := c.fds.remove() - fsName = "9p" - opts = p9MountOptions(fd, c.getMountAccessType(m)) - // If configured, add overlay to all writable mounts. - useOverlay = conf.Overlay && !mountFlags(m.Options).ReadOnly - + fsName, opts, useOverlay = c.getBindMountNameAndOptions(conf, m) default: + for _, opt := range m.Options { + if opt == "bind" || opt == "rbind" { + fsName, opts, useOverlay = c.getBindMountNameAndOptions(conf, m) + return fsName, opts, useOverlay, nil + } + } + log.Warningf("ignoring unknown filesystem type %q", m.Type) } return fsName, opts, useOverlay, nil |