From 51c8216594645b4caf614664bf10ba49e1ec9015 Mon Sep 17 00:00:00 2001 From: Eric Blake Date: Fri, 4 Oct 2013 17:25:13 -0600 Subject: [PATCH] build: fix build on RHEL 5 On RHEL 5, compilation fails with: storage/storage_backend.c: In function 'createRawFile': storage/storage_backend.c:339: warning: implicit declaration of function 'fallocate' storage/storage_backend.c:339: warning: nested extern declaration of 'fallocate' [-Wnested-externs] But: $ grep HAVE_FALLOCATE config.h /* #undef HAVE_FALLOCATE */ Huh? It turns out that in kernels that old, fallocate() is not implemented (config.h is correct), but defines HAVE_FALLOCATE as an empty witness macro for a completely different purpose. Since storage_backend.c is including on RHEL 5, we are hosed by the kernel definition. Newer kernels no longer pollute the namespace, and it's fairly easy to convert to an expression that works with both the old kernel witness and the new-style config.h (undefined or 1). Problem introduced in commit 532fef3. * src/storage/storage_backend.c (createRawFile): Avoid namespace pollution from kernel, by checking HAVE_FALLOCATE for a value. Signed-off-by: Eric Blake --- src/storage/storage_backend.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/storage/storage_backend.c b/src/storage/storage_backend.c index 5f1bc66971..662af3266f 100644 --- a/src/storage/storage_backend.c +++ b/src/storage/storage_backend.c @@ -329,7 +329,8 @@ createRawFile(int fd, virStorageVolDefPtr vol, goto cleanup; } -#ifdef HAVE_FALLOCATE +/* Avoid issues with older kernel's namespace pollution. */ +#if HAVE_FALLOCATE - 0 /* Try to preallocate all requested disk space, but fall back to * other methods if this fails with ENOSYS or EOPNOTSUPP. * NOTE: do not use posix_fallocate; posix_fallocate falls back