summaryrefslogtreecommitdiffstats
path: root/src/util.c
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@rambler-co.ru>2011-12-14 19:34:50 +0300
committerVsevolod Stakhov <vsevolod@rambler-co.ru>2011-12-14 19:34:50 +0300
commit44311f4235463a8d4d3c4128242bbd7c9d2a203b (patch)
tree61cf649234696840338a76e6c83a8d5b8f45460f /src/util.c
parent4499fc92189905fde71139822d784ab7819b181c (diff)
downloadrspamd-44311f4235463a8d4d3c4128242bbd7c9d2a203b.tar.gz
rspamd-44311f4235463a8d4d3c4128242bbd7c9d2a203b.zip
Detect and use fallocate/posix_fallocate.
Diffstat (limited to 'src/util.c')
-rw-r--r--src/util.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/util.c b/src/util.c
index dea3976f1..c5ec0145e 100644
--- a/src/util.c
+++ b/src/util.c
@@ -1381,6 +1381,19 @@ rspamd_strtoul (const gchar *s, gsize len, gulong *value)
return TRUE;
}
+gint
+rspamd_fallocate (gint fd, off_t offset, off_t len)
+{
+#if defined(HAVE_FALLOCATE) && defined(FALLOC_FL_KEEP_SIZE)
+ return fallocate (fd, FALLOC_FL_KEEP_SIZE, offset, len);
+#elif defined(HAVE_POSIX_FALLOCATE)
+ return posix_fallocate (fd, offset, len);
+#else
+ /* Return 0 as nothing can be done on this system */
+ return 0;
+#endif
+}
+
/*
* vi:ts=4
*/