Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed mtime issue for OSX #1594

Merged
merged 1 commit into from
Jun 16, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion third_party/go9p/srv_file.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ package go9p

import (
"log"
"runtime"
"sync"
"time"
)
Expand Down Expand Up @@ -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
Expand Down
4 changes: 3 additions & 1 deletion third_party/go9p/ufs_darwin.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down