[PATCH] copy_file_range: New function to copy file data

Florian Weimer fweimer@redhat.com
Thu Dec 21 13:44:00 GMT 2017


On 12/19/2017 12:01 PM, Adhemerval Zanella wrote:
> It is a default ubuntu 16 installation: /tmp is ext4 (rw,relatime,errors=remount-ro,data=ordered)
> with kernel 4.4.0-71-generic

I could reproduce this with ext4.  The different failure behavior 
exposed a bug in the compat code: It did not handle short writes 
correctly, after all.  It would return if it encountered a short write. 
The correct result in that case would be to return the length of the 
short write.  The fix was to change

+              if (copied > 0)
+                /* Report the number of bytes copied so far.  */
+                return copied + written;

into:

+              if (copied + written > 0)
+                /* Report the number of bytes copied so far.  */
+                return copied + written;

The test now handles EFBIG in addition to EINVAL.  I updated the 
documentation to mention EFBIG, too.  I do not think it is necessary to 
change the compat implementation to handle O_LARGEFILE.

Thanks,
Florian
-------------- next part --------------
A non-text attachment was scrubbed...
Name: copy_file_range.patch
Type: text/x-patch
Size: 62038 bytes
Desc: not available
URL: <http://sourceware.org/pipermail/libc-alpha/attachments/20171221/0bb7fcbf/attachment.bin>


More information about the Libc-alpha mailing list