Hard links to directories: why not?
Jonathan I. Kamens
jik at pit-manager.mit.edu
Mon Jul 23 18:32:21 AEST 1990
Are /dev and /usr/tmp on your machine on different partitions? If
so, then the behavior of mv is understandable.
Older versions of mv couldn't move files between partitions at all,
since rename() doesn't work between partitions. Newer versions first
attempt to use rename() to change the name of a file, and if that
fails because the rename() attempted to rename a file to a different
partition, than it uses the same method as cp to copy the file.
Therefore, if /usr/tmp and /dev are on different partitions on your
system, then the rename() is going to fail, so mv is going to create a
file of the specified name in /usr/tmp, then open /dev/null for read
and copy its "contents" into the file in /usr/tmp.
The "correct" solution, perhaps, is to make mv check for special
files after the rename() fails, and to use the mknod code to recreate
special files. The problem with this is that it would require mv to
be setuid. Perhaps a better solution would be for mv to notice
special files and print out an error like "cannot rename special files
across partitions"; that is, after all, what it used to print when you
tried to mv regular files across partitions (without the word
"special").
Jonathan Kamens USnail:
MIT Project Athena 11 Ashford Terrace
jik at Athena.MIT.EDU Allston, MA 02134
Office: 617-253-8495 Home: 617-782-0710
More information about the Comp.unix.wizards
mailing list