diff --git a/src/access.cpp b/src/access.cpp index a613e34d..40e24917 100644 --- a/src/access.cpp +++ b/src/access.cpp @@ -47,7 +47,7 @@ _access(Policy::Func::Search searchFunc, fs::path::make(basepaths[0],fusepath,fullpath); - rv = fs::access(fullpath,mask,AT_EACCESS); + rv = fs::eaccess(fullpath,mask); return ((rv == -1) ? -errno : 0); } diff --git a/src/fs.cpp b/src/fs.cpp index 1a6eb132..31a2a521 100644 --- a/src/fs.cpp +++ b/src/fs.cpp @@ -25,6 +25,7 @@ #include "errno.hpp" #include "fs_attr.hpp" +#include "fs_base_realpath.hpp" #include "fs_base_stat.hpp" #include "fs_base_statvfs.hpp" #include "fs_path.hpp" @@ -154,7 +155,7 @@ namespace fs { fs::path::make(&srcmounts[i],fusepath,fullpath); - rv = ::lstat(fullpath.c_str(),&st); + rv = fs::lstat(fullpath,st); if(FSTAT_FAILED(rv)) continue; @@ -201,7 +202,7 @@ namespace fs for(size_t i = 0; i < strs.size(); i++) { - rv = ::realpath(strs[i].c_str(),NULL); + rv = fs::realpath(strs[i]); if(rv == NULL) continue; diff --git a/src/fs_base_access.hpp b/src/fs_base_access.hpp index 517eafc5..4d6a9fc4 100644 --- a/src/fs_base_access.hpp +++ b/src/fs_base_access.hpp @@ -27,20 +27,29 @@ namespace fs inline int access(const int dirfd, - const std::string &pathname, + const std::string &path, const int mode, const int flags) { - return ::faccessat(dirfd,pathname.c_str(),mode,flags); + return ::faccessat(dirfd,path.c_str(),mode,flags); } static inline int - access(const std::string &pathname, + access(const std::string &path, const int mode, const int flags) { - return fs::access(AT_FDCWD,pathname,mode,flags); + return fs::access(AT_FDCWD,path,mode,flags); + } + + static + inline + int + eaccess(const std::string &path, + const int mode) + { + return fs::access(path,mode,AT_EACCESS); } } diff --git a/src/fs_base_lseek.hpp b/src/fs_base_lseek.hpp new file mode 100644 index 00000000..9ba31f78 --- /dev/null +++ b/src/fs_base_lseek.hpp @@ -0,0 +1,33 @@ +/* + ISC License + + Copyright (c) 2016, Antonio SJ Musumeci + + Permission to use, copy, modify, and/or distribute this software for any + purpose with or without fee is hereby granted, provided that the above + copyright notice and this permission notice appear in all copies. + + THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. +*/ + +#include +#include + +namespace fs +{ + static + inline + off_t + lseek(const int fd, + const off_t offset, + const int whence) + { + return ::lseek(fd,offset,whence); + } +} diff --git a/src/fs_base_read.hpp b/src/fs_base_read.hpp index 1955a267..6e7e5726 100644 --- a/src/fs_base_read.hpp +++ b/src/fs_base_read.hpp @@ -20,6 +20,16 @@ namespace fs { + static + inline + ssize_t + read(const int fd, + void *buf, + const size_t count) + { + return ::read(fd,buf,count); + } + static inline ssize_t diff --git a/src/fs_base_realpath.hpp b/src/fs_base_realpath.hpp new file mode 100644 index 00000000..324c4044 --- /dev/null +++ b/src/fs_base_realpath.hpp @@ -0,0 +1,42 @@ +/* + ISC License + + Copyright (c) 2016, Antonio SJ Musumeci + + Permission to use, copy, modify, and/or distribute this software for any + purpose with or without fee is hereby granted, provided that the above + copyright notice and this permission notice appear in all copies. + + THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. +*/ + +#include + +#include +#include + +namespace fs +{ + static + inline + char * + realpath(const std::string &path, + char *resolved_path) + { + return ::realpath(path.c_str(),resolved_path); + } + + static + inline + char * + realpath(const std::string &path) + { + return fs::realpath(path,NULL); + } +} diff --git a/src/fs_base_write.hpp b/src/fs_base_write.hpp index 69ccc103..617e9683 100644 --- a/src/fs_base_write.hpp +++ b/src/fs_base_write.hpp @@ -20,6 +20,16 @@ namespace fs { + static + inline + ssize_t + write(const int fd, + const void *buf, + const size_t count) + { + return ::write(fd,buf,count); + } + static inline ssize_t diff --git a/src/fs_clonefile.cpp b/src/fs_clonefile.cpp index d1644657..b8bac932 100644 --- a/src/fs_clonefile.cpp +++ b/src/fs_clonefile.cpp @@ -16,20 +16,21 @@ #include #include -#include -#include -#include #include #include #include "errno.hpp" #include "fs_attr.hpp" -#include "fs_base_chown.hpp" #include "fs_base_chmod.hpp" +#include "fs_base_chown.hpp" #include "fs_base_close.hpp" +#include "fs_base_lseek.hpp" #include "fs_base_mkdir.hpp" #include "fs_base_open.hpp" +#include "fs_base_read.hpp" +#include "fs_base_stat.hpp" +#include "fs_base_write.hpp" #include "fs_fadvise.hpp" #include "fs_fallocate.hpp" #include "fs_sendfile.hpp" @@ -52,7 +53,7 @@ namespace fs nleft = count; while(nleft > 0) { - nwritten = ::write(fd,buf,nleft); + nwritten = fs::write(fd,buf,nleft); if(nwritten == -1) { if(errno == EINTR) @@ -83,12 +84,12 @@ namespace fs bufsize = (blocksize * 16); buf.resize(bufsize); - ::lseek(fdin,0,SEEK_SET); + fs::lseek(fdin,0,SEEK_SET); totalwritten = 0; while(totalwritten < count) { - nr = ::read(fdin,&buf[0],bufsize); + nr = fs::read(fdin,&buf[0],bufsize); if(nr == -1) { if(errno == EINTR) @@ -151,7 +152,7 @@ namespace fs int rv; struct stat stin; - rv = ::fstat(fdin,&stin); + rv = fs::fstat(fdin,stin); if(rv == -1) return -1;