[PATCH] libc: add fallocate() and fallocate64()

Anthony G. Basile basile at opensource.dyc.edu
Wed Sep 10 23:35:52 UTC 2014


On 09/09/14 07:52, Bernhard Reutner-Fischer wrote:
> On 9 September 2014 00:17, Bernhard Reutner-Fischer
> <rep.dot.nop at gmail.com> wrote:
>> On Sun, Sep 07, 2014 at 03:33:46PM -0400, basile at opensource.dyc.edu wrote:
>>> From: "Anthony G. Basile" <blueness at gentoo.org>
>>>
>>> We add the Linux-specific function fallocate() which allows the user to
>>> directly manipulate allocate space for a file.  fallocate() can operate
>>> in different modes, but the default mode is equivalent to posix_fallocate()
>>> which is specified in POSIX.1.
>>>
>>> Recent releases of e2fsprogs 1.42.11 and above expect fallocate64() to be
>>> available.
>>
>> Looks good. A few remarks:
>
>> We should drop the libc_hidden_proto(fallocate{,64}) since we do not have
>> internal users (and iff we gain some they should use __libc_fallocate{,64})
>> though.
>
> I did that and installed your patch with my amendments.
>
>> I did not test 32bit vs 64bit targets nor all combos of the egrep above.
>>
>> Care to test and send an updated patch, please?
>
> Thanks for the patch and cheers,
>

Hi Bernhard,

I tested the patch on x86_64 and x86, and all is good but one issue. 
When running the tests with

UCLIBC_HAS_LFS=y
UCLIBC_LINUX_SPECIFIC=y
# UCLIBC_HAS_ADVANCED_REALTIME is not set

you hit

tst-posix_fallocate64.o: In function `do_test':
tst-posix_fallocate64.c:(.text+0x62): undefined reference to 
`posix_fallocate'

because the Makefile.in doesn't turn off the build for 
tst-posix_fallocate64, only tst-posix_fallocate.  The logic there is:

ifeq ($(UCLIBC_HAS_LFS),)
TESTS_DISABLED := tst-preadwrite64 tst-posix_fallocate64 tst-fallocate64
endif

ifeq ($(UCLIBC_HAS_ADVANCED_REALTIME),)
TESTS_DISABLED += tst-posix_fallocate
endif

Since LFS is on, tst-posix_fallocate64 is built even though 
UCLIBC_HAS_ADVANCED_REALTIME is not set.  That's why in my original 
patch I changed this to

ifeq ($(UCLIBC_HAS_ADVANCED_REALTIME),)
TESTS_DISABLED += tst-posix_fallocate
ifeq ($(UCLIBC_HAS_LFS),y)
TESTS_DISABLED += tst-posix_fallocate64
endif
endif


Other than that, everything worked and the code reads nicely.  Thanks 
for cleaning things up.

One final point, the patch doesn't apply cleanly to 0.9.33 branch.  Its 
just a couple of simple fixes.  Should I submit a backport patch?  We 
need this in Gentoo to keep up with e2fsprogs.  Mike adds patches from 
the 0.9.33 branch to his patchsets when he bumps the ebuilds.


-- 
Anthony G. Basile, Ph. D.
Chair of Information Technology
D'Youville College
Buffalo, NY 14201
(716) 829-8197


More information about the uClibc mailing list