Re: Getting filename from inode # in 'C'

From: Bill Vermillion (bv_at_wjv.com)
Date: 03/24/05

  • Next message: James Szabadics: "Printing headaches"
    Date: Thu, 24 Mar 2005 03:35:01 GMT
    
    

    In article <Muudnbj4fvSfZdzfRVn-ow@comcast.com>,
    Tony Lawrence <foo@pcunix.com> wrote:
    >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 ?

    Which applies to hard links.

    For symlinks you will have two separate inodes numbers, one for
    the symlink and one for the file to which it points.

    Bill

    -- 
    Bill Vermillion - bv @ wjv . com
    

  • Next message: James Szabadics: "Printing headaches"

    Relevant Pages

    • [PATCH] Incorrect increment of i_blocks when keeping the same xattr block on ext[23]
      ... From Stephen Tweedie: ... you then change an attribute in that on one inode, ... accounting to determine the difference between fast and slow symlinks. ... send the line "unsubscribe linux-kernel" in ...
      (Linux-Kernel)
    • Re: Re; Cannot erase files
      ... If you have only one filesystem you can go straigh to rm. ... When you clear the inode you need to immediately reboot and run ... Not recommend for inexperienced users. ... Bill Vermillion - bv @ wjv. ...
      (comp.unix.sco.misc)
    • Re: [SLE] reiserfs is not trustworthy.
      ... >> links and symlinks cannot prevent their targets from being removed. ... Well, it does not behave like a hard link, either. ... of the directory containing the directory entry from which the inode ... not a faked up directory entry in the proc pseudo-file ...
      (SuSE)
    • [PATCH] tmpfs symlink corrupts mempolicy
      ... Andrea discovered that short symlinks on tmpfs, stored within the inode ... memcpy(kaddr, symname, len); ... send the line "unsubscribe linux-kernel" in ...
      (Linux-Kernel)
    • Re: Out of inodes
      ... Bill Vermillion wrote: ... > softupdates and all the processing of file removal had not been ... Filesystem 1K-blocks Used Avail Capacity iused ifree %iused ... it shows that /var/ is run out of inode. ...
      (comp.unix.bsd.freebsd.misc)