diff options
Diffstat (limited to 'libpod')
-rw-r--r-- | libpod/container_internal_common.go | 4 | ||||
-rw-r--r-- | libpod/container_internal_freebsd.go | 9 | ||||
-rw-r--r-- | libpod/container_internal_linux.go | 10 |
3 files changed, 20 insertions, 3 deletions
diff --git a/libpod/container_internal_common.go b/libpod/container_internal_common.go index cb3c602af..192a86b6a 100644 --- a/libpod/container_internal_common.go +++ b/libpod/container_internal_common.go @@ -2654,9 +2654,7 @@ func (c *Container) fixVolumePermissions(v *ContainerNamedVolume) error { if err := os.Chmod(mountPoint, st.Mode()); err != nil { return err } - stat := st.Sys().(*syscall.Stat_t) - atime := time.Unix(int64(stat.Atim.Sec), int64(stat.Atim.Nsec)) //nolint: unconvert - if err := os.Chtimes(mountPoint, atime, st.ModTime()); err != nil { + if err := setVolumeAtime(mountPoint, st); err != nil { return err } } else if !os.IsNotExist(err) { diff --git a/libpod/container_internal_freebsd.go b/libpod/container_internal_freebsd.go index c87617848..40c6c5ebf 100644 --- a/libpod/container_internal_freebsd.go +++ b/libpod/container_internal_freebsd.go @@ -274,3 +274,12 @@ func (c *Container) isSlirp4netnsIPv6() (bool, error) { func (c *Container) hasNetNone() bool { return c.state.NetworkJail == "" } + +func setVolumeAtime(mountPoint string, st os.FileInfo) error { + stat := st.Sys().(*syscall.Stat_t) + atime := time.Unix(int64(stat.Atimespec.Sec), int64(stat.Atimespec.Nsec)) //nolint: unconvert + if err := os.Chtimes(mountPoint, atime, st.ModTime()); err != nil { + return err + } + return nil +} diff --git a/libpod/container_internal_linux.go b/libpod/container_internal_linux.go index ad04ef26c..83882ecac 100644 --- a/libpod/container_internal_linux.go +++ b/libpod/container_internal_linux.go @@ -11,6 +11,7 @@ import ( "strings" "sync" "syscall" + "time" "github.com/containernetworking/plugins/pkg/ns" "github.com/containers/common/libnetwork/types" @@ -634,3 +635,12 @@ func (c *Container) hasNetNone() bool { } return false } + +func setVolumeAtime(mountPoint string, st os.FileInfo) error { + stat := st.Sys().(*syscall.Stat_t) + atime := time.Unix(int64(stat.Atim.Sec), int64(stat.Atim.Nsec)) //nolint: unconvert + if err := os.Chtimes(mountPoint, atime, st.ModTime()); err != nil { + return err + } + return nil +} |