lib/fs: Unwrap mtimeFile, get fd the "correct" way (ref #6875) (#6877)

This commit is contained in:
Audrius Butkevicius
2020-08-07 07:47:48 +02:00
committed by GitHub
parent ff84f075d5
commit e9bb17307d
8 changed files with 337 additions and 157 deletions
+4 -2
View File
@@ -4,7 +4,7 @@
// License, v. 2.0. If a copy of the MPL was not distributed with this file,
// You can obtain one at https://mozilla.org/MPL/2.0/.
// +build !windows,!darwin
// +build linux solaris
package fs
@@ -51,7 +51,9 @@ func copyRangeSendFile(src, dst basicFile, srcOffset, dstOffset, size int64) err
// following the last byte that was read. If offset is not NULL, then sendfile() does not modify the current
// file offset of in_fd; otherwise the current file offset is adjusted to reflect the number of bytes read from
// in_fd.
n, err := syscall.Sendfile(int(dst.Fd()), int(src.Fd()), &srcOffset, int(size))
n, err := withFileDescriptors(dst, src, func(dstFd, srcFd uintptr) (int, error) {
return syscall.Sendfile(int(dstFd), int(srcFd), &srcOffset, int(size))
})
if n == 0 && err == nil {
err = io.ErrUnexpectedEOF
}