Procfs
From Wikipedia, the free encyclopedia
- The correct title of this article is procfs. The initial letter is shown capitalized due to technical restrictions.
On Unix-like computer systems, procfs, short for process file system, is a pseudo-file system used to access process information from the kernel. The file system is often mounted at the /proc
directory. Because /proc is not a real file system, it consumes no storage space and only a limited amount of memory.
procfs is supported under:
- Solaris
- BSD
- Linux (which extends it to non-process-related data)
- IBM AIX (operating system) (which bases its implementation on Linux to improve compatibility)
Contents |
[edit] History
[edit] UNIX 8th Edition
The UNIX 8th Edition version of /proc
was implemented by Tom J. Killian, who presented a paper titled Processes as Files at USENIX in June 1984. It was designed in order to replace the ptrace system call used for process tracing.
[edit] SVR4
Roger Faulkner and Ron Gomes ported V8 /proc
to SVR4, and published a paper called The Process File System and Process Model in UNIX System V at USENIX in January 1991. This kind of procfs supported the creation of ps
, but the files could only be accessed with functions read()
, write()
, and ioctl()
.
[edit] Plan 9
Plan 9 implemented a process file system, but went further than V8. V8's process file system required operations applied to a single file for all functions related to a process. Plan 9 used separate files to provide those functions, and it made /proc a real part of the file system.
[edit] 4.4BSD
4.4BSD's implementation of /proc
was cloned from Plan 9.
[edit] Solaris
Solaris 2.6's /proc
(finished in 1996) was also a clone from Plan 9.
[edit] Linux
The /proc
implementation of Linux is also a clone of Plan 9. Under Linux, /proc
includes:-
- A directory for each running processes (including kernel processes) at
/proc/PID
, containing information about that process. Notably:-/proc/PID/cmdline
, which contains the command which originally started the process/proc/PID/cwd
, a symlink to the current working directory of the process/proc/PID/exe
, a symlink to the original executable file, if it still exists (a process may continue running after its original exe has been deleted or upgraded)/proc/PID/root
, a symlink to the root path as seen by the process. For most processes this will be a link to / unless the process is running in a chroot jail./proc/PID/task
, a directory containing hard links to any tasks that have been started by this (ie the parent) process.
- Depending on the mode of power management (if at all), either directory,
/proc/acpi
or/proc/apm
, which predate sysfs and contain various bits of information about the state of power management. /proc/bus
contains directories representing various buses on the computer, such as input/pci/usb. This has been largely superseded by sysfs under /sys/bus which is far more useful./proc/cmdline
gives the boot options passed to the kernel/proc/cpuinfo
contains a information about the cpu, such as its vendor (and cpu family, model and model names which should allow you to identify the cpu) and its speed (cpu MHz), cache size, number of siblings and cores and cpu flags. Bogomips is intended as a means of testing CPU performance, but it isn't really accurate anymore as it is just a test of CPU speed in a tight loop (ie it ignores memory and cache performance)./proc/crypto
is a list of cryptographic modules available/proc/devices
is a list of character and block devices sorted by device id but giving the major part of the/dev
name too./proc/diskstats
gives some information (including device numbers) for each of the logical disk devices/proc/filesystems
is a list of the file systems supported by the kernel at the time of listing/proc/interrupts
,/proc/iomem
,/proc/ioports
and the directory/proc/irq
give some self explanatory details about the devices (physical or logical) using the various system resources./proc/meminfo
contains a summary of how the kernel is managing its memory/proc/modules
is one of the most important files in/proc
and contains a list of the kernel modules currently loaded and it gives some indication of dependancies (sometimes it isn't entirely correct)/proc/mounts
is a symlink to self/mounts which contains a list of the currently mounted devices and their mount points (and which file system is in use and what mount options are in use)./proc/net
is a directory containing a lot of really useful information about the network stack, in particular ip_conntrack which is the list of existing network connections (particularly useful for tracking routing when iptables FORWARD is used to redirect network connections)./proc/partitions
is a list of the devices numbers, their size and/dev
names which the kernel has identified as existing partitions (for example if /dev/sda contains a partition table, then /dev/sda1 and others will appear as availiable partitions). Note that if a partition isn't listed in this file, then a patched version of losetup is around which can essentially mount the partition and connect /dev/loop[n] devices to the various partitions (I'm not sure if these will then appear in/proc/partitions
)/proc/scsi
gives information about any devices connected via a scsi or raid controller- A symbolic link to the current (traversing) process at
/proc/self
(ie/proc/PID/
where PID is that of the current process) /proc/slabinfo
not entirely sure, but it looks like something about the memory heap and what is using the various bits of it (thats an educated guess)/proc/swaps
is a list of the active swap partitions, their various sizes and priority- Access to dynamically-configurable kernel options under
/proc/sys
. Under/proc/sys
are directories representing the areas of kernel. The one I've used the most is/proc/sys/net/ipv4/ip_forward
which is a read/writable virtual file containing either a '1' or a '0'. If its 1 then the ipv4 stack will forward on packets not meant for the local host, if its 0 it won't. All routing firewall or tunnels will need toecho 1 >/proc/sys/net/ipv4/ip_forward
or they won't route a thing. /proc/sysvipc
contains memory sharing and IPC information/proc/tty
contains information about the current terminals;/proc/tty/driver
looks to be a list of the different types of tty available each of which is a list of those of each type./proc/uptime
is the length of time the kernel has been running in seconds/proc/version
contains the Linux kernel version, distribution number, gcc version number (used to build the kernel) and any other pertinent information relating to the version of the kernel currently running./proc/version_signature
is a ubuntu specific thing, giving only the Ubuntu distribution kernel version number and which type of Ubuntu kernel it is (ie generic)- There are other files depending on various hardware and module configurations and changes to the kernel.
The basic utilities that use /proc under Linux are in the procps package, and they require that /proc is mounted in order to function.
The procfs plays an important role in moving functionality from kernel space to user space. For example the GNU version of ps
operates entirely in user mode, using the procfs to obtain its data.
In Linux kernel 2.6, much of the non-process related files under /proc
were moved to a separate pseudo-file system called sysfs (mounted under /sys
).
[edit] Cobalt
It is worth noting that Cobalt boxes also include a few additions to /proc
:-
/proc/cobalt
is a directory containing cobalt specific things like the serialnumber and the systype (system type). It also contains a file which appears to duplicate...../proc/lcd
which is a read/writable file containing the contents of the front panel lcd screen. Echoing text to this file changes that on the front panel.
[edit] /cpuinfo
/proc/cpuinfo
is a pseudo-file containing information about all the CPU's in the system. It contains a number of lines:-
processor
is a number used by the system to identify each logical CPUvendor_id
is a string used to identify the CPU manufacturer (ie AuthenticAMD or GenuineIntel)cpu_family
is a number giving the major version of the CPU, these are as follows:-
CPU family | Model | Stepping | Cache size | Model name | Description |
---|---|---|---|---|---|
3 | 0 | 0 | x | ? | Intel386™ DX |
3 | 2 | 0 | x | ? | Intel386™ SX / CX / EX |
3 | 4 | 0/1 | x | ? | Intel386™ SL |
4 | 0/1 | x | x | ? | Intel486™ DX |
4 | 2 | x | x | ? | Intel486™ SX |
4 | 3 | x | x | ? | Intel487™/ DX2 / DX2 OverDrive® |
4 | 4 | x | x | ? | Intel486™ SL |
4 | 5 | x | x | ? | IntelSX2™ |
4 | 8 | x | x | ? | IntelDX4™/ DX4 Overdrive® |
5 | 1 | x | x | ? | Pentium®/Pentium OverDrive processors (60,66) |
5 | 2 | x | x | ? | Pentium®/Pentium OverDrive processors (75,90,100,120,133,150,166,200) |
5 | 3 | x | x | ? | Pentium OverDrive for 486 based systems |
5 | 4 | x | x | ? | Pentium processor with MMX™ technology (166,200) & OverDrive with MMX™ for Pentium (75,90,100,120,133) |
6 | 1 | x | x | ? | Pentium Pro |
6 | 3 | x | x | ? | Pentium II, model 3 and Intel Pentium II OverDrive processor |
6 | 5 | x | 0 | ? | Intel® Celeron® model 5 |
6 | 5 | x | 1/2Mb | ? | Pentium II Xeon, model 5 |
6 | 5 | x | otherwise | ? | Pentium II, model 5, Pentium II Xeon with L2 Cache 512kB |
6 | 6 | x | x | ? | Celeron model 6 |
6 | 7 | x | 1/2Mb | ? | Pentium III Xeon, model 7 |
6 | 7 | x | otherwise | ? | Pentium III, model 7 or Pentium III Xeon, model 7 with L2 Cache 512kB |
6 | 8 | x | x | ? | Pentium III, model 8, Pentium III Xeon, model 8 and Intel® Celeron® model 8 |
6 | 9 | x | x | ? | Pentium M processor and Intel® Celeron® model 9 |
6 | 10 | x | x | ? | Pentium III Xeon, model A |
6 | 11 | x | x | ? | Pentium III Xeon, model B |
6 | 13 | x | x | ? | Intel Pentium M processor, Intel® Celeron M model D. All processors are manufactures using 90nm process |
6 | 14 | x | x | ? | Intel Core™ Duo processor, Intel Core™ Solo model E. All processors are manufactures using 65nm process |
6 | 15 | x | x | ? | Intel Core™2 Duo processor model F. All processors are manufactures using 65nm process |
15 | 0 | x | x | ? | Pentium 4 and Intel Xeon processor . All processors are model 0 and manufactured using the 0.18 micron process |
15 | 1 | x | x | ? | Pentium 4, Xeon processor, Intel Xeon processor MP and Intel Celeron. All processors are model 1 and manufactured using the 0.18 micron process |
15 | 2 | x | x | ? | Pentium 4, Mobile Intel P4 - M, Xeon processor, Intel Xeon processor MP, Intel Celeron and Mobile Intel Celeron. All processors are model 2 and manufactured using the 0.13 micron process |
15 | 3 | x | x | ? | Pentium 4, Xeon processor, Intel Celeron D. All processors are model 3 and manufactured using the 90nm process |
15 | 4 | x | x | ? | Pentium 4, P4 Extreme edition, Pentium D, Xeon processor, Xeon MP and Celeton D. All processors are model 4 and manufactured using the 90nm process |
15 | 6 | x | x | ? | Pentium 4, Pentium Extreme edition, Pentium D, Xeon processor, Xeon MP and Celeton D. All processors are model 6 and manufactured using the 65nm process |
[edit] /meminfo
/proc/meminfo
is a pseudo-file in the proc filesystem of recent versions of the Linux kernel. It is accessed to provide information about the current state of the system's computer memory, including information about virtual memory and the cache. It is the primary method for user-level programs to obtain information about the system's memory state, and is used in the implementation of several system monitor utilities.