Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions src/native/libs/System.Native/pal_io.c
Original file line number Diff line number Diff line change
Expand Up @@ -1259,6 +1259,15 @@ int32_t SystemNative_CopyFile(intptr_t sourceFd, intptr_t destinationFd, int64_t
copied = sourceLength == 0;
}
#endif

#if HAVE_FALLOCATE // Linux
if (!copied && sourceLength > 81920) // BufferSize used by CopyFile_ReadWrite (would require more than 1 sys-call)
{
// try to pre-allocate disk space for large destination files
while ((ret = fallocate(outFd, FALLOC_FL_KEEP_SIZE, (off_t)0, (off_t)sourceLength)) == -1 && errno == EINTR);
}
#endif

#if HAVE_SENDFILE_4
// Try copying the data using sendfile.
if (trySendFile && !copied && sourceLength != 0)
Expand Down