/proc filesystems

D Spinellis zmact61 at tsun4.doc.ic.ac.uk.doc.ic.ac.uk
Wed Jan 31 21:30:18 AEST 1990


In article <9100022 at m.cs.uiuc.edu> march at m.cs.uiuc.edu writes:
>
>I recently ran across a machine running SYSV Release 3.1.1 on a 3B15
>which, to my surprise, had a /proc filesystem. 
[...]
>I understand that each file is a "window" into user space for a particular 
>PID.  At any rate, what is the structure of a file within /proc?  Is it
>the same as the a.out with BSS allocated and used?  How do you know
>what read() is returning to you?

The memory map for a process in the 8th edition as seen by using I/O
into the /proc image is the following:

Virtual address			Length
0x80000000	------------
	  	  user area	UPAGES * NBPG
		------------
		   STACK	p.p_ssize
		~~~~~~~~~~~~

		  Dragons

		~~~~~~~~~~~~
		    DATA	p.p_dsize
		------------
		    TEXT	p.p_tsize
0x00000000	-------------

You get then lengths from the proc structure.  You need a special
ioctl to access the proc structure as it resides in kernel space.
To get the definition of UPAGES and NBPG include <sys/param.h>.
The proc structure is defined in <sys/proc.h> and the user structure
in <sys/user.h>.  The ioctl codes are defined in <sys/pioctl.h>.

To read the proc structure use:

	struct proc p;

	ioctl(f, PIOCGETPR, &p);

Diomidis
--
Diomidis Spinellis                  Internet:                 dds at cc.ic.ac.uk
Department of Computing             BITNET:                   dds at cc.ic.ac.uk
Imperial College                    UUCP:   ...!cernvax!cc.imperial.ac.uk!dds
London SW7 2BZ                      JANET:                    dds at uk.ac.ic.cc



More information about the Comp.unix.wizards mailing list