mirror of
https://github.com/trapexit/mergerfs.git
synced 2026-11-29 19:37:00 -05:00
FUSE: pass Branches::Ptr by value with empty-branches guards
Previously most FUSE ops took a reference to the live cfg.branches object. With atomic_load now producing a shared_ptr snapshot, pass it by value: the op works against a single stable view of the configuration for its whole lifetime, immune to concurrent reconfiguration. Also bail out with -ENOENT when the policy returns an empty branch set rather than dereferencing branches[0]. This was reachable if a policy rejected every branch (e.g. everything readonly while looking for a writable target). Covers access, chmod, chown, create, getattr, getxattr, ioctl, link, listxattr, mkdir, mknod, open, readdir (cor/cosr), readlink, removexattr, rename, rmdir, setxattr, statfs, statx, symlink, truncate, unlink, utimens. While here, in _getattr only dereference st_->st_mode when lstat succeeded (it is otherwise uninitialized).
This commit is contained in:
parent
4d813d4c0f
commit
1a6f4ad309
25 changed files with 110 additions and 45 deletions
|
|
@ -66,7 +66,7 @@ static
|
|||
int
|
||||
_chown(const Policy::Action &actionFunc_,
|
||||
const Policy::Search &searchFunc_,
|
||||
const Branches &branches_,
|
||||
const Branches::Ptr branches_,
|
||||
const fs::path &fusepath_,
|
||||
const uid_t uid_,
|
||||
const gid_t gid_)
|
||||
|
|
@ -78,6 +78,8 @@ _chown(const Policy::Action &actionFunc_,
|
|||
rv = actionFunc_(branches_,fusepath_,branches);
|
||||
if(rv < 0)
|
||||
return rv;
|
||||
if(branches.empty())
|
||||
return -ENOENT;
|
||||
|
||||
::_chown_loop(branches,fusepath_,uid_,gid_,&prv);
|
||||
|
||||
|
|
@ -90,6 +92,8 @@ _chown(const Policy::Action &actionFunc_,
|
|||
rv = searchFunc_(branches_,fusepath_,branches);
|
||||
if(rv < 0)
|
||||
return rv;
|
||||
if(branches.empty())
|
||||
return -ENOENT;
|
||||
|
||||
return prv.get_error(branches[0]->path);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue