From 247f90c82e0846ec108a4abab51af93fa14b86a1 Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Wed, 26 Jan 2022 14:44:54 +0100 Subject: [PATCH] pkg/system: move maxTime init() back to Chtimes code This code was moved to a separate file in fe5b34ba8828dc2f2f7db180a102cee360fec6e0, but it's unclear why it was moved (as this file is not excluded on Windows). Moving the code back into the chtimes file, to move it closer to where it's used. Signed-off-by: Sebastiaan van Stijn --- pkg/system/chtimes.go | 16 ++++++++++++++++ pkg/system/init.go | 22 ---------------------- 2 files changed, 16 insertions(+), 22 deletions(-) delete mode 100644 pkg/system/init.go diff --git a/pkg/system/chtimes.go b/pkg/system/chtimes.go index c26a4e24b6..7cd751f089 100644 --- a/pkg/system/chtimes.go +++ b/pkg/system/chtimes.go @@ -2,9 +2,25 @@ package system // import "github.com/docker/docker/pkg/system" import ( "os" + "syscall" "time" + "unsafe" ) +// Used by Chtimes +var maxTime time.Time + +func init() { + if unsafe.Sizeof(syscall.Timespec{}.Nsec) == 8 { + // This is a 64 bit timespec + // os.Chtimes limits time to the following + maxTime = time.Unix(0, 1<<63-1) + } else { + // This is a 32 bit timespec + maxTime = time.Unix(1<<31-1, 0) + } +} + // Chtimes changes the access time and modified time of a file at the given path func Chtimes(name string, atime time.Time, mtime time.Time) error { unixMinTime := time.Unix(0, 0) diff --git a/pkg/system/init.go b/pkg/system/init.go deleted file mode 100644 index a17597aaba..0000000000 --- a/pkg/system/init.go +++ /dev/null @@ -1,22 +0,0 @@ -package system // import "github.com/docker/docker/pkg/system" - -import ( - "syscall" - "time" - "unsafe" -) - -// Used by chtimes -var maxTime time.Time - -func init() { - // chtimes initialization - if unsafe.Sizeof(syscall.Timespec{}.Nsec) == 8 { - // This is a 64 bit timespec - // os.Chtimes limits time to the following - maxTime = time.Unix(0, 1<<63-1) - } else { - // This is a 32 bit timespec - maxTime = time.Unix(1<<31-1, 0) - } -}