brtmac@maverick.ksu.ksu.edu (Brett McCoy) (11/30/90)
I need to find what processes owns a given socket. Specificially, given the output from netstat how do I find what processes owns each of the sockets shown. I am running SunOS 4.0.3. Pointers to the correct kernal structures and header files would be good. Actual code would be great. Thanx in advance. -- When an eel bites your leg, and the pain makes you beg, that's a moray! If I spent as much time on my classes as I do reading news, I'd graduate. Brett McCoy Computing and Telecommunications Activities brtmac@maverick.ksu.ksu.edu Kansas State University
liam@cs.qmw.ac.uk (William Roberts) (12/04/90)
In <1990Nov30.150350.10483@maverick.ksu.ksu.edu> brtmac@maverick.ksu.ksu.edu (Brett McCoy) writes: >I need to find what processes owns a given socket. Specificially, given >the output from netstat how do I find what processes owns each of the >sockets shown. I am running SunOS 4.0.3. Pointers to the correct kernal >structures and header files would be good. Actual code would be great. There is a utility called "ofiles", which we obtained from Vic Abell, abe@mace.cc.purdue.edu in March 1989, that does this. Specifically, it can take the output of "netstat -A" and use the PCB addresses given to tell you which process owns each TCP connection. I recently hacked this on our Sequent Balance machine, so that the PCB value printed for UDP sockets is interpreted as the address of the inpcb structure; this is true for Dynix but not for BSD 4.2. -- William Roberts ARPA: liam@cs.qmw.ac.uk Queen Mary & Westfield College UUCP: liam@qmw-cs.UUCP Mile End Road AppleLink: UK0087 LONDON, E1 4NS, UK Tel: 071-975 5250 (Fax: 081-980 6533)
tchrist@convex.COM (Tom Christiansen) (12/05/90)
In article <2784@redstar.cs.qmw.ac.uk> liam@cs.qmw.ac.uk (William Roberts) writes: >In <1990Nov30.150350.10483@maverick.ksu.ksu.edu> brtmac@maverick.ksu.ksu.edu >(Brett McCoy) writes: > > >>I need to find what processes owns a given socket. Specificially, given >>the output from netstat how do I find what processes owns each of the >>sockets shown. I am running SunOS 4.0.3. Pointers to the correct kernal >>structures and header files would be good. Actual code would be great. > >There is a utility called "ofiles", which we obtained from Vic Abell, I also received a copy of fstat, a standard BSD release utility, from Vic Abell, that he made work for Sun file systems. It's nicer than ofiles. I use it all the time. It doesn't give very good information on rnodes. I modified it to chase these down by following kernel pointers and print out the same device as stat would give you, and to find the right inum as well. Unfortunately, my kernel looks different on the inside, so my changes won't help anyone else much, unless they're on a Convex, in which case they should already have fstat. It's a worthwhile exercise for someone who wants to learn about how vnodes, inodes, snodes, and rnodes are all connected. --tom -- Tom Christiansen tchrist@convex.com convex!tchrist "With a kernel dive, all things are possible, but it sure makes it hard to look at yourself in the mirror the next morning." -me