From 21b42dfcfd15ee6757bcba57acb511d5ce60a3ba Mon Sep 17 00:00:00 2001 From: Kato Kazuyoshi Date: Tue, 29 Apr 2014 08:31:58 +0900 Subject: [PATCH] UTIME_OMIT is only available on Linux Docker-DCO-1.1-Signed-off-by: Kato Kazuyoshi (github: kzys) --- archive/diff.go | 10 ---------- archive/time_linux.go | 16 ++++++++++++++++ archive/time_unsupported.go | 16 ++++++++++++++++ 3 files changed, 32 insertions(+), 10 deletions(-) create mode 100644 archive/time_linux.go create mode 100644 archive/time_unsupported.go diff --git a/archive/diff.go b/archive/diff.go index 87e8ac7dc4..49d8cb4984 100644 --- a/archive/diff.go +++ b/archive/diff.go @@ -9,7 +9,6 @@ import ( "path/filepath" "strings" "syscall" - "time" ) // Linux device nodes are a bit weird due to backwards compat with 16 bit device nodes. @@ -18,15 +17,6 @@ import ( func mkdev(major int64, minor int64) uint32 { return uint32(((minor & 0xfff00) << 12) | ((major & 0xfff) << 8) | (minor & 0xff)) } -func timeToTimespec(time time.Time) (ts syscall.Timespec) { - if time.IsZero() { - // Return UTIME_OMIT special value - ts.Sec = 0 - ts.Nsec = ((1 << 30) - 2) - return - } - return syscall.NsecToTimespec(time.UnixNano()) -} // ApplyLayer parses a diff in the standard layer format from `layer`, and // applies it to the directory `dest`. diff --git a/archive/time_linux.go b/archive/time_linux.go new file mode 100644 index 0000000000..3448569b1e --- /dev/null +++ b/archive/time_linux.go @@ -0,0 +1,16 @@ +package archive + +import ( + "syscall" + "time" +) + +func timeToTimespec(time time.Time) (ts syscall.Timespec) { + if time.IsZero() { + // Return UTIME_OMIT special value + ts.Sec = 0 + ts.Nsec = ((1 << 30) - 2) + return + } + return syscall.NsecToTimespec(time.UnixNano()) +} diff --git a/archive/time_unsupported.go b/archive/time_unsupported.go new file mode 100644 index 0000000000..e85aac0540 --- /dev/null +++ b/archive/time_unsupported.go @@ -0,0 +1,16 @@ +// +build !linux + +package archive + +import ( + "syscall" + "time" +) + +func timeToTimespec(time time.Time) (ts syscall.Timespec) { + nsec := int64(0) + if !time.IsZero() { + nsec = time.UnixNano() + } + return syscall.NsecToTimespec(nsec) +}