Re: Pathname from inode?

lm@neteng.engr.sgi.com
Wed, 7 May 1997 18:33:46 +0200


[much discussion of pathnames deleted]

Something I have wanted for a while is the basename of the inode in
the inode (perhaps conditionally compiled in for kernel debugging).
Then you can reconstruct a path to the inode. If there were hard links
involved then you aren't necessarily going to get the path you expect,
but you can get a path.

Looking at fs.h, it looks like what you want is a both a

#ifdef NAMEI
char i_basename[12]; /* basename of the last lookup */
u_long i_parent; /* inum of the parent */
#endif

The printing the path becomes a simple procedure of walking the list of
inodes and putting the path together.

It won't always work because the parent inode can be gone....

--lm