From owner-freebsd-questions Fri Jun 30 17:36:53 2000 Delivered-To: freebsd-questions@freebsd.org Received: from wopr.caltech.edu (wopr.caltech.edu [131.215.102.114]) by hub.freebsd.org (Postfix) with ESMTP id 5023637B5D7 for ; Fri, 30 Jun 2000 17:36:51 -0700 (PDT) (envelope-from mph@wopr.caltech.edu) Received: (from mph@localhost) by wopr.caltech.edu (8.9.3/8.9.3) id RAA15518; Fri, 30 Jun 2000 17:36:48 -0700 (PDT) (envelope-from mph) Date: Fri, 30 Jun 2000 17:36:48 -0700 From: Matthew Hunt To: R Joseph Wright Cc: freebsd-questions@FreeBSD.ORG Subject: Re: Inodes and filenames Message-ID: <20000630173648.A15414@wopr.caltech.edu> References: <20000630170905.A27488@manatee.mammalia.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Mailer: Mutt 1.0i In-Reply-To: <20000630170905.A27488@manatee.mammalia.org>; from rjoseph@mammalia.org on Fri, Jun 30, 2000 at 05:09:05PM -0700 Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG On Fri, Jun 30, 2000 at 05:09:05PM -0700, R Joseph Wright wrote: > First, how can I find out whether an inode has more than one filename > associated with it? If you know one filename, ls -l shows the link count as the field right after the permissions. If you only know the number, one way is to use fsdb in read-only mode: $ fsdb -r /dev/rda0a ** /dev/rda0a (NO WRITE) Examining file system `/dev/rda0a' Last Mounted on / current inode: directory I=2 MODE=40755 SIZE=1024 MTIME=Jun 30 11:57:27 2000 [0 nsec] CTIME=Jun 30 11:57:27 2000 [0 nsec] ATIME=Jun 30 17:29:07 2000 [0 nsec] OWNER=root GRP=wheel LINKCNT=27 FLAGS=0 BLKCNT=2 GEN=76c87c41 fsdb (inum: 2)> inode 896 current inode: regular file I=896 MODE=100555 SIZE=2301194 MTIME=Jun 25 12:34:06 2000 [0 nsec] CTIME=Jun 25 12:34:06 2000 [0 nsec] ATIME=Jun 25 23:19:16 2000 [0 nsec] OWNER=root GRP=wheel LINKCNT=1 FLAGS=0x20000 BLKCNT=11a0 GEN=4761b8ff ^^^^^^^^^ (This happens to be /kernel on my machine.) A slower approach is to use find(1) with the "-inum" flag, but then you'll know the filenames too. > Second, can I delete a file by specifying the inode rather than the > filename? You could combine find(1)'s "-inum" and "-delete" flags, or use clri or fsdb (and then fsck). -- Matthew Hunt * Inertia is a property http://www.pobox.com/~mph/ * of matter. To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message