From a7f992c52c205be63cf0b6e7543099a0c9b45700 Mon Sep 17 00:00:00 2001 From: Shengjing Zhu Date: Mon, 6 Jan 2020 22:23:08 +0800 Subject: [PATCH] fs: don't convert syscall.Timespec to unix.Timespec directly This doesn't work with gccgo. vendor/github.com/containerd/continuity/fs/copy_linux.go:54:43: error: invalid type conversion (cannot use type syscall.Timespec as type unix.Timespec) 54 | timespec := []unix.Timespec{unix.Timespec(StatAtime(st)), unix.Timespec(StatMtime(st))} | ^ vendor/github.com/containerd/continuity/fs/copy_linux.go:54:73: error: invalid type conversion (cannot use type syscall.Timespec as type unix.Timespec) 54 | timespec := []unix.Timespec{unix.Timespec(StatAtime(st)), unix.Timespec(StatMtime(st))} | ^ Instead, using an int64 nanosec variable as the bridge. Signed-off-by: Shengjing Zhu --- fs/copy_linux.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/fs/copy_linux.go b/fs/copy_linux.go index 81c71522..72bae7d4 100644 --- a/fs/copy_linux.go +++ b/fs/copy_linux.go @@ -51,7 +51,10 @@ func copyFileInfo(fi os.FileInfo, name string) error { } } - timespec := []unix.Timespec{unix.Timespec(StatAtime(st)), unix.Timespec(StatMtime(st))} + timespec := []unix.Timespec{ + unix.NsecToTimespec(syscall.TimespecToNsec(StatAtime(st))), + unix.NsecToTimespec(syscall.TimespecToNsec(StatMtime(st))), + } if err := unix.UtimesNanoAt(unix.AT_FDCWD, name, timespec, unix.AT_SYMLINK_NOFOLLOW); err != nil { return errors.Wrapf(err, "failed to utime %s", name) }