How does 'mv' rename directories?

Mike Maloney mike at isi.UUCP
Thu Sep 14 01:24:52 AEST 1989


Dear wizards,

I was recently trying to figure out why the 'mv' command on a Microport 
System V box would refused to rename directories.  The commands
		cd
		mkdir junk
		mv junk junk2
would elicit the response: mv: cannot link 'junk' and 'junk2'.
(No, 'junk2' did not already exist.)  The same commands would work
fine on another system RUNNING THE SAME OPERATING SYSTEM!

I suspect that it is something subtle to do with permissions.  But anyway,
this led me to wonder how the 'mv' command can rename directories at all.
The Rochkind book shows an implementation of 'mv' using link() and unlink().
If the target path is a directory it first checks to see if it already exists, 
and if it does, fails.  If I understand him correctly, his version of 'mv' 
must have the Set-UID bit set and be owned be root because only processes 
with an effective UID of root can link directories.

But on Microport, Xenix, and Sun Unix 4.0, /bin/mv is -rwxr-xr-x and is
owned by 'bin'.   How is 'mv' able to rename directories on a properly 
working system?

-- 
Mike Maloney             Integral Systems, Inc 
(301) 731-4233		 5000 Philadelpha Way, Suite A,
			 Lanham, MD  20706



More information about the Comp.unix.wizards mailing list