removing hard linked directories

Jonathan I. Kamens jik at athena.mit.edu
Wed Mar 20 21:55:08 AEST 1991


In article <1991Mar20.013744.12749 at ux1.cso.uiuc.edu>, phil at ux1.cso.uiuc.edu (Phil Howard KA9WGN) writes:
|> How would you recommend removing a directory that is linked under several
|> different names?  The directory really is empty but rmdir lies and says
|> it is not empty.

  Well, first of all, perhaps you already know this, but the problem you are
having is just one of the many reasons why the man pages for ln(1) and link(2)
say that you shouldn't create hard links to directories.  There are other
reasons, like creating circles in the filesystem that can confuse various
oft-used system utilities.

  Second, my version of "fsck" automatically deals with hard links to
directories.  I created the directory /foo on a filesystem and then
hard-linked /bar to it, and when I ran fsck, got "/bar IS AN EXTRANEOUS HARD
LINK TO DIRECTORY /foo\n\nREMOVE? "

  If your fsck isn't smart enough to do that, then you can help it along a
little bit by figuring out the inode number of the directory with multiple
links, unmounting the filesystem and then running "clri" on the inode.  When
you do this, fsck should be able to clean up.  This worked for me too.  Fsck
asked a few questions about the directories in question, I said yes to all of
them and the directories went away.

-- 
Jonathan Kamens			              USnail:
MIT Project Athena				11 Ashford Terrace
jik at Athena.MIT.EDU				Allston, MA  02134
Office: 617-253-8085			      Home: 617-782-0710



More information about the Comp.unix.questions mailing list