Skip to content
Commit 011b6954 authored by Pekka Paalanen's avatar Pekka Paalanen Committed by Kristian Høgsberg
Browse files

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: default avatarPekka Paalanen <pekka.paalanen@collabora.co.uk>
parent 5a019e38
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment