From mboxrd@z Thu Jan 1 00:00:00 1970 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: fee84,dbb154866013496c X-Google-Attributes: gidfee84,public X-Google-ArrivalTime: 1994-09-13 23:19:51 PST Path: bga.com!news.sprintlink.net!sundog.tiac.net!usenet.elf.com!news2.near.net!MathWorks.Com!yeshua.marcam.com!charnel.ecst.csuchico.edu!olivea!decwrl!pa.dec.com!src.dec.com!crl.dec.com!nntpd.lkg.dec.com!nntpd2.cxo.dec.com!nabeth.cxo.dec.com!alan From: alan@nabeth.cxo.dec.com (Alan Rollow - Dr. File System's Home for Wayward Inodes.) Newsgroups: comp.unix.osf.osf1 Subject: Re: How to get path of the image given pid Date: 13 Sep 1994 20:58:49 GMT Organization: Digital Equipment Corporation Distribution: world Message-ID: <3553q9$dbg@nntpd2.cxo.dec.com> References: <3551ga$n12@nntpd.lkg.dec.com> Reply-To: alan@nabeth.cxo.dec.com (Alan Rollow - Dr. File System's Home for Wayward Inodes.) NNTP-Posting-Host: nabeth.cxo.dec.com 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