diff options
author | Daniel J Walsh <dwalsh@redhat.com> | 2018-12-06 03:20:16 -0500 |
---|---|---|
committer | Daniel J Walsh <dwalsh@redhat.com> | 2018-12-06 03:20:16 -0500 |
commit | 40678b119c0186bf7c56dc09d131e697c55cb9fd (patch) | |
tree | dfb1cc13b0bdc1abad1ada51970bf0ac03d46810 /pkg/varlinkapi/mount.go | |
parent | dcb68d1aa24b2dd00d793f5a66f96cc5403b43c3 (diff) | |
parent | 75b19ca8abe1957f3c48035767960a6b20c10519 (diff) | |
download | podman-40678b119c0186bf7c56dc09d131e697c55cb9fd.tar.gz podman-40678b119c0186bf7c56dc09d131e697c55cb9fd.tar.bz2 podman-40678b119c0186bf7c56dc09d131e697c55cb9fd.zip |
Merge branch 'master' of github.com:containers/libpod into vendor
Diffstat (limited to 'pkg/varlinkapi/mount.go')
-rw-r--r-- | pkg/varlinkapi/mount.go | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/pkg/varlinkapi/mount.go b/pkg/varlinkapi/mount.go new file mode 100644 index 000000000..84e6b2709 --- /dev/null +++ b/pkg/varlinkapi/mount.go @@ -0,0 +1,49 @@ +package varlinkapi + +import ( + "github.com/containers/libpod/cmd/podman/varlink" +) + +// ListContainerMounts ... +func (i *LibpodAPI) ListContainerMounts(call iopodman.VarlinkCall) error { + var mounts []string + allContainers, err := i.Runtime.GetAllContainers() + if err != nil { + return call.ReplyErrorOccurred(err.Error()) + } + for _, container := range allContainers { + mounted, mountPoint, err := container.Mounted() + if err != nil { + return call.ReplyErrorOccurred(err.Error()) + } + if mounted { + mounts = append(mounts, mountPoint) + } + } + return call.ReplyListContainerMounts(mounts) +} + +// MountContainer ... +func (i *LibpodAPI) MountContainer(call iopodman.VarlinkCall, name string) error { + container, err := i.Runtime.LookupContainer(name) + if err != nil { + return call.ReplyErrorOccurred(err.Error()) + } + path, err := container.Mount() + if err != nil { + return call.ReplyErrorOccurred(err.Error()) + } + return call.ReplyMountContainer(path) +} + +// UnmountContainer ... +func (i *LibpodAPI) UnmountContainer(call iopodman.VarlinkCall, name string, force bool) error { + container, err := i.Runtime.LookupContainer(name) + if err != nil { + return call.ReplyErrorOccurred(err.Error()) + } + if err := container.Unmount(force); err != nil { + return call.ReplyErrorOccurred(err.Error()) + } + return call.ReplyUnmountContainer() +} |