Browse Source

restructure osx fallocate

pull/384/head
Antonio SJ Musumeci 9 years ago
parent
commit
b0fb5187c4
  1. 40
      src/fs_fallocate_osx.icpp

40
src/fs_fallocate_osx.icpp

@ -20,30 +20,30 @@
#include "fs_fallocate.hpp"
#include "fs_base_ftruncate.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
fallocate(const int fd,
const int mode,
@ -53,6 +53,6 @@ namespace fs
if(mode)
return (errno=EOPNOTSUPP,-1);
return _fallocate_core(fd,offset,len);
return ::_fallocate_core(fd,offset,len);
}
}
Loading…
Cancel
Save