
This mainly fixes Linux vs generic Unix differences, with some differences between Darwin and Freebsd (which are close bit not identical). Should make fixing for other Unix platforms easier. Note there are not yet `runc` equivalents for these platforms; my current use case is image manipulation for the `moby` tool. However there is interest in OCI runtime ports for both platforms. Current status is that MacOS can build and run `ctr`, `dist` and `containerd` and some operations are supported. FreeBSD 11 still needs some more fixes to continuity for extended attributes. Signed-off-by: Justin Cormack <justin.cormack@docker.com>
24 lines
481 B
Go
24 lines
481 B
Go
// +build linux freebsd
|
|
|
|
package archive
|
|
|
|
import (
|
|
"time"
|
|
|
|
"golang.org/x/sys/unix"
|
|
|
|
"github.com/pkg/errors"
|
|
)
|
|
|
|
func chtimes(path string, atime, mtime time.Time) error {
|
|
var utimes [2]unix.Timespec
|
|
utimes[0] = unix.NsecToTimespec(atime.UnixNano())
|
|
utimes[1] = unix.NsecToTimespec(mtime.UnixNano())
|
|
|
|
if err := unix.UtimesNanoAt(unix.AT_FDCWD, path, utimes[0:], unix.AT_SYMLINK_NOFOLLOW); err != nil {
|
|
return errors.Wrap(err, "failed call to UtimesNanoAt")
|
|
}
|
|
|
|
return nil
|
|
}
|