diff options
author | Matthew Heon <matthew.heon@gmail.com> | 2018-03-07 14:10:19 -0500 |
---|---|---|
committer | Atomic Bot <atomic-devel@projectatomic.io> | 2018-03-08 16:40:21 +0000 |
commit | 54f32f2cc024090c3f284f7b0b6832f2b19a6660 (patch) | |
tree | f3a221a9d1fe522afa9f43cb72b4cb94552788d0 /libpod/container.go | |
parent | c657511bce7bc1c5da4b5554a4850aa4046711b0 (diff) | |
download | podman-54f32f2cc024090c3f284f7b0b6832f2b19a6660.tar.gz podman-54f32f2cc024090c3f284f7b0b6832f2b19a6660.tar.bz2 podman-54f32f2cc024090c3f284f7b0b6832f2b19a6660.zip |
Convert bind mounts to use DB field
Refactors creation of bind mounts into a separate function that
can be called from elsewhere (e.g. pod start or container
restart). This function stores the mounts in the DB using the
field established last commit.
Spec generation now relies upon this field in the DB instead of
manually enumerating files to be bind mounted in.
Signed-off-by: Matthew Heon <matthew.heon@gmail.com>
Closes: #462
Approved by: baude
Diffstat (limited to 'libpod/container.go')
-rw-r--r-- | libpod/container.go | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/libpod/container.go b/libpod/container.go index 95db85b70..648dc821e 100644 --- a/libpod/container.go +++ b/libpod/container.go @@ -710,6 +710,35 @@ func (c *Container) Routes() ([]types.Route, error) { return routes, nil } +// BindMounts retrieves bind mounts that were created by libpod and will be +// added to the container +// All these mounts except /dev/shm are ignored if a mount in the given spec has +// the same destination +// These mounts include /etc/resolv.conf, /etc/hosts, and /etc/hostname +// The return is formatted as a map from destination (mountpoint in the +// container) to source (path of the file that will be mounted into the +// container) +// If the container has not been started yet, an empty map will be returned, as +// the files in question are only created when the container is started. +func (c *Container) BindMounts() (map[string]string, error) { + if !c.locked { + c.lock.Lock() + defer c.lock.Unlock() + + if err := c.syncContainer(); err != nil { + return nil, err + } + } + + newMap := make(map[string]string, len(c.state.BindMounts)) + + for key, val := range c.state.BindMounts { + newMap[key] = val + } + + return newMap, nil +} + // Misc Accessors // Most will require locking |