diff options
author | gVisor bot <gvisor-bot@google.com> | 2020-11-17 23:43:28 +0000 |
---|---|---|
committer | gVisor bot <gvisor-bot@google.com> | 2020-11-17 23:43:28 +0000 |
commit | 99ee4465b2972bd74bfd041ad89284815be7a876 (patch) | |
tree | 4dee07e2a48c56a9a542ea196ab7f4be973576a7 /pkg/p9 | |
parent | 543fc893e3a8a6c62a26ced3191be2c8b5b8d38d (diff) | |
parent | 949742be882149a42fcb26807bc78a6ec135bdb2 (diff) |
Merge release-20201109.0-63-g949742be8 (automated)
Diffstat (limited to 'pkg/p9')
-rw-r--r-- | pkg/p9/client_file.go | 25 |
1 files changed, 10 insertions, 15 deletions
diff --git a/pkg/p9/client_file.go b/pkg/p9/client_file.go index 28fe081d6..8b46a2987 100644 --- a/pkg/p9/client_file.go +++ b/pkg/p9/client_file.go @@ -478,28 +478,23 @@ func (r *ReadWriterFile) ReadAt(p []byte, offset int64) (int, error) { } // Write implements part of the io.ReadWriter interface. +// +// Note that this may return a short write with a nil error. This violates the +// contract of io.Writer, but is more consistent with gVisor's pattern of +// returning errors that correspond to Linux errnos. Since short writes without +// error are common in Linux, returning a nil error is appropriate. func (r *ReadWriterFile) Write(p []byte) (int, error) { n, err := r.File.WriteAt(p, r.Offset) r.Offset += uint64(n) - if err != nil { - return n, err - } - if n < len(p) { - return n, io.ErrShortWrite - } - return n, nil + return n, err } // WriteAt implements the io.WriteAt interface. +// +// Note that this may return a short write with a nil error. This violates the +// contract of io.WriterAt. See comment on Write for justification. func (r *ReadWriterFile) WriteAt(p []byte, offset int64) (int, error) { - n, err := r.File.WriteAt(p, uint64(offset)) - if err != nil { - return n, err - } - if n < len(p) { - return n, io.ErrShortWrite - } - return n, nil + return r.File.WriteAt(p, uint64(offset)) } // Rename implements File.Rename. |