home *** CD-ROM | disk | FTP | other *** search
/ PC Online 1999 April / PCO0499.ISO / filesbbs / linux / patch-2.2.1.gz < prev    next >
Encoding:
Text File  |  1999-02-11  |  69.5 KB  |  1,967 lines

  1. diff -u --recursive --new-file v2.2.0/linux/CREDITS linux/CREDITS
  2. --- v2.2.0/linux/CREDITS    Wed Jan 20 23:14:03 1999
  3. +++ linux/CREDITS    Thu Jan 28 11:25:04 1999
  4. @@ -49,12 +49,12 @@
  5.  
  6.  N: Erik Andersen
  7.  E: andersee@debian.org
  8. -W: http://www.inconnect.com/~andersen
  9. +W: http://www.xmission.com/~andersen
  10.  P: 1024/FC4CFFED 78 3C 6A 19 FA 5D 92 5A  FB AC 7B A5 A5 E1 FF 8E
  11.  D: Maintainer of ide-cd and Uniform CD-ROM driver, 
  12.  D: ATAPI CD-Changer support, Major 2.1.x CD-ROM update.
  13.  S: 4538 South Carnegie Tech Street
  14. -S: West Valley City, Utah 84120
  15. +S: Salt Lake City, Utah 84120
  16.  S: USA
  17.  
  18.  N: H. Peter Anvin
  19. diff -u --recursive --new-file v2.2.0/linux/Documentation/proc.txt linux/Documentation/proc.txt
  20. --- v2.2.0/linux/Documentation/proc.txt    Wed Dec 31 16:00:00 1969
  21. +++ linux/Documentation/proc.txt    Thu Jan 28 12:16:40 1999
  22. @@ -0,0 +1,1353 @@
  23. +
  24. +-----------------------------------------------------------------------
  25. +
  26. +                T H E  /proc   F I L E S Y S T E M
  27. +
  28. +-----------------------------------------------------------------------
  29. +/proc/sys      Terrehon Bowden <terrehon@wpi.com>       January 27 1999
  30. +               Bodo Bauer <bb@ricochet.net>                
  31. +-----------------------------------------------------------------------
  32. +Version 1.1                                         Kernel version 2.2
  33. +-----------------------------------------------------------------------
  34. +Contents
  35. +
  36. +1   Introduction/Credits
  37. +
  38. +1.1  Legal Issues
  39. +
  40. +2   The /proc file system
  41. +
  42. +2.1  Process specific subdirectories
  43. +2.2  Kernel data
  44. +2.3  IDE devices in /proc/ide
  45. +2.4  Networking info in /proc/net
  46. +2.5  SCSI info
  47. +2.6  Parallel port info in /proc/parport
  48. +2.7  TTY info in /proc/tty
  49. +
  50. +3   Reading and modifying kernel parameters
  51. +
  52. +3.1  /proc/sys/debug and /proc/sys/proc
  53. +3.2  /proc/fs - File system data
  54. +3.3  /proc/fs/binfmt_misc - Miscellaneous binary formats
  55. +3.4  /proc/sys/kernel - General kernel parameters
  56. +3.5  /proc/sys/vm - The virtual memory subsystem
  57. +3.6  /proc/sys/dev - Device specific parameters
  58. +3.7  /proc/sys/sunrpc - Remote procedure calls
  59. +3.8  /proc/sys/net - Networking stuff
  60. +3.9  /proc/sys/net/ipv4 - IPV4 settings=20
  61. +3.10 Appletalk
  62. +3.11 IPX
  63. +
  64. +-----------------------------------------------------------------------
  65. +
  66. +1   Introduction/Credits
  67. +
  68. +This documentation is part of a soon to be released book published by
  69. +IDG Books on the SuSE Linux distribution. As there is no complete
  70. +documentation for the /proc file system and we've used many freely
  71. +available sources to write this chapter, it seems only fair to give
  72. +the work back to the Linux community. This work is based on the
  73. +2.1.132 and 2.2.0-pre-kernel versions. I'm afraid it's still far from
  74. +complete, but we hope it will be useful. As far as we know, it is the
  75. +first 'all-in-oneƆ document about the /proc file system. It is
  76. +focused on the Intel x86 hardware, so if you are looking for PPC, ARM,
  77. +SPARC, APX, etc., features, you probably won't find what you are
  78. +looking for. It also only covers IPv4 networking, not IPv6 nor other
  79. +protocols - sorry.
  80. +
  81. +We'd like to thank Alan Cox, Rik van Riel, and Alexey Kuznetsov.  We'd
  82. +also like to extend a special thank you to Andi Kleen for
  83. +documentation, which we relied on heavily to create this document, as
  84. +well as the additional information he provided. Thanks to everybody
  85. +else who contributed source or docs to the Linux kernel and helped
  86. +create a great piece of software... :)
  87. +
  88. +If you have any comments, corrections or additions, please don't
  89. +hesitate to contact Bodo Bauer at bb@ricochet.net. We'll be happy to
  90. +add them to this document.
  91. +
  92. +The latest version of this document is available online at
  93. +http://www.suse.com/~bb/Docs/proc.html in HTML, ASCII, and as 
  94. +Postscript file. 
  95. +
  96. +1.1  Legal Stuff
  97. +
  98. +We don't guarantee the correctness of this document, and if you come
  99. +to us complaining about how you screwed up your system because of
  100. +incorrect documentation, we won't feel responsible...
  101. +
  102. +-----------------------------------------------------------------------
  103. +
  104. +2   The /proc file system
  105. +
  106. +The proc file system acts as an interface to internal data structures
  107. +in the kernel. It can be used to obtain information about the system
  108. +and to change certain kernel parameters at runtime.  It contains
  109. +(among other things) one subdirectory for each process running on the
  110. +system which is named after the process id (PID) of the process. The
  111. +link self points to the process reading the file system.
  112. +
  113. +2.1  Process specific subdirectories
  114. +
  115. +Each process subdirectory has the in table 1.1 listed entries.
  116. +
  117. +      _________________________________________________
  118. +      cmdline Command line arguments
  119. +      environ Values of environment variables
  120. +      fd    Directory, which contains all file descriptors
  121. +      mem   Memory held by this process
  122. +      stat   Process status
  123. +      status  Process status in human readable form
  124. +      cwd   Link to the current working directory
  125. +      exe   Link to the executable of this process
  126. +      maps   Memory maps
  127. +      root   Link to the root directory of this process
  128. +      statm  Process memory status information
  129. +     _________________________________________________
  130. +      Table 1.1: Process specific entries in /proc
  131. +
  132. +For example, to get the status information of a process, all you have
  133. +to do is read the file /proc/PID/status:
  134. +
  135. +> cat /proc/self/status
  136. +Name:   cat
  137. +State:  R (running)
  138. +Pid:    5633
  139. +PPid:   5609
  140. +Uid:    501     501     501     501
  141. +Gid:    100     100     100     100
  142. +Groups: 100 16 
  143. +VmSize:      804 kB
  144. +VmLck:         0 kB
  145. +VmRSS:       344 kB
  146. +VmData:       68 kB
  147. +VmStk:        20 kB
  148. +VmExe:        12 kB
  149. +VmLib:       660 kB
  150. +SigPnd: 0000000000000000
  151. +SigBlk: 0000000000000000
  152. +SigIgn: 0000000000000000
  153. +SigCgt: 0000000000000000
  154. +CapInh: 00000000fffffeff
  155. +CapPrm: 0000000000000000
  156. +CapEff: 0000000000000000
  157. +
  158. +This shows you almost the same information as you would get if you
  159. +viewed it with the ps command. In fact, ps uses the proc file system
  160. +to obtain its information.
  161. +
  162. +The statm file contains more detailed information about the process
  163. +memory usage. It contains seven values with the following meanings:
  164. +
  165. +size       total program size
  166. +resident   size of in memory portions
  167. +shared     number of the pages that are shared
  168. +trs        number of pages that are 'code'
  169. +drs        number of pages of data/stack
  170. +lrs        number of pages of library
  171. +dt       number of dirty pages
  172. +
  173. +The ratio text/data/library is approximate only by heuristics.
  174. +
  175. +2.2  Kernel data
  176. +
  177. +Similar to the process entries, these are files which give information
  178. +about the running kernel. The files used to obtain this information
  179. +are contained in /proc and are listed in table 1.2. Not all of these
  180. +will be present in your system. It depends on the kernel configuration
  181. +and the loaded modules, which files are there, and which are missing.
  182. +
  183. +      ________________________________________________
  184. +      apm           Advanced power management info
  185. +      cmdline       Kernel command line
  186. +      cpuinfo       Info about the CPU
  187. +      devices       Available devices (block and character)
  188. +      dma           Used DMS channels
  189. +      filesystems   Supported filesystems
  190. +      interrupts    Interrupt usage
  191. +      ioports       I/O port usage
  192. +      kcore         Kernel core image
  193. +      kmsg          Kernel messages
  194. +      ksyms         Kernel symbol table
  195. +      loadavg       Load average
  196. +      locks         Kernel locks
  197. +      meminfo       Memory info
  198. +      misc          Miscellaneous
  199. +      modules       List of loaded modules
  200. +      mounts        Mounted filesystems
  201. +      partitions    Table of partitions known to the system
  202. +      rtc           Real time clock
  203. +      slabinfo      Slab pool info
  204. +      stat          Overall statistics
  205. +      swaps         Swap space utilization
  206. +      uptime        System uptime
  207. +      version       Kernel version
  208. +      ________________________________________________
  209. +           Table 1.2: Kernel info in /proc
  210. +
  211. +You can, for example, check which interrupts are currently in use and
  212. +what they are used for by looking in the file /proc/interrupts:
  213. +
  214. +> cat /proc/interrupts
  215. +           CPU0       
  216. +  0:    8728810          XT-PIC  timer
  217. +  1:        895          XT-PIC  keyboard
  218. +  2:          0          XT-PIC  cascade
  219. +  3:     531695          XT-PIC  aha152x
  220. +  4:    2014133          XT-PIC  serial
  221. +  5:      44401          XT-PIC  pcnet_cs
  222. +  8:          2          XT-PIC  rtc
  223. + 11:          8          XT-PIC  i82365
  224. + 12:     182918          XT-PIC  PS/2 Mouse
  225. + 13:          1          XT-PIC  fpu
  226. + 14:    1232265          XT-PIC  ide0
  227. + 15:          7          XT-PIC  ide1
  228. +NMI:          0
  229. +
  230. +There three more important subdirectories in /proc: net, scsi and
  231. +sys. The general rule is that the contents, or even the existence of
  232. +these directories, depends on your kernel configuration. If SCSI is
  233. +not enabled, the directory scsi may not exist. The same is true with
  234. +the net, which is only there when networking support is present in the
  235. +running kernel.
  236. +
  237. +The slabinfo file gives information about memory usage on the slab
  238. +level.  Linux uses slab pools for memory management above page level
  239. +in version 2.2. Commonly used objects have their own slab pool (like
  240. +network buffers, directory cache, etc.).
  241. +
  242. +2.3  IDE devices in /proc/ide
  243. +
  244. +This subdirectory contains information about all IDE devices that the
  245. +kernel is aware of.  There is one subdirectory for each device
  246. +(i.e. hard disk) containing the following files:
  247. +
  248. +       cache             The cache
  249. +       capacity          Capacity of the medium
  250. +       driver            Driver and version
  251. +       geometry          Physical and logical geometry
  252. +       identify          Device identify block
  253. +       media             Media type
  254. +       model             Device identifier
  255. +       settings          Device setup
  256. +       smart_thresholds  IDE disk management thresholds
  257. +       smart_values      IDE disk management values
  258. +
  259. +2.4  Networking info in /proc/net
  260. +
  261. +This directory follows the usual pattern. Table 1.3 lists the files
  262. +and their meaning.
  263. +
  264. +     ____________________________________________________
  265. +     arp             Kernel ARP table
  266. +     dev             network devices with statistics
  267. +     dev_mcast       Lists the Layer2 multicast groups a
  268. +                     device is listening to (interface index,
  269. +                     label, number of references, number of
  270. +                     bound addresses).
  271. +     dev_stat        network device status
  272. +     ip_fwchains     Firewall chain linkage
  273. +     ip_fwnames      Firewall chains
  274. +     ip_masq         Directory containing the masquerading
  275. +                     tables.
  276. +     ip_masquerade   Major masquerading table
  277. +     netstat         Network statistics
  278. +     raw             Raw device statistics
  279. +     route           Kernel routing table
  280. +     rpc             Directory containing rpc info
  281. +     rt_cache        Routing cache
  282. +     snmp            SNMP data
  283. +     sockstat        Socket statistics
  284. +     tcp             TCP sockets
  285. +     tr_rif          Token ring RIF routing table
  286. +     udp             UDP sockets
  287. +     unix            UNIX domain sockets
  288. +     wireless        Wireless interface data (Wavelan etc)
  289. +     igmp            IP multicast addresses, which this host joined
  290. +     psched          Global packet scheduler parameters.
  291. +     netlink         List of PF_NETLINK sockets.
  292. +     ip_mr_vifs      List of multicast virtual interfaces.
  293. +     ip_mr_cache     List of multicast routing cache.
  294. +     udp6            UDP sockets (IPv6)
  295. +     tcp6            TCP sockets (IPv6)
  296. +     raw6            Raw device statistics (IPv6)
  297. +     igmp6         IP multicast addresses, which this host joineed (IPv6)
  298. +     if_inet6        List of IPv6 interface addresses.
  299. +     ipv6_route      Kernel routing table for IPv6
  300. +     rt6_stats       global IPv6 routing tables statistics.
  301. +     sockstat6       Socket statistics (IPv6)
  302. +     snmp6           Snmp data (IPv6)
  303. +     ____________________________________________________
  304. +         Table 1.3: Network info in /proc/net
  305. +
  306. +You can use this information to see which network devices are
  307. +available in your system and how much traffic was routed over those
  308. +devices:
  309. +
  310. +> cat /proc/net/dev
  311. +Inter-|Receive                                                   |[...
  312. + face |bytes    packets errs drop fifo frame compressed multicast|[...
  313. +    lo:  908188   5596     0    0    0     0          0         0 [...        
  314. +  ppp0:15475140  20721   410    0    0   410          0         0 [... 
  315. +  eth0:  614530   7085     0    0    0     0          0         1 [...
  316. +
  317. +...] Transmit
  318. +...] bytes    packets errs drop fifo colls carrier compressed
  319. +...]  908188     5596    0    0    0     0       0          0
  320. +...] 1375103    17405    0    0    0     0       0          0
  321. +...] 1703981     5535    0    0    0     3       0          0
  322. +
  323. +2.5  SCSI info
  324. +
  325. +If you have a SCSI host adapter in your system, you'll find a
  326. +subdirectory named after the driver for this adapter in /proc/scsi. 
  327. +You'll also see a list of all recognized SCSI devices in /proc/scsi:
  328. +
  329. +>cat /proc/scsi/scsi
  330. +Attached devices: 
  331. +Host: scsi0 Channel: 00 Id: 00 Lun: 00
  332. +  Vendor: QUANTUM  Model: XP34550W         Rev: LXY4
  333. +  Type:   Direct-Access                    ANSI SCSI revision: 02
  334. +Host: scsi0 Channel: 00 Id: 01 Lun: 00
  335. +  Vendor: SEAGATE  Model: ST34501W         Rev: 0018
  336. +  Type:   Direct-Access                    ANSI SCSI revision: 02
  337. +Host: scsi0 Channel: 00 Id: 02 Lun: 00
  338. +  Vendor: SEAGATE  Model: ST34501W         Rev: 0017
  339. +  Type:   Direct-Access                    ANSI SCSI revision: 02
  340. +Host: scsi0 Channel: 00 Id: 04 Lun: 00
  341. +  Vendor: ARCHIVE  Model: Python 04106-XXX Rev: 703b
  342. +  Type:   Sequential-Access                ANSI SCSI revision: 02
  343. +
  344. +The directory named after the driver has one file for each adapter
  345. +found in the system. These files contain information about
  346. +the controller, including the used IRQ and the IO address range:
  347. +
  348. +>cat /proc/scsi/ncr53c8xx/0
  349. +General information:
  350. + Chip NCR53C875, device id 0xf, revision id 0x4
  351. + IO port address 0xec00, IRQ number 11
  352. + Synchronous period factor 12, max commands per lun 4
  353. +
  354. +2.6  Parallel port info in /proc/parport
  355. +
  356. +The directory /proc/parport contains information about the parallel
  357. +ports of your system. It has one subdirectory for each port, named
  358. +after the port number (0,1,2,...).
  359. +
  360. +This directory contains four files:
  361. +
  362. +    autoprobe   Autoprobe results of this port
  363. +    devices     Connected device modules
  364. +    hardware    Hardware info (port type, io-port, DMA, IRQ, etc.)
  365. +    irq         Used interrupt, if any
  366. +
  367. +2.7  TTY info in /proc/tty
  368. +
  369. +Information about the available and the actually used tty's can be
  370. +found in /proc/tty. You'll find entries for drivers and line
  371. +disciplines in this directory, as shown in the table below:
  372. +
  373. +     drivers       List of drivers and their usage
  374. +     ldiscs        Registered line disciplines
  375. +     driver/serial Usage statistic and status of single tty lines
  376. +
  377. +To see which tty's are currently in use, you can simply look into the
  378. +file /proc/tty/drivers:
  379. +
  380. +>cat /proc/tty/drivers
  381. +pty_slave            /dev/pts      136   0-255 pty:slave
  382. +pty_master           /dev/ptm      128   0-255 pty:master
  383. +pty_slave            /dev/ttyp       3   0-255 pty:slave
  384. +pty_master           /dev/pty        2   0-255 pty:master
  385. +serial               /dev/cua        5   64-67 serial:callout
  386. +serial               /dev/ttyS       4   64-67 serial
  387. +/dev/tty0            /dev/tty0       4       0 system:vtmaster
  388. +/dev/ptmx            /dev/ptmx       5       2 system
  389. +/dev/console         /dev/console    5       1 system:console
  390. +/dev/tty             /dev/tty        5       0 system:/dev/tty
  391. +unknown              /dev/tty        4    1-63 console
  392. +
  393. +-----------------------------------------------------------------------
  394. +
  395. +3   Reading and modifying kernel parameters
  396. +
  397. +A very interesting part of /proc is the directory /proc/sys. This not
  398. +only provides information, it also allows you to change parameters
  399. +within the kernel. Be very careful when trying this. You can optimize
  400. +your system, but you also can crash it. Never play around with kernel
  401. +parameters on a production system. Set up a development machine and
  402. +test to make sure that everything works the way you want it to.  You
  403. +may have no alternative but to reboot the machine once an error has
  404. +been made.
  405. +
  406. +To change a value, simply echo the new value into the file. An example
  407. +is given below in the section on the file system data. You need to be
  408. +root to do this. You can create your own boot script to get this done
  409. +every time your system boots. 
  410. +
  411. +The files in /proc/sys can be used to tune and monitor miscellaneous
  412. +and general things in the operation of the Linux kernel.  Since some
  413. +of the files can inadvertently disrupt your system, it is advisable to
  414. +read both documentation and source before actually making
  415. +adjustments. In any case, be very careful when writing to any of these
  416. +files. The entries in /proc may change slightly between the 2.1.* and
  417. +the 2.2 kernel, so review the kernel documentation if there is any
  418. +doubt. You'll find the documentation in the directory
  419. +/usr/src/linux/Documentation/sys. This chapter is heavily based on the
  420. +documentation included in the pre 2.2 kernels. Thanks to Rick van Riel
  421. +for providing this information.
  422. +
  423. +3.1  /proc/sys/debug and /proc/sys/proc
  424. +
  425. +These two subdirectories are empty.
  426. +
  427. +3.2  /proc/fs - File system data
  428. +
  429. +This subdirectory contains specific file system, file handle, inode,
  430. +dentry and quota information.
  431. +
  432. +Currently, these files are in /proc/sys/fs:
  433. +
  434. +dentry-state
  435. +   Status of the directory cache. Since directory entries are
  436. +   dynamically allocated and deallocated, this file gives information
  437. +   about the current status. It holds six values, in which the last
  438. +   two are not used and are always zero. The other four mean:
  439. +
  440. +       nr_dentry   Seems to be zero all the time
  441. +       nr_unused   Number of unused cache entries
  442. +       age_limit   Age in seconds after the entry may be
  443. +                   reclaimed, when memory is short
  444. +       want_pages  internal
  445. +
  446. +dquot-nr and dquot-max
  447. +   The file dquot-max shows the maximum number of cached disk quota
  448. +   entries.
  449. +
  450. +   The file dquot-nr shows the number of allocated disk quota
  451. +   entries and the number of free disk quota entries.
  452. +
  453. +   If the number of free cached disk quotas is very low and you have
  454. +   a large number of simultaneous system users, you might want
  455. +   to raise the limit.
  456. +
  457. +file-nr and file-max
  458. +   The kernel allocates file handles dynamically, but as yet
  459. +   doesn't free them again.
  460. +
  461. +   The value in file-max denotes the maximum number of file handles
  462. +   that the Linux kernel will allocate. When you get a lot of error
  463. +   messages about running out of file handles, you might want to raise
  464. +   this limit. The default value is 4096. To change it, just write the
  465. +   new number into the file:
  466. +
  467. +   # cat /proc/sys/fs/file-max
  468. +   4096
  469. +   # echo 8192 > /proc/sys/fs/file-max
  470. +   # cat /proc/sys/fs/file-max
  471. +   8192
  472. +
  473. +   This method of revision is useful for all customizable parameters
  474. +   of the kernel - simply echo the new value to the corresponding
  475. +   file.
  476. +  
  477. +   The three values in file-nr denote the number of allocated file
  478. +   handles, the number of used file handles, and the maximum number of
  479. +   file handles. When the allocated file handles come close to the
  480. +   maximum, but the number of actually used ones is far behind, you've
  481. +   encountered a peak in your usage of file handles and you don't need
  482. +   to increase the maximum.
  483. +
  484. +   However, there is still a per process limit of open files, which
  485. +   unfortunatly can't be changed that easily. It is set to 1024 by
  486. +   default. To change this you have to edit the files limits.h and
  487. +   fs.h in the directory /usr/src/linux/include/linux. Change the
  488. +   definition of NR_OPEN and recompile the kernel.
  489. +
  490. +inode-state, inode-nr and inode-max
  491. +   As with file handles, the kernel allocates the inode structures
  492. +   dynamically, but can't free them yet.
  493. +
  494. +   The value in inode-max denotes the maximum number of inode
  495. +   handlers. This value should be 3 to 4 times larger than the value
  496. +   in file-max, since stdin, stdout, and network sockets also need an
  497. +   inode struct to handle them. If you regularly run out of inodes,
  498. +   you should increase this value.
  499. +
  500. +   The file inode-nr contains the first two items from inode-state, so
  501. +   we'll skip to that file...
  502. +
  503. +   inode-state contains three actual numbers and four dummy values. The 
  504. +   actual numbers are (in order of appearance) nr_inodes, nr_free_inodes,
  505. +   and preshrink.
  506. +
  507. +   nr_inodes 
  508. +     Denotes the number of inodes the system has allocated. This can
  509. +     be slightly more than inode-max because Linux allocates them one
  510. +     pageful at a time.
  511. +
  512. +   nr_free_inodes 
  513. +     Represents the number of free inodes and pre shrink is nonzero
  514. +     when the nr_inodes > inode-max and the system needs to prune the
  515. +     inode list instead of allocating more.
  516. +
  517. +super-nr and super-max
  518. +   Again, super block structures are allocated by the kernel,
  519. +   but not freed. The file super-max contains the maximum number of
  520. +   super block handlers, where super-nr shows the number of
  521. +   currently allocated ones.
  522. +
  523. +   Every mounted file system needs a super block, so if you plan to
  524. +   mount lots of file systems, you may want to increase these
  525. +   numbers.
  526. +
  527. +3.3  /proc/fs/binfmt_misc - Miscellaneous binary formats
  528. +
  529. +Besides these files, there is the subdirectory
  530. +/proc/sys/fs/binfmt_misc. This handles the kernel support for
  531. +miscellaneous binary formats.
  532. +
  533. +Binfmt_misc provides the ability to register additional binary formats
  534. +to the Kernel without compiling an additional module/kernel. Therefore
  535. +binfmt_misc needs to know magic numbers at the beginning or the
  536. +filename extension of the binary.
  537. +
  538. +It works by maintaining a linked list of structs, that contain a
  539. +description of a binary format, including a magic with size (or the
  540. +filename extension), offset and mask, and the interpreter name. On
  541. +request it invokes the given interpreter with the original program as
  542. +argument, as binfmt_java and binfmt_em86 and binfmt_mz do.
  543. +Since binfmt_misc does not define any default binary-formats, you have to
  544. +register an additional binary-format.
  545. +
  546. +There are two general files in binfmt_misc and one file per registered
  547. +format. The two general files are register and status.
  548. +
  549. +Registering a new binary format
  550. +
  551. +echo :name:type:offset:magic:mask:interpreter: > /proc/sys/fs/binfmt_misc/register 
  552. +
  553. +with appropriate name (the name for the /proc-dir entry), offset
  554. +(defaults to 0, if omitted), magic and mask (which can be omitted,
  555. +defaults to all 0xff) and last but not least, the interpreter that is
  556. +to be invoked (for example and testing '/bin/echo'). Type can be M for
  557. +usual magic matching or E for filename extension matching (give
  558. +extension in place of magic).
  559. +
  560. +To check or reset the status of the binary format handler:
  561. +
  562. +If you do a cat on the file /proc/sys/fs/binfmt_misc/status, you will
  563. +get the current status (enabled/disabled) of binfmt_misc. Change the
  564. +status by echoing 0 (disables) or 1 (enables) or -1 (caution: this
  565. +clears all previously registered binary formats) to status. For
  566. +example echo 0 > status to disable binfmt_misc (temporarily).
  567. +
  568. +Status of a single handler
  569. +
  570. +Each registered handler has an entry in /proc/sys/fs/binfmt_misc.
  571. +These files perform the same function as status, but their scope is
  572. +limited to the actual binary format. By cating this file, you also
  573. +receive all related information about the interpreter/magic of the
  574. +binfmt.
  575. +
  576. +Example usage of binfmt_misc (emulate binfmt_java)
  577. +
  578. +cd /proc/sys/fs/binfmt_misc
  579. +echo ':Java:M::\xca\xfe\xba\xbe::/usr/local/java/bin/javawrapper:' > register
  580. +echo ':HTML:E::html::/usr/local/java/bin/appletviewer:' > register
  581. +echo ':Applet:M::<!--applet::/usr/local/java/bin/appletviewer:' > register
  582. +echo ':DEXE:M::\x0eDEX::/usr/bin/dosexec:' > register
  583. +
  584. +These three lines add support for Java executables and Java applets
  585. +(like binfmt_java, additionally recognizing the .html extension with
  586. +no need to put <!--applet> to every applet file). You have to install
  587. +the JDK and the shell-script /usr/local/java/bin/javawrapper too. It
  588. +works around the brokenness of the Java filename handling. To add a
  589. +Java binary, just create a link to the class-file somewhere in the
  590. +path.
  591. +
  592. +3.4  /proc/sys/kernel - general kernel parameters
  593. +
  594. +This directory reflects general kernel behaviors. As I've said before,
  595. +the contents are depend on your configuration. I'll list the most
  596. +important files, along with descriptions of what they mean and how to
  597. +use them.
  598. +
  599. +acct
  600. +   The file contains three values; highwater, lowwater, and
  601. +   frequency.
  602. +
  603. +   It exists only when BSD-style process accounting is enabled. These
  604. +   values control its behavior. If the free space on the file system
  605. +   where the log lives goes below lowwater%, accounting suspends. If
  606. +   it goes above highwater%, accounting resumes. Frequency determines
  607. +   how often you check the amount of free space (value is in
  608. +   seconds). Default settings are: 4, 2, and 30. That is, suspend
  609. +   accounting if there left <= 2% free; resume it if we have a value
  610. +   >=3%; consider information about the amount of free space valid
  611. +   for 30 seconds
  612. +
  613. +ctrl-alt-del
  614. +   When the value in this file is 0, ctrl-alt-del is trapped and sent
  615. +   to the init(1) program to handle a graceful restart. However, when
  616. +   the value is > 0, Linux's reaction to this key combination will be
  617. +   an immediate reboot, without syncing its dirty buffers.
  618. +
  619. +   Note: when a program (like dosemu) has the keyboard in raw mode,
  620. +   the ctrl-alt-del is intercepted by the program before it ever
  621. +   reaches the kernel tty layer, and it is up to the program to decide
  622. +   what to do with it.
  623. +
  624. +domainname and hostname
  625. +   These files can be controlled to set the NIS domainname and
  626. +   hostname of your box. For the classic darkstar.frop.org a simple:
  627. +
  628. +   # echo "darkstar" > /proc/sys/kernel/hostname
  629. +   # echo "frop.org" > /proc/sys/kernel/domainname
  630. +
  631. +   would suffice to set your hostname and NIS domainname.
  632. +
  633. +osrelease, ostype and version
  634. +
  635. +   The names make it pretty obvious what these fields contain:
  636. +
  637. +   >cat /proc/sys/kernel/osrelease
  638. +   2.1.131
  639. +   >cat /proc/sys/kernel/ostype
  640. +   Linux
  641. +   >cat /proc/sys/kernel/version
  642. +   #8 Mon Jan 25 19:45:02 PST 1999
  643. +   The files osrelease and ostype should be clear enough. Version
  644. +   needs a little more clarification however. The #8 means that this
  645. +   is the 8th kernel built from this source base and the date behind
  646. +   it indicates the time the kernel was built. The only way to tune
  647. +   these values is to rebuild the kernel.
  648. +
  649. +panic 
  650. +   The value in this file represents the number of seconds the kernel
  651. +   waits before rebooting on a panic. When you use the software
  652. +   watchdog, the recommended setting is 60. If set to 0, the auto
  653. +   reboot after a kernel panic is disabled, this is the default
  654. +   setting.
  655. +
  656. +printk
  657. +   The four values in printk denote console_loglevel,
  658. +   default_message_loglevel, minimum_console_level, and
  659. +   default_console_loglevel respectively.
  660. +
  661. +   These values influence printk() behavior when printing or logging
  662. +   error messages, which come from inside the kernel. See syslog(2)
  663. +   for more information on the different log levels.
  664. +
  665. +   console_loglevel
  666. +     Messages with a higher priority than this will be printed to
  667. +     the console.
  668. +
  669. +   default_message_level
  670. +     Messages without an explicit priority will be printed with
  671. +     this priority.
  672. +
  673. +   minimum_console_loglevel
  674. +     Minimum (highest) value to which the console_loglevel can be set.
  675. +
  676. +   default_console_loglevel
  677. +     Default value for console_loglevel.
  678. +
  679. +sg-big-buff
  680. +   This file shows the size of the generic SCSI (sg) buffer. At this
  681. +   point, you canƆt tune it yet, but you can change it at compile time
  682. +   by editing include/scsi/sg.h and changing the value of
  683. +   SG_BIG_BUFF.
  684. +
  685. +   If you use a scanner with SANE (Scanner Access now easy) you
  686. +   might want to set this to a higher value. Look into the SANE
  687. +   documentation on this issue.
  688. +
  689. +modprobe
  690. +   The location where the modprobe binary is located. The kernel
  691. +   uses this program to load modules on demand.
  692. +
  693. +3.5  /proc/sys/vm - The virtual memory subsystem
  694. +
  695. +The files in this directory can be used to tune the operation of the
  696. +virtual memory (VM) subsystem of the Linux kernel. In addition, one of
  697. +the files (bdflush) has a little influence on disk usage.
  698. +
  699. +bdflush
  700. +   This file controls the operation of the bdflush kernel daemon. It
  701. +   currently contains 9 integer values, 6 of which are actually used
  702. +   by the kernel:
  703. +
  704. +    nfract      Percentage of buffer cache dirty to
  705. +                activate bdflush
  706. +    ndirty      Maximum number of dirty blocks to
  707. +                write out per-wake-cycle
  708. +    nrefill     Number of clean buffers to try to obtain
  709. +                each time we call refill
  710. +    nref_dirt   Dirty buffer threshold for activating bdflush
  711. +                when trying to refill buffers.
  712. +    dummy       unused
  713. +    age_buffer  Time for normal buffer to age before you flush it
  714. +    age_super   Time for superblock to age before you flush it
  715. +    dummy       unused
  716. +    dummy       unused
  717. +
  718. +   nfract
  719. +     This parameter governs the maximum number of dirty buffers
  720. +     in the buffer cache. Dirty means that the contents of the
  721. +     buffer still have to be written to disk (as opposed to a
  722. +     clean buffer, which can just be forgotten about). Setting
  723. +     this to a high value means that Linux can delay disk writes
  724. +     for a long time, but it also means that it will have to do a
  725. +     lot of I/O at once when memory becomes short. A low value
  726. +     will spread out disk I/O more evenly.
  727. +
  728. +   ndirty
  729. +     Ndirty gives the maximum number of dirty buffers that
  730. +     bdflush can write to the disk at one time. A high value will
  731. +     mean delayed, bursty I/O, while a small value can lead to
  732. +     memory shortage when bdflush isn't woken up often enough.
  733. +
  734. +   nrefill
  735. +     This the number of buffers that bdflush will add to the list
  736. +     of free buffers when refill_freelist() is called. It is
  737. +     necessary to allocate free buffers beforehand, since the
  738. +     buffers are often different sizes than the memory pages
  739. +     and some bookkeeping needs to be done beforehand. The
  740. +     higher the number, the more memory will be wasted and the
  741. +     less often refill_freelist() will need to run.
  742. +
  743. +   nref_dirt
  744. +     When refill_freelist() comes across more than nref_dirt
  745. +     dirty buffers, it will wake up bdflush.
  746. +
  747. +   age_buffer and age_super
  748. +     Finally, the age_buffer and age_super parameters govern the
  749. +     maximum time Linux waits before writing out a dirty buffer
  750. +     to disk. The value is expressed in jiffies (clockticks), the
  751. +     number of jiffies per second is 100. Age_buffer is the
  752. +     maximum age for data blocks, while age_super is for
  753. +     filesystems meta data.
  754. +
  755. +buffermem
  756. +   The three values in this file control how much memory should be
  757. +   used for buffer memory. The percentage is calculated as a
  758. +   percentage of total system memory.
  759. +
  760. +   The values are:
  761. +
  762. +   min_percent
  763. +     This is the minimum percentage of memory that should be
  764. +     spent on buffer memory.
  765. +
  766. +   borrow_percent
  767. +     When Linux is short on memory, and the buffer cache uses more
  768. +     than it has been allotted, the memory mangement (MM) subsystem
  769. +     will prune the buffer cache more heavily than other memory to
  770. +     compensate.
  771. +
  772. +   max_percent
  773. +     This is the maximum amount of memory that can be used for
  774. +     buffer memory.
  775. +
  776. +freepages
  777. +   This file contains three values: min, low and high:
  778. +
  779. +   min
  780. +     When the number of free pages in the system reaches this number,
  781. +     only the kernel can allocate more memory.
  782. +
  783. +   low
  784. +     If the number of free pages gets below this point, the kernel
  785. +     starts swapping aggressively.
  786. +
  787. +   high
  788. +     The kernel tries to keep up to this amount of memory free; if
  789. +     memory comes below this point, the kernel gently starts swapping
  790. +     in the hopes that it never has to do really aggressive swapping.
  791. +
  792. +kswapd
  793. +   Kswapd is the kernel swap out daemon. That is, kswapd is that piece
  794. +   of the kernel that frees memory when it gets fragmented or
  795. +   full. Since every system is different, you'll probably want some
  796. +   control over this piece of the system.
  797. +
  798. +   The file contains three numbers:
  799. +
  800. +   tries_base
  801. +     The maximum number of pages kswapd tries to free in one round is
  802. +     calculated from this number. Usually this number will be divided
  803. +     by 4 or 8 (see mm/vmscan.c), so it isn't as big as it looks.
  804. +
  805. +     When you need to increase the bandwidth to/from swap, you'll want
  806. +     to increase this number.
  807. +
  808. +   tries_min
  809. +     This is the minimum number of times kswapd tries to free a page
  810. +     each time it is called. Basically it's just there to make sure
  811. +     that kswapd frees some pages even when it's being called with
  812. +     minimum priority.
  813. +
  814. +
  815. +  swap_cluster
  816. +     This is probably the greatest influence on system
  817. +     performance. swap_cluster is the number of pages kswapd writes in
  818. +     one turn. YouƆll want this value to be large so that kswapd does
  819. +     its I/O in large chunks and the disk doesnƆt have to seek as
  820. +     often., but you donƆt want it to be too large since that would
  821. +     flood the request queue.
  822. +
  823. +overcommit_memory
  824. +   This file contains one value. The following algorithm is used to
  825. +   decide if there's enough memory: if the value of overcommit_memory
  826. +   is positive, then there's always enough memory. This is a useful
  827. +   feature, since programs often malloc() huge amounts of memory 'just
  828. +   in case', while they only use a small part of it. Leaving this
  829. +   value at 0 will lead to the failure of such a huge malloc(), when
  830. +   in fact the system has enough memory for the program to run.
  831. +
  832. +   On the other hand, enabling this feature can cause you to run out
  833. +   of memory and thrash the system to death, so large and/or important
  834. +   servers will want to set this value to 0.
  835. +
  836. +pagecache
  837. +   This file does exactly the same as buffermem, only this file
  838. +   controls the amount of memory allowed for memory mapping and
  839. +   generic caching of files.
  840. +
  841. +   You don't want the minimum level to be too low, otherwise your
  842. +   system might thrash when memory is tight or fragmentation is
  843. +   high.
  844. +
  845. +pagetable_cache
  846. +   The kernel keeps a number of page tables in a per-processor cache
  847. +   (this helps a lot on SMP systems). The cache size for each
  848. +   processor will be between the low and the high value.
  849. +
  850. +   On a low-memory, single CPU system, you can safely set these values
  851. +   to 0 so you don't waste memory. It is used on SMP systems so that
  852. +   the system can perform fast pagetable allocations without having to
  853. +   aquire the kernel memory lock.
  854. +
  855. +   For large systems, the settings are probably fine. For normal
  856. +   systems they won't hurt a bit. For small systems (<16MB ram) it
  857. +   might be advantageous to set both values to 0.
  858. +
  859. +swapctl
  860. +   This file contains no less than 8 variables. All of these values
  861. +   are used by kswapd.
  862. +
  863. +   The first four variables sc_max_page_age, sc_page_advance,
  864. +   sc_page_decline and sc_page_initial_age are used to keep track of
  865. +   Linux's page aging. Page aging is a bookkeeping method to track
  866. +   which pages of memory are often used, and which pages can be
  867. +   swapped out without consequences.
  868. +
  869. +   When a page is swapped in, it starts at sc_page_initial_age
  870. +   (default 3) and when the page is scanned by kswapd, its age is
  871. +   adjusted according to the following scheme:
  872. +
  873. +    o If the page was used since the last time we scanned, its age
  874. +      is increased by sc_page_advance (default 3) up to a
  875. +      maximum of sc_max_page_age (default 20).
  876. +
  877. +    o Else (meaning it wasn't used) its age is decreased by
  878. +      sc_page_decline (default 1).
  879. +
  880. +   When a page reaches age 0, it's ready to be swapped out.
  881. +
  882. +   The next four variables sc_age_cluster_fract, sc_age_cluster_min,
  883. +   sc_pageout_weight and sc_bufferout_weight, can be used to control
  884. +   kswapd's aggressiveness in swapping out pages.
  885. +
  886. +   Sc_age_cluster_fract is used to calculate how many pages from a
  887. +   process are to be scanned by kswapd. The formula used is
  888. +
  889. +           sc_age_cluster_fract
  890. +           -------------------- * resident set size
  891. +              1024   =20
  892. +
  893. +   So if you want kswapd to scan the whole process,
  894. +   sc_age_cluster_fract needs to have a value of 1024. The minimum
  895. +   number of pages kswapd will scan is represented by
  896. +   sc_age_cluster_min, this is done so kswapd will also scan small
  897. +   processes.
  898. +
  899. +   The values of sc_pageout_weight and sc_bufferout_weight are used
  900. +   to control how many tries kswapd will make in order to swap out
  901. +   one page/buffer. These values can be used to fine-tune the ratio
  902. +   between user pages and buffer/cache memory. When you find that
  903. +   your Linux system is swapping out too many process pages in order
  904. +   to satisfy buffer memory demands, you might want to either
  905. +   increase sc_bufferout_weight, or decrease the value of
  906. +   sc_pageout_weight.
  907. +
  908. +3.6  /proc/sys/dev - Device specific parameters
  909. +
  910. +Currently there is only support for CDROM drives, and for those, there
  911. +is only one read only file containing information about the CD-ROM
  912. +drives attached to the system:
  913. +
  914. +>cat /proc/sys/dev/cdrom/info
  915. +CD-ROM information
  916. +
  917. +drive name:           sr0  hdc
  918. +drive speed:           0    6
  919. +drive # of slots:      1    0
  920. +Can close tray:        1    1
  921. +Can open tray:         1    1
  922. +Can lock tray:         1    1
  923. +Can change speed:      1    1
  924. +Can select disk:       0    1
  925. +Can read multisession: 1    1
  926. +Can read MCN:          1    1
  927. +Reports media changed: 1    1
  928. +Can play audio:        1    1
  929. +
  930. +You see two drives, sr0 and hdc, and their lists of features.
  931. +
  932. +3.7  /proc/sys/sunrpc - Remote procedure calls
  933. +
  934. +This directory contains four files, which enable or disable debugging
  935. +for the RPC functions NFS, NFS-daemon, RPC and NLM. The default values
  936. +are 0. They can be set to one, to turn debugging on.  (The default
  937. +value is 0 for each)
  938. +
  939. +3.8  /proc/sys/net - Networking stuff
  940. +
  941. +The interface to the networking parts of the kernel is located in
  942. +/proc/sys/net. The table below shows all possible subdirectories. You
  943. +may see only some of them, depending on the configuration of your
  944. +kernel:
  945. +
  946. ++-------------------------------------------------------------+
  947. +| core     General parameter   |appletalk  Appletalk protocol |
  948. +| unix     Unix domain sockets |netrom     NET/ROM            |
  949. +| 802      E802 protocol       |ax25       AX25               |
  950. +| ethernet Ethernet protocol   |rose       X.25 PLP layer     |
  951. +| ipv4     IP version 4        |x25        X.25 protocol      |
  952. +| ipx      IPX                 |token-ring IBM token ring     |
  953. +| bridge   Bridging            |decnet     DEC net            |
  954. +| ipv6     IP version 6        |                              |
  955. ++-------------------------------------------------------------+
  956. +
  957. +We will concentrate on IP networking here. As AX15, X.25, and DEC Net
  958. +are only minor players in the Linux world, we'll skip them in this
  959. +chapter. You'll find some short info to Appletalk and IPX further down
  960. +in section 3.10 and 3.11. Please look in the online documentation and
  961. +the kernel source to get a detailed view of the parameters for those
  962. +protocols. In this section we'll discuss the subdirectories printed in
  963. +bold letters in the table above. As default values are suitable for
  964. +most needs, there is no need to change these values.
  965. +
  966. +/proc/sys/net/core - Network core options
  967. +
  968. +rmem_default
  969. +   The default setting of the socket receive buffer in bytes.
  970. +
  971. +rmem_max
  972. +   The maximum receive socket buffer size in bytes.
  973. +
  974. +wmem_default
  975. +   The default setting (in bytes) of the socket send buffer.
  976. +
  977. +wmem_max
  978. +   The maximum send socket buffer size in bytes.
  979. +
  980. +message_burst and message_cost
  981. +   These parameters are used to limit the warning messages written to
  982. +   the kernel log from the networking code. They enforce a rate limit
  983. +   to make a denial-of-service attack impossible. The higher the
  984. +   message_cost factor is, the less messages will be
  985. +   written. Message_burst controls when messages will be dropped. The
  986. +   default settings limit warning messages to one every five seconds.
  987. +
  988. +netdev_max_backlog
  989. +   Maximal number of packets, queued on INPUT side, when the interface
  990. +   receives packets faster than kernel can process them.
  991. +
  992. +optmem_max
  993. +   Maximum ancillary buffer size allowed per socket. Ancillary data is
  994. +   a sequence of struct cmsghdr structures with appended data.
  995. +
  996. +/proc/sys/net/unix - Parameters for UNIX domain sockets
  997. +
  998. +There are only two files in this subdirectory. They control the delays
  999. +for deleting and destroying socket descriptors.
  1000. +
  1001. +3.9  /proc/sys/net/ipv4 - IPV4 settings
  1002. +
  1003. +IP version 4 is still the most used protocol in Unix networking. It
  1004. +will be replaced by IP version 6 in the next couple of years, but for
  1005. +the moment it's the de facto standard for the internet and is used in
  1006. +most networking environments around the world. Because of the
  1007. +importance of this protocol, we'll have a deeper look into the subtree
  1008. +controlling the behavior of the IPv4 subsystem of the Linux kernel.
  1009. +
  1010. +Let's start with the entries in /proc/sys/net/ipv4 itself.
  1011. +
  1012. +ICMP settings
  1013. +
  1014. +icmp_echo_ignore_all and icmp_echo_ignore_broadcasts
  1015. +   Turn on (1) or off (0), if the kernel should ignore all ICMP ECHO
  1016. +   requests, or just those to broadcast and multicast addresses.
  1017. +
  1018. +   Please note that if you accept ICMP echo requests with a
  1019. +   broadcast/multicast destination address your network may be used
  1020. +   as an exploder for denial of service packet flooding attacks to
  1021. +   other hosts.
  1022. +
  1023. +icmp_destunreach_rate, icmp_echoreply_rate,
  1024. +icmp_paramprob_rate and icmp_timeexeed_rate
  1025. +   Sets limits for sending ICMP packets to specific targets. A value of
  1026. +   zero disables all limiting. Any positive value sets the maximum
  1027. +   package rate in hundredths of a second (on Intel systems).
  1028. +
  1029. +IP settings
  1030. +
  1031. +ip_autoconfig
  1032. +   This file contains one, if the host got its IP configuration by
  1033. +   RARP, BOOTP, DHCP or a similar mechanism. Otherwise it is zero.
  1034. +
  1035. +ip_default_ttl
  1036. +   TTL (Time To Live) for IPv4 interfaces. This is simply the
  1037. +   maximum number of hops a packet may travel.
  1038. +
  1039. +ip_dynaddr
  1040. +   Enable dynamic socket address rewriting on interface address change. This
  1041. +   is useful for dialup interface with changing IP addresses.
  1042. +
  1043. +ip_forward
  1044. +   Enable or disable forwarding of IP packages between interfaces. A
  1045. +   change of this value resets all other parameters to their default
  1046. +   values. They differ if the kernel is configured as host or router.
  1047. +
  1048. +ip_local_port_range
  1049. +   Range of ports used by TCP and UDP to choose the local
  1050. +   port. Contains two numbers, the first number is the lowest port,
  1051. +   the second number the highest local port. Default is 1024-4999.
  1052. +   Should be changed to 32768-61000 for high-usage systems.
  1053. +
  1054. +ip_no_pmtu_disc
  1055. +   Global switch to turn path MTU discovery off. It can also be set
  1056. +   on a per socket basis by the applications or on a per route
  1057. +   basis.
  1058. +
  1059. +ip_masq_debug
  1060. +   Enable/disable debugging of IP masquerading.
  1061. +
  1062. +
  1063. +IP fragmentation settings
  1064. +
  1065. +ipfrag_high_trash and ipfrag_low_trash
  1066. +   Maximum memory used to reassemble IP fragments. When
  1067. +   ipfrag_high_thresh bytes of memory is allocated for this purpose,
  1068. +   the fragment handler will toss packets until ipfrag_low_thresh is
  1069. +   reached.
  1070. +
  1071. +
  1072. +ipfrag_time
  1073. +   Time in seconds to keep an IP fragment in memory.
  1074. +
  1075. +TCP settings
  1076. +
  1077. +tcp_retrans_collapse
  1078. +   Bug-to-bug compatibility with some broken printers. On retransmit
  1079. +   try to send bigger packets to work around bugs in certain TCP
  1080. +   stacks. Can be turned off by setting it to zero.
  1081. +
  1082. +tcp_keepalive_probes
  1083. +   Number of keep alive probes TCP sends out, until it decides that the
  1084. +   connection is broken.
  1085. +
  1086. +tcp_keepalive_time
  1087. +   How often TCP sends out keep alive messages, when keep alive is
  1088. +   enabled. The default is 2 hours.
  1089. +
  1090. +tcp_syn_retries
  1091. +   Number of times initial SYNs for a TCP connection attempt will be
  1092. +   retransmitted. Should not be higher than 255. This is only the
  1093. +   timeout for outgoing connections, for incoming connections the
  1094. +   number of retransmits is defined by tcp_retries1.
  1095. +
  1096. +tcp_sack
  1097. +   Enable select acknowledgments after RFC2018.
  1098. +
  1099. +tcp_timestamps
  1100. +   Enable timestamps as defined in RFC1323.
  1101. +
  1102. +tcp_stdurg
  1103. +   Enable the strict RFC793 interpretation of the TCP urgent pointer
  1104. +   field. The default is to use the BSD compatible interpretation
  1105. +   of the urgent pointer pointing to the first byte after the urgent
  1106. +   data. The RFC793 interpretation is to have it point to the last
  1107. +   byte of urgent data. Enabling this option may lead to
  1108. +   interoperatibility problems. Disabled by default.
  1109. +
  1110. +tcp_syncookies
  1111. +   Only valid when the kernel was compiled with
  1112. +   CONFIG_SYNCOOKIES. Send out syncookies when the syn backlog queue
  1113. +   of a socket overflows. This is to prevent against the common 'syn
  1114. +   flood attack'. Disabled by default.
  1115. +
  1116. +   Note that the concept of a socket backlog is abandoned, this
  1117. +   means the peer may not receive reliable error messages from an
  1118. +   over loaded server with syncookies enabled.
  1119. +
  1120. +tcp_window_scaling
  1121. +   Enable window scaling as defined in RFC1323.
  1122. +
  1123. +tcp_fin_timeout
  1124. +   How many seconds to wait for a final FIN before the socket is
  1125. +   always closed. This is strictly a violation of the TCP
  1126. +   specification, but required to prevent denial-of-service attacks.
  1127. +
  1128. +tcp_max_ka_probes
  1129. +   How many keepalive probes are sent per slow timer run. Shouldn't be
  1130. +   set too high to prevent bursts.
  1131. +
  1132. +tcp_max_syn_backlog
  1133. +   Length of the per socket backlog queue. Since Linux 2.2 the backlog
  1134. +   specified in listen(2) only specifies the length of the backlog
  1135. +   queue of already established sockets. When more connection requests
  1136. +   arrive Linux starts to drop packets. When syncookies are enabled
  1137. +   the packets are still answered and the maximum queue is effectively
  1138. +   ignored.
  1139. +
  1140. +tcp_retries1
  1141. +   Defines how often an answer to a TCP connection request is
  1142. +   retransmitted before giving up.
  1143. +
  1144. +tcp_retries2
  1145. +   Defines how often a TCP packet is retransmitted before giving up.
  1146. +
  1147. +Interface specific settings
  1148. +
  1149. +In the directory /proc/sys/net/ipv4/conf you'll find one subdirectory
  1150. +for each interface the system knows about and one directory calls
  1151. +all. Changes in the all subdirectory affect all interfaces, where
  1152. +changes in the other subdirectories affect only one interface.
  1153. +
  1154. +All directories have the same entries:
  1155. +
  1156. +accept_redirects
  1157. +   This switch decides if the kernel accepts ICMP redirect messages
  1158. +   or not. The default is 'yes', if the kernel is configured for a
  1159. +   regular host; and 'no' for a router configuration.
  1160. +
  1161. +accept_source_route
  1162. +   Should source routed packages be accepted or declined. The
  1163. +   default is dependent on the kernel configuration. It's 'yes' for
  1164. +   routers and 'np' for hosts.
  1165. +
  1166. +bootp_relay
  1167. +   Accept packets with source address 0.b.c.d destined not to this
  1168. +   host as local ones. It is supposed that BOOTP relay daemon will
  1169. +   catch and forward such packets.
  1170. +
  1171. +   The default is 'no', as this feature is not implemented yet
  1172. +   (kernel version 2.2.0-pre?).
  1173. +
  1174. +forwarding
  1175. +   Enable or disable IP forwarding on this interface.
  1176. +
  1177. +log_martians
  1178. +   Log packets with source addresses with no known route to kernel log.
  1179. +
  1180. +mc_forwarding
  1181. +   Do multicast routing. The kernel needs to be compiled with
  1182. +   CONFIG_MROUTE and a multicast routing daemon is required.
  1183. +
  1184. +proxy_arp
  1185. +   Do (1) or don't (0) do proxy ARP.
  1186. +
  1187. +rp_filter
  1188. +   Integer value deciding if source validation should be made. 
  1189. +   1 means yes, 0 means no. Disabled by default, but 
  1190. +   local/broadcast address spoofing is always on.
  1191. +
  1192. +   If you set this to 1 on a router that is the only connection
  1193. +   for a network to the net , it evidently prevents spoofing attacks
  1194. +   against your internal networks (external addresses can still be
  1195. +   spoofed), without the need for additional firewall rules.
  1196. +
  1197. +secure_redirects
  1198. +   Accept ICMP redirect messages only for gateways, listed in
  1199. +   default gateway list. Enabled by default.
  1200. +
  1201. +shared_media
  1202. +   If it is not set the kernel does not assume that different subnets
  1203. +   on this device can communicate directly. Default setting is 'yes'.  
  1204. +
  1205. +send_redirects
  1206. +   Determines if or if not to send ICMP redirects to other hosts.
  1207. +
  1208. +
  1209. +Routing settings
  1210. +
  1211. +The directory /proc/sys/net/ipv4/route contains several file to
  1212. +control routing issues.
  1213. +
  1214. +error_burst and error_cost
  1215. +   These parameters are used to limit the warning messages written to
  1216. +   the kernel log from the routing code. The higher the error_cost
  1217. +   factor is, the fewer messages will be written. Error_burst controls
  1218. +   when messages will be dropped. The default settings limit warning
  1219. +   messages to one every five seconds.
  1220. +
  1221. +flush
  1222. +   Writing to this file results in a flush of the routing cache.
  1223. +
  1224. +gc_elastic, gc_interval, gc_min_interval, gc_tresh, gc_timeout
  1225. +   Values to control the frequency and behavior of the garbage
  1226. +   collection algorithm for the routing cache.
  1227. +
  1228. +max_size
  1229. +   Maximum size of the routing cache. Old entries will be purged
  1230. +   once the cache has this size.
  1231. +
  1232. +max_delay, min_delay
  1233. +   Delays for flushing the routing cache.
  1234. +
  1235. +redirect_load, redirect_number
  1236. +   Factors which determine if more ICPM redirects should be sent to
  1237. +   a specific host. No redirects will be sent once the load limit or
  1238. +   the maximum number of redirects has been reached.
  1239. +
  1240. +redirect_silence
  1241. +
  1242. +   Timeout for redirects. After this period redirects will be sent
  1243. +   again, even if this has been stopped, because the load or number
  1244. +   limit has been reached.
  1245. +
  1246. +Network Neighbor handling
  1247. +
  1248. +Settings about how to handle connections with direct neighbors (nodes
  1249. +attached to the same link) can be found in the directory
  1250. +/proc/sys/net/ipv4/neigh.
  1251. +
  1252. +As we saw it in the conf directory, there is a default subdirectory
  1253. +which holds the default values, and one directory for each
  1254. +interface. The contents of the directories are identical, with the
  1255. +single exception that the default settings contain additional options
  1256. +to set garbage collection parameters.
  1257. +
  1258. +In the interface directories you'll find the following entries:
  1259. +
  1260. +base_reachable_time
  1261. +   A base value used for computing the random reachable time value
  1262. +   as specified in RFC2461.
  1263. +
  1264. +retrans_time
  1265. +   The time, expressed in jiffies (1/100 sec), between retransmitted
  1266. +   Neighbor Solicitation messages. Used for address resolution and to
  1267. +   determine if a neighbor is unreachable.
  1268. +
  1269. +unres_qlen
  1270. +   Maximum queue length for a pending arp request - how many packets
  1271. +   are accepted from other layers while the arp address is still
  1272. +   resolved.
  1273. +
  1274. +anycast_delay
  1275. +   Maximum for random delay of answers to neighbor solicitation
  1276. +   messages in jiffies (1/100 sec). Not yet implemented (Linux does
  1277. +   not have anycast support yet).
  1278. +
  1279. +ucast_solicit
  1280. +   Maximum number of retries for unicast solicitation.
  1281. +
  1282. +mcast_solicit
  1283. +   Maximum number of retries for multicast solicitation.
  1284. +
  1285. +delay_first_probe_time
  1286. +   Delay for the first time probe if the neighbor is reachable. (see
  1287. +   gc_stale_time).
  1288. +
  1289. +locktime
  1290. +   An ARP/neighbor entry is only replaced with a new one if the old
  1291. +   is at least locktime old. This prevents ARP cache thrashing.
  1292. +
  1293. +proxy_delay
  1294. +   Maximum time (real time is random [0..proxytime]) before
  1295. +   answering to an arp request for which we have an proxy arp entry.
  1296. +   In some cases, this is used to prevent network flooding.
  1297. +
  1298. +proxy_qlen
  1299. +   Maximum queue length of the delayed proxy arp timer (see
  1300. +   proxy_delay).
  1301. +
  1302. +app_solcit
  1303. +   Determines the number of requests to send to the user level arp
  1304. +   daemon. 0 to turn off.
  1305. +
  1306. +gc_stale_time
  1307. +   Determines how often to check for stale ARP entries. After an ARP
  1308. +   entry is stale it will be resolved again (useful when an IP address
  1309. +   migrates to another machine). When ucast_solicit is > 0 it first
  1310. +   tries to send an ARP packet directly to the known host, when that
  1311. +   fails and mcast_solicit is > 0, an ARP request is broadcasted.
  1312. +
  1313. +3.10  Appletalk
  1314. +
  1315. +The /proc/sys/net/appletalk directory holds the Appletalk
  1316. +configuration data when Appletalk is loaded. The configurable
  1317. +parameters are:
  1318. +
  1319. +aarp-expiry-time
  1320. +   The amount of time we keep an AARP entry before expiring
  1321. +   it. Used to age out old hosts.
  1322. +
  1323. +aarp-resolve-time
  1324. +   The amount of time we will spend trying to resolve an Appletalk
  1325. +   address.
  1326. +
  1327. +aarp-retransmit-limit
  1328. +   The number of times we will retransmit a query before giving up.
  1329. +
  1330. +aarp-tick-time
  1331. +   Controls the rate at which expiries are checked.
  1332. +
  1333. +
  1334. +The directory /proc/net/appletalk holds the list of active appletalk
  1335. +sockets on a machine.
  1336. +
  1337. +The fields indicate the DDP type, the local address (in network:node
  1338. +format) the remote address, the size of the transmit pending queue,
  1339. +the size of the received queue (bytes waiting for applications to
  1340. +read) the state and the uid owning the socket.
  1341. +
  1342. +/proc/net/atalk_iface lists all the interfaces configured for
  1343. +appletalk.It shows the name of the interface, its appletalk address,
  1344. +the network range on that ad- dress (or network number for phase 1
  1345. +networks), and the status of the interface.
  1346. +
  1347. +/proc/net/atalk_route lists each known network route. It lists the
  1348. +target (network) that the route leads to, the router (may be directly
  1349. +connected), the route flags, and the device the route is via.
  1350. +
  1351. +3.11  IPX
  1352. +
  1353. +The IPX protocol has no tunable values in /proc/sys/net.
  1354. +
  1355. +The IPX protocol does, however, provide /proc/net/ipx. This lists each
  1356. +IPX socket giving the local and remote addresses in Novell format
  1357. +(that is network:node:port). In accordance with the strange Novell
  1358. +tradition, everything but the port is in hex. Not_Connected is
  1359. +displayed for sockets that are not tied to a specific remote
  1360. +address. The Tx and Rx queue sizes indicate the number of bytes
  1361. +pending for transmit and receive. The state indicates the state the
  1362. +socket is in and the uid is the owning uid of the socket.
  1363. +
  1364. +The /proc/net/ipx_interface file lists all IPX interfaces. For each
  1365. +interface it gives the network number, the node number, and indicates
  1366. +if the network is the primary network. It also indicates which device it is bound to (or
  1367. +Internal for internal networks) and the Frame Type if
  1368. +appropriate. Linux supports 802.3, 802.2, 802.2 SNAP and DIX (Blue
  1369. +Book) ethernet framing for IPX.
  1370. +
  1371. +The /proc/net/ipx_route table holds a list of IPX routes. For each
  1372. +route it gives the destination network, the router node (or Directly)
  1373. +and the network address of the router (or Connected) for internal
  1374. +networks.
  1375. diff -u --recursive --new-file v2.2.0/linux/Makefile linux/Makefile
  1376. --- v2.2.0/linux/Makefile    Mon Jan 25 17:44:34 1999
  1377. +++ linux/Makefile    Mon Jan 25 17:46:35 1999
  1378. @@ -1,6 +1,6 @@
  1379.  VERSION = 2
  1380.  PATCHLEVEL = 2
  1381. -SUBLEVEL = 0
  1382. +SUBLEVEL = 1
  1383.  EXTRAVERSION =
  1384.  
  1385.  ARCH := $(shell uname -m | sed -e s/i.86/i386/ -e s/sun4u/sparc64/ -e s/arm.*/arm/ -e s/sa110/arm/)
  1386. diff -u --recursive --new-file v2.2.0/linux/arch/alpha/lib/semaphore.S linux/arch/alpha/lib/semaphore.S
  1387. --- v2.2.0/linux/arch/alpha/lib/semaphore.S    Mon Jan 25 17:44:34 1999
  1388. +++ linux/arch/alpha/lib/semaphore.S    Wed Jan 27 10:18:03 1999
  1389. @@ -101,7 +101,7 @@
  1390.      .prologue 1
  1391.      
  1392.      mov    $24, $16
  1393. -    jsr    __down
  1394. +    jsr    __down_interruptible
  1395.      mov    $0, $24
  1396.      
  1397.      ldq    $28, 0*8($30)
  1398. diff -u --recursive --new-file v2.2.0/linux/drivers/sound/gus_wave.c linux/drivers/sound/gus_wave.c
  1399. --- v2.2.0/linux/drivers/sound/gus_wave.c    Fri Jan  8 22:36:11 1999
  1400. +++ linux/drivers/sound/gus_wave.c    Thu Jan 28 11:25:04 1999
  1401. @@ -144,7 +144,6 @@
  1402.  
  1403.  static int      freq_div_table[] =
  1404.  {
  1405. -    44100,
  1406.      44100,            /* 14 */
  1407.      41160,            /* 15 */
  1408.      38587,            /* 16 */
  1409. @@ -2234,9 +2233,6 @@
  1410.      gus_busy = 1;
  1411.      active_device = 0;
  1412.  
  1413. -    gus_reset();
  1414. -    reset_sample_memory();
  1415. -    gus_select_max_voices(14);
  1416.      saved_iw_mode = iw_mode;
  1417.      if (iw_mode)
  1418.      {
  1419. @@ -2244,6 +2240,11 @@
  1420.          gus_write8(0x19, gus_read8(0x19) & ~0x01);    /* Disable enhanced mode */
  1421.          iw_mode = 0;
  1422.      }
  1423. +
  1424. +    gus_reset();
  1425. +    reset_sample_memory();
  1426. +    gus_select_max_voices(14);
  1427. +
  1428.      pcm_active = 0;
  1429.      dma_active = 0;
  1430.      pcm_opened = 1;
  1431. diff -u --recursive --new-file v2.2.0/linux/drivers/sound/sb_card.c linux/drivers/sound/sb_card.c
  1432. --- v2.2.0/linux/drivers/sound/sb_card.c    Mon Jan 25 17:44:34 1999
  1433. +++ linux/drivers/sound/sb_card.c    Thu Jan 28 10:58:47 1999
  1434. @@ -113,6 +113,7 @@
  1435.  }
  1436.  
  1437.  int sb_be_quiet=0;
  1438. +int esstype = 0;    /* ESS chip type */
  1439.  
  1440.  #ifdef MODULE
  1441.  
  1442. @@ -136,7 +137,6 @@
  1443.  int pas2 = 0;    /* Set pas2=1 to load this as support for pas2 */
  1444.  int sm_games = 0;    /* Mixer - see sb_mixer.c */
  1445.  int acer = 0;    /* Do acer notebook init */
  1446. -int esstype = 0;    /* ESS chip type */
  1447.  
  1448.  MODULE_PARM(io, "i");
  1449.  MODULE_PARM(irq, "i");
  1450. diff -u --recursive --new-file v2.2.0/linux/fs/nfsd/vfs.c linux/fs/nfsd/vfs.c
  1451. --- v2.2.0/linux/fs/nfsd/vfs.c    Tue Jan 19 11:32:52 1999
  1452. +++ linux/fs/nfsd/vfs.c    Wed Jan 27 13:49:46 1999
  1453. @@ -988,6 +988,20 @@
  1454.  }
  1455.  
  1456.  /*
  1457. + * We need to do a check-parent every time
  1458. + * after we have locked the parent - to verify
  1459. + * that the parent is still our parent and
  1460. + * that we are still hashed onto it..
  1461. + *
  1462. + * This is requied in case two processes race
  1463. + * on removing (or moving) the same entry: the
  1464. + * parent lock will serialize them, but the
  1465. + * other process will be too late..
  1466. + */
  1467. +#define check_parent(dir, dentry) \
  1468. +    ((dir) == (dentry)->d_parent->d_inode && !list_empty(&dentry->d_hash))
  1469. +
  1470. +/*
  1471.   * This follows the model of double_lock() in the VFS.
  1472.   */
  1473.  static inline void nfsd_double_down(struct semaphore *s1, struct semaphore *s2)
  1474. @@ -1048,6 +1062,10 @@
  1475.      if (IS_ERR(odentry))
  1476.          goto out_nfserr;
  1477.  
  1478. +    err = -ENOENT;
  1479. +    if (!odentry->d_inode)
  1480. +        goto out_dput_old;
  1481. +
  1482.      ndentry = lookup_dentry(tname, dget(tdentry), 0);
  1483.      err = PTR_ERR(ndentry);
  1484.      if (IS_ERR(ndentry))
  1485. @@ -1057,13 +1075,18 @@
  1486.       * Lock the parent directories.
  1487.       */
  1488.      nfsd_double_down(&tdir->i_sem, &fdir->i_sem);
  1489. -    /* N.B. check for parent changes after locking?? */
  1490. -
  1491. -    err = vfs_rename(fdir, odentry, tdir, ndentry);
  1492. -    if (!err && EX_ISSYNC(tfhp->fh_export)) {
  1493. -        write_inode_now(fdir);
  1494. -        write_inode_now(tdir);
  1495. -    }
  1496. +    err = -ENOENT;
  1497. +    /* GAM3 check for parent changes after locking. */
  1498. +    if (check_parent(fdir, odentry) &&
  1499. +        check_parent(tdir, ndentry)) {
  1500. +
  1501. +        err = vfs_rename(fdir, odentry, tdir, ndentry);
  1502. +        if (!err && EX_ISSYNC(tfhp->fh_export)) {
  1503. +            write_inode_now(fdir);
  1504. +            write_inode_now(tdir);
  1505. +        }
  1506. +    } else
  1507. +        dprintk("nfsd: Caught race in nfsd_rename");
  1508.      DQUOT_DROP(fdir);
  1509.      DQUOT_DROP(tdir);
  1510.  
  1511. @@ -1137,10 +1160,9 @@
  1512.          if (!fhp->fh_pre_mtime)
  1513.              fhp->fh_pre_mtime = dirp->i_mtime;
  1514.          fhp->fh_locked = 1;
  1515. -        /* CHECKME: Should we do something with the child? */
  1516.  
  1517.          err = -ENOENT;
  1518. -        if (rdentry->d_parent->d_inode == dirp)
  1519. +        if (check_parent(dirp, rdentry))
  1520.              err = vfs_rmdir(dirp, rdentry);
  1521.  
  1522.          rdentry->d_count--;
  1523. diff -u --recursive --new-file v2.2.0/linux/fs/proc/array.c linux/fs/proc/array.c
  1524. --- v2.2.0/linux/fs/proc/array.c    Mon Jan 25 17:44:34 1999
  1525. +++ linux/fs/proc/array.c    Thu Jan 28 10:08:53 1999
  1526. @@ -24,7 +24,7 @@
  1527.   *                      <Jeff_Tranter@Mitel.COM>
  1528.   *
  1529.   * Bruno Haible      :  remove 4K limit for the maps file
  1530. - *             <haible@ma2s2.mathematik.uni-karlsruhe.de>
  1531. + *            <haible@ma2s2.mathematik.uni-karlsruhe.de>
  1532.   *
  1533.   * Yves Arrouye      :  remove removal of trailing spaces in get_array.
  1534.   *            <Yves.Arrouye@marin.fdn.fr>
  1535. @@ -42,8 +42,6 @@
  1536.   * Alan Cox         :  security fixes.
  1537.   *            <Alan.Cox@linux.org>
  1538.   *
  1539. - * Andi Kleen         :  Race Fixes.     
  1540. - *
  1541.   */
  1542.  
  1543.  #include <linux/types.h>
  1544. @@ -388,46 +386,21 @@
  1545.      return sprintf(buffer, "%s\n", saved_command_line);
  1546.  }
  1547.  
  1548. -/*
  1549. - * Caller must release_mm the mm_struct later.
  1550. - * You don't get any access to init_mm.
  1551. - */
  1552. -static struct mm_struct *get_mm_and_lock(int pid)
  1553. -{
  1554. -    struct mm_struct *mm = NULL;
  1555. -    struct task_struct *tsk;
  1556. -
  1557. -    read_lock(&tasklist_lock);
  1558. -    tsk = find_task_by_pid(pid);
  1559. -    if (tsk && tsk->mm && tsk->mm != &init_mm)
  1560. -        mmget(mm = tsk->mm);
  1561. -    read_unlock(&tasklist_lock);
  1562. -    if (mm != NULL)
  1563. -        down(&mm->mmap_sem);
  1564. -    return mm;
  1565. -}
  1566. -
  1567. -static void release_mm(struct mm_struct *mm)
  1568. -{
  1569. -    up(&mm->mmap_sem);
  1570. -    mmput(mm);
  1571. -}
  1572. -
  1573. -static unsigned long get_phys_addr(struct mm_struct *mm, unsigned long ptr)
  1574. +static unsigned long get_phys_addr(struct task_struct * p, unsigned long ptr)
  1575.  {
  1576.      pgd_t *page_dir;
  1577.      pmd_t *page_middle;
  1578.      pte_t pte;
  1579.  
  1580. -    if (ptr >= TASK_SIZE)
  1581. +    if (!p || !p->mm || ptr >= TASK_SIZE)
  1582.          return 0;
  1583.      /* Check for NULL pgd .. shouldn't happen! */
  1584. -    if (!mm->pgd) {
  1585. -        printk(KERN_DEBUG "missing pgd for mm %p\n", mm);
  1586. +    if (!p->mm->pgd) {
  1587. +        printk("get_phys_addr: pid %d has NULL pgd!\n", p->pid);
  1588.          return 0;
  1589.      }
  1590.  
  1591. -    page_dir = pgd_offset(mm,ptr);
  1592. +    page_dir = pgd_offset(p->mm,ptr);
  1593.      if (pgd_none(*page_dir))
  1594.          return 0;
  1595.      if (pgd_bad(*page_dir)) {
  1596. @@ -449,7 +422,7 @@
  1597.      return pte_page(pte) + (ptr & ~PAGE_MASK);
  1598.  }
  1599.  
  1600. -static int get_array(struct mm_struct *mm, unsigned long start, unsigned long end, char * buffer)
  1601. +static int get_array(struct task_struct *p, unsigned long start, unsigned long end, char * buffer)
  1602.  {
  1603.      unsigned long addr;
  1604.      int size = 0, result = 0;
  1605. @@ -458,7 +431,7 @@
  1606.      if (start >= end)
  1607.          return result;
  1608.      for (;;) {
  1609. -        addr = get_phys_addr(mm, start);
  1610. +        addr = get_phys_addr(p, start);
  1611.          if (!addr)
  1612.              return result;
  1613.          do {
  1614. @@ -480,28 +453,27 @@
  1615.  
  1616.  static int get_env(int pid, char * buffer)
  1617.  {
  1618. -    struct mm_struct *mm;
  1619. -    int res = 0;
  1620. +    struct task_struct *p;
  1621. +    
  1622. +    read_lock(&tasklist_lock);
  1623. +    p = find_task_by_pid(pid);
  1624. +    read_unlock(&tasklist_lock);    /* FIXME!! This should be done after the last use */
  1625.  
  1626. -    mm = get_mm_and_lock(pid);
  1627. -    if (mm) {
  1628. -        res = get_array(mm, mm->env_start, mm->env_end, buffer);
  1629. -        release_mm(mm);
  1630. -    }
  1631. -    return res;
  1632. +    if (!p || !p->mm)
  1633. +        return 0;
  1634. +    return get_array(p, p->mm->env_start, p->mm->env_end, buffer);
  1635.  }
  1636.  
  1637.  static int get_arg(int pid, char * buffer)
  1638.  {
  1639. -    struct mm_struct *mm;
  1640. -    int res = 0;
  1641. +    struct task_struct *p;
  1642.  
  1643. -    mm = get_mm_and_lock(pid);
  1644. -    if (mm) {
  1645. -        res = get_array(mm, mm->arg_start, mm->arg_end, buffer);
  1646. -        release_mm(mm);
  1647. -    }
  1648. -    return res;
  1649. +    read_lock(&tasklist_lock);
  1650. +    p = find_task_by_pid(pid);
  1651. +    read_unlock(&tasklist_lock);    /* FIXME!! This should be done after the last use */
  1652. +    if (!p || !p->mm)
  1653. +        return 0;
  1654. +    return get_array(p, p->mm->arg_start, p->mm->arg_end, buffer);
  1655.  }
  1656.  
  1657.  /*
  1658. @@ -606,7 +578,7 @@
  1659.  #ifdef __sparc_v9__
  1660.          bias = STACK_BIAS;
  1661.  #endif
  1662. -            fp = p->tss.ksp + bias;
  1663. +        fp = p->tss.ksp + bias;
  1664.          do {
  1665.              /* Bogus frame pointer? */
  1666.              if (fp < (task_base + sizeof(struct task_struct)) ||
  1667. @@ -642,7 +614,7 @@
  1668.  #define    KSTK_EIP(tsk)    \
  1669.      ({            \
  1670.      unsigned long eip = 0;     \
  1671. -     if ((tsk)->tss.esp0 > PAGE_SIZE && \
  1672. +    if ((tsk)->tss.esp0 > PAGE_SIZE && \
  1673.          MAP_NR((tsk)->tss.esp0) < max_mapnr) \
  1674.            eip = ((struct pt_regs *) (tsk)->tss.esp0)->pc;     \
  1675.      eip; })
  1676. @@ -754,14 +726,11 @@
  1677.  {
  1678.      struct mm_struct * mm = p->mm;
  1679.  
  1680. -    if (!mm)
  1681. -        return buffer;
  1682. -    if (mm != &init_mm) {
  1683. -        struct vm_area_struct * vma;
  1684. +    if (mm && mm != &init_mm) {
  1685. +        struct vm_area_struct * vma = mm->mmap;
  1686.          unsigned long data = 0, stack = 0;
  1687.          unsigned long exec = 0, lib = 0;
  1688.  
  1689. -        down(&mm->mmap_sem);
  1690.          for (vma = mm->mmap; vma; vma = vma->vm_next) {
  1691.              unsigned long len = (vma->vm_end - vma->vm_start) >> 10;
  1692.              if (!vma->vm_file) {
  1693. @@ -779,7 +748,6 @@
  1694.                  lib += len;
  1695.              }
  1696.          }    
  1697. -        up(&mm->mmap_sem);
  1698.          buffer += sprintf(buffer,
  1699.              "VmSize:\t%8lu kB\n"
  1700.              "VmLck:\t%8lu kB\n"
  1701. @@ -849,31 +817,15 @@
  1702.                  cap_t(p->cap_effective));
  1703.  }
  1704.  
  1705. -static struct task_struct *grab_task(int pid)
  1706. -{
  1707. -    struct task_struct *tsk = current;
  1708. -    if (pid != tsk->pid) {
  1709. -        read_lock(&tasklist_lock);
  1710. -        tsk = find_task_by_pid(pid);
  1711. -        if (tsk && tsk->mm && tsk->mm != &init_mm)
  1712. -            mmget(tsk->mm);
  1713. -        read_unlock(&tasklist_lock);
  1714. -    }    
  1715. -    return tsk;
  1716. -}
  1717. -
  1718. -static void release_task(struct task_struct *tsk)
  1719. -{
  1720. -    if (tsk != current && tsk->mm && tsk->mm != &init_mm)
  1721. -        mmput(tsk->mm);
  1722. -}
  1723.  
  1724.  static int get_status(int pid, char * buffer)
  1725.  {
  1726.      char * orig = buffer;
  1727.      struct task_struct *tsk;
  1728. -    
  1729. -    tsk = grab_task(pid);
  1730. +
  1731. +    read_lock(&tasklist_lock);
  1732. +    tsk = find_task_by_pid(pid);
  1733. +    read_unlock(&tasklist_lock);    /* FIXME!! This should be done after the last use */
  1734.      if (!tsk)
  1735.          return 0;
  1736.      buffer = task_name(tsk, buffer);
  1737. @@ -881,7 +833,6 @@
  1738.      buffer = task_mem(tsk, buffer);
  1739.      buffer = task_sig(tsk, buffer);
  1740.      buffer = task_cap(tsk, buffer);
  1741. -    release_task(tsk);
  1742.      return buffer - orig;
  1743.  }
  1744.  
  1745. @@ -893,22 +844,20 @@
  1746.      int tty_pgrp;
  1747.      sigset_t sigign, sigcatch;
  1748.      char state;
  1749. -    int res;
  1750.  
  1751. -    tsk = grab_task(pid);
  1752. +    read_lock(&tasklist_lock);
  1753. +    tsk = find_task_by_pid(pid);
  1754. +    read_unlock(&tasklist_lock);    /* FIXME!! This should be done after the last use */
  1755.      if (!tsk)
  1756.          return 0;
  1757.      state = *get_task_state(tsk);
  1758.      vsize = eip = esp = 0;
  1759.      if (tsk->mm && tsk->mm != &init_mm) {
  1760. -        struct vm_area_struct *vma;
  1761. -
  1762. -        down(&tsk->mm->mmap_sem);
  1763. -        for (vma = tsk->mm->mmap; vma; vma = vma->vm_next) {
  1764. +        struct vm_area_struct *vma = tsk->mm->mmap;
  1765. +        while (vma) {
  1766.              vsize += vma->vm_end - vma->vm_start;
  1767. +            vma = vma->vm_next;
  1768.          }
  1769. -        up(&tsk->mm->mmap_sem);
  1770. -        
  1771.          eip = KSTK_EIP(tsk);
  1772.          esp = KSTK_ESP(tsk);
  1773.      }
  1774. @@ -929,7 +878,7 @@
  1775.      nice = tsk->priority;
  1776.      nice = 20 - (nice * 20 + DEF_PRIORITY / 2) / DEF_PRIORITY;
  1777.  
  1778. -    res = sprintf(buffer,"%d (%s) %c %d %d %d %d %d %lu %lu \
  1779. +    return sprintf(buffer,"%d (%s) %c %d %d %d %d %d %lu %lu \
  1780.  %lu %lu %lu %lu %lu %ld %ld %ld %ld %ld %ld %lu %lu %ld %lu %lu %lu %lu %lu \
  1781.  %lu %lu %lu %lu %lu %lu %lu %lu %d\n",
  1782.          pid,
  1783. @@ -974,9 +923,6 @@
  1784.          tsk->nswap,
  1785.          tsk->cnswap,
  1786.          tsk->exit_signal);
  1787. -
  1788. -    release_task(tsk);
  1789. -    return res;
  1790.  }
  1791.          
  1792.  static inline void statm_pte_range(pmd_t * pmd, unsigned long address, unsigned long size,
  1793. @@ -1054,15 +1000,19 @@
  1794.  
  1795.  static int get_statm(int pid, char * buffer)
  1796.  {
  1797. +    struct task_struct *tsk;
  1798.      int size=0, resident=0, share=0, trs=0, lrs=0, drs=0, dt=0;
  1799. -    struct mm_struct *mm;
  1800.  
  1801. -    mm = get_mm_and_lock(pid);
  1802. -    if (mm) {
  1803. -        struct vm_area_struct * vma = mm->mmap;
  1804. +    read_lock(&tasklist_lock);
  1805. +    tsk = find_task_by_pid(pid);
  1806. +    read_unlock(&tasklist_lock);    /* FIXME!! This should be done after the last use */
  1807. +    if (!tsk)
  1808. +        return 0;
  1809. +    if (tsk->mm && tsk->mm != &init_mm) {
  1810. +        struct vm_area_struct * vma = tsk->mm->mmap;
  1811.  
  1812.          while (vma) {
  1813. -            pgd_t *pgd = pgd_offset(mm, vma->vm_start);
  1814. +            pgd_t *pgd = pgd_offset(tsk->mm, vma->vm_start);
  1815.              int pages = 0, shared = 0, dirty = 0, total = 0;
  1816.  
  1817.              statm_pgd_range(pgd, vma->vm_start, vma->vm_end, &pages, &shared, &dirty, &total);
  1818. @@ -1080,7 +1030,6 @@
  1819.                  drs += pages;
  1820.              vma = vma->vm_next;
  1821.          }
  1822. -        release_mm(mm);
  1823.      }
  1824.      return sprintf(buffer,"%d %d %d %d %d %d %d\n",
  1825.                 size, resident, share, trs, lrs, drs, dt);
  1826. @@ -1118,7 +1067,7 @@
  1827.  
  1828.  #define MAPS_LINE_MAX    MAPS_LINE_MAX8
  1829.  
  1830. -/* FIXME: this does not do proper mm locking */
  1831. +
  1832.  static ssize_t read_maps (int pid, struct file * file, char * buf,
  1833.                size_t count, loff_t *ppos)
  1834.  {
  1835. @@ -1250,11 +1199,15 @@
  1836.  #ifdef __SMP__
  1837.  static int get_pidcpu(int pid, char * buffer)
  1838.  {
  1839. -    struct task_struct * tsk;
  1840. +    struct task_struct * tsk = current ;
  1841.      int i, len;
  1842.  
  1843. -    tsk = grab_task(pid);
  1844. -    if (!tsk)
  1845. +    read_lock(&tasklist_lock);
  1846. +    if (pid != tsk->pid)
  1847. +        tsk = find_task_by_pid(pid);
  1848. +    read_unlock(&tasklist_lock);    /* FIXME!! This should be done after the last use */
  1849. +
  1850. +    if (tsk == NULL)
  1851.          return 0;
  1852.  
  1853.      len = sprintf(buffer,
  1854. @@ -1268,7 +1221,6 @@
  1855.              tsk->per_cpu_utime[cpu_logical_map(i)],
  1856.              tsk->per_cpu_stime[cpu_logical_map(i)]);
  1857.  
  1858. -    release_task(tsk);
  1859.      return len;
  1860.  }
  1861.  #endif
  1862. @@ -1306,7 +1258,7 @@
  1863.              return get_meminfo(page);
  1864.  
  1865.  #ifdef CONFIG_PCI_OLD_PROC
  1866. -              case PROC_PCI:
  1867. +            case PROC_PCI:
  1868.              return get_pci_list(page);
  1869.  #endif
  1870.  
  1871. @@ -1364,11 +1316,11 @@
  1872.          case PROC_CMDLINE:
  1873.              return get_cmdline(page);
  1874.  
  1875. -                case PROC_MTAB:
  1876. -                       return get_filesystem_info( page );
  1877. +        case PROC_MTAB:
  1878. +            return get_filesystem_info( page );
  1879.  
  1880. -                case PROC_SWAP:
  1881. -                       return get_swaparea_info(page);
  1882. +        case PROC_SWAP:
  1883. +            return get_swaparea_info(page);
  1884.  #ifdef CONFIG_RTC
  1885.          case PROC_RTC:
  1886.              return get_rtc_status(page);
  1887. @@ -1398,6 +1350,7 @@
  1888.       *    Grab the lock, find the task, save the uid and
  1889.       *    check it has an mm still (ie its not dead)
  1890.       */
  1891. +    
  1892.      p = find_task_by_pid(pid);
  1893.      if(p)
  1894.      {
  1895. @@ -1468,7 +1421,6 @@
  1896.      ssize_t end;
  1897.      unsigned int type, pid;
  1898.      struct proc_dir_entry *dp;
  1899. -    int err;
  1900.  
  1901.      if (count > PROC_BLOCK_SIZE)
  1902.          count = PROC_BLOCK_SIZE;
  1903. @@ -1497,10 +1449,8 @@
  1904.          return length;
  1905.      }
  1906.      if (start != NULL) {
  1907. -        if (length > count)
  1908. -            length = count;
  1909.          /* We have had block-adjusting processing! */
  1910. -        err = copy_to_user(buf, start, length);
  1911. +        copy_to_user(buf, start, length);
  1912.          *ppos += length;
  1913.          count = length;
  1914.      } else {
  1915. @@ -1512,11 +1462,11 @@
  1916.          if (count + *ppos > length)
  1917.              count = length - *ppos;
  1918.          end = count + *ppos;
  1919. -        err = copy_to_user(buf, (char *) page + *ppos, count);
  1920. +        copy_to_user(buf, (char *) page + *ppos, count);
  1921.          *ppos = end;
  1922.      }
  1923.      free_page(page);
  1924. -    return err ? -EFAULT : count;
  1925. +    return count;
  1926.  }
  1927.  
  1928.  static struct file_operations proc_array_operations = {
  1929. diff -u --recursive --new-file v2.2.0/linux/include/asm-i386/page.h linux/include/asm-i386/page.h
  1930. --- v2.2.0/linux/include/asm-i386/page.h    Wed Apr  8 19:36:29 1998
  1931. +++ linux/include/asm-i386/page.h    Tue Jan 26 13:04:02 1999
  1932. @@ -69,10 +69,9 @@
  1933.   * you want to use more physical memory, change this define.
  1934.   *
  1935.   * For example, if you have 2GB worth of physical memory, you
  1936. - * could change this define to 0x70000000, which gives the
  1937. - * kernel slightly more than 2GB of virtual memory (enough to
  1938. - * map all your physical memory + a bit extra for various
  1939. - * io-memory mappings)
  1940. + * could change this define to 0x80000000, which gives the
  1941. + * kernel 2GB of virtual memory (enough to most of your physical memory
  1942. + * as the kernel needs a bit extra for various io-memory mappings)
  1943.   *
  1944.   * IF YOU CHANGE THIS, PLEASE ALSO CHANGE
  1945.   *
  1946. diff -u --recursive --new-file v2.2.0/linux/mm/mmap.c linux/mm/mmap.c
  1947. --- v2.2.0/linux/mm/mmap.c    Tue Jan 19 11:32:53 1999
  1948. +++ linux/mm/mmap.c    Wed Jan 27 10:43:41 1999
  1949. @@ -393,6 +393,7 @@
  1950.              } else {
  1951.                  /* Then go through the AVL tree quickly. */
  1952.                  struct vm_area_struct * tree = mm->mmap_avl;
  1953. +                vma = NULL;
  1954.                  for (;;) {
  1955.                      if (tree == vm_avl_empty)
  1956.                          break;
  1957. @@ -556,7 +557,7 @@
  1958.      unsigned long start, unsigned long end)
  1959.  {
  1960.      unsigned long first = start & PGDIR_MASK;
  1961. -    unsigned long last = (end & PGDIR_MASK) + PGDIR_SIZE;
  1962. +    unsigned long last = (end + PGDIR_SIZE - 1) & PGDIR_MASK;
  1963.  
  1964.      if (!prev) {
  1965.          prev = mm->mmap;
  1966.