Commit 51f29320 authored by Rob Pike's avatar Rob Pike

syscalls can return negative i/o counts. fix bugs in ReadAt and WriteAt not to include

negative counts in return values.

R=rsc
CC=golang-dev
https://golang.org/cl/170044
parent d55abfd2
......@@ -141,11 +141,11 @@ func (file *File) ReadAt(b []byte, off int64) (n int, err Error) {
if m == 0 && e == 0 {
return n, EOF
}
n += m;
if e != 0 {
err = &PathError{"read", file.name, Errno(e)};
break;
}
n += m;
b = b[m:];
off += int64(m);
}
......@@ -186,11 +186,11 @@ func (file *File) WriteAt(b []byte, off int64) (n int, err Error) {
}
for len(b) > 0 {
m, e := syscall.Pwrite(file.fd, b, off);
n += m;
if e != 0 {
err = &PathError{"write", file.name, Errno(e)};
break;
}
n += m;
b = b[m:];
off += int64(m);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment