]> Cypherpunks repositories - gostls13.git/commitdiff
os: pass tests on Plan 9 again
authorFazlul Shahriar <fshahriar@gmail.com>
Wed, 25 Jan 2012 08:15:44 +0000 (00:15 -0800)
committerAnthony Martin <ality@pbrane.org>
Wed, 25 Jan 2012 08:15:44 +0000 (00:15 -0800)
R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/5563046

src/pkg/os/file_plan9.go
src/pkg/os/stat_plan9.go

index 6ee57ff23957811d2b9dab423f8945d2ce15ad40..7d136eb36868b8c2fed927c4f8fa14866ebfb3aa 100644 (file)
@@ -7,6 +7,7 @@ package os
 import (
        "runtime"
        "syscall"
+       "time"
 )
 
 // File represents an open file descriptor.
@@ -299,15 +300,14 @@ func Chmod(name string, mode FileMode) error {
 // Chtimes changes the access and modification times of the named
 // file, similar to the Unix utime() or utimes() functions.
 //
-// The argument times are in nanoseconds, although the underlying
-// filesystem may truncate or round the values to a more
-// coarse time unit.
-func Chtimes(name string, atimeNs int64, mtimeNs int64) error {
+// The underlying filesystem may truncate or round the values to a
+// less precise time unit.
+func Chtimes(name string, atime time.Time, mtime time.Time) error {
        var d Dir
        d.Null()
 
-       d.Atime = uint32(atimeNs / 1e9)
-       d.Mtime = uint32(mtimeNs / 1e9)
+       d.Atime = uint32(atime.Unix())
+       d.Mtime = uint32(mtime.Unix())
 
        if e := syscall.Wstat(name, pdir(nil, &d)); e != nil {
                return &PathError{"chtimes", name, e}
index 8d3b8a84d5c5b80557785d755b63f13c6de45dc9..f731e43740a8d268129e24439c2de2a7b626ed9c 100644 (file)
@@ -97,3 +97,8 @@ func Stat(name string) (FileInfo, error) {
 func Lstat(name string) (FileInfo, error) {
        return Stat(name)
 }
+
+// For testing.
+func atime(fi FileInfo) time.Time {
+       return time.Unix(int64(fi.(*FileStat).Sys.(*Dir).Atime), 0)
+}