[PATCH 1/2] libc: fix setting return value and errno in fallocate()

Rich Felker dalias at libc.org
Thu Sep 17 16:07:38 UTC 2015


On Thu, Sep 17, 2015 at 03:56:55PM +0000, Yuriy Kolerov wrote:
> Hi Waldemar and Bernhard.
> 
> First of all sorry for the absent of the detailed explanation of my
> fixes. I'm going to send a second version of patches after our
> discussion.
> 
> The problem is that fallocate does not pass LTP (Linux Test Project)
> which checks return code and errno after fallocate execution. Then
> I've found that fallocate in uClibc does not set errno thus I've
> decided to fix it according to Linux manpage. But thanks to Bernhard
> I've also found that posix_fallocate has another behavior:
> "posix_fallocate() returns zero on success, or an error number on
> failure. Note that errno is not set." And posix_fallocate in uClibc
> refers to fallocate (oops). So my first patch is invalid in this
> place: it's also necessary to change posix_fallocate and
> posix_fallocate64 to meet requirements of POSIX (make it don't touch
> errno and just return error code).

Not-touching-errno is not a POSIX requirement. This is just a case of
an over-aggressive man page documenting glibc-specific behavior that
is not standard and should not be relied upon by applications. You can
see here that there is no such requirement (by default any function in
the standard is allowed to modify errno unless it's specified not to):

http://pubs.opengroup.org/onlinepubs/9699919799/functions/posix_fallocate.html

Rich


More information about the uClibc mailing list