This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: Define FALLOC_FL_INSERT_RANGE, FALLOC_FL_UNSHARE_RANGE in bits/fcntl-linux.h
On Wed, 14 Dec 2016, Florian Weimer wrote:
> On 12/14/2016 12:59 AM, Joseph Myers wrote:
> > This patch adds the flags FALLOC_FL_INSERT_RANGE and
> > FALLOC_FL_UNSHARE_RANGE to bits/fcntl-linux.h.
> > FALLOC_FL_UNSHARE_RANGE is new in Linux 4.9; FALLOC_FL_INSERT_RANGE
> > was added in 4.1, but I missed it at that time.
>
> Can we just in clude <linux/falloc.h> for _GNU_SOURCE instead?
Since <linux/falloc.h> defines only these constants (and existed as far
back as 2.6.32, and nothing in glibc depends on having any more recent
FALLOC_* defines present when glibc is built), that should work. This
patch follows that approach.
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).
Tested for x86_64 and x86.
2016-12-14 Joseph Myers <joseph@codesourcery.com>
* sysdeps/unix/sysv/linux/bits/fcntl-linux.h [__USE_GNU]: Include
<linux/falloc.h>.
(FALLOC_FL_KEEP_SIZE): Remove.
(FALLOC_FL_PUNCH_HOLE): Likewise.
(FALLOC_FL_COLLAPSE_RANGE): Likewise.
(FALLOC_FL_ZERO_RANGE): Likewise.
diff --git a/sysdeps/unix/sysv/linux/bits/fcntl-linux.h b/sysdeps/unix/sysv/linux/bits/fcntl-linux.h
index 7e5b0ae..159ce14 100644
--- a/sysdeps/unix/sysv/linux/bits/fcntl-linux.h
+++ b/sysdeps/unix/sysv/linux/bits/fcntl-linux.h
@@ -318,15 +318,7 @@ struct f_owner_ex
/* Flags for fallocate. */
-# define FALLOC_FL_KEEP_SIZE 1 /* Don't extend size of file
- even if offset + len is
- greater than file size. */
-# define FALLOC_FL_PUNCH_HOLE 2 /* Create a hole in the file. */
-# define FALLOC_FL_COLLAPSE_RANGE 8 /* Remove a range of a file
- without leaving a
- hole. */
-# define FALLOC_FL_ZERO_RANGE 16 /* Convert a range of a
- file to zeros. */
+# include <linux/falloc.h>
/* File handle structure. */
--
Joseph S. Myers
joseph@codesourcery.com