From owner-freebsd-questions Sun Aug 11 8:59:36 2002 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 6935037B400 for ; Sun, 11 Aug 2002 08:59:34 -0700 (PDT) Received: from mailf.telia.com (mailf.telia.com [194.22.194.25]) by mx1.FreeBSD.org (Postfix) with ESMTP id EE75943E5E for ; Sun, 11 Aug 2002 08:59:20 -0700 (PDT) (envelope-from erikt@midgard.homeip.net) Received: from d1o913.telia.com (d1o913.telia.com [195.252.44.241]) by mailf.telia.com (8.12.5/8.12.5) with ESMTP id g7BFjv0k022429 for ; Sun, 11 Aug 2002 17:45:57 +0200 (CEST) X-Original-Recipient: Received: from falcon.midgard.homeip.net (h62n2fls20o913.telia.com [212.181.163.62]) by d1o913.telia.com (8.8.8/8.8.8) with SMTP id RAA06912 for ; Sun, 11 Aug 2002 17:45:56 +0200 (CEST) Received: (qmail 50281 invoked by uid 1001); 11 Aug 2002 15:45:52 -0000 Date: Sun, 11 Aug 2002 17:45:51 +0200 From: Erik Trulsson To: Michael Grant Cc: freebsd-questions@freebsd.org Subject: Re: find by inode Message-ID: <20020811154550.GA50205@falcon.midgard.homeip.net> Mail-Followup-To: Michael Grant , freebsd-questions@freebsd.org References: <200208111424.g7BEOxa29497@splat.grant.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <200208111424.g7BEOxa29497@splat.grant.org> User-Agent: Mutt/1.5.1i Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG On Sun, Aug 11, 2002 at 04:24:59PM +0200, Michael Grant wrote: > Does anyone know how I can list the files within a filesystem by inode > number? i.e. for each inode within a file system, print it's > filenames(s). And I do mean filename(s) because each inode can have > more than one link. > > I can write a perl script to do a find, build a hash, and print this > info out, but surely, there must be a more efficient way. > > For every given inode, I want to know what the filename(s) are. > Unfortunatly, ls doesn't provide this info. Unfortunately I don't think there is any efficient way to do this. An inode does not contain information on which filenames point to it. This means that the only way is to search through the entire filesystem and for each file check if it is a link to the desired inode. The only optimization one can do is that since an inode does know the number hardlinks to it that exists, one can stop once that number has been found. -- Erik Trulsson ertr1013@student.uu.se To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message