gnu@perl has asked for the wisdom of the Perl Monks concerning the following question:

I was wondering if anyone could point me in the right direction (or maybe even give me a new map). I have a situation where I need to travers an inode tree (solaris). I want to gather information from inode 2, the first on a filesystem, and move on from there depending on what information I find in it.

'stat()' can provide me inode information given the file name, but I won't know the file names, just the inode numbers. Yes, I realize there are utilities (find -inum, ncheck etc) but they are slow and still somewhat limited for what I need to do.

Any Ideas?

TIA, Chad.

Replies are listed 'Best First'.
Re: Reading inodes NOT 'stat()'
by idsfa (Vicar) on Nov 26, 2003 at 17:07 UTC

    ReadDir sounds like what you want. It gets you inodes AND associated names, so you can walk the tree.


    My parents just came back from a planet where the dominant life form had no
    bilateral symmetry, and all I got was this stupid F-Shirt.
Re: Reading inodes NOT 'stat()'
by Roger (Parson) on Nov 27, 2003 at 05:28 UTC
    Checkout this node -> 165103, a particular discussion (with examples) on how to walk the inode tree using Perl. Also this code snippet from merlyn -> 299168, an example of using lstat.

Re: Reading inodes NOT 'stat()'
by Anonymous Monk on Nov 26, 2003 at 16:54 UTC
    Don't use perl. That is too low level (it's filesystem/os dependent), so perl won't let you do that. If you want to use perl, you'll have to expose something to perl via XS, which may have already been done (see Solaris::).