From 86d845e385c7927398aa7d83330b05a42c7f079b Mon Sep 17 00:00:00 2001 From: Antonio SJ Musumeci Date: Wed, 25 Nov 2026 13:51:20 -0500 Subject: [PATCH] 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. --- mkdocs/docs/config/link-exdev.md | 6 ++++++ src/fuse_link.cpp | 7 +++++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/mkdocs/docs/config/link-exdev.md b/mkdocs/docs/config/link-exdev.md index fa351997..656d3524 100644 --- a/mkdocs/docs/config/link-exdev.md +++ b/mkdocs/docs/config/link-exdev.md @@ -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. diff --git a/src/fuse_link.cpp b/src/fuse_link.cpp index 6ea2aff3..f1595e84 100644 --- a/src/fuse_link.cpp +++ b/src/fuse_link.cpp @@ -292,8 +292,11 @@ _link_exdev(const fs::path &oldpath_, fs::path oldfullpath; std::vector 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;