Skip to content

Commit

Permalink
Merge pull request moby#5454 from kzys/utime-omit
Browse files Browse the repository at this point in the history
UTIME_OMIT is only available on Linux
  • Loading branch information
creack committed May 16, 2014
2 parents 87fc713 + 21b42df commit 4353ee7
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 10 deletions.
10 changes: 0 additions & 10 deletions archive/diff.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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`.
Expand Down
16 changes: 16 additions & 0 deletions archive/time_linux.go
Original file line number Diff line number Diff line change
@@ -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())
}
16 changes: 16 additions & 0 deletions archive/time_unsupported.go
Original file line number Diff line number Diff line change
@@ -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)
}

0 comments on commit 4353ee7

Please sign in to comment.