|
@ -15,34 +15,34 @@ |
|
|
*/ |
|
|
*/ |
|
|
|
|
|
|
|
|
#include <fcntl.h> |
|
|
#include <fcntl.h> |
|
|
|
|
|
#include <unistd.h> |
|
|
|
|
|
|
|
|
#include "errno.hpp" |
|
|
#include "errno.hpp" |
|
|
#include "fs_fallocate.hpp" |
|
|
|
|
|
|
|
|
|
|
|
namespace fs |
|
|
|
|
|
|
|
|
static |
|
|
|
|
|
int |
|
|
|
|
|
_fallocate_core(const int fd, |
|
|
|
|
|
const off_t offset, |
|
|
|
|
|
const off_t len) |
|
|
{ |
|
|
{ |
|
|
static |
|
|
|
|
|
int |
|
|
|
|
|
_fallocate_core(const int fd, |
|
|
|
|
|
const off_t offset, |
|
|
|
|
|
const off_t len) |
|
|
|
|
|
{ |
|
|
|
|
|
int rv; |
|
|
|
|
|
fstore_t store = {F_ALLOCATECONTIG,F_PEOFPOSMODE,offset,len,0}; |
|
|
|
|
|
|
|
|
int rv; |
|
|
|
|
|
fstore_t store = {F_ALLOCATECONTIG,F_PEOFPOSMODE,offset,len,0}; |
|
|
|
|
|
|
|
|
rv = ::fcntl(fd,F_PREALLOCATE,&store); |
|
|
|
|
|
if(rv == -1) |
|
|
|
|
|
{ |
|
|
|
|
|
store.fst_flags = F_ALLOCATEALL; |
|
|
|
|
|
rv = ::fcntl(fd,F_PREALLOCATE,&store); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
rv = ::fcntl(fd,F_PREALLOCATE,&store); |
|
|
|
|
|
if(rv == -1) |
|
|
|
|
|
{ |
|
|
|
|
|
store.fst_flags = F_ALLOCATEALL; |
|
|
|
|
|
rv = ::fcntl(fd,F_PREALLOCATE,&store); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
if(rv == -1) |
|
|
|
|
|
return rv; |
|
|
|
|
|
|
|
|
if(rv == -1) |
|
|
|
|
|
return rv; |
|
|
|
|
|
|
|
|
return ::ftruncate(fd,(offset+len)); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
return ::ftruncate(fd,(offset+len)); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
namespace fs |
|
|
|
|
|
{ |
|
|
int |
|
|
int |
|
|
fallocate(const int fd, |
|
|
fallocate(const int fd, |
|
|
const int mode, |
|
|
const int mode, |