Newsgroup: comp.unix.wizards


Article 14859 of comp.unix.wizards:
Path: icdoc!tsun4.doc.ic.ac.uk!zmact61
>From: zmact61@tsun4.doc.ic.ac.uk.doc.ic.ac.uk (D Spinellis)
Newsgroups: comp.unix.wizards
Subject: Re: /proc filesystems
Summary: Memory map of the /proc image
Keywords: proc memory map 8th edition
Message-ID: <1517@gould.doc.ic.ac.uk>
Date: 31 Jan 90 10:30:18 GMT
References: <9100022@m.cs.uiuc.edu>
Sender: news@doc.ic.ac.uk
Reply-To: dds@cc.ic.ac.uk (Diomidis Spinellis)
Organization: Imperial College Department of Computing
Lines: 46
Content-Length: 1575
In article <9100022@m.cs.uiuc.edu> march@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@cc.ic.ac.uk
Department of Computing             BITNET:                   dds@cc.ic.ac.uk
Imperial College                    UUCP:   ...!cernvax!cc.imperial.ac.uk!dds
London SW7 2BZ                      JANET:                    dds@uk.ac.ic.cc




Newsgroup comp.unix.wizards contents
Newsgroup list
Diomidis Spinellis home page

Creative Commons License Unless otherwise expressly stated, all original material on this page created by Diomidis Spinellis is licensed under a Creative Commons Attribution-Share Alike 3.0 Greece License.