OSDN Git Service

libc: fix setting return value and errno in fallocate()
authorYuriy Kolerov <yuriy.kolerov@synopsys.com>
Wed, 23 Sep 2015 12:43:37 +0000 (15:43 +0300)
committerWaldemar Brodkorb <wbx@openadk.org>
Fri, 9 Oct 2015 03:27:10 +0000 (05:27 +0200)
commit0034d10e136348316d1887a48eb642401e8a26c4
treeeae793f9c27cc9adc7a63ec5c42411c20e15ccad
parentacf24a86e915617809179a4284f6889d9d6d0c31
libc: fix setting return value and errno in fallocate()

fallocate system call must return 0 on success. On error, -1 is returned
and errno is set to indicate the error.

However there is an error in fallocate which is fixed by this patch - it
does not set errno and returns invalid value on error (it returns error
code instead of -1).

This error is detected in LTP's test kernel/syscalls/fallocate02:

    ----------->8----------
    fallocate(..., 1, 0, 1024) failed, expected errno:9: TEST_ERRNO=0
    fallocate(..., 1, -1024, 1024) failed, expected errno:22: TEST_ERRNO=0
    fallocate(..., 1, 1024, -1024) failed, expected errno:22: TEST_ERRNO=0
    fallocate(..., 1, 12288, 0) failed, expected errno:22: TEST_ERRNO=0
    fallocate(..., 1, 12288, -1024) failed, expected errno:22: TEST_ERRNO=0
    fallocate(..., 1, -24576, 1024) failed, expected errno:22: TEST_ERRNO=0
    ----------->8----------

Signed-off-by: Yuriy Kolerov <yuriy.kolerov@synopsys.com>
libc/sysdeps/linux/common/fallocate.c
libc/sysdeps/linux/common/fallocate64.c