Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mv hardlinks should be preserved when moving into a different directory #4833

Open
sylvestre opened this issue May 6, 2023 · 7 comments
Open
Labels

Comments

@sylvestre
Copy link
Contributor

Testcase:

export C=/usr/bin/
export C="target/debug/coreutils "
dir=hlink
other_partition_tmpdir=/dev/shm/tmp769306

rm -rf $dir $other_partition_tmpdir
mkdir $dir $other_partition_tmpdir
> $dir/a
ln $dir/a $dir/b

${C}mv $dir "$other_partition_tmpdir"

ls -1i "$other_partition_tmpdir/$dir"

They should be equal. They aren't currently

@Skallwar
Copy link

I've try to reproduce this:

mkdir testmkdir test2> test/aln test/a test/btarget/release-small/coreutils mv test test2ls -1i test2/test/
4219332 a
4219332 b

Does your test only work when moving the folder to another partition?

@tertsdiepraam
Copy link
Member

That's very likely, mv can't do a simple rename across partitions, so it has some fallback procedure that's probably not working as expected here.

@Skallwar
Copy link

Skallwar commented Jun 20, 2023

Ok thanks for your input, I will try to reproduce this with an USB key.

EDIT: I got the test working, I will try to fix this then

@Skallwar
Copy link

I've tracked down the issue to move_dir here. But this function comes from webdesus/fs_extra so I will have a look there

@Skallwar
Copy link

There is a similar issue for symlink and a PR was proposed without reaction from the author. I wonder if we should "just" implement it directly on our side...

@allaboutevemirolive
Copy link
Contributor

I've try to reproduce this:

❯ mkdir test
❯ mkdir test2
❯ > test/a
❯ ln test/a test/b
❯ target/release-small/coreutils mv test test2
❯ ls -1i test2/test/
4219332 a
4219332 b

Does your test only work when moving the folder to another partition?

Why do I get an error when trying to move the test into test2, but it is OKAY when using GNU mv?

nemesis@nemesis:~/Documents/Github/test/bin_3$ /home/nemesis/Documents/Github/Focus/util/coreutils_master/target/release/coreutils mv test test2
mv: cannot move 'test' to a subdirectory of itself, 'test2/test'

@cakebaker
Copy link
Contributor

@allaboutevemirolive it's a bug, I opened a ticket for it: #5481

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: No status
Development

No branches or pull requests

5 participants