mirror of
https://github.com/trapexit/mergerfs.git
synced 2025-02-09 05:40:47 +08:00
Merge pull request #1023 from trapexit/follow-symlink-fix
Fix query of attr during symlink
This commit is contained in:
commit
c4c35a9ad0
|
@ -239,8 +239,9 @@ namespace l
|
||||||
if(rv == 0)
|
if(rv == 0)
|
||||||
rv = FUSE::getattr(oldpath_,st_,timeouts_);
|
rv = FUSE::getattr(oldpath_,st_,timeouts_);
|
||||||
|
|
||||||
// Disable attr caching since we created a symlink but should be a regular.
|
// Disable caching since we created a symlink but should be a regular.
|
||||||
timeouts_->attr = 0;
|
timeouts_->attr = 0;
|
||||||
|
timeouts_->entry = 0;
|
||||||
|
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
@ -268,8 +269,9 @@ namespace l
|
||||||
if(rv == 0)
|
if(rv == 0)
|
||||||
rv = FUSE::getattr(oldpath_,st_,timeouts_);
|
rv = FUSE::getattr(oldpath_,st_,timeouts_);
|
||||||
|
|
||||||
// Disable attr caching since we created a symlink but should be a regular.
|
// Disable caching since we created a symlink but should be a regular.
|
||||||
timeouts_->attr = 0;
|
timeouts_->attr = 0;
|
||||||
|
timeouts_->entry = 0;
|
||||||
|
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
@ -292,8 +294,9 @@ namespace l
|
||||||
if(rv == 0)
|
if(rv == 0)
|
||||||
rv = FUSE::getattr(oldpath_,st_,timeouts_);
|
rv = FUSE::getattr(oldpath_,st_,timeouts_);
|
||||||
|
|
||||||
// Disable attr caching since we created a symlink but should be a regular.
|
// Disable caching since we created a symlink but should be a regular.
|
||||||
timeouts_->attr = 0;
|
timeouts_->attr = 0;
|
||||||
|
timeouts_->entry = 0;
|
||||||
|
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,7 +17,9 @@
|
||||||
#include "config.hpp"
|
#include "config.hpp"
|
||||||
#include "errno.hpp"
|
#include "errno.hpp"
|
||||||
#include "fs_clonepath.hpp"
|
#include "fs_clonepath.hpp"
|
||||||
|
#include "fs_lstat.hpp"
|
||||||
#include "fs_path.hpp"
|
#include "fs_path.hpp"
|
||||||
|
#include "fs_inode.hpp"
|
||||||
#include "fs_symlink.hpp"
|
#include "fs_symlink.hpp"
|
||||||
#include "fuse_getattr.hpp"
|
#include "fuse_getattr.hpp"
|
||||||
#include "ugid.hpp"
|
#include "ugid.hpp"
|
||||||
|
@ -59,6 +61,7 @@ namespace l
|
||||||
symlink_loop_core(const string &newbasepath_,
|
symlink_loop_core(const string &newbasepath_,
|
||||||
const char *target_,
|
const char *target_,
|
||||||
const char *linkpath_,
|
const char *linkpath_,
|
||||||
|
struct stat *st_,
|
||||||
const int error_)
|
const int error_)
|
||||||
{
|
{
|
||||||
int rv;
|
int rv;
|
||||||
|
@ -67,6 +70,12 @@ namespace l
|
||||||
fullnewpath = fs::path::make(newbasepath_,linkpath_);
|
fullnewpath = fs::path::make(newbasepath_,linkpath_);
|
||||||
|
|
||||||
rv = fs::symlink(target_,fullnewpath);
|
rv = fs::symlink(target_,fullnewpath);
|
||||||
|
if((rv != -1) && (st_ != NULL) && (st_->st_ino == 0))
|
||||||
|
{
|
||||||
|
fs::lstat(fullnewpath,st_);
|
||||||
|
if(st_->st_ino != 0)
|
||||||
|
fs::inode::calc(linkpath_,st_);
|
||||||
|
}
|
||||||
|
|
||||||
return error::calc(rv,error_,errno);
|
return error::calc(rv,error_,errno);
|
||||||
}
|
}
|
||||||
|
@ -77,7 +86,8 @@ namespace l
|
||||||
const StrVec &newbasepaths_,
|
const StrVec &newbasepaths_,
|
||||||
const char *target_,
|
const char *target_,
|
||||||
const char *linkpath_,
|
const char *linkpath_,
|
||||||
const string &newdirpath_)
|
const string &newdirpath_,
|
||||||
|
struct stat *st_)
|
||||||
{
|
{
|
||||||
int rv;
|
int rv;
|
||||||
int error;
|
int error;
|
||||||
|
@ -92,6 +102,7 @@ namespace l
|
||||||
error = l::symlink_loop_core(newbasepaths_[i],
|
error = l::symlink_loop_core(newbasepaths_[i],
|
||||||
target_,
|
target_,
|
||||||
linkpath_,
|
linkpath_,
|
||||||
|
st_,
|
||||||
error);
|
error);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -104,7 +115,8 @@ namespace l
|
||||||
const Policy::Create &createFunc_,
|
const Policy::Create &createFunc_,
|
||||||
const Branches &branches_,
|
const Branches &branches_,
|
||||||
const char *target_,
|
const char *target_,
|
||||||
const char *linkpath_)
|
const char *linkpath_,
|
||||||
|
struct stat *st_)
|
||||||
{
|
{
|
||||||
int rv;
|
int rv;
|
||||||
string newdirpath;
|
string newdirpath;
|
||||||
|
@ -122,7 +134,7 @@ namespace l
|
||||||
return -errno;
|
return -errno;
|
||||||
|
|
||||||
return l::symlink_loop(existingpaths[0],newbasepaths,
|
return l::symlink_loop(existingpaths[0],newbasepaths,
|
||||||
target_,linkpath_,newdirpath);
|
target_,linkpath_,newdirpath,st_);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -130,31 +142,39 @@ namespace FUSE
|
||||||
{
|
{
|
||||||
int
|
int
|
||||||
symlink(const char *target_,
|
symlink(const char *target_,
|
||||||
const char *linkpath_)
|
const char *linkpath_,
|
||||||
|
struct stat *st_,
|
||||||
|
fuse_timeouts_t *timeouts_)
|
||||||
{
|
{
|
||||||
|
int rv;
|
||||||
Config::Read cfg;
|
Config::Read cfg;
|
||||||
const fuse_context *fc = fuse_get_context();
|
const fuse_context *fc = fuse_get_context();
|
||||||
const ugid::Set ugid(fc->uid,fc->gid);
|
const ugid::Set ugid(fc->uid,fc->gid);
|
||||||
|
|
||||||
return l::symlink(cfg->func.getattr.policy,
|
rv = l::symlink(cfg->func.getattr.policy,
|
||||||
cfg->func.symlink.policy,
|
cfg->func.symlink.policy,
|
||||||
cfg->branches,
|
cfg->branches,
|
||||||
target_,
|
target_,
|
||||||
linkpath_);
|
linkpath_,
|
||||||
|
st_);
|
||||||
|
|
||||||
|
if(timeouts_ != NULL)
|
||||||
|
{
|
||||||
|
switch(cfg->follow_symlinks)
|
||||||
|
{
|
||||||
|
case FollowSymlinks::ENUM::NEVER:
|
||||||
|
timeouts_->entry = ((rv >= 0) ?
|
||||||
|
cfg->cache_entry :
|
||||||
|
cfg->cache_negative_entry);
|
||||||
|
timeouts_->attr = cfg->cache_attr;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
timeouts_->entry = 0;
|
||||||
|
timeouts_->attr = 0;
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
|
||||||
symlink(const char *target_,
|
|
||||||
const char *linkpath_,
|
|
||||||
struct stat *st_,
|
|
||||||
fuse_timeouts_t *timeout_)
|
|
||||||
{
|
|
||||||
int rv;
|
|
||||||
|
|
||||||
rv = FUSE::symlink(target_,linkpath_);
|
|
||||||
if(rv < 0)
|
|
||||||
return rv;
|
return rv;
|
||||||
|
|
||||||
return FUSE::getattr(linkpath_,st_,timeout_);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,13 +22,9 @@
|
||||||
|
|
||||||
namespace FUSE
|
namespace FUSE
|
||||||
{
|
{
|
||||||
int
|
|
||||||
symlink(const char *target,
|
|
||||||
const char *linkpath);
|
|
||||||
|
|
||||||
int
|
int
|
||||||
symlink(const char *target,
|
symlink(const char *target,
|
||||||
const char *linkpath,
|
const char *linkpath,
|
||||||
struct stat *st,
|
struct stat *st = NULL,
|
||||||
fuse_timeouts_t *timeouts);
|
fuse_timeouts_t *timeouts = NULL);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user