📄 1174-1175.html
字号:
<HTML>
<HEAD>
<TITLE>Linux Complete Command Reference:File Formats:EarthWeb Inc.-</TITLE>
</HEAD>
<META NAME="ROBOTS" CONTENT="NOINDEX, NOFOLLOW">
<SCRIPT>
<!--
function displayWindow(url, width, height) {
var Win = window.open(url,"displayWindow",'width=' + width +
',height=' + height + ',resizable=1,scrollbars=yes');
}
//-->
</SCRIPT>
</HEAD>
-->
<!-- ISBN=0672311046 //-->
<!-- TITLE=Linux Complete Command Reference//-->
<!-- AUTHOR=Red Hat//-->
<!-- PUBLISHER=Macmillan Computer Publishing//-->
<!-- IMPRINT=Sams//-->
<!-- CHAPTER=05 //-->
<!-- PAGES=1103-1208 //-->
<!-- UNASSIGNED1 //-->
<!-- UNASSIGNED2 //-->
<P><CENTER>
<a href="1172-1173.html">Previous</A> | <a href="../ewtoc.html">Table of Contents</A> | <a href="1176-1177.html">Next</A></CENTER></P>
<A NAME="PAGENUM-1174"><P>Page 1174</P></A>
<P>There is also a variant on the format, available by setting the
RAWBITS option at compile time. This variant is different in
the following ways:
</P>
<P>The "magic number" is P6 instead of
P3.
</P>
<P>The pixel values are stored as plain bytes, instead of ASCII decimal.
</P>
<P>Whitespace is not allowed in the pixels area, and only a single character of whitespace (typically a newline) is allowed
after the maxval.
</P>
<P>The files are smaller and many times faster to read and write.
</P>
<P>Note that this raw format can only be used for maxvals less than or equal to
255. If you use the ppm library and try to write a file with a larger maxval, it will automatically fall back on the slower but more general plain format.
<P><B>
SEE ALSO
</B></P>
<!-- CODE //-->
<PRE>
giftoppm(1), gouldtoppm(1), ilbmtoppm(1), imgtoppm(1), mtvtoppm(1), pcxtoppm(1), pgmtoppm(1), pi1toppm(1), picttoppm(1),
pjtoppm(1), qrttoppm(1), rawtoppm(1), rgb3toppm(1), sldtoppm(1), spctoppm(1), sputoppm(1), tgatoppm(1), ximtoppm(1),
xpmtoppm(1), yuvtoppm(1), ppmtoacad(1), ppmtogif(1), ppmtoicr(1), ppmtoilbm(1), ppmtopcx(1), ppmtopgm(1), ppmtopi1(1),
ppmtopict(1), ppmtopj(1), ppmtopuzz(1), ppmtorgb3(1), ppmtosixel(1), ppmtotga(1), ppmtouil(1), ppmtoxpm(1), ppmtoyuv(1),
ppmdither(1), ppmforge(1), ppmhist(1), ppmmake(1), ppmpat(1), ppmquant(1), ppmquantall(1), ppmrelief(1), pnm(5), pgm(5), pbm(5)
</PRE>
<!-- END CODE //-->
<P><B>
AUTHOR
</B></P>
<P>Copyright 1989, 1991 by Jef Poskanzer.
</P>
<P>27 September 1991
</P>
<H3><A NAME="ch05_ 48">
/proc
</A></H3>
<P>/proc—Process information pseudo-filesystem.
</P>
<P><B>
DESCRIPTION
</B></P>
<P>/proc is a pseudo-filesystem that is used as an interface to kernel data structures rather than reading and interpreting
/dev/kmem. Most of it is read-only, but some files allow kernel variables to be changed.
</P>
<P>The following outline gives a quick tour through the
/proc hierarchy.
</P>
<TABLE>
<TR><TD>
[number]
</TD><TD>
There is a numerical subdirectory for each running process; the subdirectory is named by
the process ID. Each contains the following pseudo-files and directories.
</TD></TR><TR><TD>
cmdline
</TD><TD>
This holds the complete command line for the process, unless the whole process has been
swapped out or unless the process is a zombie. In either of these later cases, there is nothing in this file:
That is, a read on this file will return as having read 0 characters. This file is null-terminated but
not newline-terminated.
</TD></TR><TR><TD>
cwd
</TD><TD>
This is a link current working directory of the process. To find out the
cwd of process 20, for instance, you can do this: cd /proc/20/cwd;
/bin/pwd. Note that the pwd command is often a
shell built in and might not work properly in this context.
</TD></TR><TR><TD>
environ
</TD><TD>
This file contains the environment for the process. The entries are separated by null characters,
and there may be a null character at the end. Thus, to print out the environment of process 1,
you would do
</TD></TR><TR><TD>
</TD><TD>
<!-- CODE SNIP //-->
<PRE>
(cat /proc/1/environ; echo) | tr "\000" "\n"
</PRE>
<!-- END CODE SNIP //-->
</TD></TR><TR><TD>
</TD><TD>
For a reason why one should want to do this, see
lilo(8).
</TD></TR><TR><TD>
exe
</TD><TD>
A pointer to the binary that was executed and appears as a symbolic link.
readlink(2) on the exe special file returns a string in the format:
</TD></TR><TR><TD>
</TD><TD>
<!-- CODE SNIP //-->
<PRE>
[device]:inode
</PRE>
<!-- END CODE SNIP //-->
</TD></TR><TR><TD>
</TD><TD>
For example, [0301]:1502 is inode 1502 on device major 03 (IDE, MFM, and so on drives),
minor
</TD></TR></TABLE>
<A NAME="PAGENUM-1175"><P>Page 1175</P></A>
<TABLE>
<TR><TD>
</TD><TD>
01 (first partition on the first drive). Also, the symbolic link can be dereferenced
normally; attempting to open exe will open the executable. You can even type
/proc/[number]/exe to run another copy of the same process as
[number].
</TD></TR><TR><TD>
</TD><TD>
find(1) with the -inum option can be used to locate the file.
</TD></TR><TR><TD>
fd
</TD><TD>
This is a subdirectory containing one entry for each file that the process has open, named by its
file descriptor, and that is a symbolic link to the actual file (as the
exe entry does). Thus, 0 is standard input, 1 standard output, 2 standard error, and so on.
</TD></TR><TR><TD>
</TD><TD>
Programs that will take a filename but will not take the standard input and that 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:
</TD></TR><TR><TD>
</TD><TD>
<!-- CODE SNIP //-->
<PRE>
foobar -i /proc/self/fd/0 -o /proc/self/fd/1 ...
</PRE>
<!-- END CODE SNIP //-->
</TD></TR><TR><TD>
</TD><TD>
and you have a working filter. Note that this will not work for programs that seek on their
files because the files in the fd directory are not seekable.
</TD></TR><TR><TD>
</TD><TD>
/proc/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
/proc/self/fd, in fact.
</TD></TR><TR><TD>
maps
</TD><TD>
A file containing the currently mapped memory regions and their access permissions.
The format is
</TD></TR><TR><TD>
</TD><TD>
<!-- CODE //-->
<PRE>
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
</PRE>
<!-- END CODE //-->
</TD></TR><TR><TD>
</TD><TD>
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).
</TD></TR><TR><TD>
</TD><TD>
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.
</TD></TR><TR><TD>
mem
</TD><TD>
This is not the same as the mem (1,1) device, despite the fact that it has the same device
numbers. The /dev/mem device is the physical memory before any address translation is done, but the
mem file here is the memory of the process that accesses it. This cannot be
mmap(2)ed currently, and will not be until a general
mmap(2) is added to the kernel. (This might have happened by the time you
read this.)
</TD></TR><TR><TD>
mmap
</TD><TD>
Directory of maps by mmap(2) that are symbolic links such as
exe, fd/*, and so on. Note that maps includes a superset of this information, so
/proc/*/mmap should be considered obsolete.
0 is usually libc.so.4.
</TD></TR><TR><TD>
</TD><TD>
/proc/*/mmap was removed in Linux kernel version 1.1.40. (It really was obsolete!)
</TD></TR><TR><TD>
root
</TD><TD>
UNIX and Linux support the idea of a per-process root of the filesystem, set by the
chroot(2) system call. root points to the filesystem root and behaves as
exe, fd/*, and so on do.
</TD></TR><TR><TD>
stat
</TD><TD>
Status information about the process. This is used by
ps(1). The fields, in order, with their proper
scanf(3) format specifiers, are
</TD></TR><TR><TD>
</TD><TD>
<!-- CODE SNIP //-->
<PRE>
pid %d The process ID.
comm %s The filename of the executable in parentheses. This is visible whether or
not the executable is swapped out.
</PRE>
<!-- END CODE SNIP //-->
</TD></TR></TABLE>
<P><CENTER>
<a href="1172-1173.html">Previous</A> | <a href="../ewtoc.html">Table of Contents</A> | <a href="1176-1177.html">Next</A></CENTER></P>
</td>
</tr>
</table>
<!-- begin footer information -->
</body></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -