os: use posix_fallocate in creating sharable buffers
authorPekka Paalanen <pekka.paalanen@collabora.co.uk>
Fri, 29 Nov 2013 15:48:51 +0000 (17:48 +0200)
committerKristian Høgsberg <krh@bitplanet.net>
Tue, 3 Dec 2013 00:20:27 +0000 (16:20 -0800)
commit5b4ddbc11e84a22caefa655f4504e2999726458b
treef33fff07598506e28a161ba3eb39db98a173faed
parent8a81b83900ae3153a07f0824a57d0daed436fc18
os: use posix_fallocate in creating sharable buffers

If posix_fallocate is available, use it instead of ftruncate. Unlike
ftruncate, when posix_fallocate succeeds, it guarantees that you cannot
run out of disk space, when later writing to the mmap()'ed file.

With posix_fallocate, if os_create_anonymous_file() succeeds, the
program cannot get a SIGBUS later from accessing this file via mmap. If
there is insufficient disk space, the function fails and errno is set to
ENOSPC.

This is useful on systems, that limit the available buffer space by
having XDG_RUNTIME_DIR on a small tmpfs.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
configure.ac
shared/os-compatibility.c