in reply to locate path to a file from inode number

In reply to some of the posts thus far:

First of all, thank all of you for your help. It is truly appreciated.

Concerning the nature of an inode, I am aware of the issues with links (both hard and symbolic), but in this circumstance I can guarantee that will never arise.

What I am trying to do is track the location of a file(s) through directories on a filesystem. Now this is not all that hard to do. There are many methods a couple of which being File::Find or a combination of opendir/readdir. The problem is that this has to be done quite regulary, only a few seconds apart in some circumstances. Both of these methods would produce heavy I/O. I am trying to find out if anyone has an idea on tracking a file that is not a heavy impact on the FS.

I hope that cleared it up a little, I apologize if it was a little vague in the original post.

  • Comment on Re: locate path to a file from inode number

Replies are listed 'Best First'.
Re: locate path to a file from inode number
by gnu@perl (Pilgrim) on Nov 08, 2002 at 18:13 UTC
    Just thought to add this. I have tried the unix utility 'ncheck' but this takes quite a long time. The system I am using runs veritas and the vxfs file system, so the ncheck utility won't work there, but there is ncheck_vxfs, although it is not installed on this box. Probably never will be either (boss is a twit).

    But either way, ncheck is not much more than a glorfied 'find /path -inum <NUM>' as far as this circumstance is concerned.

Re: Re: locate path to a file from inode number
by iburrell (Chaplain) on Nov 08, 2002 at 21:13 UTC
    What do you mean "track the location of a file through directories"? Is something moving the file around? How do you identify this file? How often is the file moved? What is moving the file?

    If the file is moved infrequently, then saving the path and only searching when it goes missing might work fine. You would basically be caching the location in a known spot. If you have control over the process moving the file, then restrict where it can be moved get it to tell the other process where to find the file.

    There is no quick way to map from inode to the paths that link to the inode. Searching the filesystem is the best you can do.