Skip to content
New issue

mv cannot move files between Windows mount and linux file system #37

Closed
mphaney opened this issue on Apr 7, 2016 · 7 comments

Comments

@mphaney

Moving a file (with mv) within the Windows file system or within the Linux file system works exactly as it should, but moving between the two file systems yields the error:
mv: cannot move 'filename' to a subdirectory of itself, '/destination/filename'

Here is a complete test scenario:

root@localhost:~# cd /mnt/c/Users/Mark/
root@localhost:/mnt/c/Users/Mark# echo test > testfile
root@localhost:/mnt/c/Users/Mark# mkdir windir
root@localhost:/mnt/c/Users/Mark# mv testfile windir/
root@localhost:/mnt/c/Users/Mark# mv windir/testfile .
root@localhost:/mnt/c/Users/Mark# mv testfile /root/
mv: cannot move ‘testfile’ to a subdirectory of itself, ‘/root/testfile’
root@localhost:/mnt/c/Users/Mark# cp testfile /root/
root@localhost:/mnt/c/Users/Mark# rm testfile
root@localhost:/mnt/c/Users/Mark# cd /root
root@localhost:~# mkdir linuxdir
root@localhost:~# mv testfile linuxdir/
root@localhost:~# mv linuxdir/testfile .
root@localhost:~# mv testfile /mnt/c/Users/Mark/
mv: cannot move ‘testfile’ to a subdirectory of itself, ‘/mnt/c/Users/Mark/testfile’
root@localhost:~# cp testfile /mnt/c/Users/Mark/
root@localhost:~# rm testfile

@jolibert

Look at it as different environments.
You will never touch /mnt/c/
as you will never mount any files on / /mnt or other letters

@mphaney
Author

mphaney commented on Apr 7, 2016

Well, they most certainly are different environments, no question, but if I can copy from one to the other, edit Windows files from within the Linux environment, create and remove Windows files from within the Linux environment...kinda seems like move should work too, and yet it fails.

As a side note I believe the assertion that one would never touch /mnt/c/ is incorrect. The whole point of giving Windows developers Bash was so it could work harmoniously with their Windows environment, not as a completely separate system.

@crutchcorn

Yeah, I can confirm for @mphaney's thought process. You can also touch files in /mnt/c/

@jbaribeault

Same happens in /root for say, CPAN....it unzips the files in /root/.cpan, then can't move the directory to a build directory under /root/.cpan - insufficient permissions. Yet looking at ls output, things are fine...

@jolibert

Just put actions on /root as UAC actions on that mini kernel.
The idea is to put developers in it, nil hackers.
If developers got hacked, their choice to put the environment in sensitive areas.

@jolibert

And I know hundreds to hack a developer, trust me, my job

@dethoma

Thanks for reporting this issue. We were returning ENOENT instead of EXDEV for the rename syscall. When that is addressed mv will switch to "copy then remove original" behavior.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
5 participants
You can’t perform that action at this time.