libreplace: Add a closefrom() implementation
authorVolker Lendecke <vl@samba.org>
Thu, 9 Jun 2016 19:27:09 +0000 (21:27 +0200)
committerAndreas Schneider <asn@cryptomilk.org>
Mon, 13 Jun 2016 08:10:11 +0000 (10:10 +0200)
commit55529d0f857ce11a1a0096850b1001d59dd6cb1d
tree18a1ee29b4950debf679ff3b8b1a47677806fb2c
parent467ea855cce70deeab95939d9385e1073e2261b6
libreplace: Add a closefrom() implementation

There is closefrom in some BSDs, but Linux ships this only as part
of libbsd.  Add a new implementation of it in libreplace. The one in
libbsd of jessie and upstream differ and it has for example optimizations
for FreeBSD, but it gets some of the array calculations slightly wrong
from my point of view. If you want those, use libbsd. This replacement
is optimized on Linux only looking at /proc/self/fd/, everything else
would do the OPEN_MAX brute force fallback.

Signed-off-by: Volker Lendecke <vl@samba.org>
lib/replace/closefrom.c [new file with mode: 0644]
lib/replace/replace.h
lib/replace/wscript