mirror of
https://github.com/trapexit/mergerfs.git
synced 2026-11-25 17:36:25 -05:00
checkpoint
This commit is contained in:
parent
7a81a5112c
commit
8f6467a11c
34 changed files with 462 additions and 954 deletions
|
|
@ -14,129 +14,12 @@
|
|||
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "config.hpp"
|
||||
#include "errno.hpp"
|
||||
#include "fs_clonepath.hpp"
|
||||
#include "fs_link.hpp"
|
||||
#include "fs_lstat.hpp"
|
||||
#include "fs_path.hpp"
|
||||
#include "fuse_getattr.hpp"
|
||||
#include "fuse_symlink.hpp"
|
||||
#include "state.hpp"
|
||||
#include "ugid.hpp"
|
||||
|
||||
#include "fuse.h"
|
||||
|
||||
|
||||
namespace l
|
||||
{
|
||||
static
|
||||
int
|
||||
link_exdev_rel_symlink(const char *oldpath_,
|
||||
const char *newpath_,
|
||||
struct stat *st_,
|
||||
fuse_timeouts_t *timeouts_)
|
||||
{
|
||||
int rv;
|
||||
gfs::path target(oldpath_);
|
||||
gfs::path linkpath(newpath_);
|
||||
|
||||
target = target.lexically_relative(linkpath.parent_path());
|
||||
|
||||
rv = FUSE::SYMLINK::symlink(target.c_str(),linkpath.c_str());
|
||||
if(rv == 0)
|
||||
rv = FUSE::GETATTR::getattr(oldpath_,st_,timeouts_);
|
||||
|
||||
// Disable caching since we created a symlink but should be a regular.
|
||||
timeouts_->attr = 0;
|
||||
timeouts_->entry = 0;
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
static
|
||||
int
|
||||
link_exdev_abs_base_symlink(const char *oldpath_,
|
||||
const char *newpath_,
|
||||
struct stat *st_,
|
||||
fuse_timeouts_t *timeouts_)
|
||||
{
|
||||
int rv;
|
||||
StrVec basepaths;
|
||||
gfs::path target;
|
||||
|
||||
target = "FIXME";
|
||||
|
||||
rv = FUSE::SYMLINK::symlink(target.c_str(),newpath_);
|
||||
if(rv == 0)
|
||||
rv = FUSE::GETATTR::getattr(oldpath_,st_,timeouts_);
|
||||
|
||||
// Disable caching since we created a symlink but should be a regular.
|
||||
timeouts_->attr = 0;
|
||||
timeouts_->entry = 0;
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
static
|
||||
int
|
||||
link_exdev_abs_pool_symlink(const gfs::path &mount_,
|
||||
const char *oldpath_,
|
||||
const char *newpath_,
|
||||
struct stat *st_,
|
||||
fuse_timeouts_t *timeouts_)
|
||||
{
|
||||
int rv;
|
||||
gfs::path target;
|
||||
|
||||
target = mount_ / &oldpath_[1];
|
||||
|
||||
rv = FUSE::SYMLINK::symlink(target.c_str(),newpath_);
|
||||
if(rv == 0)
|
||||
rv = FUSE::GETATTR::getattr(oldpath_,st_,timeouts_);
|
||||
|
||||
// Disable caching since we created a symlink but should be a regular.
|
||||
timeouts_->attr = 0;
|
||||
timeouts_->entry = 0;
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
static
|
||||
int
|
||||
link_exdev(State &s_,
|
||||
const char *oldpath_,
|
||||
const char *newpath_,
|
||||
struct stat *st_,
|
||||
fuse_timeouts_t *timeouts_)
|
||||
{
|
||||
switch(s_->link_exdev)
|
||||
{
|
||||
case LinkEXDEV::INVALID:
|
||||
case LinkEXDEV::PASSTHROUGH:
|
||||
return -EXDEV;
|
||||
case LinkEXDEV::REL_SYMLINK:
|
||||
return l::link_exdev_rel_symlink(oldpath_,
|
||||
newpath_,
|
||||
st_,
|
||||
timeouts_);
|
||||
case LinkEXDEV::ABS_BASE_SYMLINK:
|
||||
return l::link_exdev_abs_base_symlink(oldpath_,
|
||||
newpath_,
|
||||
st_,
|
||||
timeouts_);
|
||||
case LinkEXDEV::ABS_POOL_SYMLINK:
|
||||
return l::link_exdev_abs_pool_symlink(s_->mountpoint,
|
||||
oldpath_,
|
||||
newpath_,
|
||||
st_,
|
||||
timeouts_);
|
||||
}
|
||||
|
||||
return -EXDEV;
|
||||
}
|
||||
}
|
||||
|
||||
namespace FUSE::LINK
|
||||
{
|
||||
int
|
||||
|
|
@ -155,8 +38,8 @@ namespace FUSE::LINK
|
|||
oldpath = &oldpath_[1];
|
||||
newpath = &newpath_[1];
|
||||
rv = s->link(oldpath,newpath);
|
||||
if(rv == -EXDEV)
|
||||
return l::link_exdev(s,oldpath_,newpath_,st_,timeouts_);
|
||||
if(rv < 0)
|
||||
return rv;
|
||||
|
||||
return s->getattr(newpath,st_,timeouts_);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue