summaryrefslogtreecommitdiff
path: root/libpod/volume_internal.go
diff options
context:
space:
mode:
authorMatthew Heon <matthew.heon@pm.me>2019-09-03 15:03:44 -0400
committerMatthew Heon <matthew.heon@pm.me>2019-09-05 17:12:27 -0400
commita760e325f3180638f9fedd0ee79d4c6695d8ba64 (patch)
tree7969ab74dfe2c41df7387fd0601014dcd9656052 /libpod/volume_internal.go
parent5a8a71ed817a4fa50fd9444846a50b76f25228d1 (diff)
downloadpodman-a760e325f3180638f9fedd0ee79d4c6695d8ba64.tar.gz
podman-a760e325f3180638f9fedd0ee79d4c6695d8ba64.tar.bz2
podman-a760e325f3180638f9fedd0ee79d4c6695d8ba64.zip
Add ability for volumes with options to mount/umount
When volume options and the local volume driver are specified, the volume is intended to be mounted using the 'mount' command. Supported options will be used to volume the volume before the first container using it starts, and unmount the volume after the last container using it dies. This should work for any local filesystem, though at present I've only tested with tmpfs and btrfs. Signed-off-by: Matthew Heon <matthew.heon@pm.me>
Diffstat (limited to 'libpod/volume_internal.go')
-rw-r--r--libpod/volume_internal.go24
1 files changed, 24 insertions, 0 deletions
diff --git a/libpod/volume_internal.go b/libpod/volume_internal.go
index 35f0ca19d..8c11b907f 100644
--- a/libpod/volume_internal.go
+++ b/libpod/volume_internal.go
@@ -3,6 +3,8 @@ package libpod
import (
"os"
"path/filepath"
+
+ "github.com/containers/libpod/libpod/define"
)
// Creates a new volume
@@ -20,3 +22,25 @@ func newVolume(runtime *Runtime) (*Volume, error) {
func (v *Volume) teardownStorage() error {
return os.RemoveAll(filepath.Join(v.runtime.config.VolumePath, v.Name()))
}
+
+// Volumes with options set, or a filesystem type, or a device to mount need to
+// be mounted and unmounted.
+func (v *Volume) needsMount() bool {
+ return len(v.config.Options) > 0 && v.config.Driver == "local"
+}
+
+// update() updates the volume state from the DB.
+func (v *Volume) update() error {
+ if err := v.runtime.state.UpdateVolume(v); err != nil {
+ return err
+ }
+ if !v.valid {
+ return define.ErrVolumeRemoved
+ }
+ return nil
+}
+
+// save() saves the volume state to the DB
+func (v *Volume) save() error {
+ return v.runtime.state.SaveVolume(v)
+}