)
func (f *File) readFrom(r io.Reader) (written int64, handled bool, err error) {
+ // Neither copy_file_range(2) nor splice(2) supports destinations opened with
+ // O_APPEND, so don't bother to try zero-copy with these system calls.
+ //
+ // Visit https://man7.org/linux/man-pages/man2/copy_file_range.2.html#ERRORS and
+ // https://man7.org/linux/man-pages/man2/splice.2.html#ERRORS for details.
+ if f.appendMode {
+ return 0, false, nil
+ }
+
written, handled, err = f.copyFileRange(r)
if handled {
return
}
func (f *File) copyFileRange(r io.Reader) (written int64, handled bool, err error) {
- // copy_file_range(2) does not support destinations opened with
- // O_APPEND, so don't even try.
- if f.appendMode {
- return 0, false, nil
- }
-
var (
remain int64
lr *io.LimitedReader