[PATCH] Use posix_fallocate instead of ftruncate.

Rui Ueyama via llvm-commits llvm-commits at lists.llvm.org
Tue Jul 19 12:11:54 PDT 2016


I'd use fallocate(2) instead of posix_fallocate. fallocate does, contrary
to posix's one, return an error if an underlying filesystem doesn't support
the feature. You can just ignore the error.

Since fallocate is Linux-specific, you would have to add HAS_FALLOCATE.

On Tue, Jul 19, 2016 at 1:52 PM, Rafael EspĂ­ndola <
rafael.espindola at gmail.com> wrote:

> On 19 July 2016 at 14:31, Rafael EspĂ­ndola <rafael.espindola at gmail.com>
> wrote:
> > On 19 July 2016 at 13:11, Rui Ueyama <ruiu at google.com> wrote:
> >> I have a concern about this change when it is used on a filesystem that
> >> doesn't support file pre-allocation. The function should work on a
> >> filesystem that doesn't support an underlying fallocate(-ish) system
> call,
> >> but in that case I believe it tries to actually write data to force
> >> allocation. In that case it'd be slow.
> >
> > It still seems better than crashing, no?
> >
> > Which filesystems do you have in mind? I have a spare partition, so I
> > should be able to test pretty much anything that linux supports. I
> > will give HFS+ a try on OS X too.
>
>
> OS X is missing posix_fallocate :-(
>
> I am looking for an alternative.
>
> Cheers,
> Rafael
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160719/262a3619/attachment.html>


More information about the llvm-commits mailing list