Browse Source

wrap most posix filesystem functions

pull/329/head
Antonio SJ Musumeci 8 years ago
parent
commit
1dc7bff6e6
  1. 6
      src/access.cpp
  2. 3
      src/chmod.cpp
  3. 3
      src/chown.cpp
  4. 7
      src/create.cpp
  5. 1
      src/fallocate.cpp
  6. 7
      src/fgetattr.cpp
  7. 2
      src/fgetattr.hpp
  8. 8
      src/flush.cpp
  9. 44
      src/fs.cpp
  10. 3
      src/fs.hpp
  11. 23
      src/fs_attr_linux.icpp
  12. 46
      src/fs_base_access.hpp
  13. 49
      src/fs_base_chmod.hpp
  14. 74
      src/fs_base_chown.hpp
  15. 30
      src/fs_base_close.hpp
  16. 31
      src/fs_base_closedir.hpp
  17. 30
      src/fs_base_dup.hpp
  18. 38
      src/fs_base_fsync.hpp
  19. 32
      src/fs_base_ftruncate.hpp
  20. 40
      src/fs_base_getxattr.hpp
  21. 32
      src/fs_base_ioctl.hpp
  22. 33
      src/fs_base_link.hpp
  23. 39
      src/fs_base_listxattr.hpp
  24. 34
      src/fs_base_mkdir.hpp
  25. 35
      src/fs_base_mknod.hpp
  26. 45
      src/fs_base_open.hpp
  27. 33
      src/fs_base_opendir.hpp
  28. 33
      src/fs_base_read.hpp
  29. 30
      src/fs_base_readdir.hpp
  30. 34
      src/fs_base_readlink.hpp
  31. 38
      src/fs_base_removexattr.hpp
  32. 31
      src/fs_base_rename.hpp
  33. 32
      src/fs_base_rmdir.hpp
  34. 41
      src/fs_base_setxattr.hpp
  35. 62
      src/fs_base_stat.hpp
  36. 42
      src/fs_base_statvfs.hpp
  37. 34
      src/fs_base_truncate.hpp
  38. 32
      src/fs_base_unlink.hpp
  39. 50
      src/fs_base_utimensat.hpp
  40. 33
      src/fs_base_write.hpp
  41. 21
      src/fs_clonefile.cpp
  42. 24
      src/fs_clonepath.cpp
  43. 28
      src/fs_movefile.cpp
  44. 6
      src/fs_xattr.cpp
  45. 7
      src/fsync.cpp
  46. 6
      src/ftruncate.cpp
  47. 7
      src/getattr.cpp
  48. 10
      src/getxattr.cpp
  49. 12
      src/ioctl.cpp
  50. 9
      src/link.cpp
  51. 10
      src/listxattr.cpp
  52. 6
      src/mkdir.cpp
  53. 8
      src/mknod.cpp
  54. 5
      src/open.cpp
  55. 4
      src/read.cpp
  56. 11
      src/readdir.cpp
  57. 8
      src/readlink.cpp
  58. 5
      src/release.cpp
  59. 12
      src/removexattr.cpp
  60. 10
      src/rename.cpp
  61. 3
      src/rmdir.cpp
  62. 13
      src/setxattr.cpp
  63. 8
      src/statfs.cpp
  64. 19
      src/statvfs_util.hpp
  65. 3
      src/truncate.cpp
  66. 3
      src/unlink.cpp
  67. 4
      src/utimens.cpp
  68. 5
      src/write.cpp

6
src/access.cpp

@ -17,11 +17,9 @@
#include <string>
#include <vector>
#include <fcntl.h>
#include <unistd.h>
#include "config.hpp"
#include "errno.hpp"
#include "fs_base_access.hpp"
#include "fs_path.hpp"
#include "rwlock.hpp"
#include "ugid.hpp"
@ -49,7 +47,7 @@ _access(Policy::Func::Search searchFunc,
fs::path::make(basepaths[0],fusepath,fullpath);
rv = ::faccessat(AT_FDCWD,fullpath.c_str(),mask,AT_EACCESS);
rv = fs::access(fullpath,mask,AT_EACCESS);
return ((rv == -1) ? -errno : 0);
}

3
src/chmod.cpp

@ -21,6 +21,7 @@
#include "config.hpp"
#include "errno.hpp"
#include "fs_base_chmod.hpp"
#include "fs_path.hpp"
#include "rv.hpp"
#include "rwlock.hpp"
@ -42,7 +43,7 @@ _chmod_loop_core(const string *basepath,
fs::path::make(basepath,fusepath,fullpath);
rv = ::chmod(fullpath.c_str(),mode);
rv = fs::chmod(fullpath,mode);
return calc_error(rv,error,errno);
}

3
src/chown.cpp

@ -21,6 +21,7 @@
#include "config.hpp"
#include "errno.hpp"
#include "fs_base_chown.hpp"
#include "fs_path.hpp"
#include "rv.hpp"
#include "rwlock.hpp"
@ -44,7 +45,7 @@ _chown_loop_core(const string *basepath,
fs::path::make(basepath,fusepath,fullpath);
rv = ::lchown(fullpath.c_str(),uid,gid);
rv = fs::lchown(fullpath,uid,gid);
return calc_error(rv,error,errno);
}

7
src/create.cpp

