diff --git a/src/access.hpp b/src/access.hpp index 6a593fe6..1de24ee4 100644 --- a/src/access.hpp +++ b/src/access.hpp @@ -14,6 +14,9 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ +#ifndef __ACCESS_HPP__ +#define __ACCESS_HPP__ + namespace mergerfs { namespace fuse @@ -23,3 +26,5 @@ namespace mergerfs int mask); } } + +#endif diff --git a/src/assert.hpp b/src/assert.hpp index c9f098c5..20997a30 100644 --- a/src/assert.hpp +++ b/src/assert.hpp @@ -14,6 +14,9 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ +#ifndef __ASSERT_HPP__ +#define __ASSERT_HPP__ + #define STATIC_ASSERT(cond) assert::StaticAssert< (cond) >() #define STATIC_ARRAYLENGTH_ASSERT(array,size) STATIC_ASSERT(((sizeof(array)/sizeof(array[0]))==(size))) @@ -26,3 +29,5 @@ namespace assert struct StaticAssert {}; } + +#endif diff --git a/src/buildmap.hpp b/src/buildmap.hpp index 1cde403b..22293970 100644 --- a/src/buildmap.hpp +++ b/src/buildmap.hpp @@ -14,6 +14,9 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ +#ifndef __BUILDMAP_HPP__ +#define __BUILDMAP_HPP__ + #include template @@ -41,3 +44,5 @@ public: private: std::map _map; }; + +#endif diff --git a/src/buildvector.hpp b/src/buildvector.hpp index 0763345b..50d028fc 100644 --- a/src/buildvector.hpp +++ b/src/buildvector.hpp @@ -14,6 +14,9 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ +#ifndef __BUILDVECTOR_HPP__ +#define __BUILDVECTOR_HPP__ + #include template @@ -41,3 +44,5 @@ public: private: std::vector _vector; }; + +#endif diff --git a/src/chmod.cpp b/src/chmod.cpp index 123f3b60..13280a36 100644 --- a/src/chmod.cpp +++ b/src/chmod.cpp @@ -45,7 +45,7 @@ _chmod_loop_core(const string *basepath, rv = fs::chmod(fullpath,mode); - return calc_error(rv,error,errno); + return error::calc(rv,error,errno); } static diff --git a/src/chmod.hpp b/src/chmod.hpp index e1f2655b..84c920f0 100644 --- a/src/chmod.hpp +++ b/src/chmod.hpp @@ -14,6 +14,9 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ +#ifndef __CHMOD_HPP__ +#define __CHMOD_HPP__ + namespace mergerfs { namespace fuse @@ -23,3 +26,5 @@ namespace mergerfs mode_t mode); } } + +#endif diff --git a/src/chown.cpp b/src/chown.cpp index b0f210e3..2c15ffc1 100644 --- a/src/chown.cpp +++ b/src/chown.cpp @@ -47,7 +47,7 @@ _chown_loop_core(const string *basepath, rv = fs::lchown(fullpath,uid,gid); - return calc_error(rv,error,errno); + return error::calc(rv,error,errno); } static diff --git a/src/chown.hpp b/src/chown.hpp index 368b0515..2bdddf04 100644 --- a/src/chown.hpp +++ b/src/chown.hpp @@ -14,6 +14,9 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ +#ifndef __CHOWN_HPP__ +#define __CHOWN_HPP__ + namespace mergerfs { namespace fuse @@ -24,3 +27,5 @@ namespace mergerfs gid_t gid); } } + +#endif diff --git a/src/create.hpp b/src/create.hpp index 81a3263e..2e509458 100644 --- a/src/create.hpp +++ b/src/create.hpp @@ -14,6 +14,9 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ +#ifndef __CREATE_HPP__ +#define __CREATE_HPP__ + #include #include @@ -28,3 +31,5 @@ namespace mergerfs fuse_file_info *ffi); } } + +#endif diff --git a/src/destroy.hpp b/src/destroy.hpp index aec2ff3f..bd78427c 100644 --- a/src/destroy.hpp +++ b/src/destroy.hpp @@ -14,6 +14,9 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ +#ifndef __DESTROY_HPP__ +#define __DESTROY_HPP__ + namespace mergerfs { namespace fuse @@ -22,3 +25,5 @@ namespace mergerfs destroy(void *); } } + +#endif diff --git a/src/errno.hpp b/src/errno.hpp index fbb245bb..9178b9d4 100644 --- a/src/errno.hpp +++ b/src/errno.hpp @@ -14,6 +14,9 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ +#ifndef __ERRNO_HPP__ +#define __ERRNO_HPP__ + #include #if defined(ENODATA) && !defined(ENOATTR) @@ -27,3 +30,5 @@ #if !defined(ENOATTR) && !defined(ENODATA) #error "Neither ENOATTR or ENODATA defined: please contact mergerfs author with platform information" #endif + +#endif diff --git a/src/fallocate.hpp b/src/fallocate.hpp index c723b8cd..743df140 100644 --- a/src/fallocate.hpp +++ b/src/fallocate.hpp @@ -14,6 +14,9 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ +#ifndef __FALLOCATE_HPP__ +#define __FALLOCATE_HPP__ + namespace mergerfs { namespace fuse @@ -26,3 +29,5 @@ namespace mergerfs fuse_file_info *fi); } } + +#endif diff --git a/src/fgetattr.hpp b/src/fgetattr.hpp index b626dfcf..f50e8463 100644 --- a/src/fgetattr.hpp +++ b/src/fgetattr.hpp @@ -14,6 +14,9 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ +#ifndef __FGETATTR_HPP__ +#define __FGETATTR_HPP__ + #include #include #include @@ -28,3 +31,5 @@ namespace mergerfs fuse_file_info *fileinfo); } } + +#endif diff --git a/src/flock.hpp b/src/flock.hpp index 8105e489..1adaa461 100644 --- a/src/flock.hpp +++ b/src/flock.hpp @@ -14,6 +14,9 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ +#ifndef __FLOCK_HPP__ +#define __FLOCK_HPP__ + namespace mergerfs { namespace fuse @@ -24,3 +27,5 @@ namespace mergerfs int op); } } + +#endif diff --git a/src/flush.hpp b/src/flush.hpp index 825696da..ef284486 100644 --- a/src/flush.hpp +++ b/src/flush.hpp @@ -14,6 +14,9 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ +#ifndef __FLUSH_HPP__ +#define __FLUSH_HPP__ + namespace mergerfs { namespace fuse @@ -23,3 +26,5 @@ namespace mergerfs fuse_file_info *fi); } } + +#endif diff --git a/src/fs.hpp b/src/fs.hpp index cb65c6c0..96db9650 100644 --- a/src/fs.hpp +++ b/src/fs.hpp @@ -17,11 +17,11 @@ #ifndef __FS_HPP__ #define __FS_HPP__ -#include - #include #include +#include + namespace fs { using std::string; diff --git a/src/fs_base_access.hpp b/src/fs_base_access.hpp index 4d6a9fc4..f8b4defd 100644 --- a/src/fs_base_access.hpp +++ b/src/fs_base_access.hpp @@ -16,6 +16,9 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ +#ifndef __FS_BASE_ACCESS_HPP__ +#define __FS_BASE_ACCESS_HPP__ + #include #include @@ -53,3 +56,5 @@ namespace fs return fs::access(path,mode,AT_EACCESS); } } + +#endif diff --git a/src/fs_base_chmod.hpp b/src/fs_base_chmod.hpp index 6ac47887..39692d2f 100644 --- a/src/fs_base_chmod.hpp +++ b/src/fs_base_chmod.hpp @@ -16,6 +16,9 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ +#ifndef __FS_BASE_CHMOD_HPP__ +#define __FS_BASE_CHMOD_HPP__ + #include namespace fs @@ -47,3 +50,5 @@ namespace fs return ::fchmod(fd,st.st_mode); } } + +#endif diff --git a/src/fs_base_chown.hpp b/src/fs_base_chown.hpp index 783226a5..47b01741 100644 --- a/src/fs_base_chown.hpp +++ b/src/fs_base_chown.hpp @@ -16,6 +16,9 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ +#ifndef __FS_BASE_CHOWN_HPP__ +#define __FS_BASE_CHOWN_HPP__ + #include #include @@ -72,3 +75,5 @@ namespace fs return fs::fchown(fd,st.st_uid,st.st_gid); } } + +#endif diff --git a/src/fs_base_close.hpp b/src/fs_base_close.hpp index bb73080b..7a7245a6 100644 --- a/src/fs_base_close.hpp +++ b/src/fs_base_close.hpp @@ -16,6 +16,9 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ +#ifndef __FS_BASE_CLOSE_HPP__ +#define __FS_BASE_CLOSE_HPP__ + #include namespace fs @@ -28,3 +31,5 @@ namespace fs return ::close(fd); } } + +#endif diff --git a/src/fs_base_closedir.hpp b/src/fs_base_closedir.hpp index 9845cc0e..6969c644 100644 --- a/src/fs_base_closedir.hpp +++ b/src/fs_base_closedir.hpp @@ -16,6 +16,9 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ +#ifndef __FS_BASE_CLOSEDIR_HPP__ +#define __FS_BASE_CLOSEDIR_HPP__ + #include #include @@ -29,3 +32,5 @@ namespace fs return ::closedir(dirp); } } + +#endif diff --git a/src/fs_base_dup.hpp b/src/fs_base_dup.hpp index f504a49e..4b5d83c7 100644 --- a/src/fs_base_dup.hpp +++ b/src/fs_base_dup.hpp @@ -16,6 +16,9 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ +#ifndef __FS_BASE_DUP_HPP__ +#define __FS_BASE_DUP_HPP__ + #include namespace fs @@ -28,3 +31,5 @@ namespace fs return ::dup(fd); } } + +#endif diff --git a/src/fs_base_flock.hpp b/src/fs_base_flock.hpp index 31be991d..6fb7a906 100644 --- a/src/fs_base_flock.hpp +++ b/src/fs_base_flock.hpp @@ -16,6 +16,9 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ +#ifndef __FS_BASE_FLOCK_HPP__ +#define __FS_BASE_FLOCK_HPP__ + #include namespace fs @@ -29,3 +32,5 @@ namespace fs return ::flock(fd,operation); } } + +#endif diff --git a/src/fs_base_fsync.hpp b/src/fs_base_fsync.hpp index 61b9a2ad..46c2a27e 100644 --- a/src/fs_base_fsync.hpp +++ b/src/fs_base_fsync.hpp @@ -16,9 +16,13 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -#include +#ifndef __FS_BASE_FSYNC_HPP__ +#define __FS_BASE_FSYNC_HPP__ + #include +#include "errno.hpp" + namespace fs { static @@ -41,3 +45,5 @@ namespace fs #endif } } + +#endif diff --git a/src/fs_base_ftruncate.hpp b/src/fs_base_ftruncate.hpp index a084ebe1..3ab3a72b 100644 --- a/src/fs_base_ftruncate.hpp +++ b/src/fs_base_ftruncate.hpp @@ -16,6 +16,9 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ +#ifndef __FS_BASE_FTRUNCATE_HPP__ +#define __FS_BASE_FTRUNCATE_HPP__ + #include #include @@ -30,3 +33,5 @@ namespace fs return ::ftruncate(fd,size); } } + +#endif diff --git a/src/fs_base_getxattr.hpp b/src/fs_base_getxattr.hpp index efcb0d5c..cc3e26da 100644 --- a/src/fs_base_getxattr.hpp +++ b/src/fs_base_getxattr.hpp @@ -16,6 +16,9 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ +#ifndef __FS_BASE_GETXATTR_HPP__ +#define __FS_BASE_GETXATTR_HPP__ + #include #include "errno.hpp" @@ -38,3 +41,5 @@ namespace fs #endif } } + +#endif diff --git a/src/fs_base_ioctl.hpp b/src/fs_base_ioctl.hpp index 4de7ec38..9de63983 100644 --- a/src/fs_base_ioctl.hpp +++ b/src/fs_base_ioctl.hpp @@ -16,6 +16,9 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ +#ifndef __FS_BASE_IOCTL_HPP__ +#define __FS_BASE_IOCTL_HPP__ + #include namespace fs @@ -30,3 +33,5 @@ namespace fs return ::ioctl(fd,request,data); } } + +#endif diff --git a/src/fs_base_link.hpp b/src/fs_base_link.hpp index 5899cc58..c5fdff36 100644 --- a/src/fs_base_link.hpp +++ b/src/fs_base_link.hpp @@ -16,6 +16,9 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ +#ifndef __FS_BASE_LINK_HPP__ +#define __FS_BASE_LINK_HPP__ + #include #include @@ -31,3 +34,5 @@ namespace fs return ::link(oldpath.c_str(),newpath.c_str()); } } + +#endif diff --git a/src/fs_base_listxattr.hpp b/src/fs_base_listxattr.hpp index 88751892..cbb2bbce 100644 --- a/src/fs_base_listxattr.hpp +++ b/src/fs_base_listxattr.hpp @@ -16,6 +16,9 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ +#ifndef __FS_BASE_LISTXATTR_HPP__ +#define __FS_BASE_LISTXATTR_HPP__ + #include #include "errno.hpp" @@ -37,3 +40,5 @@ namespace fs #endif } } + +#endif diff --git a/src/fs_base_lseek.hpp b/src/fs_base_lseek.hpp index 9ba31f78..eee9f152 100644 --- a/src/fs_base_lseek.hpp +++ b/src/fs_base_lseek.hpp @@ -16,6 +16,9 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ +#ifndef __FS_BASE_LSEEK_HPP__ +#define __FS_BASE_LSEEK_HPP__ + #include #include @@ -31,3 +34,5 @@ namespace fs return ::lseek(fd,offset,whence); } } + +#endif diff --git a/src/fs_base_mkdir.hpp b/src/fs_base_mkdir.hpp index 34ca9ae9..e3794520 100644 --- a/src/fs_base_mkdir.hpp +++ b/src/fs_base_mkdir.hpp @@ -16,6 +16,9 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ +#ifndef __FS_BASE_MKDIR_HPP__ +#define __FS_BASE_MKDIR_HPP__ + #include #include @@ -32,3 +35,5 @@ namespace fs return ::mkdir(path.c_str(),mode); } } + +#endif diff --git a/src/fs_base_mknod.hpp b/src/fs_base_mknod.hpp index 0a6fb5d0..f39506aa 100644 --- a/src/fs_base_mknod.hpp +++ b/src/fs_base_mknod.hpp @@ -16,6 +16,9 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ +#ifndef __FS_BASE_MKNOD_HPP__ +#define __FS_BASE_MKNOD_HPP__ + #include #include #include @@ -33,3 +36,5 @@ namespace fs return ::mknod(path.c_str(),mode,dev); } } + +#endif diff --git a/src/fs_base_open.hpp b/src/fs_base_open.hpp index b32c5fdc..38ffd56c 100644 --- a/src/fs_base_open.hpp +++ b/src/fs_base_open.hpp @@ -16,6 +16,9 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ +#ifndef __FS_BASE_OPEN_HPP__ +#define __FS_BASE_OPEN_HPP__ + #include #include @@ -43,3 +46,5 @@ namespace fs return ::open(path.c_str(),flags,mode); } } + +#endif diff --git a/src/fs_base_opendir.hpp b/src/fs_base_opendir.hpp index 3124fe81..96dd735e 100644 --- a/src/fs_base_opendir.hpp +++ b/src/fs_base_opendir.hpp @@ -16,6 +16,9 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ +#ifndef __FS_BASE_OPENDIR_HPP__ +#define __FS_BASE_OPENDIR_HPP__ + #include #include @@ -31,3 +34,5 @@ namespace fs return ::opendir(name.c_str()); } } + +#endif diff --git a/src/fs_base_read.hpp b/src/fs_base_read.hpp index 6e7e5726..5b7f3df0 100644 --- a/src/fs_base_read.hpp +++ b/src/fs_base_read.hpp @@ -16,6 +16,9 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ +#ifndef __FS_BASE_READ_HPP__ +#define __FS_BASE_READ_HPP__ + #include namespace fs @@ -41,3 +44,5 @@ namespace fs return ::pread(fd,buf,count,offset); } } + +#endif diff --git a/src/fs_base_readdir.hpp b/src/fs_base_readdir.hpp index c0163af4..1fa956fa 100644 --- a/src/fs_base_readdir.hpp +++ b/src/fs_base_readdir.hpp @@ -16,6 +16,9 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ +#ifndef __FS_BASE_READDIR_HPP__ +#define __FS_BASE_READDIR_HPP__ + #include namespace fs @@ -28,3 +31,5 @@ namespace fs return ::readdir(dirp); } } + +#endif diff --git a/src/fs_base_readlink.hpp b/src/fs_base_readlink.hpp index f2291cca..efe7fa47 100644 --- a/src/fs_base_readlink.hpp +++ b/src/fs_base_readlink.hpp @@ -16,6 +16,9 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ +#ifndef __FS_BASE_READLINK_HPP__ +#define __FS_BASE_READLINK_HPP__ + #include #include @@ -32,3 +35,5 @@ namespace fs return ::readlink(path.c_str(),buf,bufsiz); } } + +#endif diff --git a/src/fs_base_realpath.hpp b/src/fs_base_realpath.hpp index 324c4044..0a51e055 100644 --- a/src/fs_base_realpath.hpp +++ b/src/fs_base_realpath.hpp @@ -16,6 +16,9 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ +#ifndef __FS_BASE_REALPATH_HPP__ +#define __FS_BASE_REALPATH_HPP__ + #include #include @@ -40,3 +43,5 @@ namespace fs return fs::realpath(path,NULL); } } + +#endif diff --git a/src/clone.hpp b/src/fs_base_remove.hpp similarity index 76% rename from src/clone.hpp rename to src/fs_base_remove.hpp index ec558fd5..3109d2a7 100644 --- a/src/clone.hpp +++ b/src/fs_base_remove.hpp @@ -1,4 +1,6 @@ /* + ISC License + Copyright (c) 2016, Antonio SJ Musumeci Permission to use, copy, modify, and/or distribute this software for any @@ -14,9 +16,22 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -namespace clonetool +#ifndef __FS_BASE_REMOVE_HPP__ +#define __FS_BASE_REMOVE_HPP__ + +#include + +#include + +namespace fs { + static + inline int - main(const int argc, - char * const *argv); + remove(const std::string &pathname) + { + return ::remove(pathname.c_str()); + } } + +#endif diff --git a/src/fs_base_removexattr.hpp b/src/fs_base_removexattr.hpp index b5105cf9..71b9c27a 100644 --- a/src/fs_base_removexattr.hpp +++ b/src/fs_base_removexattr.hpp @@ -16,6 +16,9 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ +#ifndef __FS_BASE_REMOVEXATTR_HPP__ +#define __FS_BASE_REMOVEXATTR_HPP__ + #include #include "errno.hpp" @@ -36,3 +39,5 @@ namespace fs #endif } } + +#endif diff --git a/src/fs_base_rename.hpp b/src/fs_base_rename.hpp index 5e968242..c1f59cad 100644 --- a/src/fs_base_rename.hpp +++ b/src/fs_base_rename.hpp @@ -16,6 +16,9 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ +#ifndef __FS_BASE_RENAME_HPP__ +#define __FS_BASE_RENAME_HPP__ + #include namespace fs @@ -29,3 +32,5 @@ namespace fs return ::rename(oldpath.c_str(),newpath.c_str()); } } + +#endif diff --git a/src/fs_base_rmdir.hpp b/src/fs_base_rmdir.hpp index 918750ff..64b0ba27 100644 --- a/src/fs_base_rmdir.hpp +++ b/src/fs_base_rmdir.hpp @@ -16,6 +16,9 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ +#ifndef __FS_BASE_RMDIR_HPP__ +#define __FS_BASE_RMDIR_HPP__ + #include #include @@ -30,3 +33,5 @@ namespace fs return ::rmdir(path.c_str()); } } + +#endif diff --git a/src/fs_base_setxattr.hpp b/src/fs_base_setxattr.hpp index 52d872ba..db7851e4 100644 --- a/src/fs_base_setxattr.hpp +++ b/src/fs_base_setxattr.hpp @@ -16,6 +16,9 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ +#ifndef __FS_BASE_SETXATTR_HPP__ +#define __FS_BASE_SETXATTR_HPP__ + #include #include "errno.hpp" @@ -39,3 +42,5 @@ namespace fs #endif } } + +#endif diff --git a/src/fs_base_stat.hpp b/src/fs_base_stat.hpp index d1e7a517..e67d5267 100644 --- a/src/fs_base_stat.hpp +++ b/src/fs_base_stat.hpp @@ -16,6 +16,9 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ +#ifndef __FS_BASE_STAT_HPP__ +#define __FS_BASE_STAT_HPP__ + #include #include @@ -60,3 +63,5 @@ namespace fs return ::fstat(fd,&st); } } + +#endif diff --git a/src/fs_base_statvfs.hpp b/src/fs_base_statvfs.hpp index 2b3e6d4c..253e4144 100644 --- a/src/fs_base_statvfs.hpp +++ b/src/fs_base_statvfs.hpp @@ -16,6 +16,9 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ +#ifndef __FS_BASE_STATVFS_HPP__ +#define __FS_BASE_STATVFS_HPP__ + #include #include @@ -40,3 +43,5 @@ namespace fs return fs::statvfs(path.c_str(),st); } } + +#endif diff --git a/src/clone.cpp b/src/fs_base_symlink.hpp similarity index 50% rename from src/clone.cpp rename to src/fs_base_symlink.hpp index d10a1e8a..df9e3d77 100644 --- a/src/clone.cpp +++ b/src/fs_base_symlink.hpp @@ -1,4 +1,6 @@ /* + ISC License + Copyright (c) 2016, Antonio SJ Musumeci Permission to use, copy, modify, and/or distribute this software for any @@ -14,48 +16,32 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -#include -#include +#ifndef __FS_BASE_SYMLINK_HPP__ +#define __FS_BASE_SYMLINK_HPP__ -#include +#include -#include "errno.hpp" -#include "fs.hpp" -#include "fs_clonefile.hpp" -#include "fs_clonepath.hpp" +#include -namespace clonetool +namespace fs { static - void - print_usage_and__exit(void) + inline + int + symlink(const std::string &oldpath, + const std::string &newpath) { - std::cerr << "usage: clone " - << "[path ]" - << " | " - << "[file ]" - << std::endl; - _exit(1); + return ::symlink(oldpath.c_str(),newpath.c_str()); } + static + inline int - main(const int argc, - char * const argv[]) + symlink(const char *oldpath, + const std::string &newpath) { - int rv = 0; - - if(argc == 4 && !strcmp(argv[1],"file")) - rv = fs::clonefile(argv[2],argv[3]); - else if(argc == 5 && !strcmp(argv[1],"path")) - rv = fs::clonepath(argv[2],argv[3],argv[4]); - else - print_usage_and__exit(); - - if(rv == -1) - std::cerr << "error: " - << strerror(errno) - << std::endl; - - return 0; + return ::symlink(oldpath,newpath.c_str()); } } + +#endif diff --git a/src/fs_base_truncate.hpp b/src/fs_base_truncate.hpp index 350ce7fe..8adb963d 100644 --- a/src/fs_base_truncate.hpp +++ b/src/fs_base_truncate.hpp @@ -16,6 +16,9 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ +#ifndef __FS_BASE_TRUNCATE_HPP__ +#define __FS_BASE_TRUNCATE_HPP__ + #include #include @@ -32,3 +35,5 @@ namespace fs return ::truncate(path.c_str(),length); } } + +#endif diff --git a/src/fs_base_unlink.hpp b/src/fs_base_unlink.hpp index 6e6627e4..c1be8b46 100644 --- a/src/fs_base_unlink.hpp +++ b/src/fs_base_unlink.hpp @@ -16,6 +16,9 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ +#ifndef __FS_BASE_UNLINK_HPP__ +#define __FS_BASE_UNLINK_HPP__ + #include #include @@ -30,3 +33,5 @@ namespace fs return ::unlink(path.c_str()); } } + +#endif diff --git a/src/fs_base_utime.hpp b/src/fs_base_utime.hpp index f2d5d5d3..ae1b1afe 100644 --- a/src/fs_base_utime.hpp +++ b/src/fs_base_utime.hpp @@ -14,6 +14,9 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ +#ifndef __FS_BASE_UTIME_HPP__ +#define __FS_BASE_UTIME_HPP__ + #ifdef __linux__ # include "fs_base_utime_utimensat.hpp" #elif __FreeBSD__ >= 11 @@ -61,3 +64,5 @@ namespace fs return fs::utime(AT_FDCWD,path,times,AT_SYMLINK_NOFOLLOW); } } + +#endif diff --git a/src/fs_base_utime_generic.hpp b/src/fs_base_utime_generic.hpp index 99647784..eeea26ad 100644 --- a/src/fs_base_utime_generic.hpp +++ b/src/fs_base_utime_generic.hpp @@ -16,6 +16,9 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ +#ifndef __FS_BASE_UTIME_GENERIC_HPP__ +#define __FS_BASE_UTIME_GENERIC_HPP__ + #include #include @@ -296,3 +299,5 @@ namespace fs return ::futimes(fd,tvp); } } + +#endif diff --git a/src/fs_base_utime_utimensat.hpp b/src/fs_base_utime_utimensat.hpp index f3ab6e1d..c9aafec0 100644 --- a/src/fs_base_utime_utimensat.hpp +++ b/src/fs_base_utime_utimensat.hpp @@ -16,6 +16,9 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ +#ifndef __FS_BASE_UTIME_UTIMENSAT_HPP__ +#define __FS_BASE_UTIME_UTIMENSAT_HPP__ + #include #include @@ -43,3 +46,5 @@ namespace fs return ::futimens(fd,times); } } + +#endif diff --git a/src/fs_base_write.hpp b/src/fs_base_write.hpp index 617e9683..a113b6b1 100644 --- a/src/fs_base_write.hpp +++ b/src/fs_base_write.hpp @@ -16,6 +16,9 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ +#ifndef __FS_BASE_WRITE_HPP__ +#define __FS_BASE_WRITE_HPP__ + #include namespace fs @@ -41,3 +44,5 @@ namespace fs return ::pwrite(fd,buf,count,offset); } } + +#endif diff --git a/src/fs_clonefile.hpp b/src/fs_clonefile.hpp index 2f5424d1..f0400581 100644 --- a/src/fs_clonefile.hpp +++ b/src/fs_clonefile.hpp @@ -14,6 +14,9 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ +#ifndef __FS_CLONEFILE_HPP__ +#define __FS_CLONEFILE_HPP__ + #include namespace fs @@ -23,3 +26,5 @@ namespace fs int clonefile(const std::string &from, const std::string &to); } + +#endif diff --git a/src/fs_clonepath.cpp b/src/fs_clonepath.cpp index 68e5396d..c81e6432 100644 --- a/src/fs_clonepath.cpp +++ b/src/fs_clonepath.cpp @@ -23,6 +23,7 @@ #include "fs_base_mkdir.hpp" #include "fs_base_stat.hpp" #include "fs_base_utime.hpp" +#include "fs_clonepath.hpp" #include "fs_path.hpp" #include "fs_xattr.hpp" @@ -62,7 +63,7 @@ namespace fs fs::path::dirname(dirname); if(!dirname.empty()) { - rv = fs::clonepath(fromsrc,tosrc,dirname.c_str()); + rv = fs::clonepath(fromsrc,tosrc,dirname); if(rv == -1) return -1; } @@ -105,4 +106,12 @@ namespace fs return 0; } + + int + clonepath(const std::string &from, + const std::string &to, + const std::string &relative) + { + return fs::clonepath(from,to,relative.c_str()); + } } diff --git a/src/fs_clonepath.hpp b/src/fs_clonepath.hpp index 007277f9..a3fd335e 100644 --- a/src/fs_clonepath.hpp +++ b/src/fs_clonepath.hpp @@ -14,6 +14,9 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ +#ifndef __FS_CLONEPATH_HPP__ +#define __FS_CLONEPATH_HPP__ + #include namespace fs @@ -21,4 +24,9 @@ namespace fs int clonepath(const std::string &from, const std::string &to, const char *relative); + int clonepath(const std::string &from, + const std::string &to, + const std::string &relative); } + +#endif diff --git a/src/fs_devid.hpp b/src/fs_devid.hpp index 961f040e..2ed8547b 100644 --- a/src/fs_devid.hpp +++ b/src/fs_devid.hpp @@ -42,4 +42,3 @@ namespace fs } #endif - diff --git a/src/fs_movefile.cpp b/src/fs_movefile.cpp index 045295d7..1ca1fa54 100644 --- a/src/fs_movefile.cpp +++ b/src/fs_movefile.cpp @@ -72,7 +72,7 @@ namespace fs fusedir = fusepath; fs::path::dirname(fusedir); - rv = fs::clonepath(fdin_path,fdout_path,fusedir.c_str()); + rv = fs::clonepath(fdin_path,fdout_path,fusedir); if(rv == -1) return -1; @@ -91,7 +91,7 @@ namespace fs { fs::close(fdin); fs::close(fdout); - fs::unlink(fdout_path.c_str()); + fs::unlink(fdout_path); return -1; } diff --git a/src/fsync.hpp b/src/fsync.hpp index a67b0285..00bec8d1 100644 --- a/src/fsync.hpp +++ b/src/fsync.hpp @@ -14,6 +14,9 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ +#ifndef __FSYNC_HPP__ +#define __FSYNC_HPP__ + #include namespace mergerfs @@ -26,3 +29,5 @@ namespace mergerfs fuse_file_info *fi); } } + +#endif diff --git a/src/ftruncate.hpp b/src/ftruncate.hpp index e7a7db84..1f0f6d9c 100644 --- a/src/ftruncate.hpp +++ b/src/ftruncate.hpp @@ -14,6 +14,9 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ +#ifndef __FTRUNCATE_HPP__ +#define __FTRUNCATE_HPP__ + #include #include @@ -29,3 +32,5 @@ namespace mergerfs fuse_file_info *fi); } } + +#endif diff --git a/src/getattr.hpp b/src/getattr.hpp index f0402143..c499f0cf 100644 --- a/src/getattr.hpp +++ b/src/getattr.hpp @@ -14,6 +14,9 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ +#ifndef __GETATTR_HPP__ +#define __GETATTR_HPP__ + #include #include #include @@ -27,3 +30,5 @@ namespace mergerfs struct stat *buf); } } + +#endif diff --git a/src/getxattr.hpp b/src/getxattr.hpp index 3a6a10a5..aefbf37e 100644 --- a/src/getxattr.hpp +++ b/src/getxattr.hpp @@ -14,6 +14,9 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ +#ifndef __GETXATTR_HPP__ +#define __GETXATTR_HPP__ + namespace mergerfs { namespace fuse @@ -25,3 +28,5 @@ namespace mergerfs size_t count); } } + +#endif diff --git a/src/init.hpp b/src/init.hpp index 1787f56c..17b3ad8a 100644 --- a/src/init.hpp +++ b/src/init.hpp @@ -14,6 +14,9 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ +#ifndef __INIT_HPP__ +#define __INIT_HPP__ + namespace mergerfs { namespace fuse @@ -22,3 +25,5 @@ namespace mergerfs init(fuse_conn_info *conn); } } + +#endif diff --git a/src/ioctl.hpp b/src/ioctl.hpp index 5545e053..53c8af3c 100644 --- a/src/ioctl.hpp +++ b/src/ioctl.hpp @@ -14,6 +14,9 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ +#ifndef __IOCTL_HPP__ +#define __IOCTL_HPP__ + namespace mergerfs { namespace fuse @@ -27,3 +30,5 @@ namespace mergerfs void *data); } } + +#endif diff --git a/src/link.cpp b/src/link.cpp index bae5232e..c48a25b1 100644 --- a/src/link.cpp +++ b/src/link.cpp @@ -49,7 +49,7 @@ _link_create_path_core(const string &oldbasepath, if(oldbasepath != newbasepath) { const ugid::SetRootGuard ugidGuard; - rv = fs::clonepath(newbasepath,oldbasepath,newfusedirpath.c_str()); + rv = fs::clonepath(newbasepath,oldbasepath,newfusedirpath); if(rv == -1) return errno; } @@ -59,7 +59,7 @@ _link_create_path_core(const string &oldbasepath, rv = fs::link(oldfullpath,newfullpath); - return calc_error(rv,error,errno); + return error::calc(rv,error,errno); } static @@ -176,7 +176,7 @@ _link_preserve_path_core(Policy::Func::Search searchFunc, rv = fs::link(oldfullpath,newfullpath); } - return calc_error(rv,error,errno); + return error::calc(rv,error,errno); } static diff --git a/src/link.hpp b/src/link.hpp index 3767bb79..829a0ca3 100644 --- a/src/link.hpp +++ b/src/link.hpp @@ -14,6 +14,9 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ +#ifndef __LINK_HPP__ +#define __LINK_HPP__ + namespace mergerfs { namespace fuse @@ -23,3 +26,5 @@ namespace mergerfs const char *to); } } + +#endif diff --git a/src/listxattr.hpp b/src/listxattr.hpp index 825399cf..ca540769 100644 --- a/src/listxattr.hpp +++ b/src/listxattr.hpp @@ -14,6 +14,9 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ +#ifndef __LISTXATTR_HPP__ +#define __LISTXATTR_HPP__ + namespace mergerfs { namespace fuse @@ -24,3 +27,5 @@ namespace mergerfs size_t count); } } + +#endif diff --git a/src/mergerfs.cpp b/src/mergerfs.cpp index d4c40d85..5b65b732 100644 --- a/src/mergerfs.cpp +++ b/src/mergerfs.cpp @@ -20,12 +20,10 @@ #include #include +#include "fs_path.hpp" #include "mergerfs.hpp" #include "option_parser.hpp" #include "resources.hpp" -#include "fs_path.hpp" - -#include "clone.hpp" #include "access.hpp" #include "chmod.hpp" @@ -68,14 +66,6 @@ namespace local { - static - std::string - getappname(const int argc, - char * const *argv) - { - return fs::path::basename(argv[0]); - } - static void get_fuse_operations(struct fuse_operations &ops, @@ -190,11 +180,5 @@ int main(int argc, char **argv) { - std::string appname; - - appname = local::getappname(argc,argv); - if(appname == "clone") - return clonetool::main(argc,argv); - return mergerfs::main(argc,argv); } diff --git a/src/mkdir.cpp b/src/mkdir.cpp index 819da15d..c054b321 100644 --- a/src/mkdir.cpp +++ b/src/mkdir.cpp @@ -71,7 +71,7 @@ _mkdir_loop_core(const string &existingpath, rv = _mkdir_core(fullpath,mode,umask); - return calc_error(rv,error,errno); + return error::calc(rv,error,errno); } static diff --git a/src/mkdir.hpp b/src/mkdir.hpp index ddbd7d5b..4e85b54e 100644 --- a/src/mkdir.hpp +++ b/src/mkdir.hpp @@ -14,6 +14,9 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ +#ifndef __MKDIR_HPP__ +#define __MKDIR_HPP__ + namespace mergerfs { namespace fuse @@ -23,3 +26,5 @@ namespace mergerfs mode_t mode); } } + +#endif diff --git a/src/mknod.cpp b/src/mknod.cpp index db14e980..b5033c1f 100644 --- a/src/mknod.cpp +++ b/src/mknod.cpp @@ -73,7 +73,7 @@ _mknod_loop_core(const string &existingpath, rv = _mknod_core(fullpath,mode,umask,dev); - return calc_error(rv,error,errno); + return error::calc(rv,error,errno); } static diff --git a/src/mknod.hpp b/src/mknod.hpp index ffb5e23c..aa3ec348 100644 --- a/src/mknod.hpp +++ b/src/mknod.hpp @@ -1,3 +1,4 @@ + /* Copyright (c) 2016, Antonio SJ Musumeci @@ -14,6 +15,9 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ +#ifndef __MKNOD_HPP__ +#define __MKNOD_HPP__ + namespace mergerfs { namespace fuse @@ -24,3 +28,5 @@ namespace mergerfs dev_t rdev); } } + +#endif diff --git a/src/num.hpp b/src/num.hpp index a2db43cc..2724d5e3 100644 --- a/src/num.hpp +++ b/src/num.hpp @@ -14,11 +14,16 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -#include +#ifndef __NUM_HPP__ +#define __NUM_HPP__ #include +#include + namespace num { int to_uint64_t(const std::string &str, uint64_t &value); } + +#endif diff --git a/src/open.hpp b/src/open.hpp index 95356a2c..4435aab8 100644 --- a/src/open.hpp +++ b/src/open.hpp @@ -14,6 +14,9 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ +#ifndef __OPEN_HPP__ +#define __OPEN_HPP__ + #include namespace mergerfs @@ -25,3 +28,5 @@ namespace mergerfs fuse_file_info *ffi); } } + +#endif diff --git a/src/opendir.hpp b/src/opendir.hpp index ac68337a..c77fc239 100644 --- a/src/opendir.hpp +++ b/src/opendir.hpp @@ -14,6 +14,9 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ +#ifndef __OPENDIR_HPP__ +#define __OPENDIR_HPP__ + #include namespace mergerfs @@ -25,3 +28,5 @@ namespace mergerfs fuse_file_info *ffi); } } + +#endif diff --git a/src/option_parser.hpp b/src/option_parser.hpp index c53e7168..2e8ca6af 100644 --- a/src/option_parser.hpp +++ b/src/option_parser.hpp @@ -14,6 +14,9 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ +#ifndef __OPTION_PARSER_HPP__ +#define __OPTION_PARSER_HPP__ + #include #include "config.hpp" @@ -27,3 +30,5 @@ namespace mergerfs Config &config); } } + +#endif diff --git a/src/read.hpp b/src/read.hpp index 1ce57ae2..0c106757 100644 --- a/src/read.hpp +++ b/src/read.hpp @@ -14,6 +14,9 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ +#ifndef __READ_HPP__ +#define __READ_HPP__ + namespace mergerfs { namespace fuse @@ -33,3 +36,5 @@ namespace mergerfs fuse_file_info *fi); } } + +#endif diff --git a/src/readdir.hpp b/src/readdir.hpp index a5bcdbae..ae523ddc 100644 --- a/src/readdir.hpp +++ b/src/readdir.hpp @@ -14,14 +14,14 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -#ifndef __MERGERFS_READDIR_HPP__ -#define __MERGERFS_READDIR_HPP__ - -#include +#ifndef __READDIR_HPP__ +#define __READDIR_HPP__ #include #include +#include + #include #include #include diff --git a/src/readlink.hpp b/src/readlink.hpp index a3420137..6aab4f41 100644 --- a/src/readlink.hpp +++ b/src/readlink.hpp @@ -14,6 +14,9 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ +#ifndef __READLINK_HPP__ +#define __READLINK_HPP__ + namespace mergerfs { namespace fuse @@ -24,3 +27,5 @@ namespace mergerfs size_t size); } } + +#endif diff --git a/src/release.hpp b/src/release.hpp index bb1e058d..890ca57b 100644 --- a/src/release.hpp +++ b/src/release.hpp @@ -14,6 +14,9 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ +#ifndef __RELEASE_HPP__ +#define __RELEASE_HPP__ + namespace mergerfs { namespace fuse @@ -23,3 +26,5 @@ namespace mergerfs fuse_file_info *fi); } } + +#endif diff --git a/src/releasedir.hpp b/src/releasedir.hpp index d08b88c8..0b5fd0b8 100644 --- a/src/releasedir.hpp +++ b/src/releasedir.hpp @@ -14,6 +14,9 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ +#ifndef __RELEASEDIR_HPP__ +#define __RELEASEDIR_HPP__ + #include namespace mergerfs @@ -25,3 +28,5 @@ namespace mergerfs fuse_file_info *ffi); } } + +#endif diff --git a/src/removexattr.cpp b/src/removexattr.cpp index f7398615..2bd47d36 100644 --- a/src/removexattr.cpp +++ b/src/removexattr.cpp @@ -45,7 +45,7 @@ _removexattr_loop_core(const string *basepath, rv = fs::lremovexattr(fullpath,attrname); - return calc_error(rv,error,errno); + return error::calc(rv,error,errno); } static diff --git a/src/removexattr.hpp b/src/removexattr.hpp index 1c963228..90816bed 100644 --- a/src/removexattr.hpp +++ b/src/removexattr.hpp @@ -14,6 +14,9 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ +#ifndef __REMOVEXATTR_HPP__ +#define __REMOVEXATTR_HPP__ + namespace mergerfs { namespace fuse @@ -23,3 +26,5 @@ namespace mergerfs const char *attrname); } } + +#endif diff --git a/src/rename.cpp b/src/rename.cpp index 41cc3c0e..2d4811c5 100644 --- a/src/rename.cpp +++ b/src/rename.cpp @@ -21,6 +21,7 @@ #include "config.hpp" #include "errno.hpp" +#include "fs_base_remove.hpp" #include "fs_base_rename.hpp" #include "fs_clonepath.hpp" #include "fs_path.hpp" @@ -32,7 +33,6 @@ using std::string; using std::vector; using std::set; -using mergerfs::Policy; using namespace mergerfs; static @@ -54,7 +54,7 @@ void _remove(const vector &toremove) { for(size_t i = 0, ei = toremove.size(); i != ei; i++) - ::remove(toremove[i].c_str()); + fs::remove(toremove[i]); } static @@ -70,7 +70,7 @@ _rename(const std::string &oldbasepath, if(oldbasepath != newbasepath) { const ugid::SetRootGuard guard; - rv = fs::clonepath(newbasepath,oldbasepath,newfusedirpath.c_str()); + rv = fs::clonepath(newbasepath,oldbasepath,newfusedirpath); if(rv == -1) return -1; } @@ -103,7 +103,7 @@ _rename_create_path_core(const vector &oldbasepaths, rv = _rename(oldbasepath,oldfullpath, newbasepath,newfusedirpath,newfullpath); - error = calc_error(rv,error,errno); + error = error::calc(rv,error,errno); if(RENAME_FAILED(rv)) tounlink.push_back(oldfullpath); } @@ -173,7 +173,7 @@ _clonepath(Policy::Func::Search searchFunc, { const ugid::SetRootGuard ugidGuard; - fs::clonepath(*srcbasepath[0],dstbasepath,fusedirpath.c_str()); + fs::clonepath(*srcbasepath[0],dstbasepath,fusedirpath); } return POLICY_SUCCESS; @@ -241,7 +241,7 @@ _rename_preserve_path_core(Policy::Func::Search searchFunc, rv = fs::rename(oldfullpath,newfullpath); } - error = calc_error(rv,error,errno); + error = error::calc(rv,error,errno); if(RENAME_FAILED(rv)) toremove.push_back(oldfullpath); } diff --git a/src/rename.hpp b/src/rename.hpp index c4b5c1c5..c1a798da 100644 --- a/src/rename.hpp +++ b/src/rename.hpp @@ -14,6 +14,9 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ +#ifndef __RENAME_HPP__ +#define __RENAME_HPP__ + namespace mergerfs { namespace fuse @@ -23,3 +26,5 @@ namespace mergerfs const char *to); } } + +#endif diff --git a/src/resources.hpp b/src/resources.hpp index 96187bd3..f04677d7 100644 --- a/src/resources.hpp +++ b/src/resources.hpp @@ -14,6 +14,9 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ +#ifndef __RESOURCES_HPP__ +#define __RESOURCES_HPP__ + namespace mergerfs { namespace resources @@ -25,3 +28,5 @@ namespace mergerfs int setpriority(const int prio); } } + +#endif diff --git a/src/rmdir.cpp b/src/rmdir.cpp index 4c804379..d64bf633 100644 --- a/src/rmdir.cpp +++ b/src/rmdir.cpp @@ -45,7 +45,7 @@ _rmdir_loop_core(const string *basepath, rv = fs::rmdir(fullpath); - return calc_error(rv,error,errno); + return error::calc(rv,error,errno); } diff --git a/src/rmdir.hpp b/src/rmdir.hpp index 37798631..43a802a2 100644 --- a/src/rmdir.hpp +++ b/src/rmdir.hpp @@ -14,6 +14,9 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ +#ifndef __RMDIR_HPP__ +#define __RMDIR_HPP__ + namespace mergerfs { namespace fuse @@ -22,3 +25,5 @@ namespace mergerfs rmdir(const char *fusepath); } } + +#endif diff --git a/src/rv.hpp b/src/rv.hpp index ca48e768..b2ec9243 100644 --- a/src/rv.hpp +++ b/src/rv.hpp @@ -17,21 +17,24 @@ #ifndef __RV_HPP__ #define __RV_HPP__ -static -inline -int -calc_error(const int rv, - const int prev, - const int cur) +namespace error { - if(rv == -1) - { - if(prev == 0) - return 0; - return cur; - } + static + inline + int + calc(const int rv, + const int prev, + const int cur) + { + if(rv == -1) + { + if(prev == 0) + return 0; + return cur; + } - return 0; + return 0; + } } #endif // __RV_HPP__ diff --git a/src/rwlock.hpp b/src/rwlock.hpp index 4a882fa3..7684720e 100644 --- a/src/rwlock.hpp +++ b/src/rwlock.hpp @@ -14,6 +14,9 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ +#ifndef __RWLOCK_HPP__ +#define __RWLOCK_HPP__ + #include namespace mergerfs @@ -63,3 +66,5 @@ namespace mergerfs }; } } + +#endif diff --git a/src/setxattr.cpp b/src/setxattr.cpp index 92444750..1b7b8a56 100644 --- a/src/setxattr.cpp +++ b/src/setxattr.cpp @@ -303,7 +303,7 @@ _setxattr_loop_core(const string *basepath, rv = fs::lsetxattr(fullpath,attrname,attrval,attrvalsize,flags); - return calc_error(rv,error,errno); + return error::calc(rv,error,errno); } static diff --git a/src/setxattr.hpp b/src/setxattr.hpp index 9e91e6a1..a05e382a 100644 --- a/src/setxattr.hpp +++ b/src/setxattr.hpp @@ -14,6 +14,9 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ +#ifndef __SETXATTR_HPP__ +#define __SETXATTR_HPP__ + namespace mergerfs { namespace fuse @@ -26,3 +29,5 @@ namespace mergerfs int flags); } } + +#endif diff --git a/src/statfs.hpp b/src/statfs.hpp index 7d3eb105..6e94be90 100644 --- a/src/statfs.hpp +++ b/src/statfs.hpp @@ -14,6 +14,9 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ +#ifndef __STATFS_HPP__ +#define __STATFS_HPP__ + namespace mergerfs { namespace fuse @@ -23,3 +26,5 @@ namespace mergerfs struct statvfs *fsstat); } } + +#endif diff --git a/src/statvfs_util.hpp b/src/statvfs_util.hpp index 5f7e9d01..2011e322 100644 --- a/src/statvfs_util.hpp +++ b/src/statvfs_util.hpp @@ -14,6 +14,9 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ +#ifndef __STATVFS_UTIL_HPP__ +#define __STATVFS_UTIL_HPP__ + #include #include @@ -46,3 +49,5 @@ namespace StatVFS return (st.f_frsize * (st.f_blocks - st.f_bavail)); } } + +#endif diff --git a/src/str.hpp b/src/str.hpp index 92dca191..0369fb7a 100644 --- a/src/str.hpp +++ b/src/str.hpp @@ -14,6 +14,9 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ +#ifndef __STR_HPP__ +#define __STR_HPP__ + #include #include @@ -55,3 +58,5 @@ namespace str isprefix(const std::string &s0, const std::string &s1); } + +#endif diff --git a/src/success_fail.hpp b/src/success_fail.hpp index 3c0ce172..8a73ea91 100644 --- a/src/success_fail.hpp +++ b/src/success_fail.hpp @@ -14,7 +14,8 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -#ifndef __MERGERFS_SUCCESS_FAIL_HPP__ +#ifndef __SUCCESS_FAIL_HPP__ +#define __SUCCESS_FAIL_HPP__ #define STATVFS_SUCCESS 0 #define STATVFS_SUCCEEDED(RV) ((RV) == STATVFS_SUCCESS) @@ -42,4 +43,4 @@ #define RENAME_FAILED(RV) ((RV) == RENAME_FAIL) #define RENAME_FAILED_WITH(RV,ERRNO) (((RV) == RENAME_FAIL) && (errno == ERRNO)) -#endif /*__MERGERFS_SUCCESS_FAIL_HPP__ */ +#endif diff --git a/src/symlink.cpp b/src/symlink.cpp index 8ec2a5b9..5c1434f3 100644 --- a/src/symlink.cpp +++ b/src/symlink.cpp @@ -23,6 +23,7 @@ #include "config.hpp" #include "errno.hpp" +#include "fs_base_symlink.hpp" #include "fs_clonepath.hpp" #include "fs_path.hpp" #include "rv.hpp" @@ -31,7 +32,6 @@ using std::string; using std::vector; -using mergerfs::Policy; using namespace mergerfs; static @@ -56,9 +56,9 @@ _symlink_loop_core(const string &existingpath, fs::path::make(&newbasepath,newpath,fullnewpath); - rv = ::symlink(oldpath,fullnewpath.c_str()); + rv = fs::symlink(oldpath,fullnewpath); - return calc_error(rv,error,errno); + return error::calc(rv,error,errno); } static diff --git a/src/symlink.hpp b/src/symlink.hpp index b017155c..ccbdf23f 100644 --- a/src/symlink.hpp +++ b/src/symlink.hpp @@ -14,6 +14,9 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ +#ifndef __SYMLINK_HPP__ +#define __SYMLINK_HPP__ + namespace mergerfs { namespace fuse @@ -23,3 +26,5 @@ namespace mergerfs const char *newpath); } } + +#endif diff --git a/src/truncate.cpp b/src/truncate.cpp index 035beb53..db43592e 100644 --- a/src/truncate.cpp +++ b/src/truncate.cpp @@ -48,7 +48,7 @@ _truncate_loop_core(const string *basepath, rv = fs::truncate(fullpath,size); - return calc_error(rv,error,errno); + return error::calc(rv,error,errno); } static diff --git a/src/truncate.hpp b/src/truncate.hpp index 45d801ee..7eb65b7c 100644 --- a/src/truncate.hpp +++ b/src/truncate.hpp @@ -14,6 +14,9 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ +#ifndef __TRUNCATE_HPP__ +#define __TRUNCATE_HPP__ + #include namespace mergerfs @@ -25,3 +28,5 @@ namespace mergerfs off_t size); } } + +#endif diff --git a/src/ugid.hpp b/src/ugid.hpp index 7d4110fe..2ea279ec 100644 --- a/src/ugid.hpp +++ b/src/ugid.hpp @@ -37,4 +37,4 @@ namespace mergerfs #include "ugid_rwlock.hpp" #endif -#endif /* __UGID_HPP__ */ +#endif diff --git a/src/ugid_linux.hpp b/src/ugid_linux.hpp index e0179038..a55a7abc 100644 --- a/src/ugid_linux.hpp +++ b/src/ugid_linux.hpp @@ -14,6 +14,9 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ +#ifndef __UGID_LINUX_HPP__ +#define __UGID_LINUX_HPP__ + #include #include #include @@ -87,3 +90,5 @@ namespace mergerfs }; } } + +#endif diff --git a/src/ugid_rwlock.hpp b/src/ugid_rwlock.hpp index 729a1428..0c4dfd23 100644 --- a/src/ugid_rwlock.hpp +++ b/src/ugid_rwlock.hpp @@ -14,6 +14,9 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ +#ifndef __UGID_RWLOCK_HPP__ +#define __UGID_RWLOCK_HPP__ + #include #include #include @@ -97,3 +100,5 @@ namespace mergerfs }; } } + +#endif diff --git a/src/unlink.cpp b/src/unlink.cpp index 4ace660d..9cf403e2 100644 --- a/src/unlink.cpp +++ b/src/unlink.cpp @@ -46,7 +46,7 @@ _unlink_loop_core(const string *basepath, rv = fs::unlink(fullpath); - return calc_error(rv,error,errno); + return error::calc(rv,error,errno); } static diff --git a/src/unlink.hpp b/src/unlink.hpp index 8d6a2662..bb4d2c7c 100644 --- a/src/unlink.hpp +++ b/src/unlink.hpp @@ -14,6 +14,9 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ +#ifndef __UNLINK_HPP__ +#define __UNLINK_HPP__ + namespace mergerfs { namespace fuse @@ -22,3 +25,5 @@ namespace mergerfs unlink(const char *fusepath); } } + +#endif diff --git a/src/utimens.cpp b/src/utimens.cpp index ddf57b84..e99700a2 100644 --- a/src/utimens.cpp +++ b/src/utimens.cpp @@ -47,7 +47,7 @@ _utimens_loop_core(const string *basepath, rv = fs::lutime(fullpath,ts); - return calc_error(rv,error,errno); + return error::calc(rv,error,errno); } static diff --git a/src/utimens.hpp b/src/utimens.hpp index 2984da0d..a22e287f 100644 --- a/src/utimens.hpp +++ b/src/utimens.hpp @@ -14,6 +14,9 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ +#ifndef __UTIMENS_HPP__ +#define __UTIMENS_HPP__ + namespace mergerfs { namespace fuse @@ -23,3 +26,5 @@ namespace mergerfs const timespec ts[2]); } } + +#endif diff --git a/src/write.hpp b/src/write.hpp index 1736f9a0..8a144124 100644 --- a/src/write.hpp +++ b/src/write.hpp @@ -14,6 +14,9 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ +#ifndef __WRITE_HPP__ +#define __WRITE_HPP__ + namespace mergerfs { namespace fuse @@ -33,3 +36,5 @@ namespace mergerfs fuse_file_info *fi); } } + +#endif diff --git a/src/xattr.hpp b/src/xattr.hpp index 45e0050a..181fedf8 100644 --- a/src/xattr.hpp +++ b/src/xattr.hpp @@ -14,6 +14,9 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ +#ifndef __XATTR_HPP__ +#define __XATTR_HPP__ + #ifndef WITHOUT_XATTR #include #endif @@ -25,3 +28,5 @@ #ifndef XATTR_REPLACE # define XATTR_REPLACE 0x2 #endif + +#endif