From 33a12b5540b8abbc4ee0ecb3a51912b3c7868517 Mon Sep 17 00:00:00 2001 From: "Anthony G. Basile" Date: Sun, 7 Sep 2014 15:33:46 -0400 Subject: libc: add fallocate() and fallocate64() We add the Linux-specific function fallocate() which allows the user to directly manipulate allocate space for a file. fallocate() can operate in different modes, but the default mode is equivalent to posix_fallocate() which is specified in POSIX.1. Recent releases of e2fsprogs 1.42.11 and above expect fallocate64() to be available. Signed-off-by: Anthony G. Basile Signed-off-by: Bernhard Reutner-Fischer --- include/fcntl.h | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) (limited to 'include') diff --git a/include/fcntl.h b/include/fcntl.h index c749ad552..04fc2c06d 100644 --- a/include/fcntl.h +++ b/include/fcntl.h @@ -239,6 +239,38 @@ extern int posix_fallocate64 (int __fd, __off64_t __offset, __off64_t __len); # endif #endif +#if (defined __UCLIBC_LINUX_SPECIFIC__ && defined __USE_GNU) || defined _LIBC +/* Reserve storage for the data of a file associated with FD. This function + is Linux-specific. For the portable version, use posix_fallocate(). + Unlike the latter, fallocate can operate in different modes. The default + mode = 0 is equivalent to posix_fallocate(). + + Note: These declarations are used in posix_fallocate.c and + posix_fallocate64.c, so we expose them internally. + */ + +/* Flags for fallocate's mode. */ +# 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. */ + +# ifndef __USE_FILE_OFFSET64 +extern int fallocate (int __fd, int __mode, __off_t __offset, __off_t __len); +# else +# ifdef __REDIRECT +extern int __REDIRECT (fallocate, (int __fd, int __mode, __off64_t __offset, + __off64_t __len), + fallocate64); +# else +# define fallocate fallocate64 +# endif +# endif +# ifdef __USE_LARGEFILE64 +extern int fallocate64 (int __fd, int __mode, __off64_t __offset, __off64_t __len); +# endif +#endif + __END_DECLS #endif /* fcntl.h */ -- cgit v1.2.3