aboutsummaryrefslogtreecommitdiff
path: root/src/os/file_plan9.go
diff options
context:
space:
mode:
authorDan Caddigan <goldcaddy77@gmail.com>2016-10-07 00:46:56 -0400
committerBrad Fitzpatrick <bradfitz@golang.org>2016-10-24 16:41:29 +0000
commit212d2f82e05018f1ebb5e40e2c328865201da356 (patch)
tree9ae2c53bc7d42026445ec3944dd0244ff7788185 /src/os/file_plan9.go
parent452bbfc179d6739a404aacc819ec66acc71fc55c (diff)
downloadgo-212d2f82e05018f1ebb5e40e2c328865201da356.tar.xz
os: add ErrClosed, return for use of closed File
This is clearer than syscall.EBADF. Fixes #17320. Change-Id: I14c6a362f9a6044c9b07cd7965499f4a83d2a860 Reviewed-on: https://go-review.googlesource.com/30614 Run-TryBot: Russ Cox <rsc@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
Diffstat (limited to 'src/os/file_plan9.go')
-rw-r--r--src/os/file_plan9.go8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/os/file_plan9.go b/src/os/file_plan9.go
index 880d56a16f..704e95b1e6 100644
--- a/src/os/file_plan9.go
+++ b/src/os/file_plan9.go
@@ -130,21 +130,21 @@ func OpenFile(name string, flag int, perm FileMode) (*File, error) {
// Close closes the File, rendering it unusable for I/O.
// It returns an error, if any.
func (f *File) Close() error {
- if f == nil {
- return ErrInvalid
+ if err := f.checkValid("close"); err != nil {
+ return err
}
return f.file.close()
}
func (file *file) close() error {
- if file == nil || file.fd < 0 {
+ if file == nil || file.fd == badFd {
return ErrInvalid
}
var err error
if e := syscall.Close(file.fd); e != nil {
err = &PathError{"close", file.name, e}
}
- file.fd = -1 // so it can't be closed again
+ file.fd = badFd // so it can't be closed again
// no need for a finalizer anymore
runtime.SetFinalizer(file, nil)