libpod: Factor out setting volume atime to container_internal_linux.go

It turns out that field names in syscall.Stat_t are platform-specific.
An alternative to this could change fixVolumePermissions to use
unix.Lstat since unix.Stat_t uses the same mmember name for Atim on both
Linux and FreeBSD.

[NO NEW TESTS NEEDED]

Signed-off-by: Doug Rabson <dfr@rabson.org>
This commit is contained in:
Doug Rabson
2022-08-27 16:34:57 +01:00
parent 7a1abd03c5
commit a3aecf0f26
3 changed files with 20 additions and 3 deletions

View File

@ -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
}