mirror of
https://github.com/trapexit/mergerfs.git
synced 2026-10-26 19:01:56 -04:00
Change getattr and statx to bespoke policies
* Provides: slight improvement in performance as it no longer will need to find and then act on the files. * It doesn't make sense to support all original policy types. Most people used 'newest' or 'ff' and 'combine' is a better default which has same runtime as 'newest' but with better output.
This commit is contained in:
parent
965e26989c
commit
b3b8e793f9
145 changed files with 3803 additions and 1192 deletions
104
src/func_readlink_ff.cpp
Normal file
104
src/func_readlink_ff.cpp
Normal file
|
|
@ -0,0 +1,104 @@
|
|||
#include "func_readlink_ff.hpp"
|
||||
|
||||
#include "error.hpp"
|
||||
#include "fs_readlink.hpp"
|
||||
#include "fs_lstat.hpp"
|
||||
#include "symlinkify.hpp"
|
||||
|
||||
#include <cstring>
|
||||
|
||||
|
||||
std::string_view
|
||||
Func2::ReadlinkFF::name() const
|
||||
{
|
||||
return "ff";
|
||||
}
|
||||
|
||||
static
|
||||
int
|
||||
_readlink_symlinkify(const Branches &branches_,
|
||||
const fs::path &fusepath_,
|
||||
char *buf_,
|
||||
const size_t bufsize_,
|
||||
const time_t symlinkify_timeout_)
|
||||
{
|
||||
int rv;
|
||||
Err err;
|
||||
struct stat st;
|
||||
fs::path fullpath;
|
||||
|
||||
for(const auto &branch : branches_)
|
||||
{
|
||||
fullpath = branch.path / fusepath_;
|
||||
|
||||
err = rv = fs::lstat(fullpath,&st);
|
||||
if(rv < 0)
|
||||
continue;
|
||||
|
||||
if(not symlinkify::can_be_symlink(st,symlinkify_timeout_))
|
||||
{
|
||||
err = rv = fs::readlink(fusepath_,buf_,bufsize_);
|
||||
if(rv < 0)
|
||||
continue;
|
||||
|
||||
buf_[rv] = '\0';
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
strncpy(buf_,fullpath.c_str(),bufsize_);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
static
|
||||
int
|
||||
_readlink(const Branches &branches_,
|
||||
const fs::path &fusepath_,
|
||||
char *buf_,
|
||||
const size_t bufsize_)
|
||||
{
|
||||
int rv;
|
||||
Err err;
|
||||
fs::path fullpath;
|
||||
|
||||
for(const auto &branch : branches_)
|
||||
{
|
||||
fullpath = branch.path / fusepath_;
|
||||
|
||||
err = rv = fs::readlink(fusepath_,buf_,bufsize_);
|
||||
if(rv < 0)
|
||||
continue;
|
||||
|
||||
buf_[rv] = '\0';
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
|
||||
|
||||
int
|
||||
Func2::ReadlinkFF::operator()(const Branches &branches_,
|
||||
const fs::path &fusepath_,
|
||||
char *buf_,
|
||||
const size_t bufsize_,
|
||||
const time_t symlinkify_timeout_)
|
||||
{
|
||||
if(symlinkify_timeout_ > 0)
|
||||
return ::_readlink_symlinkify(branches_,
|
||||
fusepath_,
|
||||
buf_,
|
||||
bufsize_,
|
||||
symlinkify_timeout_);
|
||||
|
||||
return ::_readlink(branches_,
|
||||
fusepath_,
|
||||
buf_,
|
||||
bufsize_);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue