summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorAnthony G. Basile <blueness@gentoo.org>2014-09-07 15:33:46 -0400
committerBernhard Reutner-Fischer <rep.dot.nop@gmail.com>2014-09-09 13:48:45 +0200
commit33a12b5540b8abbc4ee0ecb3a51912b3c7868517 (patch)
tree399a161fa8ae09eab39c25f17686c496a05b9b2b /include
parent7efe10ec5fc772f5328b35ba6716bde815212b45 (diff)
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 <blueness@gentoo.org> Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
Diffstat (limited to 'include')
-rw-r--r--include/fcntl.h32
1 files changed, 32 insertions, 0 deletions
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 */