summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDoug Rabson <dfr@rabson.org>2022-08-27 13:49:43 +0100
committerDoug Rabson <dfr@rabson.org>2022-09-05 10:17:49 +0100
commit0889215d83ef095e5817fd2d4b8fe676ad819d84 (patch)
tree8dabb4f640705251faa8d7cc2a81196a54520510
parentc1a86a8c4cbd8be87dbf11277aee055b89c8519a (diff)
downloadpodman-0889215d83ef095e5817fd2d4b8fe676ad819d84.tar.gz
podman-0889215d83ef095e5817fd2d4b8fe676ad819d84.tar.bz2
podman-0889215d83ef095e5817fd2d4b8fe676ad819d84.zip
libpod: Use platform-specific mount type for volume mounts
[NO NEW TESTS NEEDED] Signed-off-by: Doug Rabson <dfr@rabson.org>
-rw-r--r--libpod/container_internal_common.go7
-rw-r--r--libpod/container_internal_freebsd.go4
-rw-r--r--libpod/container_internal_linux.go4
3 files changed, 12 insertions, 3 deletions
diff --git a/libpod/container_internal_common.go b/libpod/container_internal_common.go
index 95d3c8ad8..2b11ff5b6 100644
--- a/libpod/container_internal_common.go
+++ b/libpod/container_internal_common.go
@@ -18,6 +18,7 @@ import (
butil "github.com/containers/buildah/util"
"github.com/containers/common/pkg/apparmor"
cutil "github.com/containers/common/pkg/util"
+ "github.com/containers/podman/v4/libpod/define"
"github.com/containers/podman/v4/pkg/annotations"
"github.com/containers/podman/v4/pkg/lookup"
"github.com/containers/podman/v4/pkg/rootless"
@@ -174,7 +175,7 @@ func (c *Container) generateSpec(ctx context.Context) (*spec.Spec, error) {
g.AddMount(overlayMount)
} else {
volMount := spec.Mount{
- Type: "bind",
+ Type: define.TypeBind,
Source: mountPoint,
Destination: namedVol.Dest,
Options: namedVol.Options,
@@ -220,10 +221,10 @@ func (c *Container) generateSpec(ctx context.Context) (*spec.Spec, error) {
// Add bind mounts to container
for dstPath, srcPath := range c.state.BindMounts {
newMount := spec.Mount{
- Type: "bind",
+ Type: define.TypeBind,
Source: srcPath,
Destination: dstPath,
- Options: []string{"bind", "rprivate"},
+ Options: bindOptions,
}
if c.IsReadOnly() && dstPath != "/dev/shm" {
newMount.Options = append(newMount.Options, "ro", "nosuid", "noexec", "nodev")
diff --git a/libpod/container_internal_freebsd.go b/libpod/container_internal_freebsd.go
index 65a74a2e4..c180528cb 100644
--- a/libpod/container_internal_freebsd.go
+++ b/libpod/container_internal_freebsd.go
@@ -51,6 +51,10 @@ import (
"golang.org/x/sys/unix"
)
+var (
+ bindOptions = []string{}
+)
+
// Network stubs to decouple container_internal_freebsd.go from
// networking_freebsd.go so they can be reviewed separately.
func (r *Runtime) createNetNS(ctr *Container) (netJail string, q map[string]types.StatusBlock, retErr error) {
diff --git a/libpod/container_internal_linux.go b/libpod/container_internal_linux.go
index 1cec3a7bc..bd50ceb45 100644
--- a/libpod/container_internal_linux.go
+++ b/libpod/container_internal_linux.go
@@ -56,6 +56,10 @@ import (
"golang.org/x/sys/unix"
)
+var (
+ bindOptions = []string{"bind", "rprivate"}
+)
+
func (c *Container) mountSHM(shmOptions string) error {
if err := unix.Mount("shm", c.config.ShmDir, "tmpfs", unix.MS_NOEXEC|unix.MS_NOSUID|unix.MS_NODEV,
label.FormatMountLabel(shmOptions, c.config.MountLabel)); err != nil {