Browse Source

restructure fallocate abstraction

pull/391/head
Antonio SJ Musumeci 8 years ago
parent
commit
e2acffe55b
  1. 2
      src/fallocate.cpp
  2. 8
      src/fs_base_fallocate.cpp
  3. 6
      src/fs_base_fallocate.hpp
  4. 1
      src/fs_base_fallocate_linux.icpp
  5. 40
      src/fs_base_fallocate_osx.icpp
  6. 1
      src/fs_base_fallocate_posix.icpp
  7. 1
      src/fs_base_fallocate_unsupported.icpp
  8. 2
      src/fs_clonefile.cpp

2
src/fallocate.cpp

@ -20,7 +20,7 @@
#include "errno.hpp"
#include "fileinfo.hpp"
#include "fs_fallocate.hpp"
#include "fs_base_fallocate.hpp"
static
int

8
src/fs_fallocate.cpp → src/fs_base_fallocate.cpp

@ -17,11 +17,11 @@
#include <fcntl.h>
#ifdef __linux__
# include "fs_fallocate_linux.icpp"
# include "fs_base_fallocate_linux.icpp"
#elif _XOPEN_SOURCE >= 600 || _POSIX_C_SOURCE >= 200112L
# include "fs_fallocate_posix.icpp"
# include "fs_base_fallocate_posix.icpp"
#elif __APPLE__
# include "fs_fallocate_osx.icpp"
# include "fs_base_fallocate_osx.icpp"
#else
# include "fs_fallocate_unsupported.icpp"
# include "fs_base_fallocate_unsupported.icpp"
#endif

6
src/fs_fallocate.hpp → src/fs_base_fallocate.hpp

@ -14,8 +14,8 @@
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
#ifndef __FS_FALLOCATE_HPP__
#define __FS_FALLOCATE_HPP__
#ifndef __FS_BASE_FALLOCATE_HPP__
#define __FS_BASE_FALLOCATE_HPP__
#include <fcntl.h>
@ -28,4 +28,4 @@ namespace fs
const off_t len);
}
#endif // __FS_FALLOCATE_HPP__
#endif

1
src/fs_fallocate_linux.icpp → src/fs_base_fallocate_linux.icpp

@ -17,7 +17,6 @@
#include <fcntl.h>
#include "errno.hpp"
#include "fs_fallocate.hpp"
namespace fs
{

40
src/fs_fallocate_osx.icpp → src/fs_base_fallocate_osx.icpp

@ -15,34 +15,34 @@
*/
#include <fcntl.h>
#include <unistd.h>
#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
fallocate(const int fd,
const int mode,

1
src/fs_fallocate_posix.icpp → src/fs_base_fallocate_posix.icpp

@ -17,7 +17,6 @@
#include <fcntl.h>
#include "errno.hpp"
#include "fs_fallocate.hpp"
namespace fs
{

1
src/fs_fallocate_unsupported.icpp → src/fs_base_fallocate_unsupported.icpp

@ -15,7 +15,6 @@
*/
#include "errno.hpp"
#include "fs_fallocate.hpp"
namespace fs
{

2
src/fs_clonefile.cpp

@ -25,6 +25,7 @@
#include "fs_base_chmod.hpp"
#include "fs_base_chown.hpp"
#include "fs_base_close.hpp"
#include "fs_base_fallocate.hpp"
#include "fs_base_lseek.hpp"
#include "fs_base_mkdir.hpp"
#include "fs_base_open.hpp"
@ -33,7 +34,6 @@
#include "fs_base_utime.hpp"
#include "fs_base_write.hpp"
#include "fs_fadvise.hpp"
#include "fs_fallocate.hpp"
#include "fs_sendfile.hpp"
#include "fs_xattr.hpp"

Loading…
Cancel
Save