Fix raw_fallocate for Android and deal with unsupported filesystems. #2363
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR does two things:
::fallocate
instead of::posix_fallocate
(no member named 'posix_fallocate' in the global namespace #2358).lseek
+write
.It's quite important not to fall back to
lseek
+write
on all allocation failures, since the whole reason for the allocation was to preventSIGBUS
errors when allocation fails after mmaping. Ignoring allocation failure for supported filesystems would defeat that purpose, but always failing on unsupported filesystems even if space is available does not seem acceptable.I skipped the fallback to
ftruncate
, because I think it is equally likely to fail due to lack of filesystem support if(posix_)fallocate
did.I also didn't implement a fallback in the OS X version because I can't find any relevant documentation on the failure modes. It could be useful if someone on OS X tries to call
raw_fallocate
on a file on FAT32 and NTFS filesystem to see if that fails, and with whaterrno
value.