From owner-freebsd-questions@FreeBSD.ORG Tue Aug 17 23:14:53 2004 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id BF2FE16A4CE for ; Tue, 17 Aug 2004 23:14:53 +0000 (GMT) Received: from ozlabs.org (ozlabs.org [203.10.76.45]) by mx1.FreeBSD.org (Postfix) with ESMTP id 5A32843D2F for ; Tue, 17 Aug 2004 23:14:53 +0000 (GMT) (envelope-from grog@lemis.com) Received: from blackwater.lemis.com (blackwater.lemis.com [192.109.197.80]) by ozlabs.org (Postfix) with ESMTP id AA9012BDAB for ; Wed, 18 Aug 2004 09:14:49 +1000 (EST) Received: by blackwater.lemis.com (Postfix, from userid 1004) id CCAB5511FA; Wed, 18 Aug 2004 08:44:47 +0930 (CST) Date: Wed, 18 Aug 2004 08:44:47 +0930 From: Greg 'groggy' Lehey To: David Kelly Message-ID: <20040817231447.GM88156@wantadilla.lemis.com> References: <6.1.2.0.0.20040816220030.04148ec0@mail1.simplenet.com> <20040817052403.GE88156@wantadilla.lemis.com> <6BDB5047-F05D-11D8-8B80-000393BB56F2@HiWAAY.net> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="xn9xNsWbHJd/50IB" Content-Disposition: inline In-Reply-To: <6BDB5047-F05D-11D8-8B80-000393BB56F2@HiWAAY.net> User-Agent: Mutt/1.4.1i Organization: The FreeBSD Project Phone: +61-8-8388-8286 Fax: +61-8-8388-8725 Mobile: +61-418-838-708 WWW-Home-Page: http://www.FreeBSD.org/ X-PGP-Fingerprint: 9A1B 8202 BCCE B846 F92F 09AC 22E6 F290 507A 4223 cc: FreeBSD_Questions FreeBSD_Questions Subject: Re: hard links for directories ? X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 17 Aug 2004 23:14:53 -0000 --xn9xNsWbHJd/50IB Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Tuesday, 17 August 2004 at 9:55:03 -0500, David Kelly wrote: > > On Aug 17, 2004, at 12:24 AM, Greg 'groggy' Lehey wrote: > >> On Monday, 16 August 2004 at 22:02:11 -0700, Tim Traver wrote: >> >>> This may be a stupid question, but is it possible to make hard links >>> to >>> directories ??? I know you can with files, and normally, you would do >>> a >>> soft link for directories, but is there any way to finagle this ? >> >> Sure, there are ways. But why would you want to? >> >> A link to a directory makes it a subdirectory of the directory >> containing the link. If you have two links to a directory, where >> should the directory's .. link point? How would fsck know what to do? > > Root is the only one allowed to make hard links to directories. This is not correct. root has no special powers here. > As Greg says, "How would fsck know which is the correct parent > directory?" To make it clearer: the term "hard link" is a misnomer. It's just a link, and there are lots of links to directories. One is always called ".", and all the others are called "..". So when you create a directory, it has a link count of 2. Every time you create a subdirectory of that directory, you add to the link count: $ mkdir new=20 $ ls -dl new drwxr-xr-x 2 grog wheel 512 Aug 18 08:42 new $ mkdir new/subdir $ ls -dl new drwxr-xr-x 3 grog wheel 512 Aug 18 08:43 new $ mkdir new/subdir2 $ ls -dl new drwxr-xr-x 4 grog wheel 512 Aug 18 08:43 new > Directories have only one parent. If a directory were to have two > parents then you'd break the tree structure of the directory > hierarchy. You would could > create a loop in the tree branches which would place > utilities such as "find" in an infinite loop. Greg -- When replying to this message, please copy the original recipients. If you don't, I may ignore the reply or reply to the original recipients. For more information, see http://www.lemis.com/questions.html Note: I discard all HTML mail unseen. Finger grog@FreeBSD.org for PGP public key. See complete headers for address and phone numbers. --xn9xNsWbHJd/50IB Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.0 (FreeBSD) iD8DBQFBIpFnIubykFB6QiMRAu/4AJ9htHQP110mc/rzlBsAOZuxqdsFCACffdrs As4reYJCc54aLaWEyQaKVl4= =Yk2L -----END PGP SIGNATURE----- --xn9xNsWbHJd/50IB--