Re: directory entry from inode

Alexander Viro (viro@math.psu.edu)
Fri, 19 Feb 1999 23:12:26 -0500 (EST)


On Fri, 19 Feb 1999, Mike Kennedy wrote:

>
> How can I find the directory entry that corresponds to a particular
> inode?

Which one? There may be any number of them (including 0). Where do you
want it? In the kernel you may wade throught the cyclic list (anchored in
i_dentry and going through d_alias. If it's a userspace - think *hard*
whether you need it or not. You are wide-open to some interesting races
here. It's simply *not* a thing natural in UNIX way. You have to scan
all directories and do readdir() in each of them. From script use find(1)
(see manpage for details). Again, there is no such thing as *the*
directory entry of inode - there may be many and there may be none.
What do you need it for?

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/