diff --git a/third_party/go9p/srv_file.go b/third_party/go9p/srv_file.go index 1489662c06ff..d2e94fda0f0e 100644 --- a/third_party/go9p/srv_file.go +++ b/third_party/go9p/srv_file.go @@ -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 diff --git a/third_party/go9p/ufs_darwin.go b/third_party/go9p/ufs_darwin.go index b7b592e1816f..159c46000c53 100644 --- a/third_party/go9p/ufs_darwin.go +++ b/third_party/go9p/ufs_darwin.go @@ -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