RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.
Bug 1476120 - glibc headers don't include linux/falloc.h, and therefore doesn't include fallocate() flags
Summary: glibc headers don't include linux/falloc.h, and therefore doesn't include fal...
Alias: None
Product: Red Hat Enterprise Linux 7
Classification: Red Hat
Component: glibc
Version: 7.4
Hardware: All
OS: Unspecified
Target Milestone: rc
: ---
Assignee: DJ Delorie
QA Contact: Sergey Kolosov
Vladimír Slávik
Depends On:
Blocks: 1505884
TreeView+ depends on / blocked
Reported: 2017-07-28 05:46 UTC by David Gibson
Modified: 2018-10-30 09:37 UTC (History)
9 users (show)

Fixed In Version: glibc-2.17-237.el7
Doc Type: Bug Fix
Doc Text:
`fallocate()` flags again available as per documentation Previously, the `fcntl.h` header file from the _glibc_ package did not include flags for the `fallocate()` function. As a consequence, programs using `fallocate()` according to the man page did not compile. The missing flags have been added by indirect inclusion of the `<linux/falloc.h>` file and compilation of such programs is again possible.
Clone Of:
Last Closed: 2018-10-30 09:36:35 UTC
Target Upstream Version:

Attachments (Terms of Use)

System ID Private Priority Status Summary Last Updated
Red Hat Product Errata RHSA-2018:3092 0 None None None 2018-10-30 09:37:36 UTC

Description David Gibson 2017-07-28 05:46:47 UTC
Description of problem:

RHEL7's kernel supports the fallocate() call and its various flags, such as FALLOC_FL_PUNCH_HOLE.  Likewise the man page for fallocate(2) lists this option and says <fcntl.h> should give you the necessary definitions.

However, while FALLOC_FL_PUNCH_HOLE (and other fallocate() flags) is included in /usr/include/linux/falloc.h (supplied by the kernel), that file is not included, directly or indirectly by /usr/include/fcntl.h

Version-Release number of selected component (if applicable):


How reproducible:


Steps to Reproduce:
1. Create fallocate.c:

#define _GNU_SOURCE

#include <fcntl.h>

int test(int fd)
			 0, 1024 * 1024);

2. Compile source file above with:

    $ gcc -Wall -c fallocate.c

Actual results:

$ gcc -c fallocate.c 
fallocate.c: In function ‘test’:
fallocate.c:7:23: error: ‘FALLOC_FL_PUNCH_HOLE’ undeclared (first use in this function)
  return fallocate(fd, FALLOC_FL_PUNCH_HOLE | FALLOC_FL_KEEP_SIZE,
fallocate.c:7:23: note: each undeclared identifier is reported only once for each function it appears in
fallocate.c:7:46: error: ‘FALLOC_FL_KEEP_SIZE’ undeclared (first use in this function)
  return fallocate(fd, FALLOC_FL_PUNCH_HOLE | FALLOC_FL_KEEP_SIZE,

Expected results:

File compiles successfully.

Additional info:

This works correctly in Fedora 26 (and therefore, presumably, in upstream glibc).  In Fedora, fcntl.h indirectly includes linux/falloc.h via bits/fcntl-linux.h.

Comment 2 David Gibson 2017-07-28 05:47:57 UTC
The fallocate() flags are used by one of the testcases in libhugetlbfs which is used for testing hugepages on various systems.

Comment 4 Florian Weimer 2017-07-28 06:52:51 UTC
Relevant upstream commit:

commit 257dabc059447934a90be6fce4b5d2a5f4b63dfd
Author: Joseph Myers <joseph>
Date:   Wed Dec 14 18:23:15 2016 +0000

    Include <linux/falloc.h> in bits/fcntl-linux.h.
    This patch makes bits/fcntl-linux.h include <linux/falloc.h> to define
    the FALLOC_* flags under __USE_GNU (linux/falloc.h defines only those
    bits, nothing else).

Comment 12 errata-xmlrpc 2018-10-30 09:36:35 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.


Note You need to log in before you can comment on or make changes to this bug.