procfs
procfs, a.k.a. "/proc", is the primary method for interacting with processes on OpenSolaris. Most other operating systems view /proc as a primary interface (i.e. "cat /proc/<pid>/map"), and application must either parse the text output or do more complicated manipulation through a system call. In Solaris, we have taken a different approach, where /proc is the de facto programmatic interface, and tools are designed to be layered on top of this interface. This results in a much more robust implementation that has some truly unique features. One thing to note is that /proc is not a repository for system-wide information (as some OSes do), only processes.
The primary documenation for /proc can be found in proc(4). For a history of /proc and a (brief) comparison with other operating systems, check out Eric Schrock's blog on the subject. Using the interfaces effectively can be quite a challenge. If you are building a project in OpenSolaris (the interfaces are not public), take a look at
libproc, a simplified abstraction layer built on top of /proc.
Finding the Source
You can find the source code in usr/src/uts/common/fs/proc. The code combines the vnode and VFS interfaces, as well as some general infrastructure that other parts of the kernel commonly use. Here's a brief description of each file.
| File | Description |
|---|---|
| prdata.h | Private internal data structures |
| prvfsops.c | VFS infrastructure (mount/unmount/stat) |
| prvnops.c | The nexus of /proc: the vnode layer |
| prcontrol.c | Subroutines to handle writes to ctl files |
| prioctl.c | Support for the (obsolete) single-file /proc interface |
| prusrio.c | Routine to read or write from/to a process |
| prsubr.c | Variety of support routines used throughout the kernel |
Understanding the Source
XXX in progress