diff options
author | Doug Rabson <dfr@rabson.org> | 2022-09-10 08:15:14 +0100 |
---|---|---|
committer | Doug Rabson <dfr@rabson.org> | 2022-09-12 16:11:25 +0100 |
commit | 36cfd05a7d90b4c620d308274d6488225d49ed6c (patch) | |
tree | 6c728cd1768b79671fb8d774ac798a40a5a41bbb /libpod | |
parent | 369d86040e82d7940f94a582336bed7ad9a19c6c (diff) | |
download | podman-36cfd05a7d90b4c620d308274d6488225d49ed6c.tar.gz podman-36cfd05a7d90b4c620d308274d6488225d49ed6c.tar.bz2 podman-36cfd05a7d90b4c620d308274d6488225d49ed6c.zip |
libpod: Move platform-specific bind mounts to a per-platform method
This adds a new per-platform method makePlatformBindMounts and moves the
/etc/hostname mount. This file is only needed on Linux.
[NO NEW TESTS NEEDED]
Signed-off-by: Doug Rabson <dfr@rabson.org>
Diffstat (limited to 'libpod')
-rw-r--r-- | libpod/container_internal_common.go | 12 | ||||
-rw-r--r-- | libpod/container_internal_freebsd.go | 4 | ||||
-rw-r--r-- | libpod/container_internal_linux.go | 13 |
3 files changed, 18 insertions, 11 deletions
diff --git a/libpod/container_internal_common.go b/libpod/container_internal_common.go index 62cc57815..c7f59aba5 100644 --- a/libpod/container_internal_common.go +++ b/libpod/container_internal_common.go @@ -1766,16 +1766,6 @@ func (c *Container) makeBindMounts() error { } } - // Make /etc/hostname - // This should never change, so no need to recreate if it exists - if _, ok := c.state.BindMounts["/etc/hostname"]; !ok { - hostnamePath, err := c.writeStringToRundir("hostname", c.Hostname()) - if err != nil { - return fmt.Errorf("creating hostname file for container %s: %w", c.ID(), err) - } - c.state.BindMounts["/etc/hostname"] = hostnamePath - } - // Make /etc/localtime ctrTimezone := c.Timezone() if ctrTimezone != "" { @@ -1879,7 +1869,7 @@ rootless=%d } } - return nil + return c.makePlatformBindMounts() } // generateResolvConf generates a containers resolv.conf diff --git a/libpod/container_internal_freebsd.go b/libpod/container_internal_freebsd.go index c6ed6147c..6dedfbee1 100644 --- a/libpod/container_internal_freebsd.go +++ b/libpod/container_internal_freebsd.go @@ -283,3 +283,7 @@ func setVolumeAtime(mountPoint string, st os.FileInfo) error { } return nil } + +func (c *Container) makePlatformBindMounts() error { + return nil +} diff --git a/libpod/container_internal_linux.go b/libpod/container_internal_linux.go index 0fec1a7d2..ef8649776 100644 --- a/libpod/container_internal_linux.go +++ b/libpod/container_internal_linux.go @@ -652,3 +652,16 @@ func setVolumeAtime(mountPoint string, st os.FileInfo) error { } return nil } + +func (c *Container) makePlatformBindMounts() error { + // Make /etc/hostname + // This should never change, so no need to recreate if it exists + if _, ok := c.state.BindMounts["/etc/hostname"]; !ok { + hostnamePath, err := c.writeStringToRundir("hostname", c.Hostname()) + if err != nil { + return fmt.Errorf("creating hostname file for container %s: %w", c.ID(), err) + } + c.state.BindMounts["/etc/hostname"] = hostnamePath + } + return nil +} |