try
try copied to clipboard
Potential issue with `rename` system call
If the command being run has rename in it, while the renaming target is an existing directory, try gives EXDEV (Invalid cross-device link)
Potentially related to redirect_dir feature (https://docs.kernel.org/filesystems/overlayfs.html#renaming-directories)
To recreate:
Create rename.c:
#include <stdio.h>
#include <unistd.h>
int main(void)
{
int ret;
ret = link("x", "y");
printf("link ret=%d\n", ret);
ret = unlink("x");
printf("unlink ret=%d\n", ret);
}
Then do the following:
$ gcc rename.c -o rename
$ mkdir x
$ ./rename
rename: Success
$ rmdir y; mkdir x
$ try ./rename
rename: Invalid cross-device link