next up previous
Next: Performance Up: The Linux Proc File Previous: Introduction

Proc Basics

Before going into specifics of building an interface using the proc file system, a basic concept overview of this special file system is given.

There is a tight relation between proc and sysctl functions. In general, all sysctl functions are also represented under /proc/sys/ as a proc file system entry. proc file system entries are not stored on a non-volatile media such as a hard-drive, they are generated on the fly, i.e. every time the read-method for the associated file is invoked. This results in a large freedom in the way output is represented to the user without requiring to parse complex input formats just to stay user-friendly. The proc file system is a file system in the sense that it provides an interface to the user-space that resembles a normal virtual file system interface of any other file system allowing POSIX style access via open, read, write and close.

Two basic interface types exist in proc, character based text-mode interfaces, and binary interfaces. Most interfaces are text-mode, and in cases where binary interfaces are used, usually both types are implemented at the same time. For user-space applications it is generally simpler to interface to the binary version rather than to text-mode, since in the latter case parsing (or at least scanning fixed format input lines) would be required. On the other hand, binary interfaces are not well suited for direct interpretation by humans. As an example /proc/pci and /proc/bus/pci/devices basically contain the same information, interpreted and raw, respectively.

In this paper, the representation of the sysctl tree in /proc/sys is treated as part of the proc file system, since sysctl handlers are not covered, but only the proc related functions.



Subsections
next up previous
Next: Performance Up: The Linux Proc File Previous: Introduction
Der Herr Hofrat
2003-03-26