mirror of
https://github.com/trapexit/mergerfs.git
synced 2026-10-26 19:01:56 -04:00
rework fallocate logic
This commit is contained in:
parent
68210d9252
commit
cb35a374ac
6 changed files with 156 additions and 43 deletions
|
|
@ -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,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue