summaryrefslogtreecommitdiff
path: root/pkg/util
diff options
context:
space:
mode:
authorAditya Rajan <arajan@redhat.com>2021-12-28 16:02:25 +0530
committerAditya R <arajan@redhat.com>2022-01-28 13:10:15 +0530
commite64e6500d3a3bdbb2d3c9faa5e2d9d845f120b17 (patch)
tree21f9548d8b1c880359a44a2c2357d31a0452f442 /pkg/util
parent5b01dab618fc287df4e6c41fa88c4a64d31fa3f3 (diff)
downloadpodman-e64e6500d3a3bdbb2d3c9faa5e2d9d845f120b17.tar.gz
podman-e64e6500d3a3bdbb2d3c9faa5e2d9d845f120b17.tar.bz2
podman-e64e6500d3a3bdbb2d3c9faa5e2d9d845f120b17.zip
volume: add support for non-volatile upperdir,workdir for overlay volumes
Often users want their overlayed volumes to be `non-volatile` in nature that means that same `upper` dir can be re-used by one or more containers but overall of nature of volumes still have to be `overlay` so work done is still on a overlay not on the actual volume. Following PR adds support for more advanced options i.e custom `workdir` and `upperdir` for overlayed volumes. So that users can re-use `workdir` and `upperdir` across new containers as well. Usage ```console $ podman run -it -v myvol:/data:O,upperdir=/path/persistant/upper,workdir=/path/persistant/work alpine sh ``` Signed-off-by: Aditya R <arajan@redhat.com>
Diffstat (limited to 'pkg/util')
-rw-r--r--pkg/util/mountOpts.go18
1 files changed, 16 insertions, 2 deletions
diff --git a/pkg/util/mountOpts.go b/pkg/util/mountOpts.go
index 959763dba..f32cf6ea6 100644
--- a/pkg/util/mountOpts.go
+++ b/pkg/util/mountOpts.go
@@ -25,16 +25,30 @@ type defaultMountOptions struct {
// The sourcePath variable, if not empty, contains a bind mount source.
func ProcessOptions(options []string, isTmpfs bool, sourcePath string) ([]string, error) {
var (
- foundWrite, foundSize, foundProp, foundMode, foundExec, foundSuid, foundDev, foundCopyUp, foundBind, foundZ, foundU bool
+ foundWrite, foundSize, foundProp, foundMode, foundExec, foundSuid, foundDev, foundCopyUp, foundBind, foundZ, foundU, foundOverlay bool
)
newOptions := make([]string, 0, len(options))
for _, opt := range options {
// Some options have parameters - size, mode
splitOpt := strings.SplitN(opt, "=", 2)
+
+ // add advanced options such as upperdir=/path and workdir=/path, when overlay is specified
+ if foundOverlay {
+ if strings.Contains(opt, "upperdir") {
+ newOptions = append(newOptions, opt)
+ continue
+ }
+ if strings.Contains(opt, "workdir") {
+ newOptions = append(newOptions, opt)
+ continue
+ }
+ }
+
switch splitOpt[0] {
- case "idmap":
case "O":
+ foundOverlay = true
+ case "idmap":
if len(options) > 1 {
return nil, errors.Wrapf(ErrDupeMntOption, "'O' option can not be used with other options")
}