Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 11 Feb 1999 05:22:46 +1000
From:      Greg Black <gjb@comkey.com.au>
To:        cjclark@home.com
Cc:        freebsd-questions@FreeBSD.ORG
Subject:   Re: Get Filename from Inode 
Message-ID:  <19990210192246.23067.qmail@alpha.comkey.com.au>
In-Reply-To: <199902101732.MAA16082@cc942873-a.ewndsr1.nj.home.com>  of Wed, 10 Feb 1999 12:32:14 EST
References:  <199902101732.MAA16082@cc942873-a.ewndsr1.nj.home.com> 

next in thread | previous in thread | raw e-mail | index | archive | help

> I have some error messages reporting problems with files by their
> inode numbers. However, I have been unable to figure out how to locate
> the files. Despite my best efforts with man and apropos, I cannot find
> a command to do the 'reverse-lookup' of a filename from an inode. I
> have not even found a C function for it to write my own
> quick-n-dirty executable.
> 
> Some quick help?

The canonical answer is to use find(1), which has a "-inum n"
expression.  You need to know which file system your target file
is in or you may get confusing results -- inode numbers are only
unique on a single filesystem.  If you know which directory the
files are in, a simpler way is with the "-i" option to ls(1).

You don't need it for this exercise, since find can certainly do
what you want, but if you ever decide that you need to write
code yourself to walk the file system, the man page to start
with is fts(3) which describes the routines used by find and ls.

> PS: 'man inode' refers to a <sys/inode.h>, but I have no
> /usr/include/sys/inode/.h file. Is this normal? Or manpage not
> up-to-date?

Of course you don't have "/usr/include/sys/inode/.h" -- the
expression "<sys/inode.h>" refers to "/usr/include/sys/inode.h"
which you may or may not have -- it doesn't exist on 2.2.8, but
then the 2.2.8 man page refers to "<ufs/ufs/inode.h>" and 2.2.8
does have "/usr/include/ufs/ufs/inode.h", as you would expect.
Not that any of these files will tell you what you want to know.

-- 
Greg Black <gjb@acm.org>


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-questions" in the body of the message



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?19990210192246.23067.qmail>