* How to get path of the image given pid
@ 1994-09-13 20:19 Satyamahesh Avala
1994-09-13 20:58 ` Alan Rollow - Dr. File System's Home for Wayward Inodes.
0 siblings, 1 reply; 2+ messages in thread
From: Satyamahesh Avala @ 1994-09-13 20:19 UTC (permalink / raw)
Here is a question.
I know the process id . If I look at 'ps' it gives me the command string used to invoke that image.
I am interested in finding the full path for the image file.
Any suggestions how to get the full path of the image file given the pid ?
------
satya
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: How to get path of the image given pid
1994-09-13 20:19 How to get path of the image given pid Satyamahesh Avala
@ 1994-09-13 20:58 ` Alan Rollow - Dr. File System's Home for Wayward Inodes.
0 siblings, 0 replies; 2+ messages in thread
From: Alan Rollow - Dr. File System's Home for Wayward Inodes. @ 1994-09-13 20:58 UTC (permalink / raw)
In article <3551ga$n12@nntpd.lkg.dec.com>, satya@riscee.bxb.dec.com (Satyamahesh Avala) writes:
>
>Here is a question.
>
>I know the process id . If I look at 'ps' it gives me the command string used to invoke that image.
That's because argv[*] (in C terms) are kept around with the process,
either in the proc table or in the user space for the process. The
part that gets printed by ps(1) isn't necessarily interesting, since
the process can change it.
>
>I am interested in finding the full path for the image file.
It is hard, but goes something like:
Either directly or indirectly you can get the vnode (virtual inode)
associated with the image file. I don't happen to know if it is
include in the process structures directly or part of the text
structures. Given a vnode you can determine whether corresponding
file is on a local file or on a remote one. If a remote one you're
basically done, because there probably isn't a way to ask the remote
system what the path name of the that vnode is.
When the vnode represents a local file, then you can, in a file system
dependent way, start working to figure where the file(s) is (are) (not).
Particular to UFS you should be able to get the device number and inode
number from the vnode data. Once you have the device number you can
back track that to a special device file name. Given the inode you
can start the somewhat difficult process of finding the name or names
(not) that belong to that inode.
Now you may be wonder why I write the "name" as one, many or none. Because
that is how many names a file can have. Typically files have a single
name, but since names just represent multiple links to a single file
can have many names. Further, since a file can be opened and the name
removed with the file staying around until it is close, a file can
have no names.
Probably the simplest way to look for the names is to use find:
% find /file-system -inum # -print
Doing it in a program is hard. And it will be different for local
file system you have to cope with. For OSF this is:
CDFS
UFS
the Advanced File System (Advfs)
>
>Any suggestions how to get the full path of the image file given the pid ?
Ask yourself if REALLY need to know that bit of information, because
it will be hard to get.
>
>------
>satya
>
--
Alan Rollow alan@nabeth.cxo.dec.com
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~1994-09-13 20:58 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
1994-09-13 20:19 How to get path of the image given pid Satyamahesh Avala
1994-09-13 20:58 ` Alan Rollow - Dr. File System's Home for Wayward Inodes.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox