Merge pull request #1594 from aaron-prindle/mtime

Fixed mtime issue for OSX
pull/1602/head
Aaron Prindle 2017-06-16 10:51:14 -07:00 committed by GitHub
commit dec0742f87
2 changed files with 11 additions and 2 deletions

View File

@ -6,6 +6,7 @@ package go9p
import (
"log"
"runtime"
"sync"
"time"
)
@ -132,7 +133,13 @@ func (f *srvFile) Add(dir *srvFile, name string, uid User, gid Group, mode uint3
f.Qid.Version = 0
f.Qid.Path = qpath
f.Mode = mode
f.Atime = uint32(time.Now().Unix())
// macOS filesystem st_mtime values are only accurate to the second
// without truncating, 9p will invent a changing fractional time #1375
if runtime.GOOS == "darwin" {
f.Atime = uint32(time.Now().Truncate(time.Second).Unix())
} else {
f.Atime = uint32(time.Now().Unix())
}
f.Mtime = f.Atime
f.Length = 0
f.Name = name

View File

@ -228,7 +228,9 @@ func (u *Ufs) Wstat(req *SrvReq) {
//at = time.Time(0)//atime(st.Sys().(*syscall.Stat_t))
}
}
e := os.Chtimes(fid.path, at, mt)
// macOS filesystem st_mtime values are only accurate to the second
// this ensures, 9p will only write mtime to the second #1375
e := os.Chtimes(fid.path, at.Truncate(time.Second), mt.Truncate(time.Second))
if e != nil {
req.RespondError(toError(e))
return