@ -16,16 +16,13 @@
#include <fuse.h>
#include <fcntl.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <string>
#include <vector>
#include "config.hpp"
#include "errno.hpp"
#include "fileinfo.hpp"
#include "fs_base_open.hpp"
#include "fs_clonepath.hpp"
#include "fs_path.hpp"
#include "rwlock.hpp"
@ -57,7 +54,7 @@ _create_core(const string &existingpath,
fs::path::make(&createpath,fusepath,fullpath);
fd = ::open(fullpath.c_str(),flags,mode);
fd = fs::open(fullpath,flags,mode);
if(fd == -1)
return -errno;

1
src/fallocate.cpp

@ -49,7 +49,6 @@ namespace mergerfs
{
FileInfo *fi = reinterpret_cast<FileInfo*>(ffi->fh);
return _fallocate(fi->fd,
mode,
offset,

7
src/fgetattr.cpp

@ -16,12 +16,9 @@
#include <fuse.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include "errno.hpp"
#include "fileinfo.hpp"
#include "fs_base_stat.hpp"
static
int
@ -30,7 +27,7 @@ _fgetattr(const int fd,
{
int rv;
rv = ::fstat(fd,&st);
rv = fs::fstat(fd,st);
return ((rv == -1) ? -errno : 0);
}

2
src/fgetattr.hpp

@ -14,8 +14,8 @@
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h>
namespace mergerfs

8
src/flush.cpp

@ -16,10 +16,10 @@
#include <fuse.h>
#include <unistd.h>
#include "errno.hpp"
#include "fileinfo.hpp"
#include "fs_base_close.hpp"
#include "fs_base_dup.hpp"
static
int
@ -27,11 +27,11 @@ _flush(const int fd)
{
int rv;
rv = ::dup(fd);
rv = fs::dup(fd);
if(rv == -1)
errno = EIO;
else
rv = ::close(rv);
rv = fs::close(rv);
return ((rv == -1) ? -errno : 0);
}

44
src/fs.cpp

@ -17,19 +17,16 @@
#include <string>
#include <vector>
#include <fcntl.h>
#include <fcntl.h>
#include <glob.h>
#include <limits.h>
#include <stdint.h>
#include <stdlib.h>
#include <sys/stat.h>
#include <sys/statvfs.h>
#include <sys/types.h>
#include <unistd.h>
#include "errno.hpp"
#include "fs_attr.hpp"
#include "fs_base_stat.hpp"
#include "fs_base_statvfs.hpp"
#include "fs_path.hpp"
#include "fs_xattr.hpp"
#include "statvfs_util.hpp"
@ -47,7 +44,7 @@ namespace fs
{
int rv;
rv = ::lstat(path.c_str(),&st);
rv = fs::lstat(path,st);
return LSTAT_SUCCEEDED(rv);
}
@ -60,74 +57,63 @@ namespace fs
return exists(path,st);
}
bool
statvfs(const string &path,
struct statvfs &st)
{
int rv;
rv = ::statvfs(path.c_str(),&st);
return STATVFS_SUCCEEDED(rv);
}
bool
info(const string &path,
bool &readonly,
uint64_t &spaceavail,
uint64_t &spaceused)
{
bool rv;
int rv;
struct statvfs st;
rv = fs::statvfs(path,st);
if(rv)
if(STATVFS_SUCCEEDED(rv))
{
readonly = StatVFS::readonly(st);
spaceavail = StatVFS::spaceavail(st);
spaceused = StatVFS::spaceused(st);
}
return rv;
return STATVFS_SUCCEEDED(rv);
}
bool
readonly(const string &path)
{
bool rv;
int rv;
struct statvfs st;
rv = fs::statvfs(path,st);
return (rv && StatVFS::readonly(st));
return (STATVFS_SUCCEEDED(rv) && StatVFS::readonly(st));
}
bool
spaceavail(const string &path,
uint64_t &spaceavail)
{
bool rv;
int rv;
struct statvfs st;
rv = fs::statvfs(path,st);
if(rv)
if(STATVFS_SUCCEEDED(rv))
spaceavail = StatVFS::spaceavail(st);
return rv;
return STATVFS_SUCCEEDED(rv);
}
bool
spaceused(const string &path,
uint64_t &spaceused)
{
bool rv;
int rv;
struct statvfs st;
rv = fs::statvfs(path,st);
if(rv)
if(STATVFS_SUCCEEDED(rv))
spaceused = StatVFS::spaceused(st);
return rv;
return STATVFS_SUCCEEDED(rv);
}
void
@ -159,7 +145,7 @@ namespace fs
string fullpath;
struct stat st;
rv = ::fstat(fd,&st);
rv = fs::fstat(fd,st);
if(FSTAT_FAILED(rv))
return -1;

3
src/fs.hpp

@ -31,9 +31,6 @@ namespace fs
struct stat &st);
bool exists(const string &path);
bool statvfs(const string &path,
struct statvfs &st);
bool info(const string &path,
bool &readonly,
uint64_t &spaceavail,

23
src/fs_attr_linux.icpp

@ -16,14 +16,13 @@
#include <fcntl.h>
#include <linux/fs.h>
#include <sys/ioctl.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h>
#include <string>
#include "errno.hpp"
#include "fs_base_close.hpp"
#include "fs_base_open.hpp"
#include "fs_base_ioctl.hpp"
using std::string;
@ -36,7 +35,7 @@ namespace fs
get_fs_ioc_flags(const int fd,
int &flags)
{
return ::ioctl(fd,FS_IOC_GETFLAGS,&flags);
return fs::ioctl(fd,FS_IOC_GETFLAGS,(void*)&flags);
}
static
@ -48,7 +47,7 @@ namespace fs
int rv;
const int openflags = O_RDONLY|O_NONBLOCK;
fd = ::open(file.c_str(),openflags);
fd = fs::open(file,openflags);
if(fd == -1)
return -1;
@ -56,12 +55,12 @@ namespace fs
if(rv == -1)
{
int error = errno;
::close(fd);
fs::close(fd);
errno = error;
return -1;
}
return ::close(fd);
return fs::close(fd);
}
static
@ -69,7 +68,7 @@ namespace fs
set_fs_ioc_flags(const int fd,
const int flags)
{
return ::ioctl(fd,FS_IOC_SETFLAGS,&flags);
return fs::ioctl(fd,FS_IOC_SETFLAGS,(void*)&flags);
}
static
@ -81,7 +80,7 @@ namespace fs
int rv;
const int openflags = O_RDONLY|O_NONBLOCK;
fd = ::open(file.c_str(),openflags);
fd = fs::open(file,openflags);
if(fd == -1)
return -1;
@ -89,12 +88,12 @@ namespace fs
if(rv == -1)
{
int error = errno;
::close(fd);
fs::close(fd);
errno = error;
return -1;
}
return ::close(fd);
return fs::close(fd);
}
int

46
src/fs_base_access.hpp

@ -0,0 +1,46 @@
/*
ISC License
Copyright (c) 2016, Antonio SJ Musumeci <trapexit@spawn.link>
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 <string>
#include <fcntl.h>
#include <unistd.h>
namespace fs
{
static
inline
int
access(const int dirfd,
const std::string &pathname,
const int mode,
const int flags)
{
return ::faccessat(dirfd,pathname.c_str(),mode,flags);
}
static
inline
int
access(const std::string &pathname,
const int mode,
const int flags)
{
return fs::access(AT_FDCWD,pathname,mode,flags);
}
}

49
src/fs_base_chmod.hpp

@ -0,0 +1,49 @@
/*
ISC License
Copyright (c) 2016, Antonio SJ Musumeci <trapexit@spawn.link>
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 <sys/stat.h>
namespace fs
{
static
inline
int
chmod(const std::string &path,
const mode_t mode)
{
return ::chmod(path.c_str(),mode);
}
static
inline
int
fchmod(const int fd,
const mode_t mode)
{
return ::fchmod(fd,mode);
}
static
inline
int
fchmod(const int fd,
const struct stat &st)
{
return ::fchmod(fd,st.st_mode);
}
}

74
src/fs_base_chown.hpp

@ -0,0 +1,74 @@
/*
ISC License
Copyright (c) 2016, Antonio SJ Musumeci <trapexit@spawn.link>
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 <string>
#include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h>
namespace fs
{
static
inline
int
chown(const std::string &path,
const uid_t uid,
const gid_t gid)
{
return ::chown(path.c_str(),uid,gid);
}
static
inline
int
chown(const std::string &path,
const struct stat &st)
{
return fs::chown(path,st.st_uid,st.st_gid);
}
static
inline
int
lchown(const std::string &path,
const uid_t uid,
const gid_t gid)
{
return ::lchown(path.c_str(),uid,gid);
}
static
inline
int
fchown(const int fd,
const uid_t uid,
const gid_t gid)
{
return ::fchown(fd,uid,gid);
}
static
inline
int
fchown(const int fd,
const struct stat &st)
{
return fs::fchown(fd,st.st_uid,st.st_gid);
}
}

30
src/fs_base_close.hpp

@ -0,0 +1,30 @@
/*
ISC License
Copyright (c) 2016, Antonio SJ Musumeci <trapexit@spawn.link>
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 <unistd.h>
namespace fs
{
static
inline
int
close(const int fd)
{
return ::close(fd);
}
}

31
src/fs_base_closedir.hpp

@ -0,0 +1,31 @@
/*
ISC License
Copyright (c) 2016, Antonio SJ Musumeci <trapexit@spawn.link>
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 <dirent.h>
#include <sys/types.h>
namespace fs
{
static
inline
int
closedir(DIR *dirp)
{
return ::closedir(dirp);
}
}

30
src/fs_base_dup.hpp

@ -0,0 +1,30 @@
/*
ISC License
Copyright (c) 2016, Antonio SJ Musumeci <trapexit@spawn.link>
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 <unistd.h>
namespace fs
{
static
inline
int
dup(const int fd)
{
return ::dup(fd);
}
}

38
src/fs_base_fsync.hpp

@ -0,0 +1,38 @@
/*
ISC License
Copyright (c) 2016, Antonio SJ Musumeci <trapexit@spawn.link>
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 <unistd.h>
namespace fs
{
static
inline
int
fsync(const int fd)
{
return ::fsync(fd);
}
static
inline
int
fdatasync(const int fd)
{
return ::fdatasync(fd);
}
}

32
src/fs_base_ftruncate.hpp

@ -0,0 +1,32 @@
/*
ISC License
Copyright (c) 2016, Antonio SJ Musumeci <trapexit@spawn.link>
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 <sys/types.h>
#include <unistd.h>
namespace fs
{
static
inline
int
ftruncate(const int fd,
const off_t size)
{
return ::ftruncate(fd,size);
}
}

40
src/fs_base_getxattr.hpp

@ -0,0 +1,40 @@
/*
ISC License
Copyright (c) 2016, Antonio SJ Musumeci <trapexit@spawn.link>
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 <sys/types.h>
#include "errno.hpp"
#include "xattr.hpp"
namespace fs
{
static
inline
int
lgetxattr(const std::string &path,
const char *attrname,
void *value,
const size_t size)
{
#ifndef WITHOUT_XATTR
return ::lgetxattr(path.c_str(),attrname,value,size);
#else
return (errno=ENOTSUP,-1);
#endif
}
}

32
src/fs_base_ioctl.hpp

@ -0,0 +1,32 @@
/*
ISC License
Copyright (c) 2016, Antonio SJ Musumeci <trapexit@spawn.link>
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 <sys/ioctl.h>
namespace fs
{
static
inline
int
ioctl(const int fd,
const int request,
void *data)
{
return ::ioctl(fd,request,data);
}
}

33
src/fs_base_link.hpp

@ -0,0 +1,33 @@
/*
ISC License
Copyright (c) 2016, Antonio SJ Musumeci <trapexit@spawn.link>
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 <string>
#include <unistd.h>
namespace fs
{
static
inline
int
link(const std::string &oldpath,
const std::string &newpath)
{
return ::link(oldpath.c_str(),newpath.c_str());
}
}

39
src/fs_base_listxattr.hpp

@ -0,0 +1,39 @@
/*
ISC License
Copyright (c) 2016, Antonio SJ Musumeci <trapexit@spawn.link>
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 <sys/types.h>
#include "errno.hpp"
#include "xattr.hpp"
namespace fs
{
static
inline
int
llistxattr(const std::string &path,
char *list,
const size_t size)
{
#ifndef WITHOUT_XATTR
return ::llistxattr(path.c_str(),list,size);
#else
return (errno=ENOTSUP,-1);
#endif
}
}

34
src/fs_base_mkdir.hpp

@ -0,0 +1,34 @@
/*
ISC License
Copyright (c) 2016, Antonio SJ Musumeci <trapexit@spawn.link>
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 <string>
#include <sys/stat.h>
#include <sys/types.h>
namespace fs
{
static
inline
int
mkdir(const std::string &path,
const mode_t mode)
{
return ::mkdir(path.c_str(),mode);
}
}

35
src/fs_base_mknod.hpp

@ -0,0 +1,35 @@
/*
ISC License
Copyright (c) 2016, Antonio SJ Musumeci <trapexit@spawn.link>
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 <fcntl.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h>
namespace fs
{
static
inline
int
mknod(const std::string &path,
const mode_t mode,
const dev_t dev)
{
return ::mknod(path.c_str(),mode,dev);
}
}

45
src/fs_base_open.hpp

@ -0,0 +1,45 @@
/*
ISC License
Copyright (c) 2016, Antonio SJ Musumeci <trapexit@spawn.link>
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 <string>
#include <fcntl.h>
#include <sys/stat.h>
#include <sys/types.h>
namespace fs
{
static
inline
int
open(const std::string &path,
const int flags)
{
return ::open(path.c_str(),flags);
}
static
inline
int
open(const std::string &path,
const int flags,
const mode_t mode)
{
return ::open(path.c_str(),flags,mode);
}
}

33
src/fs_base_opendir.hpp

@ -0,0 +1,33 @@
/*
ISC License
Copyright (c) 2016, Antonio SJ Musumeci <trapexit@spawn.link>
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 <string>
#include <dirent.h>
#include <sys/types.h>
namespace fs
{
static
inline
DIR *
opendir(const std::string &name)
{
return ::opendir(name.c_str());
}
}

33
src/fs_base_read.hpp

@ -0,0 +1,33 @@
/*
ISC License
Copyright (c) 2016, Antonio SJ Musumeci <trapexit@spawn.link>
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 <unistd.h>
namespace fs
{
static
inline
ssize_t
pread(const int fd,
void *buf,
const size_t count,
const off_t offset)
{
return ::pread(fd,buf,count,offset);
}
}

30
src/fs_base_readdir.hpp

@ -0,0 +1,30 @@
/*
ISC License
Copyright (c) 2016, Antonio SJ Musumeci <trapexit@spawn.link>
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 <dirent.h>
namespace fs
{
static
inline
struct dirent *
readdir(DIR *dirp)
{
return ::readdir(dirp);
}
}

34
src/fs_base_readlink.hpp

@ -0,0 +1,34 @@
/*
ISC License
Copyright (c) 2016, Antonio SJ Musumeci <trapexit@spawn.link>
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 <string>
#include <unistd.h>
namespace fs
{
static
inline
int
readlink(const std::string &path,
char *buf,
const size_t bufsiz)
{
return ::readlink(path.c_str(),buf,bufsiz);
}
}

38
src/fs_base_removexattr.hpp

@ -0,0 +1,38 @@
/*
ISC License
Copyright (c) 2016, Antonio SJ Musumeci <trapexit@spawn.link>
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 <sys/types.h>
#include "errno.hpp"
#include "xattr.hpp"
namespace fs
{
static
inline
int
lremovexattr(const std::string &path,
const char *attrname)
{
#ifndef WITHOUT_XATTR
return ::lremovexattr(path.c_str(),attrname);
#else
return (errno=ENOTSUP,-1);
#endif
}
}

31
src/fs_base_rename.hpp

@ -0,0 +1,31 @@
/*
ISC License
Copyright (c) 2016, Antonio SJ Musumeci <trapexit@spawn.link>
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 <stdio.h>
namespace fs
{
static
inline
int
rename(const std::string &oldpath,
const std::string &newpath)
{
return ::rename(oldpath.c_str(),newpath.c_str());
}
}

32
src/fs_base_rmdir.hpp

@ -0,0 +1,32 @@
/*
ISC License
Copyright (c) 2016, Antonio SJ Musumeci <trapexit@spawn.link>
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 <string>
#include <unistd.h>
namespace fs
{
static
inline
int
rmdir(const std::string &path)
{
return ::rmdir(path.c_str());
}
}

41
src/fs_base_setxattr.hpp

@ -0,0 +1,41 @@
/*
ISC License
Copyright (c) 2016, Antonio SJ Musumeci <trapexit@spawn.link>
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 <sys/types.h>
#include "errno.hpp"
#include "xattr.hpp"
namespace fs
{
static
inline
int
lsetxattr(const std::string &path,
const char *name,
const void *value,
const size_t size,
const int flags)
{
#ifndef WITHOUT_XATTR
return ::lsetxattr(path.c_str(),name,value,size,flags);
#else
return (errno=ENOTSUP,-1);
#endif
}
}

62
src/fs_base_stat.hpp

@ -0,0 +1,62 @@
/*
ISC License
Copyright (c) 2016, Antonio SJ Musumeci <trapexit@spawn.link>
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 <string>
#include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h>
namespace fs
{
static
inline
int
stat(const char *path,
struct stat &st)
{
return ::stat(path,&st);
}
static
inline
int
stat(const std::string &path,
struct stat &st)
{
return fs::stat(path.c_str(),st);
}
static
inline
int
lstat(const std::string &path,
struct stat &st)
{
return ::lstat(path.c_str(),&st);
}
static
inline
int
fstat(const int fd,
struct stat &st)
{
return ::fstat(fd,&st);
}
}

42
src/fs_base_statvfs.hpp

@ -0,0 +1,42 @@
/*
ISC License
Copyright (c) 2016, Antonio SJ Musumeci <trapexit@spawn.link>
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 <string>
#include <sys/statvfs.h>
namespace fs
{
static
inline
int
statvfs(const char *path,
struct statvfs &st)
{
return ::statvfs(path,&st);
}
static
inline
int
statvfs(const std::string &path,
struct statvfs &st)
{
return fs::statvfs(path.c_str(),st);
}
}

34
src/fs_base_truncate.hpp

@ -0,0 +1,34 @@
/*
ISC License
Copyright (c) 2016, Antonio SJ Musumeci <trapexit@spawn.link>
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 <string>
#include <sys/types.h>
#include <unistd.h>
namespace fs
{
static
inline
int
truncate(const std::string &path,
const off_t length)
{
return ::truncate(path.c_str(),length);
}
}

32
src/fs_base_unlink.hpp

@ -0,0 +1,32 @@
/*
ISC License
Copyright (c) 2016, Antonio SJ Musumeci <trapexit@spawn.link>
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 <string>
#include <unistd.h>
namespace fs
{
static
inline
int
unlink(const std::string &path)
{
return ::unlink(path.c_str());
}
}

50
src/fs_base_utimensat.hpp

@ -0,0 +1,50 @@
/*
ISC License
Copyright (c) 2016, Antonio SJ Musumeci <trapexit@spawn.link>
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 <string>
#include <fcntl.h>
#include <sys/stat.h>
namespace fs
{
static
inline
int
utimensat(const int dirfd,
const std::string &path,
const struct timespec times[2],
const int flags)
{
return ::utimensat(dirfd,path.c_str(),times,flags);
}
static
inline
int
utimensat(const std::string &path,
const struct stat &st)
{
struct timespec times[2];
times[0] = st.st_atim;
times[1] = st.st_mtim;
return fs::utimensat(AT_FDCWD,path,times,0);
}
}

33
src/fs_base_write.hpp

@ -0,0 +1,33 @@
/*
ISC License
Copyright (c) 2016, Antonio SJ Musumeci <trapexit@spawn.link>
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 <unistd.h>
namespace fs
{
static
inline
ssize_t
pwrite(const int fd,
const void *buf,
const size_t count,
const off_t offset)
{
return ::pwrite(fd,buf,count,offset);
}
}

21
src/fs_clonefile.cpp

@ -25,6 +25,11 @@
#include "errno.hpp"
#include "fs_attr.hpp"
#include "fs_base_chown.hpp"
#include "fs_base_chmod.hpp"
#include "fs_base_close.hpp"
#include "fs_base_mkdir.hpp"
#include "fs_base_open.hpp"
#include "fs_fadvise.hpp"
#include "fs_fallocate.hpp"
#include "fs_sendfile.hpp"
@ -162,11 +167,11 @@ namespace fs
if(rv == -1 && !ignorable_error(errno))
return -1;
rv = ::fchown(fdout,stin.st_uid,stin.st_gid);
rv = fs::fchown(fdout,stin);
if(rv == -1)
return -1;
rv = ::fchmod(fdout,stin.st_mode);
rv = fs::fchmod(fdout,stin);
if(rv == -1)
return -1;
@ -186,21 +191,21 @@ namespace fs
int fdout;
int error;
fdin = ::open(in.c_str(),O_RDONLY|O_NOFOLLOW);
fdin = fs::open(in,O_RDONLY|O_NOFOLLOW);
if(fdin == -1)
return -1;
const int flags = O_CREAT|O_LARGEFILE|O_NOATIME|O_NOFOLLOW|O_TRUNC|O_WRONLY;
const int mode = S_IWUSR;
fdout = ::open(out.c_str(),flags,mode);
const int flags = O_CREAT|O_LARGEFILE|O_NOATIME|O_NOFOLLOW|O_TRUNC|O_WRONLY;
const mode_t mode = S_IWUSR;
fdout = fs::open(out,flags,mode);
if(fdout == -1)
return -1;
rv = fs::clonefile(fdin,fdout);
error = errno;
::close(fdin);
::close(fdout);
fs::close(fdin);
fs::close(fdout);
errno = error;
return rv;

24
src/fs_clonepath.cpp

@ -14,14 +14,15 @@
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <string>
#include "errno.h"
#include "fs_attr.hpp"
#include "fs_base_chmod.hpp"
#include "fs_base_chown.hpp"
#include "fs_base_mkdir.hpp"
#include "fs_base_stat.hpp"
#include "fs_base_utimensat.hpp"
#include "fs_path.hpp"
#include "fs_xattr.hpp"
@ -61,26 +62,26 @@ namespace fs
fs::path::dirname(dirname);
if(!dirname.empty())
{
rv = clonepath(fromsrc,tosrc,dirname.c_str());
rv = fs::clonepath(fromsrc,tosrc,dirname.c_str());
if(rv == -1)
return -1;
}
fs::path::make(&fromsrc,relative,frompath);
rv = ::stat(frompath.c_str(),&st);
rv = fs::stat(frompath,st);
if(rv == -1)
return -1;
else if(!S_ISDIR(st.st_mode))
return (errno = ENOTDIR,-1);
fs::path::make(&tosrc,relative,topath);
rv = ::mkdir(topath.c_str(),st.st_mode);
rv = fs::mkdir(topath,st.st_mode);
if(rv == -1)
{
if(errno != EEXIST)
return -1;
rv = ::chmod(topath.c_str(),st.st_mode);
rv = fs::chmod(topath,st.st_mode);
if(rv == -1)
return -1;
}
@ -94,14 +95,11 @@ namespace fs
if(rv == -1 && !ignorable_error(errno))
return -1;
rv = ::chown(topath.c_str(),st.st_uid,st.st_gid);
rv = fs::chown(topath,st);
if(rv == -1)
return -1;
struct timespec times[2];
times[0] = st.st_atim;
times[1] = st.st_mtim;
rv = ::utimensat(-1,topath.c_str(),times,0);
rv = fs::utimensat(topath,st);
if(rv == -1)
return -1;

28
src/fs_movefile.cpp

@ -23,6 +23,10 @@
#include <vector>
#include "fs.hpp"
#include "fs_base_open.hpp"
#include "fs_base_close.hpp"
#include "fs_base_unlink.hpp"
#include "fs_base_stat.hpp"
#include "fs_clonefile.hpp"
#include "fs_clonepath.hpp"
#include "fs_path.hpp"
@ -49,7 +53,7 @@ namespace fs
fdin = origfd;
rv = fstat(fdin,&fdin_st);
rv = fs::fstat(fdin,fdin_st);
if(rv == -1)
return -1;
@ -73,35 +77,35 @@ namespace fs
return -1;
fs::path::append(fdin_path,fusepath);
fdin = ::open(fdin_path.c_str(),O_RDONLY);
fdin = fs::open(fdin_path,O_RDONLY);
if(fdin == -1)
return -1;
fs::path::append(fdout_path,fusepath);
fdout = ::open(fdout_path.c_str(),fdin_flags|O_CREAT,fdin_st.st_mode);
fdout = fs::open(fdout_path,fdin_flags|O_CREAT,fdin_st.st_mode);
if(fdout == -1)
return -1;
rv = fs::clonefile(fdin,fdout);
if(rv == -1)
{
::close(fdin);
::close(fdout);
::unlink(fdout_path.c_str());
fs::close(fdin);
fs::close(fdout);
fs::unlink(fdout_path.c_str());
return -1;
}
rv = ::unlink(fdin_path.c_str());
rv = fs::unlink(fdin_path);
if(rv == -1)
{
::close(fdin);
::close(fdout);
::unlink(fdout_path.c_str());
fs::close(fdin);
fs::close(fdout);
fs::unlink(fdout_path);
return -1;
}
::close(fdin);
::close(origfd);
fs::close(fdin);
fs::close(origfd);
origfd = fdout;

6
src/fs_xattr.cpp

@ -26,6 +26,8 @@
#include <sstream>
#include "errno.hpp"
#include "fs_base_open.hpp"
#include "fs_base_close.hpp"
#include "str.hpp"
#include "xattr.hpp"
@ -349,13 +351,13 @@ namespace fs
{
int fd;
fd = ::open(path.c_str(),O_RDONLY|O_NONBLOCK);
fd = fs::open(path,O_RDONLY|O_NONBLOCK);
if(fd == -1)
return -1;
set(fd,attrs);
return ::close(fd);
return fs::close(fd);
}
int

7
src/fsync.cpp

@ -23,10 +23,9 @@
#include <string>
#include <vector>
#include <unistd.h>
#include "errno.hpp"
#include "fileinfo.hpp"
#include "fs_base_fsync.hpp"
static
int
@ -36,8 +35,8 @@ _fsync(const int fd,
int rv;
rv = (isdatasync ?
::fdatasync(fd) :
::fsync(fd));
fs::fdatasync(fd) :
fs::fsync(fd));
return ((rv == -1) ? -errno : 0);
}

6
src/ftruncate.cpp

@ -16,11 +16,9 @@
#include <fuse.h>
#include <unistd.h>
#include <sys/types.h>
#include "errno.hpp"
#include "fileinfo.hpp"
#include "fs_base_ftruncate.hpp"
static
int
@ -29,7 +27,7 @@ _ftruncate(const int fd,
{
int rv;
rv = ::ftruncate(fd,size);
rv = fs::ftruncate(fd,size);
return ((rv == -1) ? -errno : 0);
}

7
src/getattr.cpp

@ -19,12 +19,9 @@
#include <string>
#include <vector>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include "config.hpp"
#include "errno.hpp"
#include "fs_base_stat.hpp"
#include "fs_path.hpp"
#include "rwlock.hpp"
#include "ugid.hpp"
@ -76,7 +73,7 @@ _getattr(Policy::Func::Search searchFunc,
fs::path::make(basepaths[0],fusepath,fullpath);
rv = ::lstat(fullpath.c_str(),&buf);
rv = fs::lstat(fullpath,buf);
return ((rv == -1) ? -errno : 0);
}

10
src/getxattr.cpp

@ -23,17 +23,15 @@
#include <stdio.h>
#include <string.h>
#include <sys/types.h>
#include <unistd.h>
#include "config.hpp"
#include "errno.hpp"
#include "fs_base_getxattr.hpp"
#include "fs_path.hpp"
#include "rwlock.hpp"
#include "str.hpp"
#include "ugid.hpp"
#include "version.hpp"
#include "xattr.hpp"
using std::string;
using std::vector;
@ -47,15 +45,11 @@ _lgetxattr(const string &path,
void *value,
const size_t size)
{
#ifndef WITHOUT_XATTR
int rv;
rv = ::lgetxattr(path.c_str(),attrname,value,size);
rv = fs::lgetxattr(path,attrname,value,size);
return ((rv == -1) ? -errno : rv);
#else
return -ENOTSUP;
#endif
}
static

12
src/ioctl.cpp

@ -20,13 +20,13 @@
#include <vector>
#include <fcntl.h>
#include <sys/ioctl.h>
#include <sys/stat.h>
#include <sys/types.h>
#include "config.hpp"
#include "errno.hpp"
#include "fileinfo.hpp"
#include "fs_base_close.hpp"
#include "fs_base_ioctl.hpp"
#include "fs_base_open.hpp"
#include "fs_path.hpp"
#include "rwlock.hpp"
#include "ugid.hpp"
@ -43,7 +43,7 @@ _ioctl(const int fd,
{
int rv;
rv = ::ioctl(fd,cmd,data);
rv = fs::ioctl(fd,cmd,data);
return ((rv == -1) ? -errno : rv);
}
@ -75,13 +75,13 @@ _ioctl_dir_base(Policy::Func::Search searchFunc,
fs::path::make(basepaths[0],fusepath,fullpath);
const int flags = O_RDONLY | O_NOATIME | O_NONBLOCK;
fd = ::open(fullpath.c_str(),flags);
fd = fs::open(fullpath,flags);
if(fd == -1)
return -errno;
rv = _ioctl(fd,cmd,data);
::close(fd);
fs::close(fd);
return rv;
}

9
src/link.cpp

@ -19,10 +19,9 @@
#include <string>
#include <vector>
#include <unistd.h>
#include "config.hpp"
#include "errno.hpp"
#include "fs_base_link.hpp"
#include "fs_clonepath.hpp"
#include "fs_path.hpp"
#include "rv.hpp"
@ -56,7 +55,7 @@ _link_create_path_core(const string &oldbasepath,
fs::path::make(&oldbasepath,oldfusepath,oldfullpath);
fs::path::make(&oldbasepath,newfusepath,newfullpath);
rv = ::link(oldfullpath.c_str(),newfullpath.c_str());
rv = fs::link(oldfullpath,newfullpath);
return calc_error(rv,error,errno);
}
@ -171,7 +170,7 @@ _link_preserve_path_core(Policy::Func::Search searchFunc,
fs::path::make(&oldbasepath,oldfusepath,oldfullpath);
fs::path::make(&oldbasepath,newfusepath,newfullpath);
rv = ::link(oldfullpath.c_str(),newfullpath.c_str());
rv = fs::link(oldfullpath,newfullpath);
if((rv == -1) && (errno == ENOENT))
{
rv = _clonepath_if_would_create(searchFunc,createFunc,
@ -179,7 +178,7 @@ _link_preserve_path_core(Policy::Func::Search searchFunc,
oldbasepath,
oldfusepath,newfusepath);
if(rv != -1)
rv = ::link(oldfullpath.c_str(),newfullpath.c_str());
rv = fs::link(oldfullpath,newfullpath);
}
return calc_error(rv,error,errno);

10
src/listxattr.cpp

@ -19,13 +19,13 @@
#include <string>
#include <vector>
#include <sys/types.h>
#include <string.h>
#include "buildvector.hpp"
#include "category.hpp"
#include "config.hpp"
#include "errno.hpp"
#include "fs_base_listxattr.hpp"
#include "fs_path.hpp"
#include "rwlock.hpp"
#include "ugid.hpp"
@ -69,7 +69,6 @@ _listxattr_controlfile(char *list,
return xattrs.size();
}
#ifndef WITHOUT_XATTR
static
int
_listxattr(Policy::Func::Search searchFunc,
@ -89,11 +88,10 @@ _listxattr(Policy::Func::Search searchFunc,
fs::path::make(basepaths[0],fusepath,fullpath);
rv = ::llistxattr(fullpath.c_str(),list,size);
rv = fs::llistxattr(fullpath,list,size);
return ((rv == -1) ? -errno : rv);
}
#endif
namespace mergerfs
{
@ -110,7 +108,6 @@ namespace mergerfs
if(fusepath == config.controlfile)
return _listxattr_controlfile(list,size);
#ifndef WITHOUT_XATTR
const ugid::Set ugid(fc->uid,fc->gid);
const rwlock::ReadGuard readlock(&config.srcmountslock);
@ -120,9 +117,6 @@ namespace mergerfs
fusepath,
list,
size);
#else
return -ENOTSUP;
#endif
}
}
}

6
src/mkdir.cpp

@ -16,14 +16,12 @@
#include <fuse.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <string>
#include <vector>
#include "config.hpp"
#include "errno.hpp"
#include "fs_base_mkdir.hpp"
#include "fs_clonepath.hpp"
#include "fs_path.hpp"
#include "rv.hpp"
@ -55,7 +53,7 @@ _mkdir_loop_core(const string &existingpath,
fs::path::make(&createpath,fusepath,fullpath);
rv = ::mkdir(fullpath.c_str(),mode);
rv = fs::mkdir(fullpath,mode);
return calc_error(rv,error,errno);
}

8
src/mknod.cpp

@ -19,13 +19,9 @@
#include <string>
#include <vector>
#include <fcntl.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h>
#include "config.hpp"
#include "errno.hpp"
#include "fs_base_mknod.hpp"
#include "fs_clonepath.hpp"
#include "fs_path.hpp"
#include "rv.hpp"
@ -57,7 +53,7 @@ _mknod_loop_core(const string &existingpath,
fs::path::make(&createpath,fusepath,fullpath);
rv = ::mknod(fullpath.c_str(),mode,dev);
rv = fs::mknod(fullpath,mode,dev);
return calc_error(rv,error,errno);
}

5
src/open.cpp

@ -17,8 +17,6 @@
#include <fuse.h>
#include <fcntl.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <string>
#include <vector>
@ -26,6 +24,7 @@
#include "config.hpp"
#include "errno.hpp"
#include "fileinfo.hpp"
#include "fs_base_open.hpp"
#include "fs_path.hpp"
#include "rwlock.hpp"
#include "ugid.hpp"
@ -46,7 +45,7 @@ _open_core(const string *basepath,
fs::path::make(basepath,fusepath,fullpath);
fd = ::open(fullpath.c_str(),flags);
fd = fs::open(fullpath,flags);
if(fd == -1)
return -errno;

4
src/read.cpp

@ -17,12 +17,12 @@
#include <fuse.h>
#include <string.h>
#include <unistd.h>
#include <string>
#include "errno.hpp"
#include "fileinfo.hpp"
#include "fs_base_read.hpp"
static
int
@ -33,7 +33,7 @@ _read(const int fd,
{
int rv;
rv = ::pread(fd,buf,count,offset);
rv = fs::pread(fd,buf,count,offset);
return ((rv == -1) ? -errno : rv);
}

11
src/readdir.cpp

@ -22,10 +22,11 @@
#include <set>
#include <vector>
#include <dirent.h>
#include "config.hpp"
#include "errno.hpp"
#include "fs_base_closedir.hpp"
#include "fs_base_opendir.hpp"
#include "fs_base_readdir.hpp"
#include "fs_path.hpp"
#include "readdir.hpp"
#include "rwlock.hpp"
@ -55,11 +56,11 @@ _readdir(const vector<string> &srcmounts,
fs::path::make(&srcmounts[i],dirname,basepath);
dh = ::opendir(basepath.c_str());
dh = fs::opendir(basepath);
if(!dh)
continue;
for(struct dirent *de = ::readdir(dh); de != NULL; de = ::readdir(dh))
for(struct dirent *de = fs::readdir(dh); de != NULL; de = fs::readdir(dh))
{
if(found.insert(de->d_name).second == false)
continue;
@ -69,7 +70,7 @@ _readdir(const vector<string> &srcmounts,
return -ENOMEM;
}
::closedir(dh);
fs::closedir(dh);
}
if(found.empty())

8
src/readlink.cpp

@ -16,13 +16,9 @@
#include <fuse.h>
#include <string.h>
#include <string>
#include <sys/types.h>
#include <unistd.h>
#include "config.hpp"
#include "errno.hpp"
#include "fs_base_readlink.hpp"
#include "fs_path.hpp"
#include "rwlock.hpp"
#include "ugid.hpp"
@ -43,7 +39,7 @@ _readlink_core(const string *basepath,
fs::path::make(basepath,fusepath,fullpath);
rv = ::readlink(fullpath.c_str(),buf,size);
rv = fs::readlink(fullpath,buf,size);
if(rv == -1)
return -errno;

5
src/release.cpp

@ -16,18 +16,17 @@
#include <fuse.h>
#include <unistd.h>
#include <string>
#include "errno.hpp"
#include "fileinfo.hpp"
#include "fs_base_close.hpp"
static
int
_release(FileInfo *fi)
{
::close(fi->fd);
fs::close(fi->fd);
delete fi;

12
src/removexattr.cpp

@ -19,21 +19,18 @@
#include <string>
#include <vector>
#include <sys/types.h>
#include "config.hpp"
#include "errno.hpp"
#include "fs_base_removexattr.hpp"
#include "fs_path.hpp"
#include "rv.hpp"
#include "rwlock.hpp"
#include "ugid.hpp"
#include "xattr.hpp"
using std::string;
using std::vector;
using mergerfs::Policy;
#ifndef WITHOUT_XATTR
static
int
_removexattr_loop_core(const string *basepath,
@ -46,7 +43,7 @@ _removexattr_loop_core(const string *basepath,
fs::path::make(basepath,fusepath,fullpath);
rv = ::lremovexattr(fullpath.c_str(),attrname);
rv = fs::lremovexattr(fullpath,attrname);
return calc_error(rv,error,errno);
}
@ -86,7 +83,6 @@ _removexattr(Policy::Func::Action actionFunc,
return _removexattr_loop(basepaths,fusepath,attrname);
}
#endif
namespace mergerfs
{
@ -96,7 +92,6 @@ namespace mergerfs
removexattr(const char *fusepath,
const char *attrname)
{
#ifndef WITHOUT_XATTR
const fuse_context *fc = fuse_get_context();
const Config &config = Config::get(fc);
@ -111,9 +106,6 @@ namespace mergerfs
config.minfreespace,
fusepath,
attrname);
#else
return -ENOTSUP;
#endif
}
}
}

10
src/rename.cpp

@ -14,9 +14,6 @@
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
#include <stdio.h>
#include <unistd.h>
#include <algorithm>
#include <set>
#include <string>
@ -24,6 +21,7 @@
#include "config.hpp"
#include "errno.hpp"
#include "fs_base_rename.hpp"
#include "fs_clonepath.hpp"
#include "fs_path.hpp"
#include "rv.hpp"
@ -88,7 +86,7 @@ _rename_create_path_core(const vector<const string*> &oldbasepaths,
fs::path::make(&oldbasepath,oldfusepath,oldfullpath);
rv = ::rename(oldfullpath.c_str(),newfullpath.c_str());
rv = fs::rename(oldfullpath,newfullpath);
error = calc_error(rv,error,errno);
if(RENAME_FAILED(rv))
tounlink.push_back(oldfullpath);
@ -217,14 +215,14 @@ _rename_preserve_path_core(Policy::Func::Search searchFunc,
fs::path::make(&oldbasepath,oldfusepath,oldfullpath);
rv = ::rename(oldfullpath.c_str(),newfullpath.c_str());
rv = fs::rename(oldfullpath,newfullpath);
if(RENAME_FAILED_WITH(rv,ENOENT))
{
rv = _clonepath_if_would_create(searchFunc,createFunc,
srcmounts,minfreespace,
oldbasepath,oldfusepath,newfusepath);
if(POLICY_SUCCEEDED(rv))
rv = ::rename(oldfullpath.c_str(),newfullpath.c_str());
rv = fs::rename(oldfullpath,newfullpath);
}
error = calc_error(rv,error,errno);

3
src/rmdir.cpp

@ -22,6 +22,7 @@
#include "config.hpp"
#include "errno.hpp"
#include "fs_base_rmdir.hpp"
#include "fs_path.hpp"
#include "rv.hpp"
#include "rwlock.hpp"
@ -42,7 +43,7 @@ _rmdir_loop_core(const string *basepath,
fs::path::make(basepath,fusepath,fullpath);
rv = ::rmdir(fullpath.c_str());
rv = fs::rmdir(fullpath);
return calc_error(rv,error,errno);
}

13
src/setxattr.cpp

@ -21,17 +21,16 @@
#include <sstream>
#include <string.h>
#include <sys/types.h>
#include "config.hpp"
#include "errno.hpp"
#include "fs_base_setxattr.hpp"
#include "fs_path.hpp"
#include "num.hpp"
#include "rv.hpp"
#include "rwlock.hpp"
#include "str.hpp"
#include "ugid.hpp"
#include "xattr.hpp"
using std::string;
using std::vector;
@ -287,8 +286,6 @@ _setxattr_controlfile(Config &config,
return -EINVAL;
}
#ifndef WITHOUT_XATTR
static
int
_setxattr_loop_core(const string *basepath,
@ -304,7 +301,7 @@ _setxattr_loop_core(const string *basepath,
fs::path::make(basepath,fusepath,fullpath);
rv = ::lsetxattr(fullpath.c_str(),attrname,attrval,attrvalsize,flags);
rv = fs::lsetxattr(fullpath,attrname,attrval,attrvalsize,flags);
return calc_error(rv,error,errno);
}
@ -352,8 +349,6 @@ _setxattr(Policy::Func::Action actionFunc,
return _setxattr_loop(basepaths,fusepath,attrname,attrval,attrvalsize,flags);
}
#endif
namespace mergerfs
{
namespace fuse
@ -374,7 +369,6 @@ namespace mergerfs
string(attrval,attrvalsize),
flags);
#ifndef WITHOUT_XATTR
const ugid::Set ugid(fc->uid,fc->gid);
const rwlock::ReadGuard readlock(&config.srcmountslock);
@ -386,9 +380,6 @@ namespace mergerfs
attrval,
attrvalsize,
flags);
#else
return -ENOTSUP;
#endif
}
}
}

8
src/statfs.cpp

@ -16,8 +16,6 @@
#include <fuse.h>
#include <sys/statvfs.h>
#include <algorithm>
#include <climits>
#include <map>
@ -26,6 +24,8 @@
#include "config.hpp"
#include "errno.hpp"
#include "fs_base_stat.hpp"
#include "fs_base_statvfs.hpp"
#include "rwlock.hpp"
#include "success_fail.hpp"
#include "ugid.hpp"
@ -75,11 +75,11 @@ _statfs_core(const char *srcmount,
struct stat st;
struct statvfs fsstat;
rv = ::statvfs(srcmount,&fsstat);
rv = fs::statvfs(srcmount,fsstat);
if(STATVFS_FAILED(rv))
return;
rv = ::stat(srcmount,&st);
rv = fs::stat(srcmount,st);
if(STAT_FAILED(rv))
return;

19
src/statvfs_util.hpp

@ -14,10 +14,10 @@
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
#include <sys/statvfs.h>
#include <string>
#include <sys/statvfs.h>
#include "success_fail.hpp"
namespace StatVFS
@ -30,21 +30,6 @@ namespace StatVFS
return (st.f_flag & ST_RDONLY);
}
static
inline
bool
readonly(const std::string &path)
{
int rv;
struct statvfs st;
rv = ::statvfs(path.c_str(),&st);
if(STATVFS_FAILED(rv))
return false;
return readonly(st);
}
static
inline
uint64_t

3
src/truncate.cpp

@ -24,6 +24,7 @@
#include "config.hpp"
#include "errno.hpp"
#include "fs_base_truncate.hpp"
#include "fs_path.hpp"
#include "rv.hpp"
#include "rwlock.hpp"
@ -45,7 +46,7 @@ _truncate_loop_core(const string *basepath,
fs::path::make(basepath,fusepath,fullpath);
rv = ::truncate(fullpath.c_str(),size);
rv = fs::truncate(fullpath,size);
return calc_error(rv,error,errno);
}

3
src/unlink.cpp

@ -23,6 +23,7 @@
#include "config.hpp"
#include "errno.hpp"
#include "fs_base_unlink.hpp"
#include "fs_path.hpp"
#include "rv.hpp"
#include "rwlock.hpp"
@ -43,7 +44,7 @@ _unlink_loop_core(const string *basepath,
fs::path::make(basepath,fusepath,fullpath);
rv = ::unlink(fullpath.c_str());
rv = fs::unlink(fullpath);
return calc_error(rv,error,errno);
}

4
src/utimens.cpp

@ -17,13 +17,13 @@
#include <fuse.h>
#include <fcntl.h>
#include <sys/stat.h>
#include <string>
#include <vector>
#include "config.hpp"
#include "errno.hpp"
#include "fs_base_utimensat.hpp"
#include "fs_path.hpp"
#include "rv.hpp"
#include "rwlock.hpp"
@ -45,7 +45,7 @@ _utimens_loop_core(const string *basepath,
fs::path::make(basepath,fusepath,fullpath);
rv = ::utimensat(0,fullpath.c_str(),ts,AT_SYMLINK_NOFOLLOW);
rv = fs::utimensat(AT_FDCWD,fullpath,ts,AT_SYMLINK_NOFOLLOW);
return calc_error(rv,error,errno);
}

5
src/write.cpp

@ -16,11 +16,10 @@
#include <fuse.h>
#include <unistd.h>
#include "config.hpp"
#include "errno.hpp"
#include "fileinfo.hpp"
#include "fs_base_write.hpp"
#include "fs_movefile.hpp"
#include "rwlock.hpp"
#include "ugid.hpp"
@ -42,7 +41,7 @@ _write(const int fd,
{
int rv;
rv = ::pwrite(fd,buf,count,offset);
rv = fs::pwrite(fd,buf,count,offset);
return ((rv == -1) ? -errno : rv);
}

Loading…
Cancel
Save