summaryrefslogtreecommitdiff
path: root/libpod/storage.go
diff options
context:
space:
mode:
authorDaniel J Walsh <dwalsh@redhat.com>2018-07-30 09:04:18 -0400
committerAtomic Bot <atomic-devel@projectatomic.io>2018-08-01 17:53:30 +0000
commit8e1ef558eb324767ac46e452c80cc79f7ba2e9d2 (patch)
treeedfbbf2dee75ef08a7eb1a4139e3f2da3cf27ecf /libpod/storage.go
parenta8ae7eae9c9e545b685abfd1e42a2a63cb547a80 (diff)
downloadpodman-8e1ef558eb324767ac46e452c80cc79f7ba2e9d2.tar.gz
podman-8e1ef558eb324767ac46e452c80cc79f7ba2e9d2.tar.bz2
podman-8e1ef558eb324767ac46e452c80cc79f7ba2e9d2.zip
Add --force to podman umount to force the unmounting of the rootfs
podman umount will currently only unmount file system if not other process is using it, otherwise the umount decrements the container storage to indicate that the caller is no longer using the mount point, once the count gets to 0, the file system is actually unmounted. Signed-off-by: Daniel J Walsh <dwalsh@redhat.com> Closes: #1184 Approved by: TomSweeneyRedHat
Diffstat (limited to 'libpod/storage.go')
-rw-r--r--libpod/storage.go14
1 files changed, 12 insertions, 2 deletions
diff --git a/libpod/storage.go b/libpod/storage.go
index 9c5fc858e..10827f13e 100644
--- a/libpod/storage.go
+++ b/libpod/storage.go
@@ -231,7 +231,7 @@ func (r *storageService) MountContainerImage(idOrName string) (string, error) {
return mountPoint, nil
}
-func (r *storageService) UnmountContainerImage(idOrName string) (bool, error) {
+func (r *storageService) UnmountContainerImage(idOrName string, force bool) (bool, error) {
if idOrName == "" {
return false, ErrEmptyID
}
@@ -239,7 +239,17 @@ func (r *storageService) UnmountContainerImage(idOrName string) (bool, error) {
if err != nil {
return false, err
}
- mounted, err := r.store.Unmount(container.ID, false)
+
+ if !force {
+ mounted, err := r.store.Mounted(container.ID)
+ if err != nil {
+ return false, err
+ }
+ if mounted == 0 {
+ return false, storage.ErrLayerNotMounted
+ }
+ }
+ mounted, err := r.store.Unmount(container.ID, force)
if err != nil {
logrus.Debugf("failed to unmount container %q: %v", container.ID, err)
return false, err