mirror of
https://github.com/trapexit/mergerfs.git
synced 2025-02-21 16:15:26 +08:00
Merge pull request #391 from trapexit/fallocate
restructure fallocate abstraction
This commit is contained in:
commit
581356a0c3
@ -20,7 +20,7 @@
|
||||
|
||||
#include "errno.hpp"
|
||||
#include "fileinfo.hpp"
|
||||
#include "fs_fallocate.hpp"
|
||||
#include "fs_base_fallocate.hpp"
|
||||
|
||||
static
|
||||
int
|
||||
|
@ -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
|
@ -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
|
@ -17,7 +17,6 @@
|
||||
#include <fcntl.h>
|
||||
|
||||
#include "errno.hpp"
|
||||
#include "fs_fallocate.hpp"
|
||||
|
||||
namespace fs
|
||||
{
|
@ -15,34 +15,34 @@
|
||||
*/
|
||||
|
||||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "errno.hpp"
|
||||
#include "fs_fallocate.hpp"
|
||||
|
||||
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};
|
||||
|
||||
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;
|
||||
|
||||
return ::ftruncate(fd,(offset+len));
|
||||
}
|
||||
|
||||
namespace fs
|
||||
{
|
||||
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};
|
||||
|
||||
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;
|
||||
|
||||
return ::ftruncate(fd,(offset+len));
|
||||
}
|
||||
|
||||
int
|
||||
fallocate(const int fd,
|
||||
const int mode,
|
@ -17,7 +17,6 @@
|
||||
#include <fcntl.h>
|
||||
|
||||
#include "errno.hpp"
|
||||
#include "fs_fallocate.hpp"
|
||||
|
||||
namespace fs
|
||||
{
|
@ -15,7 +15,6 @@
|
||||
*/
|
||||
|
||||
#include "errno.hpp"
|
||||
#include "fs_fallocate.hpp"
|
||||
|
||||
namespace fs
|
||||
{
|
@ -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…
x
Reference in New Issue
Block a user