mirror of https://github.com/trapexit/mergerfs.git
trapexit
6 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
40 changed files with 554 additions and 427 deletions
-
7.travis.yml
-
3src/create.cpp
-
94src/fs.cpp
-
20src/fs.hpp
-
6src/fs_acl.cpp
-
4src/fs_base_statvfs.hpp
-
3src/fs_clonepath.cpp
-
6src/fs_copy_file_range_linux.icpp
-
76src/fs_exists.hpp
-
68src/fs_info.cpp
-
35src/fs_info.hpp
-
31src/fs_info_t.hpp
-
4src/fs_movefile.cpp
-
31src/fs_path.cpp
-
20src/fs_path.hpp
-
6src/link.cpp
-
3src/mkdir.cpp
-
3src/mknod.cpp
-
33src/policy_all.cpp
-
36src/policy_epall.cpp
-
48src/policy_epff.cpp
-
48src/policy_eplfs.cpp
-
48src/policy_eplus.cpp
-
48src/policy_epmfs.cpp
-
7src/policy_eprand.cpp
-
6src/policy_erofs.cpp
-
31src/policy_ff.cpp
-
6src/policy_invalid.cpp
-
44src/policy_lfs.cpp
-
44src/policy_lus.cpp
-
40src/policy_mfs.cpp
-
41src/policy_newest.cpp
-
7src/policy_rand.cpp
-
2src/readdir.cpp
-
9src/rename.cpp
-
5src/statfs.cpp
-
4src/statvfs_util.hpp
-
8src/strset.hpp
-
43src/success_fail.hpp
-
3src/symlink.cpp
@ -0,0 +1,76 @@ |
|||
/*
|
|||
ISC License |
|||
|
|||
Copyright (c) 2018, 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. |
|||
*/ |
|||
|
|||
#pragma once
|
|||
|
|||
#include "fs_base_stat.hpp"
|
|||
#include "fs_path.hpp"
|
|||
|
|||
#include <string>
|
|||
|
|||
namespace fs |
|||
{ |
|||
static |
|||
inline |
|||
bool |
|||
exists(const std::string &path_, |
|||
struct stat &st_) |
|||
{ |
|||
int rv; |
|||
|
|||
rv = fs::lstat(path_,st_); |
|||
|
|||
return (rv == 0); |
|||
} |
|||
|
|||
static |
|||
inline |
|||
bool |
|||
exists(const std::string &path_) |
|||
{ |
|||
struct stat st; |
|||
|
|||
return fs::exists(path_,st); |
|||
} |
|||
|
|||
|
|||
static |
|||
inline |
|||
bool |
|||
exists(const std::string &basepath_, |
|||
const char *relpath_, |
|||
struct stat &st_) |
|||
{ |
|||
std::string fullpath; |
|||
|
|||
fullpath = fs::path::make(&basepath_,relpath_); |
|||
|
|||
return fs::exists(fullpath,st_); |
|||
} |
|||
|
|||
static |
|||
inline |
|||
bool |
|||
exists(const std::string &basepath_, |
|||
const char *relpath_) |
|||
{ |
|||
struct stat st; |
|||
|
|||
return fs::exists(basepath_,relpath_,st); |
|||
} |
|||
} |
@ -0,0 +1,68 @@ |
|||
/*
|
|||
ISC License |
|||
|
|||
Copyright (c) 2018, 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 "fs_base_stat.hpp"
|
|||
#include "fs_base_statvfs.hpp"
|
|||
#include "fs_info_t.hpp"
|
|||
#include "fs_path.hpp"
|
|||
#include "statvfs_util.hpp"
|
|||
|
|||
#include <stdint.h>
|
|||
|
|||
#include <string>
|
|||
|
|||
using std::string; |
|||
|
|||
namespace fs |
|||
{ |
|||
int |
|||
info(const string *path_, |
|||
fs::info_t *info_) |
|||
{ |
|||
int rv; |
|||
struct statvfs st; |
|||
|
|||
rv = fs::statvfs(*path_,st); |
|||
if(rv == 0) |
|||
{ |
|||
info_->readonly = StatVFS::readonly(st); |
|||
info_->spaceavail = StatVFS::spaceavail(st); |
|||
info_->spaceused = StatVFS::spaceused(st); |
|||
} |
|||
|
|||
return rv; |
|||
} |
|||
|
|||
int |
|||
info(const string *basepath_, |
|||
const char *relpath_, |
|||
fs::info_t *info_) |
|||
{ |
|||
int rv; |
|||
string fullpath; |
|||
struct stat st; |
|||
|
|||
fullpath = fs::path::make(basepath_,relpath_); |
|||
|
|||
rv = fs::lstat(fullpath,st); |
|||
if(rv == -1) |
|||
return -1; |
|||
|
|||
return fs::info(basepath_,info_); |
|||
} |
|||
} |
@ -0,0 +1,35 @@ |
|||
/*
|
|||
ISC License |
|||
|
|||
Copyright (c) 2018, 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. |
|||
*/ |
|||
|
|||
#pragma once
|
|||
|
|||
#include "fs_info_t.hpp"
|
|||
|
|||
#include <string>
|
|||
|
|||
namespace fs |
|||
{ |
|||
int |
|||
info(const std::string *basepath_, |
|||
const char *relpath_, |
|||
fs::info_t *info_); |
|||
|
|||
int |
|||
info(const std::string *path_, |
|||
fs::info_t *info_); |
|||
} |
@ -0,0 +1,31 @@ |
|||
/*
|
|||
ISC License |
|||
|
|||
Copyright (c) 2018, 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. |
|||
*/ |
|||
|
|||
#pragma once
|
|||
|
|||
#include <stdint.h>
|
|||
|
|||
namespace fs |
|||
{ |
|||
struct info_t |
|||
{ |
|||
bool readonly; |
|||
uint64_t spaceavail; |
|||
uint64_t spaceused; |
|||
}; |
|||
} |
@ -1,43 +0,0 @@ |
|||
/*
|
|||
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. |
|||
*/ |
|||
|
|||
#pragma once
|
|||
|
|||
#define STATVFS_SUCCESS 0
|
|||
#define STATVFS_SUCCEEDED(RV) ((RV) == STATVFS_SUCCESS)
|
|||
#define STATVFS_FAIL -1
|
|||
#define STATVFS_FAILED(RV) ((RV) == STATVFS_FAIL)
|
|||
|
|||
#define STAT_SUCCESS 0
|
|||
#define STAT_SUCCEEDED(RV) ((RV) == STAT_SUCCESS)
|
|||
#define STAT_FAIL -1
|
|||
#define STAT_FAILED(RV) ((RV) == STAT_FAIL)
|
|||
|
|||
#define LSTAT_SUCCESS 0
|
|||
#define LSTAT_SUCCEEDED(RV) ((RV) == LSTAT_SUCCESS)
|
|||
#define LSTAT_FAIL -1
|
|||
#define LSTAT_FAILED(RV) ((RV) == LSTAT_FAIL)
|
|||
|
|||
#define FSTAT_SUCCESS 0
|
|||
#define FSTAT_SUCCEEDED(RV) ((RV) == FSTAT_SUCCESS)
|
|||
#define FSTAT_FAIL -1
|
|||
#define FSTAT_FAILED(RV) ((RV) == FSTAT_FAIL)
|
|||
|
|||
#define RENAME_SUCCESS 0
|
|||
#define RENAME_SUCCEEDED(RV) ((RV) == RENAME_SUCCESS)
|
|||
#define RENAME_FAIL -1
|
|||
#define RENAME_FAILED(RV) ((RV) == RENAME_FAIL)
|
|||
#define RENAME_FAILED_WITH(RV,ERRNO) (((RV) == RENAME_FAIL) && (errno == ERRNO))
|
Write
Preview
Loading…
Cancel
Save
Reference in new issue