Browse Source

os,syscall: Stat_t timespec fields are Atimespec on darwin

This allows archive/tar to build and pass.
pull/2444/merge
Damian Gryski 2 years ago
committed by Damian Gryski
parent
commit
4716298044
  1. 4
      src/os/stat_darwin.go
  2. 13
      src/syscall/syscall_libc_darwin.go

4
src/os/stat_darwin.go

@ -12,7 +12,7 @@ import (
func fillFileStatFromSys(fs *fileStat, name string) { func fillFileStatFromSys(fs *fileStat, name string) {
fs.name = basename(name) fs.name = basename(name)
fs.size = fs.sys.Size fs.size = fs.sys.Size
fs.modTime = timespecToTime(fs.sys.Mtim) fs.modTime = timespecToTime(fs.sys.Mtimespec)
fs.mode = FileMode(fs.sys.Mode & 0777) fs.mode = FileMode(fs.sys.Mode & 0777)
switch fs.sys.Mode & syscall.S_IFMT { switch fs.sys.Mode & syscall.S_IFMT {
case syscall.S_IFBLK, syscall.S_IFWHT: case syscall.S_IFBLK, syscall.S_IFWHT:
@ -47,5 +47,5 @@ func timespecToTime(ts syscall.Timespec) time.Time {
// For testing. // For testing.
func atime(fi FileInfo) time.Time { func atime(fi FileInfo) time.Time {
return timespecToTime(fi.Sys().(*syscall.Stat_t).Atim) return timespecToTime(fi.Sys().(*syscall.Stat_t).Atimespec)
} }

13
src/syscall/syscall_libc_darwin.go

@ -147,6 +147,11 @@ type Timespec struct {
Nsec int64 Nsec int64
} }
// Unix returns the time stored in ts as seconds plus nanoseconds.
func (ts *Timespec) Unix() (sec int64, nsec int64) {
return int64(ts.Sec), int64(ts.Nsec)
}
// Source: upstream ztypes_darwin_amd64.go // Source: upstream ztypes_darwin_amd64.go
type Dirent struct { type Dirent struct {
Ino uint64 Ino uint64
@ -168,10 +173,10 @@ type Stat_t struct {
Gid uint32 Gid uint32
Rdev int32 Rdev int32
Pad_cgo_0 [4]byte Pad_cgo_0 [4]byte
Atim Timespec Atimespec Timespec
Mtim Timespec Mtimespec Timespec
Ctim Timespec Ctimespec Timespec
Btim Timespec Btimespec Timespec
Size int64 Size int64
Blocks int64 Blocks int64
Blksize int32 Blksize int32

Loading…
Cancel
Save