From owner-freebsd-questions@FreeBSD.ORG Tue May 22 21:24:31 2012 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id AEC83106564A; Tue, 22 May 2012 21:24:31 +0000 (UTC) (envelope-from bonomi@mail.r-bonomi.com) Received: from mail.r-bonomi.com (mx-out.r-bonomi.com [204.87.227.120]) by mx1.freebsd.org (Postfix) with ESMTP id 538FD8FC0C; Tue, 22 May 2012 21:24:30 +0000 (UTC) Received: (from bonomi@localhost) by mail.r-bonomi.com (8.14.4/rdb1) id q4MLQImN071457; Tue, 22 May 2012 16:26:18 -0500 (CDT) Date: Tue, 22 May 2012 16:26:18 -0500 (CDT) From: Robert Bonomi Message-Id: <201205222126.q4MLQImN071457@mail.r-bonomi.com> To: dteske@freebsd.org, freebsd-questions@freebsd.org, freebsd@dreamchaser.org In-Reply-To: <0ae301cd385c$31813370$94839a50$@freebsd.org> Cc: Subject: RE: hard link identification X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 22 May 2012 21:24:31 -0000 wrote; > > For directories, the link-count is quite obviously the number of filesystem > entities contained within. That is *INCORRECT*. The link-count on a directory is the number of dir- ectory entries (file names) tht resolve to it, just as with any other file. The count starts at *TWO* -- one for the directory name itself, plus one for the '.' self-refernce 'in' that directory -- plus one for the '..' reference in each and every sub-directory that is in that directory, PLUS one (albeit rare) for any other hard-linked names that also resolve to that diretory. To wit: $ mkdir foo # 'ls -l foo' will show a link-count of 2 $ touch foo/bar # 'ls -l foo' will show a link-count of 2 $ mkdir foo/baz # 'ls -l foo' will show a link-count of 3 $ ln -s foo foo2 # 'ls -l foo' will show a link-count of 3 $ ln foo quux # 'ls -l foo' will show a link-count of 4