fix: use one link-exdev decision per request

An administrator changing link-exdev during a request could make
source selection use one mode and link construction another. Read the
option once per request and use that value for both.

Document that branch selection and target construction share one
branch snapshot, while the replacement symlink is created by the
symlink create policy on the current branch configuration.
This commit is contained in:
Antonio SJ Musumeci 2026-11-25 13:51:20 -05:00
parent c9854f236f
commit 86d845e385
2 changed files with 11 additions and 2 deletions

View file

@ -39,6 +39,12 @@ default). A replacement symlink owned by the source's owner there would
be unusable by everyone else, root included, so in that case mergerfs
does not use the fallback and returns `EXDEV`, as if it were set to
`passthrough`.
Source branch selection and target path construction retain the same
branch snapshot, even when the branch list is updated at runtime. The
replacement symlink itself is created through the symlink create policy
on the current branch configuration, which may differ from that
snapshot.
**NOTE:** It is possible that some applications check the file they
link. In those cases, it is possible it will error or complain.

View file

@ -292,8 +292,11 @@ _link_exdev(const fs::path &oldpath_,
fs::path oldfullpath;
std::vector<Branch*> oldbranches;
const Policy::Search *sourcePolicy;
// Read once: link-exdev can be changed at runtime and the source
// branch selection below must match the mode dispatched on.
const LinkEXDEV::ENUM mode = cfg.link_exdev;
switch(cfg.link_exdev)
switch(mode)
{
case LinkEXDEV::ENUM::REL_SYMLINK:
case LinkEXDEV::ENUM::ABS_POOL_SYMLINK:
@ -320,7 +323,7 @@ _link_exdev(const fs::path &oldpath_,
const ugid_t owner{source.st_uid,source.st_gid};
switch(cfg.link_exdev)
switch(mode)
{
case LinkEXDEV::ENUM::PASSTHROUGH:
return -EXDEV;