fix: initialize EXDEV rename staging for root sources

This commit is contained in:
Antonio SJ Musumeci 2026-10-28 12:12:26 -05:00 • committed by trapexit
parent 3d81e24f32
commit 7b7e96bbc5
3 changed files with 15 additions and 7 deletions

View file

@ -14,8 +14,9 @@ The `target` value is determined by the value of `rename-exdev`.
mount point.
* Defaults to `passthrough`.
Relative targets are calculated within the pool's relative path
namespace.
The staging directory is created on demand, including for files at the
pool root. Relative targets are calculated within the pool's relative
path namespace.
**NOTE:** It is possible that some applications check the file they
rename. In those cases it is possible it will error or complain.

View file

@ -220,12 +220,11 @@ _rename_exdev_rename_target(const Policy::Action &actionPolicy_,
clonedst = branch->path;
clonedst /= ".mergerfs_rename_exdev";
rv = fs::mkdir_as({0,0},clonedst,01777);
if((rv < 0) && (rv != -EEXIST))
goto error;
rv = fs::clonepath(clonesrc,clonedst,oldfusepath_.parent_path());
if(rv == -ENOENT)
{
fs::mkdir_as({0,0},clonedst,01777);
rv = fs::clonepath(clonesrc,clonedst,oldfusepath_.parent_path());
}
if(rv < 0)
goto error;

View file

@ -3326,6 +3326,13 @@ test_fuse_rename_exdev_relative_nested()
test_rename_exdev_case("rel-symlink",false,0);
}
void
test_fuse_rename_exdev_root_source()
{
for(const auto mode : {"rel-symlink","abs-symlink"})
test_rename_exdev_case(mode,true,0);
}
void
test_fs_copyfile_basic()
{
@ -4121,6 +4128,7 @@ TEST_LIST =
{"config_prune_ctrl_xattr",test_config_prune_ctrl_xattr},
{"config_prune_cmd_xattr",test_config_prune_cmd_xattr},
{"fuse_rename_exdev_relative_nested",test_fuse_rename_exdev_relative_nested},
{"fuse_rename_exdev_root_source",test_fuse_rename_exdev_root_source},
{"fs_copyfile_basic",test_fs_copyfile_basic},
{"fs_copyfile_source_changes_cleanup_tmpfiles",test_fs_copyfile_source_changes_cleanup_tmpfiles},
{"str_eq_nullptr",test_str_eq_nullptr},