#define _GNU_SOURCE
#include <errno.h>
#include <fcntl.h>
#include <stdio.h>

/* Invalid descriptors keep the check independent of files and free space. */
int main(void) {
    errno = 0;
    int posix_result = posix_fallocate(-1, 0, 4096);
    int posix_errno = errno;
    errno = 0;
    int linux_result = fallocate(-1, 0, 0, 4096);
    int linux_errno = errno;
    printf("{\"posix_return\":%d,\"posix_errno\":%d,"
           "\"linux_return\":%d,\"linux_errno\":%d,\"EBADF\":%d}\n",
           posix_result, posix_errno, linux_result, linux_errno, EBADF);
    return posix_result == EBADF && linux_result == -1 && linux_errno == EBADF
        ? 0 : 1;
}
