rework fallocate logic

This commit is contained in:
Antonio SJ Musumeci 2016-05-11 11:43:26 -04:00
parent 68210d9252
commit cb35a374ac
6 changed files with 156 additions and 43 deletions

View file

@ -19,8 +19,8 @@
#include <fuse.h>
#include <errno.h>
#include <fcntl.h>
#include "fs_fallocate.hpp"
#include "fileinfo.hpp"
static
@ -32,22 +32,7 @@ _fallocate(const int fd,
{
int rv;
#ifdef _GNU_SOURCE
rv = ::fallocate(fd,mode,offset,len);
#elif defined _XOPEN_SOURCE >= 600 || _POSIX_C_SOURCE >= 200112L
if(mode)
{
rv = -1;
errno = EOPNOTSUPP;
}
else
{
rv = ::posix_fallocate(fd,offset,len);
}
#else
rv = -1;
errno = EOPNOTSUPP;
#endif
rv = fs::fallocate(fd,mode,offset,len);
return ((rv == -1) ? -errno : 0);
}
@ -65,6 +50,7 @@ namespace mergerfs
{
FileInfo *fi = reinterpret_cast<FileInfo*>(ffi->fh);
return _fallocate(fi->fd,
mode,
offset,