If copy_file_range() returns 0, then that means no data was copied. We
should break out of the loop in this case to prevent looping
indefinitely.
Additionally, if an error is returned by copy_file_range() then we need
to print out the string form to be used by error checking tests in
xfstests.
Signed-off-by: Anna Schumaker <Anna.Schumaker@Netapp.com>
Reviewed-by: Carlos Maiolino <cmaiolino@redhat.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
do {
ret = syscall(__NR_copy_file_range, fd, src, file->fd, dst, len, 0);
- if (ret == -1)
+ if (ret == -1) {
+ perror("copy_range");
return errno;
+ } else if (ret == 0)
+ break;
len -= ret;
} while (len > 0);