diff options
author | Matthew Heon <matthew.heon@gmail.com> | 2018-07-20 12:31:32 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-07-20 12:31:32 -0400 |
commit | 7944bca4681893971ad6bda4ade4e1b3470b9559 (patch) | |
tree | a829606b854c78edccd041f6d911580c24b5356e /libpod/container_api.go | |
parent | d433e5612409f9e2207b11b017b1101631a7971b (diff) | |
parent | 85db3f09bff68efb0a8509f7470b61604aefb447 (diff) | |
download | podman-7944bca4681893971ad6bda4ade4e1b3470b9559.tar.gz podman-7944bca4681893971ad6bda4ade4e1b3470b9559.tar.bz2 podman-7944bca4681893971ad6bda4ade4e1b3470b9559.zip |
Merge pull request #1104 from rhatdan/mounting
Let containers/storage keep track of mounts
Diffstat (limited to 'libpod/container_api.go')
-rw-r--r-- | libpod/container_api.go | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/libpod/container_api.go b/libpod/container_api.go index a3756ac5f..bb9727ec1 100644 --- a/libpod/container_api.go +++ b/libpod/container_api.go @@ -437,11 +437,7 @@ func (c *Container) Mount() (string, error) { } } - if err := c.mountStorage(); err != nil { - return "", err - } - - return c.state.Mountpoint, nil + return c.mount() } // Unmount unmounts a container's filesystem on the host @@ -456,15 +452,24 @@ func (c *Container) Unmount() error { } if c.state.State == ContainerStateRunning || c.state.State == ContainerStatePaused { - return errors.Wrapf(ErrCtrStateInvalid, "cannot remove storage for container %s as it is running or paused", c.ID()) + return errors.Wrapf(ErrCtrStateInvalid, "cannot unmount storage for container %s as it is running or paused", c.ID()) } // Check if we have active exec sessions if len(c.state.ExecSessions) != 0 { - return errors.Wrapf(ErrCtrStateInvalid, "container %s has active exec sessions, refusing to clean up", c.ID()) + return errors.Wrapf(ErrCtrStateInvalid, "container %s has active exec sessions, refusing to unmount", c.ID()) } - return c.cleanupStorage() + if c.state.Mounted { + mounted, err := c.runtime.storageService.MountedContainerImage(c.ID()) + if err != nil { + return errors.Wrapf(err, "can't determine how many times %s is mounted, refusing to unmount", c.ID()) + } + if mounted == 1 { + return errors.Wrapf(err, "can't unmount %s last mount, it is still in use", c.ID()) + } + } + return c.unmount() } // Pause pauses a container |