public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
* Define FALLOC_FL_INSERT_RANGE, FALLOC_FL_UNSHARE_RANGE in bits/fcntl-linux.h
@ 2016-12-13 23:59 Joseph Myers
  2016-12-14  8:35 ` Florian Weimer
  0 siblings, 1 reply; 4+ messages in thread
From: Joseph Myers @ 2016-12-13 23:59 UTC (permalink / raw)
  To: libc-alpha

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.

Tested for x86_64 and x86.

2016-12-13  Joseph Myers  <joseph@codesourcery.com>

	* sysdeps/unix/sysv/linux/bits/fcntl-linux.h [__USE_GNU]
	(FALLOC_FL_INSERT_RANGE): New macro.
	[__USE_GNU] (FALLOC_FL_UNSHARE_RANGE): Likewise.

diff --git a/sysdeps/unix/sysv/linux/bits/fcntl-linux.h b/sysdeps/unix/sysv/linux/bits/fcntl-linux.h
index 7e5b0ae..0a30af2 100644
--- a/sysdeps/unix/sysv/linux/bits/fcntl-linux.h
+++ b/sysdeps/unix/sysv/linux/bits/fcntl-linux.h
@@ -327,6 +327,9 @@ struct f_owner_ex
 					     hole.  */
 # define FALLOC_FL_ZERO_RANGE		16 /* Convert a range of a
 					      file to zeros.  */
+# define FALLOC_FL_INSERT_RANGE		32 /* Insert a range in a file.  */
+# define FALLOC_FL_UNSHARE_RANGE	64 /* Unshare shared blocks in
+					      a file.  */
 
 
 /* File handle structure.  */

-- 
Joseph S. Myers
joseph@codesourcery.com

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Define FALLOC_FL_INSERT_RANGE, FALLOC_FL_UNSHARE_RANGE in bits/fcntl-linux.h
  2016-12-13 23:59 Define FALLOC_FL_INSERT_RANGE, FALLOC_FL_UNSHARE_RANGE in bits/fcntl-linux.h Joseph Myers
@ 2016-12-14  8:35 ` Florian Weimer
  2016-12-14 18:12   ` Joseph Myers
  0 siblings, 1 reply; 4+ messages in thread
From: Florian Weimer @ 2016-12-14  8:35 UTC (permalink / raw)
  To: Joseph Myers, libc-alpha

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?

Thanks,
Florian

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Define FALLOC_FL_INSERT_RANGE, FALLOC_FL_UNSHARE_RANGE in bits/fcntl-linux.h
  2016-12-14  8:35 ` Florian Weimer
@ 2016-12-14 18:12   ` Joseph Myers
  2016-12-14 18:21     ` Florian Weimer
  0 siblings, 1 reply; 4+ messages in thread
From: Joseph Myers @ 2016-12-14 18:12 UTC (permalink / raw)
  To: Florian Weimer; +Cc: libc-alpha

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

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Define FALLOC_FL_INSERT_RANGE, FALLOC_FL_UNSHARE_RANGE in bits/fcntl-linux.h
  2016-12-14 18:12   ` Joseph Myers
@ 2016-12-14 18:21     ` Florian Weimer
  0 siblings, 0 replies; 4+ messages in thread
From: Florian Weimer @ 2016-12-14 18:21 UTC (permalink / raw)
  To: Joseph Myers; +Cc: libc-alpha

* Joseph Myers:

> 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.

Looks good to me.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2016-12-14 18:21 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-12-13 23:59 Define FALLOC_FL_INSERT_RANGE, FALLOC_FL_UNSHARE_RANGE in bits/fcntl-linux.h Joseph Myers
2016-12-14  8:35 ` Florian Weimer
2016-12-14 18:12   ` Joseph Myers
2016-12-14 18:21     ` Florian Weimer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).