add osx version of fallocate

This commit is contained in:
Antonio SJ Musumeci 2016-08-01 17:26:55 -04:00
parent 939b4a0fe5
commit 45f757dc60
5 changed files with 159 additions and 24 deletions

View file

@ -14,31 +14,12 @@
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
#include <errno.h>
#include <fcntl.h>
#include "fs_fallocate.hpp"
namespace fs
{
int
fallocate(const int fd,
const int mode,
const off_t offset,
const off_t len)
{
int rv;
#ifdef __linux__
rv = ::fallocate(fd,mode,offset,len);
# include "fs_fallocate_linux.icpp"
#elif _XOPEN_SOURCE >= 600 || _POSIX_C_SOURCE >= 200112L
rv = (mode ?
(errno=EOPNOTSUPP,-1) :
(::posix_fallocate(fd,offset,len)));
# include "fs_fallocate_posix.icpp"
#elif __APPLE__
# include "fs_fallocate_osx.icpp"
#else
rv = (errno=EOPNOTSUPP,-1);
# include "fs_fallocate_unsupported.icpp"
#endif
return rv;
}
}