summaryrefslogtreecommitdiff
path: root/pkg/varlinkapi/mount.go
diff options
context:
space:
mode:
authorbaude <bbaude@redhat.com>2018-12-03 09:15:29 -0600
committerbaude <bbaude@redhat.com>2018-12-03 10:56:07 -0600
commit5c02dda869390725a799339b094f548d327c9122 (patch)
tree8cc4e1a8b8154cd2bf0d9b28c8437ea8d7a94071 /pkg/varlinkapi/mount.go
parent5bb66a47a46ea3cd66a86889d39b57bb28256c7a (diff)
downloadpodman-5c02dda869390725a799339b094f548d327c9122.tar.gz
podman-5c02dda869390725a799339b094f548d327c9122.tar.bz2
podman-5c02dda869390725a799339b094f548d327c9122.zip
Adding more varlink endpoints
* runlabel * checkpoint * restore * container|image exists * mount * unmount Signed-off-by: baude <bbaude@redhat.com>
Diffstat (limited to 'pkg/varlinkapi/mount.go')
-rw-r--r--pkg/varlinkapi/mount.go49
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()
+}