Operating System - HP-UX
1822002 Members
3905 Online
109639 Solutions
New Discussion юеВ

Re: Finding path name from its inode number

 
Mladen Despic
Honored Contributor

Finding path name from its inode number

I can use 'find' and 'ls -i' to get the result, but the file system is very large, so this is taking too long.
I have a similar problem with 'ncheck -i'.

Is there an easy way to find the file path name, given the (VxFS) inode number?

Mladen
7 REPLIES 7
Rodney Hills
Honored Contributor

Re: Finding path name from its inode number

What tool is giving you the inode number. Usually "lsof" or "glance" will also give the file system too. Then you can limit "find" to that system.

Since their aren't any pointers from the file header back to the directory structure, I think you have to use find.

-- Rod Hills
There be dragons...
Mladen Despic
Honored Contributor

Re: Finding path name from its inode number

Rodney,

The file system's mount point is also given.
But this file system is over 60 Gb in size, with more than 600000 inodes. Thanks,

Mladen
James R. Ferguson
Acclaimed Contributor

Re: Finding path name from its inode number

Hi Mladen:

At the risk of sounding sarcastic, this is an example of why it helps to divide (and conquer) large numbers of files into directories. I don't think you have any other solution to speeding searches up.

Regards!

...JRF...
Jordan Bean
Honored Contributor

Re: Finding path name from its inode number


This should be sufficient:

find ${fs} -xdev -inum ${inode}
Systeemingenieurs Infoc
Valued Contributor

Re: Finding path name from its inode number

James, it's not that simple. Limit # files/dir is no help. It might be helpful to create seperate filesystems thought.

Consider the following example :

This is an entry from the audit subsystem :

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
020206 09:57:24 7237 S 15 7068 33 0 3 0 3 157:0x000002
[ Event=chmod; User=wroot; Real Grp=sys; Eff.Grp=sys; ]

RETURN_VALUE 1 = 0;
PARAM #1 (file path) = 1 (cnode);
0x40000003 (dev);
1380 (inode);
(path) = .profile
PARAM #2 (int) = 384
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

You only have the device and the inode. It can reside in any directory.

HeCou
A Life ? Cool ! Where can I download one of those from ?
Mladen Despic
Honored Contributor

Re: Finding path name from its inode number

I can try re-organizing the file system into several smaller file systems, but this is too much work at this point.
The problem is not too important, but I appreciate your comments and suggestions.
The file system in question has been created for Netscape Mail Server data.

Rodney Hills
Honored Contributor

Re: Finding path name from its inode number

One last thought...

If the file system is accumulating new files daily, could you right a program that looked for new files, collect the inode/pathname info, and write it to an index file.

Then when you wanted to lookup an inode, you would read it from the index file.

This way you can prevent re-reading through the file system each time you want to look for an i-node.

Usually the only time I've had to lookup a file based on i-node is when debugging an application. So the wait time for the scan is not as important.

Good Luck

-- Rod Hills
There be dragons...