diff --git a/mkdocs/docs/config/rename-exdev.md b/mkdocs/docs/config/rename-exdev.md index e3dc562f..2b353ffe 100644 --- a/mkdocs/docs/config/rename-exdev.md +++ b/mkdocs/docs/config/rename-exdev.md @@ -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. diff --git a/src/fuse_rename.cpp b/src/fuse_rename.cpp index cc1e5997..7c02bf98 100644 --- a/src/fuse_rename.cpp +++ b/src/fuse_rename.cpp @@ -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; diff --git a/tests/tests.cpp b/tests/tests.cpp index 256ccbd5..fddb1b15 100644 --- a/tests/tests.cpp +++ b/tests/tests.cpp @@ -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},