Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 16 May 1996 10:19:59 +0300 (EET DST)
From:      Heikki Suonsivu <hsu@clinet.fi>
To:        lamuh@stoat.riga.lv
Cc:        freebsd-bugs@freebsd.org
Subject:   Re: bin/1205: ln -F dir1 dir2
Message-ID:  <199605160719.KAA19035@cantina.clinet.fi>
In-Reply-To: lamuh@stoat.riga.lv's message of 16 May 1996 05:23:00 %2B0300
References:  <199605152321.CAA00516@stoat.riga.lv>

next in thread | previous in thread | raw e-mail | index | archive | help

From: lamuh@stoat.riga.lv
   >Number:         1205
   >Synopsis:       hardlinked directories can be created but not deleted

	   theres an undocumented option to ln(1), it is ``-F''.
	   it allows to hardlink directories. seems that there is no
	   way to delete these directories. so, fsck(8) should be done
	   three times to correct this problem.

   >How-To-Repeat:

	   # cd /tmp
	   # mkdir dir1
	   # ln -F dir1 dir2
	   # rmdir dir1
	   rmdir: dir1: Directory not empty
	   #

   >Fix:

	   i have no ideas how to fix it.

This might work if run as root:

cat > foo.c
main()
{
	exit(unlink("dir1"));
}
^D
gcc foo.c -o foo
./foo
rm foo

At some point in history, and still reflected by unlink(2), unlink system
call allows removing a directory.  The result will be a mess, so make sure
to fsck after doing it.

Another way to get rid of the doubly linked directory is to use clri to
clear the directory inode and let fsck to fix the results.

-- 
Heikki Suonsivu, T{ysikuu 10 C 83/02210 Espoo/FINLAND, hsu@clinet.fi
mobile +358-40-5519679 work +358-0-4375360 fax -4555276 home -8031121



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199605160719.KAA19035>