Hard links to directories: why not?

John Bruner bruner at sp15.csrd.uiuc.edu
Wed Jul 25 23:41:05 AEST 1990


In article <1990Jul25.044952.20933 at mintaka.lcs.mit.edu>, jik at athena (Jonathan I. Kamens) writes:
>  Yes, before the rename system call existed, all mv's did basically
>the same thing as cp (but they deleted the original after successful
>writing of the copy).  However, when rename was created, many vendors
>(although not all, I'm sure) changed mv to use rename exclusively and
>to fail if the rename failed.  Many of those same vendors have more
>recently once again modified mv to do what the original, pre-rename mv
>did if the rename system call fails because of an attempt at
>cross-device renaming.

Before the rename() system call existed, "mv" attempted to link() the
old name to the new name and then to unlink() the old name.  If the
link() failed (e.g., because it crossed a mount point) then it would
copy the file instead.

I'm not well acquainted with the introduction of rename() into kernels
derived from System V.  When Berkeley implemented rename() they
substituted it for link()/unlink() in "mv" and left the copy code
intact.  If a company shipping a BSD-derived "mv" removed the code
that copies files when rename() fails, then they deserve all of the
criticisms that can be sent their way.
--
John Bruner	Center for Supercomputing R&D, University of Illinois
	bruner at csrd.uiuc.edu		(217) 244-4476	



More information about the Comp.unix.wizards mailing list