From b0fb5187c46693182f598b92e1a9632cfdde28eb Mon Sep 17 00:00:00 2001 From: Antonio SJ Musumeci Date: Thu, 6 Apr 2017 11:18:03 -0400 Subject: [PATCH] restructure osx fallocate --- src/fs_fallocate_osx.icpp | 40 +++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/src/fs_fallocate_osx.icpp b/src/fs_fallocate_osx.icpp index 6d57f471..c43a0821 100644 --- a/src/fs_fallocate_osx.icpp +++ b/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); } }