Skip to content
This repository has been archived by the owner on May 2, 2018. It is now read-only.

Commit

Permalink
os: pass tests on Plan 9 again
Browse files Browse the repository at this point in the history
R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/5563046
  • Loading branch information
fhs authored and ality committed Jan 25, 2012
1 parent 0ae9d81 commit c93ca60
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/pkg/os/file_plan9.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ package os
import (
"runtime"
"syscall"
"time"
)

// File represents an open file descriptor.
Expand Down Expand Up @@ -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}
Expand Down
5 changes: 5 additions & 0 deletions src/pkg/os/stat_plan9.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

0 comments on commit c93ca60

Please sign in to comment.