Re: Getting filename from inode # in 'C'

From: Tony Lawrence (foo_at_pcunix.com)
Date: 03/24/05


Date: Wed, 23 Mar 2005 18:13:06 -0500

Murray Hooper wrote:
> "Tony Lawrence" <foo@pcunix.com> wrote in message
> news:qvydnecuhseAQtzfRVn-1g@comcast.com...
>
>>Murray Hooper wrote:
>>
>>>I am working on a project on OpenServer 5 that I need to get a filename
>>>(text) back when given an inode #?
>>>any advice on what functions to investigate?
>>>thank you
>>>murray
>>
>>find / -inum 1234
>>
>>but you need to restrict that to the filesystem that has the one you are
>>looking for..
>>
>>--
>>
>>Unix/Linux/Mac OS X resources: http://aplawrence.com
>
>
> Thanks Tony.
>
> I am trying to do it within a 'C' program if possible?
>
>
>

Well of course it's possible, but you need to re-invent "find" - well ,
not all of it, but you need to walk every directory, read the inode, and
if it matches, print the filename.

You do understand that the ONLY relationship between filenames and
inodes is in directories and that there can be multiple filenames
pointing to the same inode ?

-- 
Tony Lawrence
Unix/Linux/Mac OS X  resources: http://aplawrence.com


Relevant Pages

  • Re: df reports a drive as a 100% full but cannot find the files with du
    ... you have some ghost files taking up all the room. ... An application cannot gain access to a file without a ... OTOH, once a file (inode) has been opened, the *filename* ... allow the removal of *filenames* for inodes, ...
    (comp.os.linux.misc)
  • Re: Blue Filenames?
    ... "Tony" wrote in message ... > I can't figure out why some of my filenames are coming up ... blue (dark) = Hot-tracking. ...
    (microsoft.public.windowsxp.general)
  • Recursively reading a directory tree
    ... read a directory tree and also want to be able to go back in the tree. ... consume less space then filenames. ... If you have a mounted filesystem on linux (f.i. ... or FAT with USB key) are there always inode with unique ...
    (comp.os.linux.development.apps)
  • Re: mmap()ed filenames?
    ... > filenames of mapped files? ... That's a generally hard problem -- given some sort of open file, ... (none of which is /the/ name of the file: hard links are all equal ... You might think of extracting the inode number (easily done using ...
    (freebsd-questions)