aboutsummaryrefslogtreecommitdiff
path: root/libgo/go/os/file_plan9.go
diff options
context:
space:
mode:
Diffstat (limited to 'libgo/go/os/file_plan9.go')
-rw-r--r--libgo/go/os/file_plan9.go16
1 files changed, 10 insertions, 6 deletions
diff --git a/libgo/go/os/file_plan9.go b/libgo/go/os/file_plan9.go
index 48bf5f5..eb15890 100644
--- a/libgo/go/os/file_plan9.go
+++ b/libgo/go/os/file_plan9.go
@@ -112,10 +112,9 @@ func openFileNolog(name string, flag int, perm FileMode) (*File, error) {
} else {
fd, e = syscall.Open(name, flag)
if IsNotExist(e) && create {
- var e1 error
- fd, e1 = syscall.Create(name, flag, syscallMode(perm))
- if e1 == nil {
- e = nil
+ fd, e = syscall.Create(name, flag, syscallMode(perm))
+ if e != nil {
+ return nil, &PathError{"create", name, e}
}
}
}
@@ -234,10 +233,10 @@ func (f *File) Sync() error {
var buf [syscall.STATFIXLEN]byte
n, err := d.Marshal(buf[:])
if err != nil {
- return NewSyscallError("fsync", err)
+ return &PathError{"sync", f.name, err}
}
if err = syscall.Fwstat(f.fd, buf[:n]); err != nil {
- return NewSyscallError("fsync", err)
+ return &PathError{"sync", f.name, err}
}
return nil
}
@@ -290,6 +289,11 @@ func (f *File) pwrite(b []byte, off int64) (n int, err error) {
// relative to the current offset, and 2 means relative to the end.
// It returns the new offset and an error, if any.
func (f *File) seek(offset int64, whence int) (ret int64, err error) {
+ if f.dirinfo != nil {
+ // Free cached dirinfo, so we allocate a new one if we
+ // access this file as a directory again. See #35767 and #37161.
+ f.dirinfo = nil
+ }
return syscall.Seek(f.fd, offset, whence)
}