[PATCH 4/5] Do not call posix_fallocate() if unavailable

Clayton Shotwell clayton.shotwell at rockwellcollins.com
Thu May 28 13:04:08 UTC 2015


uClibc does not implement posix_fallocate(), and posix_fallocate() is
mostly only an hint to the kernel that we will need such or such
amount of space inside a file. Adding a check around the
posix_fallocate() call so it is only called when it is available.

Signed-off-by: Clayton Shotwell <clayton.shotwell at rockwellcollins.com>
---
 audisp/plugins/remote/queue.c | 2 ++
 configure.ac                  | 1 +
 2 files changed, 3 insertions(+)

diff --git a/audisp/plugins/remote/queue.c b/audisp/plugins/remote/queue.c
index 79eebd7..971e4e4 100644
--- a/audisp/plugins/remote/queue.c
+++ b/audisp/plugins/remote/queue.c
@@ -215,9 +215,11 @@ static int q_open_file(struct queue *q, const char *path)
 			return -1;
 		if (q_sync(q) != 0)
 			return -1;
+#ifdef HAVE_POSIX_FALLOCATE
 		if (posix_fallocate(q->fd, 0,
 				    (q->num_entries + 1) * q->entry_size) != 0)
 			return -1;
+#endif
 	} else {
 		uint32_t file_entries;
 		if (full_pread(q->fd, &fh, sizeof(fh), 0) != 0)
diff --git a/configure.ac b/configure.ac
index 57aec03..c14ec80 100644
--- a/configure.ac
+++ b/configure.ac
@@ -67,6 +67,7 @@ AC_CHECK_DECLS([MS_DIRSYNC], [], [], [[#include <sys/mount.h>]])
 AC_CHECK_DECLS([AUDIT_FEATURE_VERSION], [], [], [[#include <linux/audit.h>]])
 AC_CHECK_DECLS([AUDIT_VERSION_BACKLOG_WAIT_TIME], [], [], [[#include <linux/audit.h>]])
 AC_CHECK_DECLS([ADDR_NO_RANDOMIZE],,, [#include <sys/personality.h>])
+AC_CHECK_FUNCS([posix_fallocate])
 
 ALLWARNS=""
 ALLDEBUG="-g"
-- 
1.9.1




More information about the Linux-audit mailing list