mirror of
https://github.com/trapexit/mergerfs.git
synced 2026-10-26 19:01:56 -04:00
Move everything to negative errno return types (#1499)
This commit is contained in:
parent
2b500f194a
commit
e8cd74cab0
177 changed files with 5952 additions and 5843 deletions
276
src/fs_inode.cpp
276
src/fs_inode.cpp
|
|
@ -31,18 +31,18 @@ typedef uint64_t (*inodefunc_t)(const std::string_view,
|
|||
const mode_t,
|
||||
const ino_t);
|
||||
|
||||
static uint64_t hybrid_hash(const std::string_view,
|
||||
const std::string_view,
|
||||
const mode_t,
|
||||
const ino_t);
|
||||
static uint64_t _hybrid_hash(const std::string_view,
|
||||
const std::string_view,
|
||||
const mode_t,
|
||||
const ino_t);
|
||||
|
||||
|
||||
static inodefunc_t g_func = hybrid_hash;
|
||||
static inodefunc_t g_func = ::_hybrid_hash;
|
||||
|
||||
|
||||
static
|
||||
uint32_t
|
||||
h64_to_h32(uint64_t h_)
|
||||
_h64_to_h32(uint64_t h_)
|
||||
{
|
||||
h_ ^= (h_ >> 32);
|
||||
h_ *= 0x9E3779B9;
|
||||
|
|
@ -51,20 +51,20 @@ h64_to_h32(uint64_t h_)
|
|||
|
||||
static
|
||||
uint64_t
|
||||
passthrough(const std::string_view branch_path_,
|
||||
const std::string_view fusepath_,
|
||||
const mode_t mode_,
|
||||
const ino_t ino_)
|
||||
_passthrough(const std::string_view branch_path_,
|
||||
const std::string_view fusepath_,
|
||||
const mode_t mode_,
|
||||
const ino_t ino_)
|
||||
{
|
||||
return ino_;
|
||||
}
|
||||
|
||||
static
|
||||
uint64_t
|
||||
path_hash(const std::string_view branch_path_,
|
||||
const std::string_view fusepath_,
|
||||
const mode_t mode_,
|
||||
const ino_t ino_)
|
||||
_path_hash(const std::string_view branch_path_,
|
||||
const std::string_view fusepath_,
|
||||
const mode_t mode_,
|
||||
const ino_t ino_)
|
||||
{
|
||||
uint64_t seed;
|
||||
|
||||
|
|
@ -75,27 +75,27 @@ path_hash(const std::string_view branch_path_,
|
|||
|
||||
static
|
||||
uint64_t
|
||||
path_hash32(const std::string_view branch_path_,
|
||||
const std::string_view fusepath_,
|
||||
const mode_t mode_,
|
||||
const ino_t ino_)
|
||||
_path_hash32(const std::string_view branch_path_,
|
||||
const std::string_view fusepath_,
|
||||
const mode_t mode_,
|
||||
const ino_t ino_)
|
||||
{
|
||||
uint64_t h;
|
||||
|
||||
h = path_hash(branch_path_,
|
||||
fusepath_,
|
||||
mode_,
|
||||
ino_);
|
||||
h = ::_path_hash(branch_path_,
|
||||
fusepath_,
|
||||
mode_,
|
||||
ino_);
|
||||
|
||||
return h64_to_h32(h);
|
||||
return ::_h64_to_h32(h);
|
||||
}
|
||||
|
||||
static
|
||||
uint64_t
|
||||
devino_hash(const std::string_view branch_path_,
|
||||
const std::string_view fusepath_,
|
||||
const mode_t mode_,
|
||||
const ino_t ino_)
|
||||
_devino_hash(const std::string_view branch_path_,
|
||||
const std::string_view fusepath_,
|
||||
const mode_t mode_,
|
||||
const ino_t ino_)
|
||||
{
|
||||
uint64_t seed;
|
||||
|
||||
|
|
@ -107,122 +107,116 @@ devino_hash(const std::string_view branch_path_,
|
|||
|
||||
static
|
||||
uint64_t
|
||||
devino_hash32(const std::string_view branch_path_,
|
||||
const std::string_view fusepath_,
|
||||
const mode_t mode_,
|
||||
const ino_t ino_)
|
||||
_devino_hash32(const std::string_view branch_path_,
|
||||
const std::string_view fusepath_,
|
||||
const mode_t mode_,
|
||||
const ino_t ino_)
|
||||
{
|
||||
uint64_t h;
|
||||
|
||||
h = devino_hash(branch_path_,
|
||||
h = ::_devino_hash(branch_path_,
|
||||
fusepath_,
|
||||
mode_,
|
||||
ino_);
|
||||
|
||||
return ::_h64_to_h32(h);
|
||||
}
|
||||
|
||||
static
|
||||
uint64_t
|
||||
_hybrid_hash(const std::string_view branch_path_,
|
||||
const std::string_view fusepath_,
|
||||
const mode_t mode_,
|
||||
const ino_t ino_)
|
||||
{
|
||||
return (S_ISDIR(mode_) ?
|
||||
::_path_hash(branch_path_,fusepath_,mode_,ino_) :
|
||||
::_devino_hash(branch_path_,fusepath_,mode_,ino_));
|
||||
}
|
||||
|
||||
static
|
||||
uint64_t
|
||||
_hybrid_hash32(const std::string_view branch_path_,
|
||||
const std::string_view fusepath_,
|
||||
const mode_t mode_,
|
||||
const ino_t ino_)
|
||||
{
|
||||
return (S_ISDIR(mode_) ?
|
||||
::_path_hash32(branch_path_,fusepath_,mode_,ino_) :
|
||||
::_devino_hash32(branch_path_,fusepath_,mode_,ino_));
|
||||
}
|
||||
|
||||
int
|
||||
fs::inode::set_algo(const std::string &algo_)
|
||||
{
|
||||
if(algo_ == "passthrough")
|
||||
g_func = ::_passthrough;
|
||||
ef(algo_ == "path-hash")
|
||||
g_func = ::_path_hash;
|
||||
ef(algo_ == "path-hash32")
|
||||
g_func = ::_path_hash32;
|
||||
ef(algo_ == "devino-hash")
|
||||
g_func = ::_devino_hash;
|
||||
ef(algo_ == "devino-hash32")
|
||||
g_func = ::_devino_hash32;
|
||||
ef(algo_ == "hybrid-hash")
|
||||
g_func = ::_hybrid_hash;
|
||||
ef(algo_ == "hybrid-hash32")
|
||||
g_func = ::_hybrid_hash32;
|
||||
else
|
||||
return -EINVAL;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
std::string
|
||||
fs::inode::get_algo(void)
|
||||
{
|
||||
if(g_func == ::_passthrough)
|
||||
return "passthrough";
|
||||
if(g_func == ::_path_hash)
|
||||
return "path-hash";
|
||||
if(g_func == ::_path_hash32)
|
||||
return "path-hash32";
|
||||
if(g_func == ::_devino_hash)
|
||||
return "devino-hash";
|
||||
if(g_func == ::_devino_hash32)
|
||||
return "devino-hash32";
|
||||
if(g_func == ::_hybrid_hash)
|
||||
return "hybrid-hash";
|
||||
if(g_func == ::_hybrid_hash32)
|
||||
return "hybrid-hash32";
|
||||
|
||||
return {};
|
||||
}
|
||||
|
||||
uint64_t
|
||||
fs::inode::calc(const std::string_view branch_path_,
|
||||
const std::string_view fusepath_,
|
||||
const mode_t mode_,
|
||||
const ino_t ino_)
|
||||
{
|
||||
return g_func(branch_path_,fusepath_,mode_,ino_);
|
||||
}
|
||||
|
||||
void
|
||||
fs::inode::calc(const std::string_view branch_path_,
|
||||
const std::string_view fusepath_,
|
||||
struct stat *st_)
|
||||
{
|
||||
st_->st_ino = calc(branch_path_,
|
||||
fusepath_,
|
||||
st_->st_mode,
|
||||
st_->st_ino);
|
||||
}
|
||||
|
||||
void
|
||||
fs::inode::calc(const std::string_view branch_path_,
|
||||
const std::string_view fusepath_,
|
||||
struct fuse_statx *st_)
|
||||
{
|
||||
st_->ino = calc(branch_path_,
|
||||
fusepath_,
|
||||
mode_,
|
||||
ino_);
|
||||
|
||||
return h64_to_h32(h);
|
||||
}
|
||||
|
||||
static
|
||||
uint64_t
|
||||
hybrid_hash(const std::string_view branch_path_,
|
||||
const std::string_view fusepath_,
|
||||
const mode_t mode_,
|
||||
const ino_t ino_)
|
||||
{
|
||||
return (S_ISDIR(mode_) ?
|
||||
path_hash(branch_path_,fusepath_,mode_,ino_) :
|
||||
devino_hash(branch_path_,fusepath_,mode_,ino_));
|
||||
}
|
||||
|
||||
static
|
||||
uint64_t
|
||||
hybrid_hash32(const std::string_view branch_path_,
|
||||
const std::string_view fusepath_,
|
||||
const mode_t mode_,
|
||||
const ino_t ino_)
|
||||
{
|
||||
return (S_ISDIR(mode_) ?
|
||||
path_hash32(branch_path_,fusepath_,mode_,ino_) :
|
||||
devino_hash32(branch_path_,fusepath_,mode_,ino_));
|
||||
}
|
||||
|
||||
namespace fs
|
||||
{
|
||||
namespace inode
|
||||
{
|
||||
int
|
||||
set_algo(const std::string &algo_)
|
||||
{
|
||||
if(algo_ == "passthrough")
|
||||
g_func = passthrough;
|
||||
ef(algo_ == "path-hash")
|
||||
g_func = path_hash;
|
||||
ef(algo_ == "path-hash32")
|
||||
g_func = path_hash32;
|
||||
ef(algo_ == "devino-hash")
|
||||
g_func = devino_hash;
|
||||
ef(algo_ == "devino-hash32")
|
||||
g_func = devino_hash32;
|
||||
ef(algo_ == "hybrid-hash")
|
||||
g_func = hybrid_hash;
|
||||
ef(algo_ == "hybrid-hash32")
|
||||
g_func = hybrid_hash32;
|
||||
else
|
||||
return -EINVAL;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
std::string
|
||||
get_algo(void)
|
||||
{
|
||||
if(g_func == passthrough)
|
||||
return "passthrough";
|
||||
if(g_func == path_hash)
|
||||
return "path-hash";
|
||||
if(g_func == path_hash32)
|
||||
return "path-hash32";
|
||||
if(g_func == devino_hash)
|
||||
return "devino-hash";
|
||||
if(g_func == devino_hash32)
|
||||
return "devino-hash32";
|
||||
if(g_func == hybrid_hash)
|
||||
return "hybrid-hash";
|
||||
if(g_func == hybrid_hash32)
|
||||
return "hybrid-hash32";
|
||||
|
||||
return std::string();
|
||||
}
|
||||
|
||||
uint64_t
|
||||
calc(const std::string_view branch_path_,
|
||||
const std::string_view fusepath_,
|
||||
const mode_t mode_,
|
||||
const ino_t ino_)
|
||||
{
|
||||
return g_func(branch_path_,fusepath_,mode_,ino_);
|
||||
}
|
||||
|
||||
void
|
||||
calc(const std::string_view branch_path_,
|
||||
const std::string_view fusepath_,
|
||||
struct stat *st_)
|
||||
{
|
||||
st_->st_ino = calc(branch_path_,
|
||||
fusepath_,
|
||||
st_->st_mode,
|
||||
st_->st_ino);
|
||||
}
|
||||
|
||||
void
|
||||
calc(const std::string_view branch_path_,
|
||||
const std::string_view fusepath_,
|
||||
struct fuse_statx *st_)
|
||||
{
|
||||
st_->ino = calc(branch_path_,
|
||||
fusepath_,
|
||||
st_->mode,
|
||||
st_->ino);
|
||||
}
|
||||
}
|
||||
st_->mode,
|
||||
st_->ino);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue