Commit 48defba0 authored by Kirill Smelkov's avatar Kirill Smelkov

bigfile/ram_shmfs: Try to support compiling on older systems

For example on Debian 7 Wheezy the kernel (linux 3.2) supports holepunching,
because holepunching was added in linux 2.6.38:

but glibc does not provide fallocate mode constants, and compilation fails:

    gcc -pthread -fno-strict-aliasing -g -O2 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -D_GNU_SOURCE -I./include -I./3rdparty/ccan -I./3rdparty/include -I/opt/slapgrid/f2a5f59d0d2b521681b9333ee76a2859/parts/python2.7/include/python2.7 -c bigfile/ram_shmfs.c -o build/temp.linux-x86_64-2.7/bigfile/ram_shmfs.o -std=gnu99 -fplan9-extensions -fvisibility=hidden -Wno-declaration-after-statement -Wno-error=declaration-after-statement
    bigfile/ram_shmfs.c: In function ‘shmfs_drop_memory’:
    bigfile/ram_shmfs.c:135:31: error: ‘FALLOC_FL_PUNCH_HOLE’ undeclared (first use in this function)
    bigfile/ram_shmfs.c:135:31: note: each undeclared identifier is reported only once for each function it appears in
    bigfile/ram_shmfs.c:135:54: error: ‘FALLOC_FL_KEEP_SIZE’ undeclared (first use in this function)
    error: command 'gcc' failed with exit status 1

Try to fix it via fallbacking to provide the needed defines on older systems ourselves.

Cc: Klaus Wölfel <>
Cc: Ivan Tyagov <>
parent e0b25398
......@@ -26,6 +26,17 @@
#include <wendelin/bug.h>
#include <fcntl.h>
/* FIXME glibc in Debian before Jessie does not define FALLOC_FL_KEEP_SIZE and
* FALLOC_FL_PUNCH_HOLE, even when kernel supports it
# define FALLOC_FL_KEEP_SIZE 0x01
# define FALLOC_FL_PUNCH_HOLE 0x02
#include <unistd.h>
#include <sys/vfs.h>
#include <sys/mman.h>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment