Path: utzoo!censor!geac!torsqnt!news-server.csri.toronto.edu!cs.utexas.edu!usc!sdd.hp.com!ucsd!rutgers!mcnc!rti!dg-rtp!larrybud.rtp.dg.com!goudreau From: goudreau@larrybud.rtp.dg.com (Bob Goudreau) Newsgroups: comp.unix.wizards Subject: Re: Hard links to directories: why not? Message-ID: <1990Jul30.153949.28122@dg-rtp.dg.com> Date: 30 Jul 90 15:39:49 GMT References: <5222@milton.u.washington.edu> <6940@eos.UUCP> <1990Jul24.200022.2265@dg-rtp.dg.com> Sender: usenet@dg-rtp.dg.com (Usenet Administration) Reply-To: goudreau@larrybud.rtp.dg.com (Bob Goudreau) Organization: Data General Corporation, Research Triangle Park, NC Lines: 52 In article , peter@ficc.ferranti.com (peter da silva) writes: > In article <1990Jul24.200022.2265@dg-rtp.dg.com>, goudreau@larrybud.rtp.dg.com (Bob Goudreau) writes: > > If you prohibit > > non-superusers from unlinking them, then you're stuck with the unlovely > > situation of users being unable to delete links they've created, even > > though they have write access in the affected directory. If you lift > > this prohibition, then you can easily end up with directories whose > > ".." entry points nowhere (or worse yet, points to what used to be > > the parent inode, but has now been recycled into something completely > > different). > > (a) There still remain link counts. Just make rmdir check link counts. > It already checks to see if the directory is empty. Then it will > say "rmdir: Directory has firm links". > > (b) The inode won't be reused. Link counts again. But my basic point still stands. If you add such a restriction (based on link counts instead of root privileges this time), then you're still stuck with the "unlovely situation" I mentioned (see below for example). And if you don't add the prohibition, you're stuck with the ".." problem. Here's an example of the problem: 1) I create a subdirectory named "sub". 2) Unbeknownst to be me, Joe Schmo creates a hard link of his own to "sub". 3) I try to rmdir "sub", which is empty, and find that I cannot, because its link count is > 2. So now I'm stuck with a subdirectory that I own that lives in a directory that I can write, but I can't delete it! All I know is how many extra links to it exist -- and I have no way of finding out *where* those links are. Contrast this case to the deletion of an ordinary file with many links, and you'll see the difference. There's nothing preventing me unlinking the file, yet there is for the directory. That is the behavior I find objectionable. ------------------------------------------------------------------------ Bob Goudreau +1 919 248 6231 Data General Corporation 62 Alexander Drive goudreau@dg-rtp.dg.com Research Triangle Park, NC 27709 ...!mcnc!rti!xyzzy!goudreau USA