[PATCH] PR70975 Pass valid offset argument to sendfile

Jonathan Wakely jwakely@redhat.com
Thu Oct 27 14:37:00 GMT 2016


This fixes a FAIL on Solaris, due to a difference between the GNU and
Solaris versions of sendfile(2).

2016-10-27  Uros Bizjak  <ubizjak@gmail.com>

	PR libstdc++/70975
	* src/filesystem/ops.cc (do_copy_file): Pass non-null pointer to
	sendfile for offset argument.

Tested powerpc64le-linux, committed to trunk.

-------------- next part --------------
commit 27d5ce18d1d752dafb757ba31948aa1bb32cf122
Author: Jonathan Wakely <jwakely@redhat.com>
Date:   Thu Oct 27 15:23:10 2016 +0100

    PR70975 Pass valid offset argument to sendfile
    
    2016-10-27  Uros Bizjak  <ubizjak@gmail.com>
    
    	PR libstdc++/70975
    	* src/filesystem/ops.cc (do_copy_file): Pass non-null pointer to
    	sendfile for offset argument.

diff --git a/libstdc++-v3/src/filesystem/ops.cc b/libstdc++-v3/src/filesystem/ops.cc
index 9abcee0..8ed0a10 100644
--- a/libstdc++-v3/src/filesystem/ops.cc
+++ b/libstdc++-v3/src/filesystem/ops.cc
@@ -444,7 +444,8 @@ namespace
       }
 
 #ifdef _GLIBCXX_USE_SENDFILE
-    const auto n = ::sendfile(out.fd, in.fd, nullptr, from_st->st_size);
+    off_t offset = 0;
+    const auto n = ::sendfile(out.fd, in.fd, &offset, from_st->st_size);
     if (n < 0 && (errno == ENOSYS || errno == EINVAL))
       {
 #endif


More information about the Gcc-patches mailing list