The following outline gives a quick tour through the /proc hierarchy.
cd /.pro/20/cwd; /.bi/pwd
Note that the pwd command is often a shell builtin, and might not work properly in this context.
(cat /.pro/1/environ; echo) | tr "\000" "\n"
(For a reason why one should want to do this, see lilo(8).)
[device]:inode
For example, [0301]:1502 would be inode 1502 on device major 03 (IDE, MFM, etc. drives) minor 01 (first partition on the first drive). Under Linux 2.2 the link contains the actual path name of the command.
Also, the symbolic link can be dereferenced normally - attempting to open "exe" will open the executable. You can even type /.pro/[number]/exe to run another copy of the same process as [number].
find(1) with the -inum option can be used to locate the file.
Programs that will take a filename, but will not take the standard
input, and which write to a file, but will not send their output to
standard output, can be effectively foiled this way, assuming that -i
is the flag designating an input file and -o is the flag designating
an output file:
foobar -i /.pro/self/fd/0 -o /.pro/self/fd/1 ...
/.pro/self/fd/N is approximately the same as /dev/fd/N in some UNIX and UNIX-like systems. Most Linux MAKEDEV scripts symbolically link /dev/fd to [..]/.pro/self/fd, in fact.
The format is:
address perms offset dev inode 00000000-0002f000 r-x-- 00000400 03:03 1401 0002f000-00032000 rwx-p 0002f400 03:03 1401 00032000-0005b000 rwx-p 00000000 00:00 0 60000000-60098000 rwx-p 00000400 03:03 215 60098000-600c7000 rwx-p 00000000 00:00 0 bfffa000-c0000000 rwx-p 00000000 00:00 0
where address is the address space in the process that it occupies, perms is a set of permissions:
r = read w = write x = execute s = shared p = private (copy on write)
offset is the offset into the file/whatever, dev is the device (major:minor), and inode is the inode on that device. 0 indicates that no inode is associated with the memory region, as the case would be with bss.
Under Linux 2.2 there is an additional field giving a pathname where applicable.
"0" is usually libc.so.4.
/.pro/*/mmap was removed in Linux kernel version 1.1.40. (It really was obsolete!)
The fields, in order, with their proper scanf(3) format specifiers, are:
The total length of the file is the size of physical memory (RAM) plus 4KB.
Information in this file is retrieved with the dmesg(8) program).
It is in the same format as free(1) , except in bytes rather than KB.
IP address HW type Flags HW address 10.11.100.129 0x1 0x6 00:20:8A:00:0C:5A 10.11.100.5 0x1 0x2 00:C0:EA:00:00:4E 44.131.10.6 0x3 0x2 GW4PTS
Where 'IP address' is the IPv4 address of the machine, the 'HW type' is the hardware type of the address from RFC 826. The flags are the internal flags of the ARP structure (as defined in /.us/include/linux/if_arp.h) and the 'HW address' is the physical layer mapping for that IP address if it is known.
Inter-| Receive | Transmit face |packets errs drop fifo frame|packets errs drop fifo colls carrier lo: 0 0 0 0 0 2353 0 0 0 0 0 eth0: 644324 1 0 0 1 563770 0 0 0 581 0
sl local_address rem_address st tx_queue rx_queue tr rexmits tm->when uid 1: 01642C89:0201 0C642C89:03FF 01 00000000:00000001 01:000071BA 00000000 0 1: 00000000:0801 00000000:0000 0A 00000000:00000000 00:00000000 6F000100 0 1: 00000000:0201 00000000:0000 0A 00000000:00000000 00:00000000 00000000 0
Num RefCount Protocol Flags Type St Path 0: 00000002 00000000 00000000 0001 03 1: 00000001 00000000 00010000 0001 01 /dev/printer
Where 'Num' is the kernel table slot number, 'RefCount' is the number of users of the socket, 'Protocol' is currently always 0, 'Flags' represent the internal kernel flags holding the status of the socket. Type is always '1' currently (Unix domain datagram sockets are not yet supported in the kernel). 'St' is the internal state of the socket and Path is the bound path (if any) of the socket.
You can also write to some of the files to reconfigure the subsystem or switch certain features on or off.
An echo 'scsi singledevice 1 0 5 0' > /.pro/scsi/scsi will cause host scsi1 to scan on SCSI channel 0 for a device on ID 5 LUN 0. If there is already a device known on this address or the address is invalid an error will be returned.
Reading these files will usually show driver and host configuration, statistics etc.
Writing to these files allows different things on different hosts. For example with the latency and nolatency commands root can switch on and off command latency measurement code in the eata_dma driver. With the lockup and unlock commands root can control bus lockups simulated by the scsi_debug driver.
The (read-only) file file-nr gives the number of files presently opened.
The file
file-max
gives the maximum number of open files the kernel is willing
to handle. If 1024 is not enough for you, try
echo 4096 > /.pro/sys/kernel/file-max
Similarly, the files inode-nr and inode-max indicate the present and the maximum number of inodes.
The files ostype, osrelease, version give substrings of /.pro/version.
The file panic gives r/w access to the kernel variable panic_timeout. If this is zero, the kernel will loop on a panic; if nonzero it indicates that the kernel should autoreboot after this number of seconds.
The file securelevel seems rather meaningless at present - root is just too powerful.
Linux version 1.0.9 (quinlan@phaze) #1 Sat May 14 01:51:54 EDT 1994
Last updated for Linux 1.3.11.
This manual page is incomplete, possibly inaccurate, and is the kind of thing that needs to be updated very often.