Re: directory entry from inode

Mike Kennedy (mkennedy@cs.ucr.edu)
Fri, 19 Feb 1999 21:20:48 -0800 (PST)


I'm trying to get the filename that corresponds to a particular inode. I
know that it is not stored in the inode itself, but as a directory
entry. I'm trying to implement some type of auditing on the ext2
filesystem. ie, when I read a particular file, it will put something in
the logs stating that the file was accessed.

:===========================================================:
: Mike Kennedy mkennedy@cs.ucr.edu :
: Systems Administrator (909) 787-2946 :
: Computer Science Department :
: University of California, Riverside :
:===========================================================:

On Fri, 19 Feb 1999, Alexander Viro wrote:

>
>
> 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/