[EMAIL PROTECTED] wrote:
> Din you know somebody, if somewhere exist (complete if is possible:-)
> documentation about proc-fs.
There's the proc(5) manpage, although it seems to be a bit out of
date.
> Especialy, I am interested now about how can I make a program wich
> be able to show me what files use each process. Ot it is that allready
> done somewhere?
Read the /proc/<pid>/fd directory. Each descriptor has an entry there
which is a (pseudo) symlink. Use readlink() to get the contents of the
link. This will be of the form `[dddd]:iiiiii', where `dddd' is the
device number (in hex), and `iiiiii' is the inode number (in decimal).
Scan the /dev directory to translate the device number into a device
name, and look up the device name in /etc/mtab to find the mount
point.
You will then need to scan the filesystem beneath the mount point
looking for the inode number. This may produce a single filename,
multiple filenames (if there are multiple hard links to the file), or
no filenames (if the file has been deleted since it was opened).
Also, a device number of 0000 corresponds to something that isn't a
file (e.g. a network socket).
--
Glynn Clements <[EMAIL PROTECTED]>