Skip to content

Commit

Permalink
Fix GH-10548: copy() fails on cifs mounts because of incorrect length…
Browse files Browse the repository at this point in the history
… (cfr_max) specified in streams.c:1584 copy_file_range() (#10551)

On some filesystems, the copy operation fails if we specify a size
larger than the file size in certain circumstances and configurations.
In those cases EIO will be returned as errno and we will therefore fall
back to other methods.
  • Loading branch information
nielsdos committed Feb 11, 2023
1 parent 0d56a5b commit e787d6c
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions main/streams/streams.c
Expand Up @@ -1614,6 +1614,13 @@ PHPAPI zend_result _php_stream_copy_to_stream_ex(php_stream *src, php_stream *de
/* not implemented by this Linux kernel */
break;

case EIO:
/* Some filesystems will cause failures if the max length is greater than the file length
* in certain circumstances and configuration. In those cases the errno is EIO and we will
* fall back to other methods. We cannot use stat to determine the file length upfront because
* that is prone to races and outdated caching. */
break;

default:
/* unexpected I/O error - give up, no fallback */
*len = haveread;
Expand Down

0 comments on commit e787d6c

Please sign in to comment.