## Automatically generated incremental diff
## From:   linux-2.2.15-pre15
## To:     linux-2.2.15-pre16
## Robot:  $Id: make-incremental-diff,v 1.7 2001/12/04 05:19:54 hpa Exp $

diff -urN linux-2.2.15-pre15/Documentation/devices.txt linux/Documentation/devices.txt
--- linux-2.2.15-pre15/Documentation/devices.txt	Tue Jan  4 10:12:10 2000
+++ linux/Documentation/devices.txt	Mon Dec  3 22:01:46 2001
@@ -1,7 +1,8 @@
+
 		       LINUX ALLOCATED DEVICES
 	     Maintained by H. Peter Anvin <hpa@zytor.com>
 
-		   Last revised: December 21, 1999
+		     Last revised: March 23, 2000
 
 This list is the Linux Device List, the official registry of allocated
 device numbers and /dev directory nodes for the Linux operating
@@ -20,6 +21,9 @@
 platform only.	Allocations marked (68k/Atari) apply to Linux/68k on
 the Atari platform only.
 
+The symbol {2.6} means the allocation is obsolete and scheduled for
+removal once kernel version 2.6 (or equivalent) is released.
+
 This document is in the public domain.	The author requests, however,
 that semantically altered versions are not distributed without
 permission of the author, assuming the author can be contacted without
@@ -306,8 +310,9 @@
 		  9 = /dev/pc110pad	IBM PC-110 digitizer pad
 		 10 = /dev/adbmouse	Apple Desktop Bus mouse
 		 11 = /dev/vrtpanel	Vr41xx embedded touch panel
+		 13 = /dev/vpcmouse	Connectix Virtual PC Mouse
 		128 = /dev/beep		Fancy beep device
-		129 = /dev/modreq	Kernel module load request
+		129 = /dev/modreq	Kernel module load request {2.6}
 		130 = /dev/watchdog	Watchdog timer port
 		131 = /dev/temperature	Machine internal temperature
 		132 = /dev/hwtrap	Hardware fault trap
@@ -320,7 +325,7 @@
 		142 = /dev/msr		x86 model-specific registers
 		143 = /dev/pciconf	PCI configuration space
 		144 = /dev/nvram	Non-volatile configuration RAM
-		145 = /dev/hfmodem	Soundcard shortwave modem control
+		145 = /dev/hfmodem	Soundcard shortwave modem control {2.6}
 		146 = /dev/graphics	Linux/SGI graphics device
 		147 = /dev/opengl	Linux/SGI OpenGL pipe
 		148 = /dev/gfx		Linux/SGI graphics effects device
@@ -355,6 +360,10 @@
 		178 = /dev/jsflash	JavaStation OS flash SIMM
 		179 = /dev/xsvc		High-speed shared-mem/semaphore service
 		180 = /dev/vrbuttons	Vr41xx button input device
+		181 = /dev/toshiba	Toshiba laptop SMM support
+		182 = /dev/perfctr	Performance-monitoring counters
+		183 = /dev/intel_rng	Intel i8x0 random number generator
+		184 = /dev/cpu/microcode CPU microcode update interface
 		240-255			Reserved for local use
 
  11 char	Raw keyboard device
@@ -383,7 +392,7 @@
 		The device names specified are proposed -- if there
 		are "standard" names for these devices, please let me know.
 
-    block	MSCDEX CD-ROM callback support
+    block	MSCDEX CD-ROM callback support {2.6}
 		  0 = /dev/dos_cd0	First MSCDEX CD-ROM
 		  1 = /dev/dos_cd1	Second MSCDEX CD-ROM
 		    ...
@@ -410,7 +419,7 @@
 		  2 = /dev/midi00	First MIDI port
 		  3 = /dev/dsp		Digital audio
 		  4 = /dev/audio	Sun-compatible digital audio
-		  6 = /dev/sndstat	Sound card status information
+		  6 = /dev/sndstat	Sound card status information {2.6}
 		  7 = /dev/audioctl	SPARC audio control device
 		  8 = /dev/sequencer2	Sequencer -- alternate device
 		 16 = /dev/mixer1	Second soundcard mixer control
@@ -421,7 +430,7 @@
 		 33 = /dev/patmgr1	Sequencer patch manager
 		 34 = /dev/midi02	Third MIDI port
 		 50 = /dev/midi03	Fourth MIDI port
-    block	BIOS harddrive callback support
+    block	BIOS harddrive callback support {2.6}
 		  0 = /dev/dos_hda	First BIOS harddrive whole disk
 		 64 = /dev/dos_hdb	Second BIOS harddrive whole disk
 		128 = /dev/dos_hdc	Third BIOS harddrive whole disk
@@ -552,7 +561,7 @@
 		  2 = /dev/sbpcd2	Panasonic CD-ROM controller 0 unit 2
 		  3 = /dev/sbpcd3	Panasonic CD-ROM controller 0 unit 3
 
- 26 char	Quanta WinVision frame grabber
+ 26 char	Quanta WinVision frame grabber {2.6}
 		  0 = /dev/wvisfgrab	Quanta WinVision frame grabber
     block	Second Matsushita (Panasonic/SoundBlaster) CD-ROM
 		  0 = /dev/sbpcd4	Panasonic CD-ROM controller 1 unit 0
@@ -779,7 +788,7 @@
 		      ...
     block	Reserved for Linux/AP+
 
- 40 char	Matrox Meteor frame grabber
+ 40 char	Matrox Meteor frame grabber {2.6}
 		  0 = /dev/mmetfgrab	Matrox Meteor frame grabber
     block	Syquest EZ135 parallel port removable drive
 		  0 = /dev/eza		Parallel EZ135 drive, whole disk
@@ -1267,7 +1276,7 @@
 		disks (see major number 3) except that the limit on
 		partitions is 15.
 
- 83 char	Teletext/videotext interfaces
+ 83 char	Teletext/videotext interfaces {2.6}
 		  0 = /dev/vtx		Teletext decoder
 		 16 = /dev/vttuner	TV tuner on teletext interface
 
@@ -1406,7 +1415,7 @@
 		disks (see major number 3) except that the limit on
 		partitions is 15.
 
- 93 char	IBM Smart Capture Card frame grabber
+ 93 char	IBM Smart Capture Card frame grabber {2.6}
 		  0 = /dev/iscc0	First Smart Capture Card
 		  1 = /dev/iscc1	Second Smart Capture Card
 		    ...
@@ -1420,7 +1429,7 @@
 		    ...
 		240 = /dev/nftlp	16th NTFL layer
 
- 94 char	miroVIDEO DC10/30 capture/playback device
+ 94 char	miroVIDEO DC10/30 capture/playback device {2.6}
 		  0 = /dev/dcxx0	First capture card
 		  1 = /dev/dcxx1	Second capture card
 		    ...
@@ -1464,6 +1473,11 @@
 		These devices support the same API as the generic SCSI
 		devices.
 
+    block	Packet writing for CD/DVD devices
+		  0 = /dev/pktcdvd0	First packet-writing module
+		  1 = /dev/pktcdvd1	Second packet-writing module
+		    ...
+
  98 char	Control and Measurement Device (comedi)
 		  0 = /dev/comedi0	First comedi device
 		  1 = /dev/comedi1	Second comedi device
@@ -1471,23 +1485,34 @@
 
 		See http://stm.lbl.gov/comedi or http://www.llp.fu-berlin.de/.
 
+    block	User-mode virtual block device
+		  0 = /dev/ubd0		First user-mode block device
+		  1 = /dev/ubd1		Second user-mode block device
+		    ...
+
+		This device is used by the user-mode virtual kernel port.
+
  99 char	Raw parallel ports
 		  0 = /dev/parport0	First parallel port
 		  1 = /dev/parport1	Second parallel port
 		    ...
 
-100 char	POTS (analogue telephone) A/B port
+100 char	POTS (analogue telephone) A/B port {2.6}
 		  0 = /dev/phone0	First telephone port
 		  1 = /dev/phone1	Second telephone port
 		    ...
 
+		The names have been reallocated to Telephony For
+		Linux, major 159.  All use of major 100 should be
+		considered legacy and deprecated.
+
 101 char	Motorola DSP 56xxx board
 		  0 = /dev/mdspstat	Status information
 		  1 = /dev/mdsp1	First DSP board I/O controls
 		    ...
 		 16 = /dev/mdsp16	16th DSP board I/O controls
 
-102 char	Philips SAA5249 Teletext signal decoder
+102 char	Philips SAA5249 Teletext signal decoder {2.6}
 		  0 = /dev/tlk0		First Teletext decoder
 		  1 = /dev/tlk1		Second Teletext decoder
 		  2 = /dev/tlk2		Third Teletext decoder
@@ -1528,7 +1553,7 @@
 		  1 = /dev/srnd1	Second miroMEDIA Surround board
 		    ...
 
-111 char	Philips SAA7146-based audio/video card
+111 char	Philips SAA7146-based audio/video card {2.6}
 		  0 = /dev/av0		First A/V card
 		  1 = /dev/av1		Second A/V card
 		    ...
@@ -1564,7 +1589,7 @@
 
 		Plays music using IBM BASIC style strings.
 
-116 char	Advanced Linux System Driver (ALSA)
+116 char	Advanced Linux Sound Driver (ALSA)
 
 117 char	COSA/SRP synchronous serial card
 		  0 = /dev/cosa0c0	1st board, 1st channel
@@ -1693,9 +1718,9 @@
 		  1 = /dev/gfax1	GammaLink channel 1
 		    ...
 
-159 char	Quicknet Technologies Internet PhoneJack/LineJack
-		  0 = /dev/ixj0		First device
-		  1 = /dev/ixj1		Second device
+159 char	Telephony for Linux
+		  0 = /dev/phone0	First telephony device
+		  1 = /dev/phone1	Second telephony device
 		    ...
 
 160 char	General Purpose Instrument Bus (GPIB)
@@ -1831,6 +1856,7 @@
 		 48 = /dev/usb/scanner0	First USB scanner
 		    ...
 		 63 = /dev/usb/scanner15 16th USB scanner
+		 64 = /dev/usb/rio500	Diamond Rio 500
 
 181 char	Conrad Electronic parallel port radio clocks
 		  0 = /dev/pcfclock0	First Conrad radio clock
@@ -1855,7 +1881,12 @@
 		  1 = /dev/pevss1	Second sender board
 		    ...
 
-185 char	Reserved for InterMezzo high availability file system
+185 char	InterMezzo high availability file system
+		  0 = /dev/intermezzo0	First cache manager
+		  1 = /dev/intermezzo1	Second cache manager
+		    ...
+
+		See http://www.inter-mezzo.org/ for more information.
 
 186 char	Object-based storage control device
 		  0 = /dev/obd0		First obd control device
@@ -1864,7 +1895,10 @@
 
 		See ftp://ftp.lustre.org/pub/obd for code and information.
 
-187 char	UNALLOCATED
+187 char	DESkey hardware encryption device
+		  0 = /dev/deskey0	First DES key
+		  1 = /dev/deskey1	Second DES key
+		    ...
 
 188 char	USB serial converters
 		  0 = /dev/ttyUSB0	First USB serial converter
@@ -1881,7 +1915,37 @@
 		  1 = /dev/kctt1	Second KCT/T card
 		    ...
 
-191-239		UNALLOCATED
+191 char	Reserved for PCMCIA
+
+192 char	Kernel profiling interface
+		  0 = /dev/profile	Profiling control device
+		  1 = /dev/profile0	Profiling device for CPU 0
+		  2 = /dev/profile1	Profiling device for CPU 1
+		    ...
+
+193 char	Kernel event-tracing interface
+		  0 = /dev/trace	Tracing control device
+		  1 = /dev/trace0	Tracing device for CPU 0
+		  2 = /dev/trace1	Tracing device for CPU 1
+		    ...
+
+194 char	linVideoStreams (LINVS)
+		  0 = /dev/mvideo/status0	Video compression status
+		  1 = /dev/mvideo/stream0	Video stream
+		  2 = /dev/mvideo/frame0	Single compressed frame
+		  3 = /dev/mvideo/rawframe0	Raw uncompressed frame
+		  4 = /dev/mvideo/codec0	Direct codec access
+		  5 = /dev/mvideo/video4linux0	Video4Linux compatibility
+
+		 16 = /dev/mvideo/status1	Second device
+		    ...
+		 32 = /dev/mvideo/status2	Third device
+		    ...
+		    ...
+		240 = /dev/mvideo/status15	16th device 
+		    ...
+
+195-239		UNALLOCATED
 
 240-254		LOCAL/EXPERIMENTAL USE
 
@@ -1910,7 +1974,6 @@
 /dev/stderr	fd/2		symbolic	stderr file descriptor
 /dev/nfsd	socksys		symbolic	Required by iBCS-2
 /dev/X0R	null		symbolic	Required by iBCS-2
-/dev/i2o*	/dev/i2o/*	symbolic	Backward compatibility
 
 Note: /dev/X0R is <letter X>-<digit 0>-<letter R>.
 
@@ -1923,6 +1986,7 @@
 /dev/ftape	qft0		symbolic	Backward compatibility
 /dev/bttv0	video0		symbolic	Backward compatibility
 /dev/radio	radio0		symbolic	Backward compatibility
+/dev/i2o*	/dev/i2o/*	symbolic	Backward compatibility
 /dev/scd?	sr?		hard		Alternate SCSI CD-ROM name
 
 	Locally defined links
diff -urN linux-2.2.15-pre15/Documentation/scsi-generic.txt linux/Documentation/scsi-generic.txt
--- linux-2.2.15-pre15/Documentation/scsi-generic.txt	Mon Dec  3 22:01:40 2001
+++ linux/Documentation/scsi-generic.txt	Wed Dec 31 16:00:00 1969
@@ -1,785 +0,0 @@
-            Notes on Linux's SG driver version 2.1.36
-            -----------------------------------------
-                                                        20000110
-
-Introduction
-============
-The SCSI Generic driver (sg) is one of the four "high level" SCSI device
-drivers along with sd, st and sr (disk, tape and CDROM respectively). Sg
-is more generalized (but lower level) than its siblings and tends to be
-used on SCSI devices that don't fit into the already serviced categories.
-Thus sg is used for scanners, cd writers and reading audio cds digitally
-amongst other things.
-
-These are notes on the Linux SCSI generic packet device driver (sg)
-describing version 2.1.36 . The original driver was written by Lawrence
-Foard and remained in place with minimal changes since circa 1992.
-Version 2 of this driver remains backward compatible (binary and
-source **) with the original. It adds scatter gather, command queuing,
-per file descriptor sequencing, asynchronous notification and better
-error reporting.
-
-This is an abridged version of the sg documentation that is targeted
-at the linux/Documentation directory. The full document can be found
-at http://www.torque.net/sg/p/scsi-generic_long.txt .
-
-The interface and usage of the original sg driver have been documented
-by Heiko Eissfeldt in a HOWTO called SCSI-Programming-HOWTO. My copy
-of the document is version 1.5 dated 7th May 1996. It can found at
-ftp://sunsite.unc.edu/pub/Linux/docs/HOWTO-SCSI-Programming-HOWTO .
-A copy of this document can be found at:
-http://www.torque.net/sg/p/original/HOWTO-SCSI-Programming-HOWTO.txt .
-
-** It is possible to write applications that perform differently
-depending on whether they are using the original or this version of
-the sg device driver. The author is not aware of any useful
-pre-existing applications that have problems with version 2.
-
-
-Architecture
-============
-The SCSI generic packet device driver (sg) is a character based device.
-It is one of the four high level device driver in the SCSI sub-system;
-the others are sd (for direct-access devices - disks), st (for tapes)
-and sr (for data cdroms). The other three devices are block devices.
-
-The unifying layer of the SCSI sub-system is the so-called mid-level.
-Below that are the "low level" drivers which are the drivers for the
-various adapters supported by Linux. Also at this level are pseudo
-adapter drivers such as ide-scsi which converts the SCSI protocol to
-ATAPI (which are similar to one another) for use by IDE devices.
-
-Since sg is a character device it supports the traditional Unix
-system calls of open(), close(), read(), write() and ioctl(). Two other
-related system calls: poll() and fcntl() are added to this list and
-how they interact with the sg device driver is documented later.
-
-An SG device is accessed by write()ing SCSI commands plus any associated
-outgoing data to it; the resulting status codes and any incoming data are
-then obtained by a read() call. The device can be opened O_NONBLOCK
-(non-blocking) and poll() used to monitor its progress. The device may be
-opened O_EXCL which excludes other "sg" users from this device (but not
-"sd", "st" or "sr" users). The buffer given to the write() call is made
-up as follows:
-        - struct sg_header image (see below)
-        - scsi command (6, 10 or 12 bytes long)
-        - data to be written to the device (if any)
-
-The buffer received from the corresponding read() call contains:
-        - struct sg_header image (check status/errors + sense_buffer)
-        - data read back from device (if any)
-
-The given SCSI command has its LUN field overwritten by the LUN value of
-the associated sg device that has been open()ed.
-
-SCSI commands are only attempted once (i.e. there are no internal
-retries). If appropriate (e.g. a SCSI READ) the data buffer is copied back
-to user space irrespective of the values of the various SCSI related
-error/status codes. [Some adapters that use an old error interface in
-the SCSI mid level ignore the retry count and retry certain errors.]
-
-
-sg_header
-=========
-This is the name of the control structure that conveys information
-about the length of data to be read/written by the associated SCSI
-command. It also conveys error and status information from the
-read() call. An instance of this structure is the first thing that
-is placed in the data buffers of both write() and read().
-
-In its original form it looked like this:
-struct sg_header {
-    int pack_len;
-    int reply_len;
-    int pack_id;
-    int result;
-    unsigned int twelve_byte:1;
-    unsigned int other_flags:31;
-    unsigned char sense_buffer[16];
-}; /* this structure is 36 bytes long */
-
-The 'pack_len' is bizarre and ends up having the 'reply_len' put in it
-(perhaps it had a use at some stage). Even though it looks like an
-input variable, it is not read by sg internally (only written).
-
-The 'reply_len' is the length of the data the corresponding read()
-will/should request (including the sg_header).
-
-The 'pack_id' is not acted upon by the sg device driver but is conveyed
-back to the corresponding read() so it can be used for sequencing by an
-application.
-
-The 'result' is also bizarre, turning certain types of host codes to 0 (no
-error), EBUSY or EIO. With better error reporting now available, the
-'result' is best ignored.
-
-The 'twelve_byte' field overrides the internal SCSI command length detection
-algorithm for group 6 and 7 commands (ie when 1st byte >= 0xc0) and forces
-a command length of 12 bytes.
-The command length detection algorithm is as follows:
-Group:  0    1    2    3    4    5    6    7
-Length: 6   10   10   12   12   12   10   10
-
-'other_flags' was originally documented as "not used" but some current
-applications assume it has 0 placed in it.
-
-The 'sense_buffer' is the first 16 bytes of SCSI sense buffer that is
-returned when the target returns a SCSI status code of CHECK_CONDITION
-or COMMAND_TERMINATED [or (driver_status & DRIVER_SENSE) is true]. This
-buffer should be at least 18 bytes long and arguably 32 bytes; unfortunately
-this is unlikely to happen in the 2.2.x series of kernels.
-
-
-The new sg_header offered in this driver is:
-#define SG_MAX_SENSE 16
-struct sg_header
-{
-    int pack_len;    /* [o] reply_len (ie useless) ignored as input */
-    int reply_len;   /* [i] max length of expected reply (inc. sg_header) */
-    int pack_id;     /* [io] id number of packet (use ints >= 0) */
-    int result;      /* [o] 0==ok, else (+ve) Unix errno (best ignored) */
-    unsigned int twelve_byte:1;
-        /* [i] Force 12 byte command length for group 6 & 7 commands  */
-    unsigned int target_status:5;   /* [o] scsi status from target */
-    unsigned int host_status:8;     /* [o] host status (see "DID" codes) */
-    unsigned int driver_status:8;   /* [o] driver status+suggestion */
-    unsigned int other_flags:10;    /* unused */
-    unsigned char sense_buffer[SG_MAX_SENSE]; /* [o] Output in 3 cases:
-           when target_status is CHECK_CONDITION or
-           when target_status is COMMAND_TERMINATED or
-           when (driver_status & DRIVER_SENSE) is true. */
-};      /* This structure is 36 bytes long on i386 */
-
-Firstly the new header is binary compatible with the original. This is
-important for keeping existing apps working without recompilation.
-
-Only those elements (or fields) that are new or in some way different
-from the original are documented below.
-
-'pack_id' becomes input to a read() when ioctl(sg_fd, SG_SET_FORCE_PACK_ID,
-&one) is active. A 'pack_id' of -1 is interpreted as fetch the oldest
-waiting packet; any other value will cause the read() to wait (or yield
-EAGAIN) until a packet with that 'pack_id' becomes available. In all cases
-the value of 'pack_id' available after a read() is the value given to that
-variable in the prior, corresponding write().
-
-The SCSI command length can now be given directly using the SG_NEXT_CMD_LEN
-ioctl().
-
-The 'target_status' field is always output and is the (masked and shifted
-1 bit right) SCSI status code from the target device. The allowable
-values are (found in <scsi/scsi.h>):
-/* N.B. 1 bit offset from usual SCSI status values */
-#define GOOD                 0x00
-#define CHECK_CONDITION      0x01
-#define CONDITION_GOOD       0x02
-#define BUSY                 0x04
-#define INTERMEDIATE_GOOD    0x08
-#define INTERMEDIATE_C_GOOD  0x0a
-#define RESERVATION_CONFLICT 0x0c
-#define COMMAND_TERMINATED   0x11
-#define QUEUE_FULL           0x14
-When the 'target_status' is CHECK_CONDITION or COMMAND_TERMINATED the
-'sense_buffer' is output. Note that when (driver_status & DRIVER_SENSE)
-is true then the 'sense_buffer' is also output (this seems to occur when
-the ide-scsi emulation is used). When the 'sense_buffer' is output the
-SCSI Sense Key can be found at (sense_buffer[2] & 0x0f) .
-
-The 'host_status' field is always output and has the following values
-whose "defines" are not visible outside the kernel. A copy of these
-defines can be found in sg_err.h (see the utilities section):
-#define DID_OK          0x00 /* NO error                                */
-#define DID_NO_CONNECT  0x01 /* Couldn't connect before timeout period  */
-#define DID_BUS_BUSY    0x02 /* BUS stayed busy through time out period */
-#define DID_TIME_OUT    0x03 /* TIMED OUT for other reason              */
-#define DID_BAD_TARGET  0x04 /* BAD target, device not responding?      */
-#define DID_ABORT       0x05 /* Told to abort for some other reason     */
-#define DID_PARITY      0x06 /* Parity error                            */
-#define DID_ERROR       0x07 /* Internal error [DMA underrun on aic7xxx]*/
-#define DID_RESET       0x08 /* Reset by somebody.                      */
-#define DID_BAD_INTR    0x09 /* Got an interrupt we weren't expecting.  */
-#define DID_PASSTHROUGH 0x0a /* Force command past mid-layer            */
-#define DID_SOFT_ERROR  0x0b /* The low level driver wants a retry      */
-
-The 'driver_status' field is always output. When ('driver_status' &
-DRIVER_SENSE) is true the 'sense_buffer' is also output. A copy of these
-defines can be found in sg_err.h (see the utilities section):
-#define DRIVER_OK           0x00 /* Typically no suggestion */
-#define DRIVER_BUSY         0x01
-#define DRIVER_SOFT         0x02
-#define DRIVER_MEDIA        0x03
-#define DRIVER_ERROR        0x04
-#define DRIVER_INVALID      0x05
-#define DRIVER_TIMEOUT      0x06
-#define DRIVER_HARD         0x07
-#define DRIVER_SENSE        0x08 /* Implies sense_buffer output */
-/* above status 'or'ed with one of the following suggestions */
-#define SUGGEST_RETRY       0x10
-#define SUGGEST_ABORT       0x20
-#define SUGGEST_REMAP       0x30
-#define SUGGEST_DIE         0x40
-#define SUGGEST_SENSE       0x80
-
-'other_flags' still remains as a 10 bit field (reduced from 31 bits), so
-code that places 0 in it will still be happy. It is not used.
-
-
-System Calls
-============
-What follows are descriptions of the characteristics of the standard
-Unix operating system calls when applied to a SCSI generic device
-using this version of the device driver.
-
-open(const char * filename, int flags)
---------------------------------------
-The filename should be an 'sg' device such as
-/dev/sg[a-z]
-/dev/sg[0,1,2,...]
-or a symbolic link to one of these. [Devfs has its own sub-directory for
-sg devices with entries like: /dev/sg/c1b2t3u4 .] It seems as though SCSI
-devices are allocated to sg minor numbers in the same order as they appear
-in 'cat /proc/scsi/scsi'. Sg is a "character" based Linux device driver.
-This means it has an open/close/read/write/ioctl type interface.
-
-Flags can be either O_RDONLY or O_RDWR or-ed with either
-O_EXCL          waits for other opens on sg device to be closed before
-                proceeding. If O_NONBLOCK is set then yields EBUSY when
-                someone else has the sg device open. The combination of
-                O_RDONLY and O_EXCL is disallowed.
-O_NONBLOCK      Sets non-blocking mode. Calls that would otherwise block
-                yield EAGAIN (eg read() ) or EBUSY (eg open() ).
-
-The original version of sg did not allow the O_RDONLY (yielding a EACCES
-error). This version allows it for accessing ioctls (e.g. doing an sg
-device scan with the SG_GET_SCSI_ID ioctl) but write()s will not be
-allowed. These flags are found in <fcntl.h> .
-
-By default, sequencing is per file descriptor in this version of sg. This
-means, for example that 2 processes can independently manipulate the same
-sg device at the same time. This may or may not make sense depending on
-the application: 2 processes (logically) reading from the same direct access
-device (ie a disk) is ok while running 2 instances of cd writing software
-on the same device at the same time probably wouldn't be a good idea. The
-previous version of sg supported only per device sequencing and this can
-still be selected with the SG_SET_MERGE_FD,1 ioctl().
-
-The driver will attempt to reserve SG_DEF_RESERVED_SIZE bytes (32KBytes in
-the current sg.h) on open(). The size of this reserved buffer can
-subsequently be modified with the SG_SET_RESERVED_SIZE ioctl(). In both
-cases these are requests subject to various dynamic constraints. The actual
-amount of memory obtained can be found by the SG_GET_RESERVED_SIZE ioctl().
-The reserved buffer will be used if:
-    -  it is not already in use (eg when command queuing is in use)
-    -  a write() does not call for a buffer size larger than the
-       reserved size.
-
-Returns a file descriptor if >= 0 , otherwise -1 implies an error.
-
-Error codes (value in 'errno' after -1 returned):
-EACCES          Either the user doesn't have appropriate permissions on
-                'filename' or attempted to use both O_RDONLY and O_EXCL
-EBUSY           O_NONBLOCK set and some user of this sg device has O_EXCL
-                set while someone is already using this device
-EINTR           while waiting for an "exclusive" lock to clear, a signal
-                is received, just try again ...
-ENODEV          sg not compiled into kernel or the kernel cannot find the
-                sg module (or it can't initialize itself (low memory??))
-ENOENT          given filename not found
-ENOMEM          An attempt to get memory to store this open's context
-                failed (this was _not_ a request to reserve DMA memory)
-ENXIO           either there is no attached device corresponding to given
-                filename or scsi sub-system is currently processing some
-                error (eg doing a device reset) or the sg driver/module
-                removed or corrupted
-
-
-write(int sg_fd, const void * buffer, size_t count)
----------------------------------------------------
-Even though sg is a character-based device driver it sends and receives
-packets to/from the associated scsi device. Write() is used to send a
-packet containing 2 mandatory parts and 1 optional part. The mandatory
-parts are:
-  - a control block (an instance of struct sg_header)
-  - a SCSI command (6, 10 or 12 bytes long)
-The optional part is:
-  - outgoing data (eg if a SCSI write command is being sent)
-These should appear as one contiguous string in the buffer given to
-write() in the above order with no pad characters.
-
-If a write() accepts this packet then at some later time the user should
-call a read() to get the result of the SCSI command. The previous sg
-driver enforced a strict write()/read()/write()/read() regime so that a
-second write() would block until first read() was finished. This sg
-driver relaxes that condition and thereby allows command queuing
-(limit is SG_MAX_QUEUE (16) outstanding packets per file descriptor).
-However, for backward compatibility, command queuing is turned off
-by default (#define SG_DEF_COMMAND_Q 0 in sg.h). This can be changed
-via the the SG_SET_COMMAND_Q ioctl() [or by recompiling after changing
-the above define to 1].
-
-In this sg driver a write() should return more or less immediately.
-
-Returns number of bytes written if > 0 , otherwise -1 implies an error.
-
-Error codes (value in 'errno' after -1 returned):
-EACCES          opened with RD_ONLY flag
-EAGAIN          SCSI mid-level out of command blocks (rare), try again.
-                This is more likely to happen when queuing commands,
-                so wait a bit (eg usleep(10000) ) before trying again
-EDOM            a) command queuing off: a packet is already queued
-                b) command queuing on: too many packets queued
-                   (SG_MAX_QUEUE exceeded)
-EFAULT          'buffer' for 'count' bytes is an invalid memory range
-EIO             a) incoming buffer too short. It should be at least
-                   (6 + sizeof(struct sg_header))==42 bytes long
-                b) SCSI command length given in SG_NEXT_CMD_LEN too long
-                c) reply_len negative
-ENOMEM          can't get memory for DMA. Take evasive action ...
-ENXIO           either scsi sub-system is currently processing some error
-                (eg doing a device reset) or the sg driver/module removed
-                or corrupted
-
-
-read(int sg_fd, void * buffer, size_t count)
---------------------------------------------
-Read() is used to receive a packet containing 1 mandatory part and 1
-optional part. The mandatory part is:
-  - a control block (an instance of struct sg_header)
-The optional part is:
-  - incoming data (eg if a SCSI read command was sent by earlier write() )
-The buffer given to a read() and its corresponding count should be
-sufficient to accommodate this packet to avoid truncation. Truncation occurs
-if count < sg_header::replylen .
-
-By default, read() will return the oldest packet queued up. If the
-SG_SET_FORCE_PACK_ID,1 ioctl() is active then read() will attempt to
-fetch the packet whose pack_id (given earlier to write()) matches the
-sg_header::pack_id given to this read(). If not available it will either
-wait or yield EAGAIN. As a special case, -1 in sg_header::pack_id given
-to read() will match the oldest packet.
-
-Returns number of bytes read if > 0 , otherwise -1 implies an error.
-Unfortunately the return value in the non-error case is simply the
-same as the count argument. It is not the actual number of bytes
-DMA-ed by the SCSI device. This driver is currently unable to provide
-such an underrun indication.
-
-If the SCSI device reports an error then a REQUEST SENSE is automatically
-done and the output is placed in the sense_buffer array which is in the
-control block. This action is sometimes called "auto-sense".
-
-Error codes (value in 'errno' after -1 returned):
-EAGAIN          either no waiting packet or requested packet is not
-                available while O_NONBLOCK flag was set
-EFAULT          'buffer' for 'count' bytes is an invalid memory range
-EINTR           while waiting for a packet, a signal is received, just
-                try again ...
-EIO             if the 'count' given to read() is < sizeof(struct sg_header)
-                and the 'result' element in sg_header is non-zero. Not a
-                recommended error reporting technique
-ENXIO           either scsi sub-system is currently processing some error
-                (eg doing a device reset) or the sg driver/module removed
-                or corrupted
-
-
-close(int sg_fd)
-----------------
-Preferably a close() should be done after all issued write()s have had
-their corresponding read() calls completed. Unfortunately this is not
-always possible. The semantics of close() in Unix are to return more
-or less immediately (ie not wait on any event) so the driver needs to
-arrange for an orderly cleanup of those packets that are still "in
-flight".
-
-A process that has an open file descriptor to an sg device may be aborted
-(eg by a kill signal). In this case, the kernel automatically calls close
-(which is called 'sg_release()' in the version 2 driver) to facilitate
-the cleanup mentioned above.
-
-A problem persists in version 2.1.36 if the sg driver is a module and is
-removed while packets are still "in flight".
-
-Returns 0 if successful, otherwise -1 implies an error.
-
-Error codes (value in 'errno' after -1 returned):
-ENXIO           sg driver/module removed or corrupted
-
-ioctl(int sg_fd, int command, ...)  [sg specific]
--------------------------------------------------
-Ken Thompson (or perhaps some other Unix luminary) described ioctl() as
-the "garbage bin of Unix". This driver compounds the situation by adding
-more ...
-If a ioctl command is not recognized by sg (and the various lower levels
-that it may pass the command on to) then the error EINVAL occurs. If an
-invalid address is given (in the 3rd argument) then the error EFAULT occurs.
-
-Those commands with an appended "+" are new in version 2.
-
-Those commands with an appended "W" are only accessible from file
-descriptors opened with O_RDWR. They will yield EACCES otherwise.
-
-SG_GET_TIMEOUT:
-Ignores its 3rd argument and _returns_ the timeout value (which will be
->= 0 ). The unit of this timeout is "jiffies" which are currently 10
-millisecond intervals on i386 (less on an alpha). Linux supplies
-a manifest constant HZ which is the number of "jiffies" in 1 second.
-
-SG_SET_TIMEOUT:
-Assumes 3rd argument points to an int containing the new timeout value
-for this file descriptor. The unit is a "jiffy". Packets that are
-already "in flight" will not be affected. The default value is set
-on open() and is SG_DEFAULT_TIMEOUT (defined in sg.h). This default is
-currently 1 minute and may not be long enough for formats. Negative
-values will yield an EIO error.
-
-SG_EMULATED_HOST:
-Assumes 3rd argument points to an int and outputs a flag indicating
-whether the host (adapter) is connected to a real SCSI bus or is an
-emulated one (eg ide-scsi device driver). A value of 1 means emulated
-while 0 is not.
-
-SG_SET_TRANSFORM  W:
-Only is meaningful when SG_EMULATED host has yielded 1 (i.e. the low-level
-is the ide-scsi device driver); otherwise an EINVAL error occurs. The
-default state is to _not_ transform SCSI commands to the corresponding
-ATAPI commands but pass them straight through as is. [Only certain classes
-of SCSI commands need to be transformed to their ATAPI equivalents.]
-The third argument is interpreted as an integer. When it is non-zero then
-a flag is set inside the ide-scsi driver that transforms subsequent
-commands sent to this driver. When zero is passed as the 3rd argument to
-this ioctl then the flag within the ide-scsi driver is cleared and
-subsequent commands are not transformed. Beware, this state will affect
-all devices (and hence all related sg file descriptors) associated with
-this ide-scsi "bus".
-
-SG_GET_TRANSFORM:
-Third argument is ignored. Only is meaningful when SG_EMULATED host has
-yielded 1 (ie the low-level is the ide-scsi device driver); otherwise
-an EINVAL error occurs. Returns 0 to indicate _not_ transforming SCSI
-to ATAPI commands (default). Returns 1 when it is transforming them.
-
-SG_SET_FORCE_LOW_DMA +:
-Assumes 3rd argument points to an int containing 0 or 1. 0 (default)
-means sg decides whether to use memory above 16 Mbyte level (on i386)
-based on the host adapter being used by this SCSI device. Typically
-PCI SCSI adapters will indicate they can DMA to the whole 32 bit address
-space.
-If 1 is given then the host adapter is overridden and only memory below
-the 16MB level is used for DMA. A requirement for this should be
-extremely rare. If the "reserved" buffer allocated on open() is not in
-use then it will be de-allocated and re-allocated under the 16MB level
-(and the latter operation could fail yielding ENOMEM).
-Only the current file descriptor is affected.
-
-SG_GET_LOW_DMA +:
-Assumes 3rd argument points to an int and places 0 or 1 in it. 0
-indicates the whole 32 bit address space is being used for DMA transfers
-on this file descriptor. 1 indicates the memory below the 16MB level
-(on i386) is being used (and this may be the case because the host
-adapters setting has been overridden by SG_SET_FORCE_LOW_DMA,1 .
-
-SG_GET_SCSI_ID +:
-Assumes 3rd argument is pointing to an object of type Sg_scsi_id (see
-sg.h) and populates it. That structure contains ints for host_no,
-channel, scsi_id, lun, scsi_type, allowable commands per lun and
-queue_depth. Most of this information is available from other sources
-(eg SCSI_IOCTL_GET_IDLUN and SCSI_IOCTL_GET_BUS_NUMBER) but tends to be
-awkward to collect.
-Allowable commands per lun and queue_depth give an insight to the
-command queuing capabilities of the adapters and the device. The latter
-overrides the former (logically) and the former is only of interest
-if it is equal to queue_depth which probably indicates the device
-does not support queueing commands (e.g. most scanners).
-
-SG_SET_FORCE_PACK_ID +:
-Assumes 3rd argument is pointing to an int. 0 (default) instructs read()
-to return the oldest (written) packet if multiple packets are
-waiting to be read (when command queuing is being used).
-1 instructs read() to view the sg_header::pack_id as input and return the
-oldest packet matching that pack_id or wait until it arrives (or yield
-EAGAIN if O_NONBLOCK is in force). As a special case the pack_id of -1
-given to read() in the mode will match the oldest packet.
-Only the current file descriptor is affected by this command.
-
-SG_GET_PACK_ID +:
-Assumes 3rd argument points to an int and places the pack_id of the
-oldest (written) packet in it. If no packet is waiting to be read then
-yields -1.
-
-SG_GET_NUM_WAITING +:
-Assumes 3rd argument points to an int and places the number of packets
-waiting to be read in it.
-
-SG_GET_SG_TABLESIZE +:
-Assumes 3rd argument points to an int and places the maximum number of
-scatter gather elements supported by the host adapter. 0 indicates that
-the adapter does support scatter gather.
-
-SG_SET_RESERVED_SIZE +W:
-Assumes 3rd argument is pointing to an int. That value will be used to
-request a new reserved buffer of that size. The previous reserved buffer
-is freed (if it is not in use; if it was in use -EBUSY is returned).
-A new reserved buffer is then allocated and its actual size can be found by
-calling the SG_GET_RESERVED_SIZE ioctl(). The reserved buffer is then used
-for DMA purposes by subsequent write() commands if it is not already in
-use and if the write() is not calling for a buffer size larger than that
-reserved. The reserved buffer may well be a series of kernel buffers if the
-adapter supports scatter-gather. Large buffers can be requested (eg 1 MB).
-
-SG_GET_RESERVED_SIZE +:
-Assumes 3rd argument points to an int and places the size in bytes of
-the reserved buffer from open() or the most recent SG_SET_RESERVED_SIZE
-ioctl() call on this fd.  The result can be 0 if memory is very tight. In
-this case it may not be wise to attempt something like burning a CD on
-this file descriptor.
-
-SG_SET_MERGE_FD +W:
-Assumes 3rd argument is pointing to an int. 0 (the default) causes all
-subsequent sequencing to be per file descriptor. 1 causes all subsequent
-sequencing to be per device. If this command tries to change the current
-state and there is one or more _other_ file descriptors using this sg
-device then an EBUSY error occurs. Per device sequencing was the original
-semantics and allowed, for example different processes to "share" the
-device, one perhaps write()ing with the other one read()ing. This command
-is supplied if anyone needs those semantics. Per file descriptor
-sequencing, perhaps with the use of the O_EXCL flag, seems more sensible.
-
-SG_GET_MERGE_FD +:
-Assumes 3rd argument points to an int and places 0 or 1 in it. 0 implies
-sequencing is per file descriptor. 1 implies sequencing is per device
-(original sg driver's semantics).
-
-SG_SET_COMMAND_Q +:
-Assumes 3rd argument is pointing to an int. 0 (current default, set by
-SG_DEF_COMMAND_Q in sg.h) disables command queuing. Attempts to write()
-a packet while one is already queued will result in a EDOM error.
-1 turns command queuing on.
-Changing the queuing state only affects write()s done after the change.
-Only the current file descriptor is affected by this command.
-
-SG_GET_COMMAND_Q +:
-Assumes 3rd argument points to an int and places 0 or 1 in it. 0 implies
-that command queuing is off on this file descriptor. 1 implies command
-queuing is on.
-
-SG_SET_UNDERRUN_FLAG +:
-Assumes 3rd argument is pointing to an int. 0 (current default, set by
-SG_DEF_UNDERRUN_FLAG in sg.h) requests underruns be ignored. 1 requests
-that underruns be flagged. [The only low level driver that acts on this
-at the moment is the aic7xxx which yields a DID_ERROR error on underrun.]
-Only the current file descriptor is affected by this command (unless
-"per device" sequencing has been selected).
-
-SG_GET_UNDERRUN_FLAG +:
-Assumes 3rd argument points to an int and places 0 or 1 in it. 0 implies
-that underruns are not being reported. 1 implies that underruns are being
-reported (see SG_SET_UNDERRUN_FLAG for more details).
-
-SG_NEXT_CMD_LEN +:
-Assumes 3rd argument is pointing to an int. The value of the int (if > 0)
-will be used as the SCSI command length of the next SCSI command sent to
-a write() on this fd. After that write() the SCSI command length logic is
-reset to use automatic length detection (ie depending on SCSI command group
-and the 'twelve_byte' field). If the current SCSI command length maximum of
-12 is exceeded then the affected write() will yield an EDOM error.
-Giving this ioctl() a value of 0 will set automatic length detection for
-the next write(). N.B. Only the following write() on this fd is affected by
-this ioctl().
-
-SG_GET_VERSION_NUM +:
-Assumes 3rd argument points to an int. The version number is then placed
-in that int. A sg version such as 2.1.36 will yield "20136" from this ioctl.
-
-SG_SCSI_RESET +:
-Assumes 3rd argument points to an int. Unfortunately doesn't currently
-do much (may in the future after other issues are resolved). Yields an
-EBUSY error if the SCSI bus or the associated device is being reset
-when this ioctl() is called, otherwise returns 0.
-
-SG_SET_DEBUG +:
-Assumes 3rd argument is pointing to an int. 0 (default) turns debugging
-off. Values > 0 cause the SCSI sense buffer to be decoded and output
-to the console/log when a SCSI device error occurs. Values > 8 cause
-the current sg device driver's state to be output to the console/log
-(this is a "one off" effect).
-If you need a _lot_ of the SCSI sub-system debug information (mainly from
-the mid-level) then try 'echo "scsi dump 0" > /proc/scsi/scsi' and lots of
-debug will appear in your console/log.
-
-
-poll(struct pollfd * udfds, unsigned int nfds, int timeout_ms)
---------------------------------------------------------------
-This is a native call in Linux 2.2 but most of its capabilities are available
-through the older select() call. Given a choice poll() should probably be
-used. Typically poll() is used when a sg scsi device is open()ed O_NONBLOCK
-for polling; and optionally with asynchronous notification as well using
-the fcntl() system call (below) and the SIGPOLL (aka SIGIO) signal.
-Only if something drastically is wrong (eg file handle gone stale) will
-POLLERR ever be set. POLLPRI, POLLHUP and POLLNVAL are never set.
-POLLIN is set when there is one or more packets waiting to be read.
-When POLLIN is set it implies that a read() will not block (nor yield
-EAGAIN in non-blocking mode) but return a packet immediately.
-POLLOUT (aka POLLWRNORM) is set when write() is able to accept a packet
-(ie will _not_ yield an EDOM error). The setting of POLLOUT is affected
-by the SG_SET_COMMAND_Q state: if the state is on then POLLOUT will remain
-set until the number of queued packets reaches SG_MAX_QUEUE, if the
-state is off then POLLOUT is only set when no packets are queued.
-Note that a packet can be queued after write()ing but not available to be
-read(); this typically happens when a SCSI read command is issued while
-the data is being retrieved.
-Poll() is per file descriptor unless SG_SET_MERGE_FD is set in which case
-it is per device.
-
-
-fcntl(int sg_fd, int cmd) or fcntl(int sg_fd, int cmd, long arg)
-----------------------------------------------------------------
-There are several uses for this system call in association with a sg
-file descriptor. The following pseudo code shows code that is useful for
-scanning the sg devices, taking care not to be caught in a wait for
-an O_EXCL lock by another process, and when the appropriate device is
-found, switching to normal blocked io. A working example of this logic
-is in the sg_scan utility program.
-
-open("/dev/sga", O_RDONLY | O_NONBLOCK)
-/* check device, EBUSY means some other process has O_EXCL lock on it */
-/* when the device you want is found then ... */
-flags = fcntl(sg_fd, F_GETFL)
-fcntl(sg_fd, F_SETFL, flags & (~ O_NONBLOCK))
-/* since, for simple apps, it is easier to use normal blocked io */
-
-
-Some work has to be done in Linux to set up for asynchronous notification.
-This is a non-blocking mode of operation in which, when the driver receives
-data back from a device so that a read() can be done, it sends a SIGPOLL
-(aka SIGIO) signal to the owning process. A working example of this logic
-is in the sg_poll test program.
-
-sigemptyset(&sig_set)
-sigaddset(&sig_set, SIGPOLL)
-sigaction(SIGPOLL, &s_action, 0)
-fcntl(sg_fd, F_SETOWN, getpid())
-flags = fcntl(sg_fd, F_GETFL);
-fcntl(sg_fd, F_SETFL, flags | O_ASYNC)
-
-
-Utility and Test Programs
-=========================
-See the README file in the sg_utils<date>.tgz tarball. Look on the
-http://www.torque.net/sg website for the latest version.
-
-Briefly, that tarball contains the following utilities:
-sg_dd512        'dd' like program that assumes 512 byte blocks size
-sg_dd2048       'dd' like program that assumes 2048 byte blocks size
-sg_dd2352       'dd' like program that assumes 2352 byte blocks size
-sgq_dd512       like 'sg_dd512' but does command queuing on "if"
-sgp_dd          probably the most flexible 'dd' variant. It uses POSIX
-                threads, block size set by "bs=..." plus other options.
-sg_scan         outputs information (optionally Inquiry) on SCSI devices
-sg_rbuf         tests SCSI bus transfer speed (without physical IO)
-sg_whoami       outputs info (optionally capacity) of given SCSI device
-sginfo          outputs "mode" information about SCSI devices (it is a
-                  re-port of the scsiinfo program onto the sg interface)
-
-It also contains the following test programs:
-sg_debug        outputs sg driver state to console/log file
-sg_poll         tests asynchronous notification
-sg_runt_ex      example run time selection program for application authors
-sg_simple1      example program first time users
-sg_simple2      like sg_simple1 but with more primitive error processing
-sg_inquiry      does a SCSI Inquiry command (from original HOWTO)
-sg_tst_med      checks presence of media (from original HOWTO)
-
-There are also 2 source files (sg_err.[hc]) for outputting and categorizing
-SCSI 2 errors and warnings. This code is used by most of the above
-utility and test programs.
-
-The following programs: sg_dd512, sg_dd2048, sg_dd2352, sg_scan, sg_runt_ex,
-sg_rbuf, sg_tst_med, sg_inquiry and sginfo, can be compiled either for this
-new sg driver _or_ the original sg driver (in 2.0 or 2.2 series kernels).
-sg_runt_ex can be run on 2.0, 2.2 or 2.3 series kernels even if it is
-compiled on a different series (eg compiled on 2.0, run on 2.2).
-
-
-Header files
-============
-User applications need to find the correct "sg.h" header file matching
-their kernel in order to write code using the sg device driver. This is
-sometimes more difficult than it should be. The correct "sg.h" will usually
-be found at /usr/src/linux/include/scsi/sg.h . Another important header
-file is "scsi.h" which will be in the same directory.
-
-When "#include <scsi/sg.h>" is written in an application then this refers
-to the file /usr/include/scsi/sg.h . A problem sometimes arises because
-the files in the /usr/include/scsi directory are controlled by the GNU
-library people who maintain glibc. Unfortunately these 2 versions of
-the sg.h header file are not always in sync. [This was the case in Redhat
-6.0 and 6.1 .] Glibc 2.1.3 and later versions should get this right.
-
-If this is a problem, the user may need to copy sg.h (and scsi.h) from
-the kernel source includes to /usr/include scsi. If the user can change
-the effected source code then another approach is to rely on the fact that
-/usr/src/linux is a symbolic link to /usr/src/linux/include/linux and
-change the sg.h include to look like:
-    #include <linux/../scsi/sg.h>
-This solution is used by the author of cdparanoia (Monty) in his application.
-
-[Former scsi generic documents suggested adding a symbolic link to
-bypass this problem but that is not popular with the glibc maintainers.
-I would like to thank Andreas Jaeger <aj@suse.de> for his contributions
-on this subject.]
-
-
-Extra information in scsi-generic_long.txt
-==========================================
-This document is an abridged form of a more comprehensive document called
-scsi-generic_long.txt (see www.torque.net/sg/p/scsi-generic_long.txt).
-
-The longer document contains additional sections on:
-   - memory issues
-   - ioctl()s in common with sd, st + sr
-   - distinguishing the original from the new driver
-   - SG_BIG_BUFF and friends
-   - shortcomings
-   - future directions
-   - an appendix with some SCSI 2 information in it
-
-
-References
-==========
-http://www.t10.org      Very important site for SCSI related information.
-                        Contains SCSI 2 and 3 draft standards.
-http://www.andante.org/scsi.html
-                        This is Eric Youngdale's site. Eric is primarily
-                        responsible for the Linux SCSI architecture and
-                        its mid-level implementation.
-http://www.kernel.dk    Jens Axboe's site for Linux cdrom matters including
-                        the SCSI "sr" driver.
-http://www.torque.net/sg
-                        My site with sg related information.
-newsgroup:linux-scsi@vger.rutgers.edu
-                        Newsgroup for Linux related SCSI matters
-/usr/src/linux/MAINTAINERS
-                        This is a file in the Linux kernel source that
-                        contains up to date information about who maintains
-                        what and where information can be found. Links to
-                        SCSI adapter information are also here.
-
-
-Conclusion
-==========
-The SCSI generic packet device driver attempts to make as few assumptions
-as possible about the device it is connected to while giving applications
-using it as much flexibility as possible on the SCSI command level. Sg
-needs to hide the "messy" kernel related details while protecting
-the integrity of the kernel against sg "abuse". Some of these aims are
-contradictory and some compromises need to be made. For example: should
-a sg based application be able to reset a SCSI bus when that could cause
-collateral damage to a disk holding the root file system? There is no
-easy answer to this and many other related questions.
-
-If you have any suggestion about sg (or improving (the accuracy of) this
-document) please contact me.
-
-
-Douglas Gilbert
-dgilbert@interlog.com
diff -urN linux-2.2.15-pre15/Documentation/sound/OPL3-SA2 linux/Documentation/sound/OPL3-SA2
--- linux-2.2.15-pre15/Documentation/sound/OPL3-SA2	Mon Aug  9 12:04:38 1999
+++ linux/Documentation/sound/OPL3-SA2	Mon Dec  3 22:01:46 2001
@@ -1,7 +1,7 @@
 Documentation for the OPL3-SA2, SA3, and SAx driver (opl3sa2.o)
 ---------------------------------------------------------------
 
-Scott Murray, scottm@interlog.com
+Scott Murray, scott@spiteful.org
 January 5, 1999
 
 NOTE: All trade-marked terms mentioned below are properties of their
diff -urN linux-2.2.15-pre15/Makefile linux/Makefile
--- linux-2.2.15-pre15/Makefile	Mon Dec  3 22:01:40 2001
+++ linux/Makefile	Mon Dec  3 22:01:46 2001
@@ -1,7 +1,7 @@
 VERSION = 2
 PATCHLEVEL = 2
 SUBLEVEL = 15
-EXTRAVERSION = pre15
+EXTRAVERSION = pre16
 
 ARCH := $(shell uname -m | sed -e s/i.86/i386/ -e s/sun4u/sparc64/ -e s/arm.*/arm/ -e s/sa110/arm/)
 
diff -urN linux-2.2.15-pre15/arch/alpha/kernel/bios32.c linux/arch/alpha/kernel/bios32.c
--- linux-2.2.15-pre15/arch/alpha/kernel/bios32.c	Tue Jan  4 10:12:11 2000
+++ linux/arch/alpha/kernel/bios32.c	Mon Dec  3 22:01:46 2001
@@ -57,6 +57,7 @@
 
 asmlinkage int sys_pciconfig_read() { return -ENOSYS; }
 asmlinkage int sys_pciconfig_write() { return -ENOSYS; }
+asmlinkage long sys_pciconfig_iobase() { return -ENOSYS; }
 void reset_for_srm(void) { }
 
 #else /* CONFIG_PCI */
@@ -93,6 +94,14 @@
 void __init
 pcibios_init(void)
 {
+	long i;
+
+	/* For the benefit of single-bus machines, emulate a multi-bus
+	   machine to the (limited) extent necessary.  Init all bus2hose
+	   entries to point to a dummy.  */
+	for (i = 0; i < 256; ++i)
+		bus2hose[i] = &default_hose;
+
 	if (!pcibios_present())
 		return;
 
@@ -280,6 +289,34 @@
 	return err;
 }
 
+/* Provide information on locations of various I/O regions in physical
+   memory.  Do this on a per-card basis so that we choose the right hose.  */
+
+asmlinkage long
+sys_pciconfig_iobase(long which, unsigned long bus, unsigned long dfn)
+{
+	struct linux_hose_info *hose;
+
+	hose = bus2hose[bus & 255];
+	if (!hose)
+		return -ENODEV;
+
+	switch (which) {
+	case IOBASE_HOSE:
+		return hose->pci_hose_index;
+	case IOBASE_SPARSE_MEM:
+		return hose->pci_sparse_mem_space;
+	case IOBASE_DENSE_MEM:
+		return hose->pci_dense_mem_space;
+	case IOBASE_SPARSE_IO:
+		return hose->pci_sparse_io_space;
+	case IOBASE_DENSE_IO:
+		return hose->pci_dense_io_space;
+	}
+
+	return -EOPNOTSUPP;
+}
+
 
 /*
  * Gory details start here...
@@ -1342,13 +1379,6 @@
 
 		for (hose = hose_head; hose; hose = hose->next)
 			layout_one_hose(hose);
-	} else {
-		/* For the benefit of single-bus machines, emulate a
-		   multi-bus machine to the (limited) extent necessary. 
-		   Init all bus2hose entries to point to a dummy.  */
-		hose = &default_hose;
-		for (i = 0; i < 256; ++i)
-			bus2hose[i] = hose;
 	}
 }
 
diff -urN linux-2.2.15-pre15/arch/alpha/kernel/bios32.h linux/arch/alpha/kernel/bios32.h
--- linux-2.2.15-pre15/arch/alpha/kernel/bios32.h	Sun Jan 10 09:59:54 1999
+++ linux/arch/alpha/kernel/bios32.h	Mon Dec  3 22:01:46 2001
@@ -164,3 +164,4 @@
 extern struct linux_hose_info *hose_head, **hose_tail;
 extern int hose_count;
 extern int pci_probe_enabled;
+extern struct linux_hose_info default_hose;
diff -urN linux-2.2.15-pre15/arch/alpha/kernel/core_apecs.c linux/arch/alpha/kernel/core_apecs.c
--- linux-2.2.15-pre15/arch/alpha/kernel/core_apecs.c	Sun Sep  6 10:34:33 1998
+++ linux/arch/alpha/kernel/core_apecs.c	Mon Dec  3 22:01:46 2001
@@ -17,6 +17,7 @@
 
 #include <asm/system.h>
 #include <asm/ptrace.h>
+#include <asm/pci.h>
 
 #define __EXTERN_INLINE inline
 #include <asm/io.h>
@@ -24,6 +25,7 @@
 #undef __EXTERN_INLINE
 
 #include "proto.h"
+#include "bios32.h"
 
 /*
  * NOTE: Herein lie back-to-back mb instructions.  They are magic. 
@@ -436,6 +438,12 @@
 	 * what ARC or SRM might have left behind...
 	 */
 	*(vuip)APECS_IOC_HAXR2 = 0; mb();
+
+	/* Tell userland where I/O space is located.  */
+	default_hose.pci_sparse_io_space = APECS_IO - IDENT_ADDR;
+	default_hose.pci_sparse_mem_space = APECS_SPARSE_MEM - IDENT_ADDR;
+	default_hose.pci_dense_io_space = 0;
+	default_hose.pci_dense_mem_space = APECS_DENSE_MEM - IDENT_ADDR;
 }
 
 int
diff -urN linux-2.2.15-pre15/arch/alpha/kernel/core_cia.c linux/arch/alpha/kernel/core_cia.c
--- linux-2.2.15-pre15/arch/alpha/kernel/core_cia.c	Mon Aug  9 12:05:05 1999
+++ linux/arch/alpha/kernel/core_cia.c	Mon Dec  3 22:01:46 2001
@@ -16,6 +16,7 @@
 
 #include <asm/system.h>
 #include <asm/ptrace.h>
+#include <asm/pci.h>
 
 #define __EXTERN_INLINE inline
 #include <asm/io.h>
@@ -23,6 +24,7 @@
 #undef __EXTERN_INLINE
 
 #include "proto.h"
+#include "bios32.h"
 
 /*
  * NOTE: Herein lie back-to-back mb instructions.  They are magic. 
@@ -580,6 +582,12 @@
 		*((vuip)CIA_IOC_HAE_IO) = 0; mb();
 		*((vuip)CIA_IOC_HAE_IO);  /* read it back. */
         }
+
+	/* Tell userland where I/O space is located.  */
+	default_hose.pci_sparse_io_space = CIA_IO - IDENT_ADDR;
+	default_hose.pci_sparse_mem_space = CIA_SPARSE_MEM - IDENT_ADDR;
+	default_hose.pci_dense_io_space = 0;
+	default_hose.pci_dense_mem_space = CIA_DENSE_MEM - IDENT_ADDR;
 }
 
 void
diff -urN linux-2.2.15-pre15/arch/alpha/kernel/core_irongate.c linux/arch/alpha/kernel/core_irongate.c
--- linux-2.2.15-pre15/arch/alpha/kernel/core_irongate.c	Tue Jan  4 10:12:11 2000
+++ linux/arch/alpha/kernel/core_irongate.c	Mon Dec  3 22:01:46 2001
@@ -301,35 +301,21 @@
 void __init
 irongate_init_arch(unsigned long *mem_start, unsigned long *mem_end)
 {
-	struct linux_hose_info *hose;
-
 	irongate_register_dump(__FUNCTION__);
 
-	/* Align memory to cache line; we'll be allocating from it. */
-
-	*mem_start = (*mem_start | 31) + 1;
-
-	/*
-	 * Irongate only supports one PCI bus but do the hose thing anyway.
-	 * Anything to do for AGP???
-	 */
-
-	hose = (struct linux_hose_info *) *mem_start;
-	*mem_start = (unsigned long)(hose + 1);
-	memset(hose, 0, sizeof(*hose));
-	hose->pci_io_space = IRONGATE_IO;
-	hose->pci_mem_space = IRONGATE_MEM;
-	hose->pci_config_space = IRONGATE_CONF;
-	hose->pci_sparse_space = 0;
-	hose->pci_hose_index = 0;
-
-	/* add it to the hose list for bios32.[ch] */
-
-	*hose_tail = hose;
-	hose_tail = &hose->next;
-
 	IRONGATE0->stat_cmd = IRONGATE0->stat_cmd & ~0x100;
 	irongate_pci_clr_err();
+
+	/* Tell userland where I/O space is located.  For some reason,
+	   the 40-bit PIO bias that we use in the kernel through KSEG
+	   didn't work for the page table based user mappings.  So make
+	   sure we get the 43-bit PIO bias.  */
+	default_hose.pci_sparse_io_space = 0;
+	default_hose.pci_sparse_mem_space = 0;
+	default_hose.pci_dense_io_space
+	  = (IRONGATE_IO & 0xffffffffff) | 0x80000000000;
+	default_hose.pci_dense_mem_space
+	  = (IRONGATE_MEM & 0xffffffffff) | 0x80000000000;
 }
 
 int
diff -urN linux-2.2.15-pre15/arch/alpha/kernel/core_lca.c linux/arch/alpha/kernel/core_lca.c
--- linux-2.2.15-pre15/arch/alpha/kernel/core_lca.c	Sun Sep  6 10:34:33 1998
+++ linux/arch/alpha/kernel/core_lca.c	Mon Dec  3 22:01:46 2001
@@ -16,7 +16,7 @@
 
 #include <asm/ptrace.h>
 #include <asm/system.h>
-#include <asm/smp.h>
+#include <asm/pci.h>
 
 #define __EXTERN_INLINE inline
 #include <asm/io.h>
@@ -24,6 +24,7 @@
 #undef __EXTERN_INLINE
 
 #include "proto.h"
+#include "bios32.h"
 
 /*
  * BIOS32-style PCI interface:
@@ -349,6 +350,12 @@
 	 * data parity errors.
 	 */
 	*(vulp)LCA_IOC_PAR_DIS = 1UL<<5;
+
+	/* Tell userland where I/O space is located.  */
+	default_hose.pci_sparse_io_space = LCA_IO - IDENT_ADDR;
+	default_hose.pci_sparse_mem_space = LCA_SPARSE_MEM - IDENT_ADDR;
+	default_hose.pci_dense_io_space = 0;
+	default_hose.pci_dense_mem_space = LCA_DENSE_MEM - IDENT_ADDR;
 }
 
 /*
diff -urN linux-2.2.15-pre15/arch/alpha/kernel/core_mcpcia.c linux/arch/alpha/kernel/core_mcpcia.c
--- linux-2.2.15-pre15/arch/alpha/kernel/core_mcpcia.c	Tue Jan  4 10:12:11 2000
+++ linux/arch/alpha/kernel/core_mcpcia.c	Mon Dec  3 22:01:46 2001
@@ -328,13 +328,16 @@
 
 		mcpcia_hoses[h] = hose;
 
-		hose->pci_io_space = MCPCIA_IO(h);
-		hose->pci_mem_space = MCPCIA_DENSE(h);
 		hose->pci_config_space = MCPCIA_CONF(h);
-		hose->pci_sparse_space = MCPCIA_SPARSE(h);
 		hose->pci_hose_index = h;
 		hose->pci_first_busno = 255;
 		hose->pci_last_busno = 0;
+
+		/* Tell userland where I/O space is located.  */
+		hose->pci_sparse_io_space = MCPCIA_IO(h) - IDENT_ADDR;
+		hose->pci_sparse_mem_space = MCPCIA_SPARSE(h) - IDENT_ADDR;
+		hose->pci_dense_io_space = 0;
+		hose->pci_dense_mem_space = MCPCIA_DENSE(h) - IDENT_ADDR;
 	}
 
 #if 1
diff -urN linux-2.2.15-pre15/arch/alpha/kernel/core_polaris.c linux/arch/alpha/kernel/core_polaris.c
--- linux-2.2.15-pre15/arch/alpha/kernel/core_polaris.c	Sun Jan 10 22:56:43 1999
+++ linux/arch/alpha/kernel/core_polaris.c	Mon Dec  3 22:01:46 2001
@@ -193,6 +193,12 @@
 #if 0
 	printk("polaris_init_arch(): trusting firmware for setup\n");
 #endif
+
+	/* Tell userland where I/O space is located.  */
+	default_hose.pci_sparse_io_space = 0;
+	default_hose.pci_sparse_mem_space = 0;
+	default_hose.pci_dense_io_space = POLARIS_DENSE_IO_BASE - IDENT_ADDR;
+	default_hose.pci_dense_mem_space = POLARIS_DENSE_MEM_BASE - IDENT_ADDR;
 }
 
 int polaris_pci_clr_err(void)
diff -urN linux-2.2.15-pre15/arch/alpha/kernel/core_pyxis.c linux/arch/alpha/kernel/core_pyxis.c
--- linux-2.2.15-pre15/arch/alpha/kernel/core_pyxis.c	Tue Jan  4 10:12:11 2000
+++ linux/arch/alpha/kernel/core_pyxis.c	Mon Dec  3 22:01:46 2001
@@ -15,6 +15,7 @@
 
 #include <asm/ptrace.h>
 #include <asm/system.h>
+#include <asm/pci.h>
 
 #define __EXTERN_INLINE inline
 #include <asm/io.h>
@@ -22,6 +23,7 @@
 #undef __EXTERN_INLINE
 
 #include "proto.h"
+#include "bios32.h"
 
 /* NOTE: Herein are back-to-back mb instructions.  They are magic.
    One plausible explanation is that the I/O controller does not properly
@@ -509,6 +511,12 @@
 			ctrl1 = *(vuip)PYXIS_CTRL1;  /* re-read */
 		}
 	}
+
+	/* Tell userland where I/O space is located.  */
+	default_hose.pci_sparse_io_space = 0;
+	default_hose.pci_sparse_mem_space = 0;
+	default_hose.pci_dense_io_space = PYXIS_BW_IO - IDENT_ADDR;
+	default_hose.pci_dense_mem_space = PYXIS_BW_MEM - IDENT_ADDR;
 }
 
 void __init
diff -urN linux-2.2.15-pre15/arch/alpha/kernel/core_t2.c linux/arch/alpha/kernel/core_t2.c
--- linux-2.2.15-pre15/arch/alpha/kernel/core_t2.c	Sat Jan  9 19:08:21 1999
+++ linux/arch/alpha/kernel/core_t2.c	Mon Dec  3 22:01:46 2001
@@ -18,6 +18,7 @@
 
 #include <asm/ptrace.h>
 #include <asm/system.h>
+#include <asm/pci.h>
 
 #define __EXTERN_INLINE
 #include <asm/io.h>
@@ -25,6 +26,7 @@
 #undef __EXTERN_INLINE
 
 #include "proto.h"
+#include "bios32.h"
 
 /*
  * NOTE: Herein lie back-to-back mb instructions.  They are magic. 
@@ -477,6 +479,12 @@
 		*(vulp)T2_HAE_4 = 0; mb(); /* do not touch this */
 #endif
 	}
+
+	/* Tell userland where I/O space is located.  */
+	default_hose.pci_sparse_io_space = T2_IO - IDENT_ADDR;
+	default_hose.pci_sparse_mem_space = T2_SPARSE_MEM - IDENT_ADDR;
+	default_hose.pci_dense_io_space = 0;
+	default_hose.pci_dense_mem_space = T2_DENSE_MEM - IDENT_ADDR;
 }
 
 #define SIC_SEIC (1UL << 33)    /* System Event Clear */
diff -urN linux-2.2.15-pre15/arch/alpha/kernel/core_tsunami.c linux/arch/alpha/kernel/core_tsunami.c
--- linux-2.2.15-pre15/arch/alpha/kernel/core_tsunami.c	Tue Jan  4 10:12:11 2000
+++ linux/arch/alpha/kernel/core_tsunami.c	Mon Dec  3 22:01:46 2001
@@ -98,12 +98,12 @@
 		 "pci_addr=0x%p, type1=0x%p)\n",
 		 bus, device_fn, where, pci_addr, type1));
 
-        *type1 = (bus != 0);
+	*type1 = (bus != 0);
 
-        if (hose->pci_first_busno == bus)
+	if (hose->pci_first_busno == bus)
 		bus = 0;
 
-        addr = (bus << 16) | (device_fn << 8) | where;
+	addr = (bus << 16) | (device_fn << 8) | where;
 	addr |= hose->pci_config_space;
 		
 	*pci_addr = addr;
@@ -266,12 +266,20 @@
 	*hose_tail = hose;
 	hose_tail = &hose->next;
 
-	hose->pci_io_space = TSUNAMI_IO(index);
-	hose->pci_mem_space = TSUNAMI_MEM(index);
 	hose->pci_config_space = TSUNAMI_CONF(index);
-	hose->pci_sparse_space = 0;
 	hose->pci_hose_index = index;
 
+	/* This is for userland consumption.  For some reason, the 40-bit
+	   PIO bias that we use in the kernel through KSEG didn't work for
+	   the page table based user mappings.  So make sure we get the
+	   43-bit PIO bias.  */
+	hose->pci_sparse_io_space = 0;
+	hose->pci_sparse_mem_space = 0;
+	hose->pci_dense_io_space
+	  = (TSUNAMI_IO(index) & 0xffffffffff) | 0x80000000000;
+	hose->pci_dense_mem_space
+	  = (TSUNAMI_MEM(index) & 0xffffffffff) | 0x80000000000;
+
 	switch (alpha_use_srm_setup)
 	{
 	default:
@@ -329,7 +337,7 @@
 {
 #ifdef NXM_MACHINE_CHECKS_ON_TSUNAMI
 	extern asmlinkage void entInt(void);
-        unsigned long tmp;
+	unsigned long tmp;
 	
 	/* Ho hum.. init_arch is called before init_IRQ, but we need to be
 	   able to handle machine checks.  So install the handler now.  */
diff -urN linux-2.2.15-pre15/arch/alpha/kernel/entry.S linux/arch/alpha/kernel/entry.S
--- linux-2.2.15-pre15/arch/alpha/kernel/entry.S	Tue Jan  4 10:12:11 2000
+++ linux/arch/alpha/kernel/entry.S	Mon Dec  3 22:01:46 2001
@@ -8,7 +8,7 @@
 
 #define SIGCHLD 20
 
-#define NR_SYSCALLS 371
+#define NR_SYSCALLS 377
 
 /*
  * These offsets must match with alpha_mv in <asm/machvec.h>.
@@ -1143,3 +1143,9 @@
 	.quad sys_capget
 	.quad sys_capset
 	.quad sys_sendfile			/* 370 */
+	.quad sys_ni_syscall
+	.quad sys_ni_syscall
+	.quad sys_ni_syscall
+	.quad sys_ni_syscall
+	.quad sys_ni_syscall			/* 375 */
+	.quad sys_pciconfig_iobase
diff -urN linux-2.2.15-pre15/arch/alpha/kernel/osf_sys.c linux/arch/alpha/kernel/osf_sys.c
--- linux-2.2.15-pre15/arch/alpha/kernel/osf_sys.c	Mon Aug  9 12:04:57 1999
+++ linux/arch/alpha/kernel/osf_sys.c	Mon Dec  3 22:01:46 2001
@@ -886,20 +886,8 @@
 		/* Return current software fp control & status bits.  */
 		/* Note that DU doesn't verify available space here.  */
 
-		/* EV6 implements most of the bits in hardware.  If
-		   UNDZ is not set, UNFD is maintained in software.  */
-		if (implver() == IMPLVER_EV6) {
-			unsigned long fpcr = rdfpcr();
-			w = ieee_fpcr_to_swcr(fpcr);
-			if (!(fpcr & FPCR_UNDZ)) {
-				w &= ~IEEE_TRAP_ENABLE_UNF;
-				w |= current->tss.flags & IEEE_TRAP_ENABLE_UNF;
-			}
-		} else {
-			/* Otherwise we are forced to do everything in sw.  */
-			w = current->tss.flags & IEEE_SW_MASK;
-		}
-
+		w = current->tss.flags & IEEE_SW_MASK;
+		w = swcr_update_status(w, rdfpcr());
 		if (put_user(w, (unsigned long *) buffer))
 			return -EFAULT;
 		return 0;
@@ -950,7 +938,7 @@
 {
 	switch (op) {
 	case SSI_IEEE_FP_CONTROL: {
-		unsigned long swcr, fpcr, undz, ev6;
+		unsigned long swcr, fpcr;
 
 		/* 
 		 * Alpha Architecture Handbook 4.7.7.3:
@@ -959,29 +947,24 @@
 		 * set in the trap shadow of a software-complete insn.
 		 */
 
-		ev6 = (implver() == IMPLVER_EV6);
-
 		/* Update softare trap enable bits.  */
 		if (get_user(swcr, (unsigned long *)buffer))
 			return -EFAULT;
 		current->tss.flags &= ~IEEE_SW_MASK;
 		current->tss.flags |= swcr & IEEE_SW_MASK;
 
-		/* Update the real fpcr.  Keep UNFD off if not UNDZ.  */
+		/* Update the real fpcr.  */
 		fpcr = rdfpcr();
-		if(ev6) {
-		    undz = (fpcr & FPCR_UNDZ);
-		    fpcr &= (~(FPCR_MASK | FPCR_UNDZ)) | FPCR_DYN_MASK;
-		}
-		else {
-		    fpcr &= (~FPCR_MASK) | FPCR_DYN_MASK;
-		}
+		fpcr &= FPCR_DYN_MASK;
 		fpcr |= ieee_swcr_to_fpcr(swcr);
-		if(ev6 && !undz) {
-		    fpcr &= ~FPCR_UNFD;
-		}
 		wrfpcr(fpcr);
-		   
+
+		/* If any exceptions are now unmasked, send a signal.  */
+		if (((swcr & IEEE_STATUS_MASK)
+		     >> IEEE_STATUS_TO_EXCSUM_SHIFT) & swcr) {
+			send_sig(SIGFPE, current, 1);
+		}
+
 		return 0;
 	}
 
diff -urN linux-2.2.15-pre15/arch/alpha/kernel/process.c linux/arch/alpha/kernel/process.c
--- linux-2.2.15-pre15/arch/alpha/kernel/process.c	Tue Jan  4 10:12:11 2000
+++ linux/arch/alpha/kernel/process.c	Mon Dec  3 22:01:46 2001
@@ -288,12 +288,9 @@
 void flush_thread(void)
 {
 	/* Arrange for each exec'ed process to start off with a clean slate
-	   with respect to the FPU.  This is all exceptions disabled.  Note
-           that EV6 defines UNFD valid only with UNDZ, which we don't want
-	   for IEEE conformance -- so that disabled bit remains in software.  */
-
+	   with respect to the FPU.  This is all exceptions disabled.  */
 	current->tss.flags &= ~IEEE_SW_MASK;
-	wrfpcr(FPCR_DYN_NORMAL | FPCR_INVD | FPCR_DZED | FPCR_OVFD | FPCR_INED);
+	wrfpcr(FPCR_DYN_NORMAL | ieee_swcr_to_fpcr(0));
 }
 
 void release_thread(struct task_struct *dead_task)
diff -urN linux-2.2.15-pre15/arch/alpha/kernel/ptrace.c linux/arch/alpha/kernel/ptrace.c
--- linux-2.2.15-pre15/arch/alpha/kernel/ptrace.c	Tue Jan  4 10:12:11 2000
+++ linux/arch/alpha/kernel/ptrace.c	Mon Dec  3 22:01:46 2001
@@ -17,6 +17,7 @@
 #include <asm/uaccess.h>
 #include <asm/pgtable.h>
 #include <asm/system.h>
+#include <asm/fpu.h>
 
 #include "proto.h"
 
@@ -119,18 +120,30 @@
 /*
  * Get contents of register REGNO in task TASK.
  */
-static inline long
+static long
 get_reg(struct task_struct * task, unsigned long regno)
 {
+	/* Special hack for fpcr -- combine hardware and software bits.  */
+	if (regno == 63) {
+		unsigned long fpcr = *get_reg_addr(task, regno);
+		unsigned long swcr = task->tss.flags & IEEE_SW_MASK;
+		swcr = swcr_update_status(swcr, fpcr);
+		return fpcr | swcr;
+	}
 	return *get_reg_addr(task, regno);
 }
 
 /*
  * Write contents of register REGNO in task TASK.
  */
-static inline int
+static int
 put_reg(struct task_struct *task, unsigned long regno, long data)
 {
+	if (regno == 63) {
+		task->tss.flags = ((task->tss.flags & ~IEEE_SW_MASK)
+				   | (data & IEEE_SW_MASK));
+		data = (data & FPCR_DYN_MASK) | ieee_swcr_to_fpcr(data);
+	}
 	*get_reg_addr(task, regno) = data;
 	return 0;
 }
diff -urN linux-2.2.15-pre15/arch/alpha/kernel/sys_jensen.c linux/arch/alpha/kernel/sys_jensen.c
--- linux-2.2.15-pre15/arch/alpha/kernel/sys_jensen.c	Mon Oct 12 11:40:12 1998
+++ linux/arch/alpha/kernel/sys_jensen.c	Mon Dec  3 22:01:46 2001
@@ -31,6 +31,11 @@
 #include "irq.h"
 #include "machvec.h"
 
+#ifdef CONFIG_PCI
+#include <asm/pci.h>
+#include "bios32.h"
+#endif
+
 
 static void
 jensen_update_irq_hw(unsigned long irq, unsigned long mask, int unmask_p)
@@ -116,6 +121,18 @@
 	printk(KERN_CRIT "Machine check\n");
 }
 
+static void __init
+jensen_init_arch(void)
+{
+#ifdef CONFIG_PCI
+	/* Tell userland where I/O space is located.  */
+	default_hose.pci_sparse_io_space = EISA_IO - IDENT_ADDR;
+	default_hose.pci_sparse_mem_space = EISA_MEM - IDENT_ADDR;
+	default_hose.pci_dense_io_space = 0;
+	default_hose.pci_dense_mem_space = 0;
+#endif
+}
+
 
 /*
  * The System Vector
@@ -136,7 +153,7 @@
 	ack_irq:		generic_ack_irq,
 	device_interrupt:	jensen_device_interrupt,
 
-	init_arch:		NULL,
+	init_arch:		jensen_init_arch,
 	init_irq:		jensen_init_irq,
 	init_pit:		generic_init_pit,
 	kill_arch:		generic_kill_arch,
diff -urN linux-2.2.15-pre15/arch/alpha/math-emu/math.c linux/arch/alpha/math-emu/math.c
--- linux-2.2.15-pre15/arch/alpha/math-emu/math.c	Tue Jan  4 10:12:11 2000
+++ linux/arch/alpha/math-emu/math.c	Mon Dec  3 22:01:46 2001
@@ -159,8 +159,7 @@
 	FP_DECL_S(SA); FP_DECL_S(SB); FP_DECL_S(SR);
 	FP_DECL_D(DA); FP_DECL_D(DB); FP_DECL_D(DR);
 
-	unsigned long fa, fb, fc, func, mode, src;
-	unsigned long fpcw = current->tss.flags;
+	unsigned long fa, fb, fc, func, mode, src, swcr;
 	unsigned long res, va, vb, vc, fpcr;
 	__u32 insn;
 
@@ -175,10 +174,11 @@
 	mode   = (insn >> 11) & 0x3;
 	
 	fpcr = rdfpcr();
+	swcr = swcr_update_status(current->tss.flags, fpcr);
 
 	if (mode == 3) {
-	    /* Dynamic -- get rounding mode from fpcr.  */
-	    mode = (fpcr >> FPCR_DYN_SHIFT) & 3;
+		/* Dynamic -- get rounding mode from fpcr.  */
+		mode = (fpcr >> FPCR_DYN_SHIFT) & 3;
 	}
 
 	switch (src) {
@@ -231,9 +231,14 @@
 			}
 			FP_CMP_D(res, DA, DB, 3);
 			vc = 0x4000000000000000;
-			/* CMPTEQ, CMPTUN don't trap on QNaN, while CMPTLT and CMPTLE do */
-			if (res == 3 && ((func & 3) >= 2 || FP_ISSIGNAN_D(DA) || FP_ISSIGNAN_D(DB)))
+			/* CMPTEQ, CMPTUN don't trap on QNaN,
+			   while CMPTLT and CMPTLE do */
+			if (res == 3
+			    && ((func & 3) >= 2
+				|| FP_ISSIGNAN_D(DA)
+				|| FP_ISSIGNAN_D(DB))) {
 				FP_SET_EXCEPTION(FP_EX_INVALID);
+			}
 			switch (func) {
 			case FOP_FNC_CMPxUN: if (res != 3) vc = 0; break;
 			case FOP_FNC_CMPxEQ: if (res) vc = 0; break;
@@ -285,9 +290,11 @@
 			}
 
 		case FOP_FNC_CVTxQ:
-			if (DB_c == FP_CLS_NAN && (_FP_FRAC_HIGH_RAW_D(DB) & _FP_QNANBIT_D))
-				vc = 0; /* AAHB Table B-2 sais QNaN should not trigger INV */
-			else
+			if (DB_c == FP_CLS_NAN
+			    && (_FP_FRAC_HIGH_RAW_D(DB) & _FP_QNANBIT_D)) {
+			  /* AAHB Table B-2 says QNaN should not trigger INV */
+				vc = 0;
+			} else
 				FP_TO_INT_ROUND_D(vc, DB, 64, 2);
 			goto done_d;
 		}
@@ -321,11 +328,15 @@
 
 pack_s:
 	FP_PACK_SP(&vc, SR);
+	if ((_fex & FP_EX_UNDERFLOW) && (swcr & IEEE_MAP_UMZ))
+		vc = 0;
 	alpha_write_fp_reg_s(fc, vc);
 	goto done;
 
 pack_d:
 	FP_PACK_DP(&vc, DR);
+	if ((_fex & FP_EX_UNDERFLOW) && (swcr & IEEE_MAP_UMZ))
+		vc = 0;
 done_d:
 	alpha_write_fp_reg(fc, vc);
 	goto done;
@@ -345,16 +356,16 @@
 done:
 	if (_fex) {
 		/* Record exceptions in software control word.  */
-		current->tss.flags
-		  = fpcw |= (_fex << IEEE_STATUS_TO_EXCSUM_SHIFT);
+		swcr |= (_fex << IEEE_STATUS_TO_EXCSUM_SHIFT);
+		current->tss.flags |= (_fex << IEEE_STATUS_TO_EXCSUM_SHIFT);
 
 		/* Update hardware control register */
 		fpcr &= (~FPCR_MASK | FPCR_DYN_MASK);
-		fpcr |= ieee_swcr_to_fpcr(fpcw);
+		fpcr |= ieee_swcr_to_fpcr(swcr);
 		wrfpcr(fpcr);
 
 		/* Do we generate a signal?  */
-		if (_fex & fpcw & IEEE_TRAP_ENABLE_MASK) {
+		if (_fex & swcr & IEEE_TRAP_ENABLE_MASK) {
 			MOD_DEC_USE_COUNT;
 			return 0;
 		}
diff -urN linux-2.2.15-pre15/arch/alpha/math-emu/sfp-machine.h linux/arch/alpha/math-emu/sfp-machine.h
--- linux-2.2.15-pre15/arch/alpha/math-emu/sfp-machine.h	Tue Jan  4 10:12:11 2000
+++ linux/arch/alpha/math-emu/sfp-machine.h	Mon Dec  3 22:01:46 2001
@@ -74,7 +74,7 @@
 #define FP_EX_INEXACT		IEEE_TRAP_ENABLE_INE
 #define FP_EX_DENORM		IEEE_TRAP_ENABLE_DNO
 
-#define FP_DENORM_ZERO		(fpcw & IEEE_MAP_DMZ)
+#define FP_DENORM_ZERO		(swcr & IEEE_MAP_DMZ)
 
 #define FP_HANDLE_EXCEPTIONS return _fex
 
diff -urN linux-2.2.15-pre15/arch/i386/kernel/entry.S linux/arch/i386/kernel/entry.S
--- linux-2.2.15-pre15/arch/i386/kernel/entry.S	Fri Apr 30 08:13:37 1999
+++ linux/arch/i386/kernel/entry.S	Mon Dec  3 22:01:46 2001
@@ -216,9 +216,11 @@
 	movl $-ENOSYS,EAX(%esp)
 	call SYMBOL_NAME(syscall_trace)
 	movl ORIG_EAX(%esp),%eax
+        cmpl $(NR_syscalls),%eax 
+        jae 1f 
 	call *SYMBOL_NAME(sys_call_table)(,%eax,4)
 	movl %eax,EAX(%esp)		# save the return value
-	call SYMBOL_NAME(syscall_trace)
+1:	call SYMBOL_NAME(syscall_trace)
 	jmp ret_from_sys_call
 badsys:
 	movl $-ENOSYS,EAX(%esp)
diff -urN linux-2.2.15-pre15/arch/i386/kernel/ptrace.c linux/arch/i386/kernel/ptrace.c
--- linux-2.2.15-pre15/arch/i386/kernel/ptrace.c	Tue Jan  4 10:12:11 2000
+++ linux/arch/i386/kernel/ptrace.c	Mon Dec  3 22:01:46 2001
@@ -11,6 +11,7 @@
 #include <linux/errno.h>
 #include <linux/ptrace.h>
 #include <linux/user.h>
+#include <linux/sys.h> 
 
 #include <asm/uaccess.h>
 #include <asm/pgtable.h>
@@ -320,7 +321,9 @@
 {
 	switch (regno >> 2) {
 		case ORIG_EAX:
-			return -EIO;
+			if(value >= NR_syscalls)
+				return -EIO;
+			break;
 		case FS:
 			if (value && (value & 3) != 3)
 				return -EIO;
diff -urN linux-2.2.15-pre15/arch/i386/kernel/setup.c linux/arch/i386/kernel/setup.c
--- linux-2.2.15-pre15/arch/i386/kernel/setup.c	Mon Dec  3 22:01:40 2001
+++ linux/arch/i386/kernel/setup.c	Mon Dec  3 22:01:46 2001
@@ -445,27 +445,29 @@
 	cpuid(0x80000003, &v[4], &v[5], &v[6], &v[7]);
 	cpuid(0x80000004, &v[8], &v[9], &v[10], &v[11]);
 	c->x86_model_id[48] = 0;
+	
+	if(c->x86_vendor == X86_VENDOR_AMD)
+	{
+		/*  Set MTRR capability flag if appropriate  */
+		if(boot_cpu_data.x86 == 5) {
+			if((boot_cpu_data.x86_model == 9) ||
+			   ((boot_cpu_data.x86_model == 8) && 
+			    (boot_cpu_data.x86_mask >= 8)))
+				c->x86_capability |= X86_FEATURE_MTRR;
+		}
 
-	/*  Set MTRR capability flag if appropriate  */
-	if(boot_cpu_data.x86 == 5) {
-		if((boot_cpu_data.x86_model == 9) ||
-		   ((boot_cpu_data.x86_model == 8) && 
-		    (boot_cpu_data.x86_mask >= 8)))
-			c->x86_capability |= X86_FEATURE_MTRR;
-	}
-
-	if (n >= 0x80000005){
-		cpuid(0x80000005, &dummy, &dummy, &ecx, &edx);
-		printk("CPU: L1 I Cache: %dK  L1 D Cache: %dK\n",
-			ecx>>24, edx>>24);
-		c->x86_cache_size=(ecx>>24)+(edx>>24);
-	}
-	if (n >= 0x80000006){
-		cpuid(0x80000006, &dummy, &dummy, &ecx, &edx);
-		printk("CPU: L2 Cache: %dK\n", ecx>>16);
-		c->x86_cache_size = ecx>>16;
+		if (n >= 0x80000005){
+			cpuid(0x80000005, &dummy, &dummy, &ecx, &edx);
+			printk("CPU: L1 I Cache: %dK  L1 D Cache: %dK\n",
+				ecx>>24, edx>>24);
+			c->x86_cache_size=(ecx>>24)+(edx>>24);
+		}
+		if (n >= 0x80000006){
+			cpuid(0x80000006, &dummy, &dummy, &ecx, &edx);
+			printk("CPU: L2 Cache: %dK\n", ecx>>16);
+			c->x86_cache_size = ecx>>16;
+		}
 	}
-
 	return 1;
 }
 
@@ -501,7 +503,7 @@
 				rdmsr(0xC0000082, l, h);
 				if((l&0x0000FFFF)==0)
 				{		
-					l=(1<<0)|(mbytes/4);
+					l=(1<<0)|((mbytes/4)<<1);
 					save_flags(flags);
 					__cli();
 					__asm__ __volatile__ ("wbinvd": : :"memory");
diff -urN linux-2.2.15-pre15/arch/sparc/kernel/sys_sparc.c linux/arch/sparc/kernel/sys_sparc.c
--- linux-2.2.15-pre15/arch/sparc/kernel/sys_sparc.c	Tue Jan  4 10:12:13 2000
+++ linux/arch/sparc/kernel/sys_sparc.c	Mon Dec  3 22:01:47 2001
@@ -1,4 +1,4 @@
-/* $Id: sys_sparc.c,v 1.52.2.1 1999/10/04 10:36:15 davem Exp $
+/* $Id: sys_sparc.c,v 1.52.2.2 2000/03/24 00:03:22 davem Exp $
  * linux/arch/sparc/kernel/sys_sparc.c
  *
  * This file contains various random system calls that
@@ -235,6 +235,13 @@
 	show_regs (regs);
 #endif
 	unlock_kernel();
+	return -ENOSYS;
+}
+
+/* We don't want to warn about LFS syscalls which are defined in our headers */
+asmlinkage unsigned long
+sys_lfs_syscall (void)
+{
 	return -ENOSYS;
 }
 
diff -urN linux-2.2.15-pre15/arch/sparc/kernel/systbls.S linux/arch/sparc/kernel/systbls.S
--- linux-2.2.15-pre15/arch/sparc/kernel/systbls.S	Tue Oct 26 17:53:39 1999
+++ linux/arch/sparc/kernel/systbls.S	Mon Dec  3 22:01:47 2001
@@ -1,4 +1,4 @@
-/* $Id: systbls.S,v 1.83.2.1 1999/09/22 11:37:27 jj Exp $
+/* $Id: systbls.S,v 1.83.2.2 2000/03/24 00:03:18 davem Exp $
  * systbls.S: System call entry point tables for OS compatibility.
  *            The native Linux system call table lives here also.
  *
@@ -29,12 +29,12 @@
 /*40*/	.long sys_newlstat, sys_dup, sys_pipe, sys_times, sys_nis_syscall
 /*45*/	.long sys_umount, sys_setgid, sys_getgid, sys_signal, sys_geteuid
 /*50*/	.long sys_getegid, sys_acct, sys_nis_syscall, sys_nis_syscall, sys_ioctl
-/*55*/	.long sys_reboot, sys_nis_syscall, sys_symlink, sys_readlink, sys_execve
-/*60*/	.long sys_umask, sys_chroot, sys_newfstat, sys_nis_syscall, sys_getpagesize
+/*55*/	.long sys_reboot, sys_lfs_syscall, sys_symlink, sys_readlink, sys_execve
+/*60*/	.long sys_umask, sys_chroot, sys_newfstat, sys_lfs_syscall, sys_getpagesize
 /*65*/	.long sys_msync, sys_vfork, sys_pread, sys_pwrite, sys_nis_syscall
 /*70*/	.long sys_nis_syscall, sys_mmap, sys_nis_syscall, sys_munmap, sys_mprotect
-/*75*/	.long sys_nis_syscall, sys_vhangup, sys_nis_syscall, sys_nis_syscall, sys_getgroups
-/*80*/	.long sys_setgroups, sys_getpgrp, sys_nis_syscall, sys_setitimer, sys_nis_syscall
+/*75*/	.long sys_nis_syscall, sys_vhangup, sys_lfs_syscall, sys_nis_syscall, sys_getgroups
+/*80*/	.long sys_setgroups, sys_getpgrp, sys_nis_syscall, sys_setitimer, sys_lfs_syscall
 /*85*/	.long sys_swapon, sys_getitimer, sys_nis_syscall, sys_sethostname, sys_nis_syscall
 /*90*/	.long sys_dup2, sys_nis_syscall, sys_fcntl, sys_select, sys_nis_syscall
 /*95*/	.long sys_fsync, sys_setpriority, sys_nis_syscall, sys_nis_syscall, sys_nis_syscall
@@ -44,8 +44,8 @@
 /*115*/	.long sys_nis_syscall, sys_gettimeofday, sys_getrusage, sys_nis_syscall, sys_getcwd
 /*120*/	.long sys_readv, sys_writev, sys_settimeofday, sys_fchown, sys_fchmod
 /*125*/	.long sys_nis_syscall, sys_setreuid, sys_setregid, sys_rename, sys_truncate
-/*130*/	.long sys_ftruncate, sys_flock, sys_nis_syscall, sys_nis_syscall, sys_nis_syscall
-/*135*/	.long sys_nis_syscall, sys_mkdir, sys_rmdir, sys_utimes, sys_nis_syscall
+/*130*/	.long sys_ftruncate, sys_flock, sys_lfs_syscall, sys_nis_syscall, sys_nis_syscall
+/*135*/	.long sys_nis_syscall, sys_mkdir, sys_rmdir, sys_utimes, sys_lfs_syscall
 /*140*/	.long sys_nis_syscall, sys_nis_syscall, sys_nis_syscall, sys_nis_syscall, sys_getrlimit
 /*145*/	.long sys_setrlimit, sys_nis_syscall, sys_prctl, sys_pciconfig_read, sys_pciconfig_write
 /*150*/	.long sys_nis_syscall, sys_nis_syscall, sys_nis_syscall, sys_poll, sys_nis_syscall
diff -urN linux-2.2.15-pre15/arch/sparc64/kernel/sys_sparc.c linux/arch/sparc64/kernel/sys_sparc.c
--- linux-2.2.15-pre15/arch/sparc64/kernel/sys_sparc.c	Tue Oct 26 17:53:39 1999
+++ linux/arch/sparc64/kernel/sys_sparc.c	Mon Dec  3 22:01:47 2001
@@ -1,4 +1,4 @@
-/* $Id: sys_sparc.c,v 1.26.2.1 1999/09/22 11:37:38 jj Exp $
+/* $Id: sys_sparc.c,v 1.26.2.2 2000/03/24 00:03:27 davem Exp $
  * linux/arch/sparc64/kernel/sys_sparc.c
  *
  * This file contains various random system calls that
@@ -211,6 +211,13 @@
 	show_regs (regs);
 #endif
 	unlock_kernel();
+	return -ENOSYS;
+}
+
+/* We don't want to warn about LFS syscalls which are defined in our headers */
+asmlinkage unsigned long
+sys_lfs_syscall (void)
+{
 	return -ENOSYS;
 }
 
diff -urN linux-2.2.15-pre15/arch/sparc64/kernel/systbls.S linux/arch/sparc64/kernel/systbls.S
--- linux-2.2.15-pre15/arch/sparc64/kernel/systbls.S	Mon Dec  3 22:01:40 2001
+++ linux/arch/sparc64/kernel/systbls.S	Mon Dec  3 22:01:47 2001
@@ -1,4 +1,4 @@
-/* $Id: systbls.S,v 1.53.2.3 2000/01/24 22:14:40 davem Exp $
+/* $Id: systbls.S,v 1.53.2.4 2000/03/24 00:03:28 davem Exp $
  * systbls.S: System call entry point tables for OS compatibility.
  *            The native Linux system call table lives here also.
  *
@@ -30,12 +30,12 @@
 /*40*/	.word sys32_newlstat, sys_dup, sys_pipe, sys32_times, sys_nis_syscall
 	.word sys_umount, sys_setgid, sys_getgid, sys_signal, sys_geteuid
 /*50*/	.word sys_getegid, sys_acct, sys_nis_syscall, sys_nis_syscall, sys32_ioctl
-	.word sys_reboot, sys_nis_syscall, sys_symlink, sys_readlink, sys32_execve
-/*60*/	.word sys_umask, sys_chroot, sys32_newfstat, sys_nis_syscall, sys_getpagesize
+	.word sys_reboot, sys_lfs_syscall, sys_symlink, sys_readlink, sys32_execve
+/*60*/	.word sys_umask, sys_chroot, sys32_newfstat, sys_lfs_syscall, sys_getpagesize
 	.word sys_msync, sys_vfork, sys32_pread, sys32_pwrite, sys_nis_syscall
 /*70*/	.word sys_nis_syscall, sys32_mmap, sys_nis_syscall, sys_munmap, sys_mprotect
-	.word sys_nis_syscall, sys_vhangup, sys_nis_syscall, sys_nis_syscall, sys32_getgroups
-/*80*/	.word sys32_setgroups, sys_getpgrp, sys_nis_syscall, sys32_setitimer, sys_nis_syscall
+	.word sys_nis_syscall, sys_vhangup, sys_lfs_syscall, sys_nis_syscall, sys32_getgroups
+/*80*/	.word sys32_setgroups, sys_getpgrp, sys_nis_syscall, sys32_setitimer, sys_lfs_syscall
 	.word sys_swapon, sys32_getitimer, sys_nis_syscall, sys_sethostname, sys_nis_syscall
 /*90*/	.word sys_dup2, sys_nis_syscall, sys32_fcntl, sys32_select, sys_nis_syscall
 	.word sys_fsync, sys_setpriority, sys_nis_syscall, sys_nis_syscall, sys_nis_syscall
@@ -45,8 +45,8 @@
 	.word sys_nis_syscall, sys32_gettimeofday, sys32_getrusage, sys_nis_syscall, sys_getcwd
 /*120*/	.word sys32_readv, sys32_writev, sys32_settimeofday, sys32_fchown16, sys_fchmod
 	.word sys_nis_syscall, sys32_setreuid, sys32_setregid, sys_rename, sys_truncate
-/*130*/	.word sys_ftruncate, sys_flock, sys_nis_syscall, sys_nis_syscall, sys_nis_syscall
-	.word sys_nis_syscall, sys_mkdir, sys_rmdir, sys32_utimes, sys_nis_syscall
+/*130*/	.word sys_ftruncate, sys_flock, sys_lfs_syscall, sys_nis_syscall, sys_nis_syscall
+	.word sys_nis_syscall, sys_mkdir, sys_rmdir, sys32_utimes, sys_lfs_syscall
 /*140*/	.word sys_nis_syscall, sys_nis_syscall, sys_nis_syscall, sys_nis_syscall, sys32_getrlimit
 	.word sys32_setrlimit, sys_nis_syscall, sys32_prctl, sys32_pciconfig_read, sys32_pciconfig_write
 /*150*/	.word sys_nis_syscall, sys_nis_syscall, sys_nis_syscall, sys_poll, sys_nis_syscall
diff -urN linux-2.2.15-pre15/drivers/i2o/i2o_block.c linux/drivers/i2o/i2o_block.c
--- linux-2.2.15-pre15/drivers/i2o/i2o_block.c	Mon Dec  3 22:01:40 2001
+++ linux/drivers/i2o/i2o_block.c	Mon Dec  3 22:01:47 2001
@@ -705,6 +705,9 @@
 		 */
 		u32 msg[5];
 		int *query_done = &dev->done_flag;
+
+		fsync_dev(inode->i_rdev);
+
 		msg[0] = FIVE_WORD_MSG_SIZE|SGL_OFFSET_0;
 		msg[1] = I2O_CMD_BLOCK_CFLUSH<<24|HOST_TID<<12|dev->tid;
 		msg[2] = i2ob_context|0x40000000;
diff -urN linux-2.2.15-pre15/drivers/i2o/i2o_pci.c linux/drivers/i2o/i2o_pci.c
--- linux-2.2.15-pre15/drivers/i2o/i2o_pci.c	Mon Dec  3 22:01:40 2001
+++ linux/drivers/i2o/i2o_pci.c	Mon Dec  3 22:01:47 2001
@@ -53,8 +53,10 @@
 	iounmap(((u8 *)c->post_port)-0x40);
 
 #ifdef CONFIG_MTRR
-	if(c->bus.pci.mtrr_reg > 0)
-		mtrr_del(c->bus.pci.mtrr_reg, 0, 0);
+	if(c->bus.pci.mtrr_reg0 > 0)
+		mtrr_del(c->bus.pci.mtrr_reg0, 0, 0);
+	if(c->bus.pci.mtrr_reg1 > 0)
+		mtrr_del(c->bus.pci.mtrr_reg1, 0, 0);
 #endif
 }
 
@@ -109,7 +111,7 @@
  *
  * TODO: Add support for polled controllers
  */
-int __init i2o_pci_install(struct pci_dev *dev)
+int i2o_pci_install(struct pci_dev *dev)
 {
 	struct i2o_controller *c=kmalloc(sizeof(struct i2o_controller),
 						GFP_KERNEL);
@@ -183,8 +185,30 @@
 	 * Enable Write Combining MTRR for IOP's memory region
 	 */
 #ifdef CONFIG_MTRR
-	c->bus.pci.mtrr_reg = 
-		mtrr_add(c->mem_phys, size, MTRR_TYPE_WRCOMB, 1);
+	c->bus.pci.mtrr_reg0 =  mtrr_add(c->mem_phys, size, MTRR_TYPE_WRCOMB, 1);
+
+	/*
+	 * If it is an INTEL i960 I/O processor then set the first 64K to Uncacheable
+	 * since the region contains the Messaging unit which shouldn't be cached.
+	 */
+
+	c->bus.pci.mtrr_reg1 = -1;
+
+	if(dev->vendor == PCI_VENDOR_ID_INTEL) 
+        {
+		printk(KERN_INFO "i2o_pci: MTRR workaround for Intel i960 processor\n");
+	        c->bus.pci.mtrr_reg1 = mtrr_add(c->mem_phys, 65536, MTRR_TYPE_UNCACHABLE, 1);
+	        if(c->bus.pci.mtrr_reg1< 0)
+	        {
+			printk(KERN_INFO "i2o_pci: Error in setting MTRR_TYPE_UNCACHABLE\n");
+			if(c->bus.pci.mtrr_reg0>=0)
+			{
+				mtrr_del(c->bus.pci.mtrr_reg0, 0, 0);
+				c->bus.pci.mtrr_reg0 = -1;
+			}
+		}
+	}
+
 #endif
 
 	I2O_IRQ_WRITE32(c,0xFFFFFFFF);
@@ -230,7 +254,7 @@
 	return 0;	
 }
 
-int __init i2o_pci_scan(void)
+int i2o_pci_scan(void)
 {
 	struct pci_dev *dev;
 	int count=0;
diff -urN linux-2.2.15-pre15/drivers/net/eepro.c linux/drivers/net/eepro.c
--- linux-2.2.15-pre15/drivers/net/eepro.c	Tue Oct 26 17:53:40 1999
+++ linux/drivers/net/eepro.c	Mon Dec  3 22:01:47 2001
@@ -1696,6 +1696,8 @@
 
 		if (register_netdev(d) == 0)
 			n_eepro++;
+		else
+			break;
 	}
 	
 	return n_eepro ? 0 : -ENODEV;
diff -urN linux-2.2.15-pre15/drivers/net/eepro100.c linux/drivers/net/eepro100.c
--- linux-2.2.15-pre15/drivers/net/eepro100.c	Mon Dec  3 22:01:41 2001
+++ linux/drivers/net/eepro100.c	Mon Dec  3 22:01:47 2001
@@ -42,7 +42,7 @@
 
 /* Set the copy breakpoint for the copy-only-tiny-buffer Rx method.
    Lower values use more memory, but are faster. */
-#ifdef __alpha__
+#if defined(__alpha__) || defined(__sparc__)
 /* force copying of all packets to avoid unaligned accesses on Alpha */
 static int rx_copybreak = 1518;
 #else
@@ -366,7 +366,7 @@
 #if defined(__LITTLE_ENDIAN)
 #define clear_suspend(cmd)  ((__u16 *)&(cmd)->cmd_status)[1] &= ~0x4000
 #elif defined(__BIG_ENDIAN)
-#define clear_suspend(cmd)  ((__u16 *)&(cmd)->cmd_status)[0] &= ~0x4000
+#define clear_suspend(cmd)  ((__u16 *)&(cmd)->cmd_status)[1] &= ~0x0040
 #else
 #error Unsupported byteorder
 #endif
@@ -480,7 +480,7 @@
 	struct timer_list timer;	/* Media selection timer. */
 	struct speedo_mc_block *mc_setup_head;/* Multicast setup frame list head. */
 	struct speedo_mc_block *mc_setup_tail;/* Multicast setup frame list tail. */
-	int in_interrupt;					/* Word-aligned dev->interrupt */
+	long in_interrupt;					/* Word-aligned dev->interrupt */
 	char rx_mode;						/* Current PROMISC/ALLMULTI setting. */
 	unsigned int tx_full:1;				/* The Tx queue is full. */
 	unsigned int full_duplex:1;			/* Full-duplex operation requested. */
@@ -587,11 +587,19 @@
 			ioaddr = pciaddr & ~3UL;
 			if (check_region(ioaddr, 32))
 				continue;
-		} else if ((ioaddr = (long)ioremap(pciaddr & ~0xfUL, 0x1000)) == 0) {
+		} else 
+#ifdef __sparc__
+		{
+			/* ioremap is hosed in 2.2.x on Sparc. */
+			ioaddr = pciaddr & ~0xfUL;
+		}
+#else
+		if ((ioaddr = (long)ioremap(pciaddr & ~0xfUL, 0x1000)) == 0) {
 			printk(KERN_INFO "Failed to map PCI address %#lx.\n",
 				   pciaddr);
 			continue;
 		}
+#endif
 		if (speedo_debug > 2)
 			printk("Found Intel i82557 PCI Speedo at I/O %#lx, IRQ %d.\n",
 				   ioaddr, irq);
diff -urN linux-2.2.15-pre15/drivers/net/tulip.c linux/drivers/net/tulip.c
--- linux-2.2.15-pre15/drivers/net/tulip.c	Mon Dec  3 22:01:41 2001
+++ linux/drivers/net/tulip.c	Mon Dec  3 22:01:47 2001
@@ -420,7 +420,7 @@
 {0,0,0,16,  3,19,16,24,  27,4,7,5, 0,20,23,20 };
 static u8 t21040_csr13[] = {2,0x0C,8,4,  4,0,0,0, 0,0,0,0, 4,0,0,0};
 /* 21041 transceiver register settings: 10-T, 10-2, AUI, 10-T, 10T-FD*/
-static u16 t21041_csr13[] = { 0xEF01, 0xEF09, 0xEF09, 0xEF01, 0xEF09, };
+static u16 t21041_csr13[] = { 0xEF05, 0xEF0D, 0xEF0D, 0xEF05, 0xEF05, };
 static u16 t21041_csr14[] = { 0xFFFF, 0xF7FD, 0xF7FD, 0x7F3F, 0x7F3D, };
 static u16 t21041_csr15[] = { 0x0008, 0x0006, 0x000E, 0x0008, 0x0008, };
 
diff -urN linux-2.2.15-pre15/drivers/sound/opl3sa2.c linux/drivers/sound/opl3sa2.c
--- linux-2.2.15-pre15/drivers/sound/opl3sa2.c	Mon Aug  9 12:04:40 1999
+++ linux/drivers/sound/opl3sa2.c	Mon Dec  3 22:01:48 2001
@@ -4,7 +4,7 @@
  * A low level driver for Yamaha OPL3-SA2 and SA3 cards.
  * SAx cards should work, as they are just variants of the SA3.
  *
- * Copyright 1998, 1999 Scott Murray <scottm@interlog.com>
+ * Copyright 1998, 1999, 2000 Scott Murray <scott@spiteful.org>
  *
  * Originally based on the CS4232 driver (in cs4232.c) by Hannu Savolainen
  * and others.  Now incorporates code/ideas from pss.c, also by Hannu
@@ -32,6 +32,7 @@
  * Scott Murray            Simpler detection code should work all the time now
  *                         (with thanks to Ben Hutchings for the heuristic),
  *                         removed now unnecessary force option. (Jan 5, 1999)
+ * Scott Murray            Updated e-mail address. (Mar 18, 2000)
  *
  */
 
@@ -648,7 +649,7 @@
 MODULE_PARM_DESC(dma2, "Set MSS (audio) second DMA channel (0, 1, 3)");
 
 MODULE_DESCRIPTION("Module for OPL3-SA2 and SA3 sound cards (uses AD1848 MSS driver).");
-MODULE_AUTHOR("Scott Murray <scottm@interlog.com>");
+MODULE_AUTHOR("Scott Murray <scott@spiteful.org>");
 
 EXPORT_NO_SYMBOLS;
 
diff -urN linux-2.2.15-pre15/fs/binfmt_elf.c linux/fs/binfmt_elf.c
--- linux-2.2.15-pre15/fs/binfmt_elf.c	Mon Dec  3 22:01:41 2001
+++ linux/fs/binfmt_elf.c	Mon Dec  3 22:01:48 2001
@@ -489,7 +489,7 @@
 		  	if (elf_interpreter ||
 			    elf_ppnt->p_filesz < 2 ||
 			    elf_ppnt->p_filesz > PAGE_SIZE)
-				goto out_free_interp;
+				goto out_free_dentry;
 
 			/* This is the program interpreter used for
 			 * shared libraries - for now assume that this
@@ -526,12 +526,12 @@
 					
 				current->personality = PER_SVR4;
 				interpreter_dentry = open_namei(elf_interpreter,
-								0, 0);
+								1, 0);
 				current->personality = old_pers;
 			} else
 #endif					
 				interpreter_dentry = open_namei(elf_interpreter,
-								0, 0);
+								1, 0);
 			set_fs(old_fs);
 			retval = PTR_ERR(interpreter_dentry);
 			if (IS_ERR(interpreter_dentry))
diff -urN linux-2.2.15-pre15/fs/ext2/dir.c linux/fs/ext2/dir.c
--- linux-2.2.15-pre15/fs/ext2/dir.c	Mon Dec  3 22:01:41 2001
+++ linux/fs/ext2/dir.c	Mon Dec  3 22:01:48 2001
@@ -183,8 +183,8 @@
 						   bh, offset)) {
 				/* On error, skip the f_pos to the
                                    next block. */
-				filp->f_pos = (filp->f_pos & (sb->s_blocksize - 1))
-					      + sb->s_blocksize;
+				filp->f_pos = (filp->f_pos | (sb->s_blocksize - 1))
+					      + 1;
 				brelse (bh);
 				return stored;
 			}
diff -urN linux-2.2.15-pre15/fs/ufs/dir.c linux/fs/ufs/dir.c
--- linux-2.2.15-pre15/fs/ufs/dir.c	Fri Apr 23 21:20:38 1999
+++ linux/fs/ufs/dir.c	Mon Dec  3 22:01:48 2001
@@ -108,9 +108,9 @@
 						   bh, offset)) {
 				/* On error, skip the f_pos to the
 				   next block. */
-				filp->f_pos = (filp->f_pos &
+				filp->f_pos = (filp->f_pos |
 				              (sb->s_blocksize - 1)) +
-					       sb->s_blocksize;
+					       1;
 				brelse (bh);
 				return stored;
 			}
diff -urN linux-2.2.15-pre15/include/asm-alpha/asm_offsets.h linux/include/asm-alpha/asm_offsets.h
--- linux-2.2.15-pre15/include/asm-alpha/asm_offsets.h	Tue Jan  4 10:12:24 2000
+++ linux/include/asm-alpha/asm_offsets.h	Mon Dec  3 22:01:48 2001
@@ -6,7 +6,7 @@
 #define TASK_ADDR_LIMIT 24
 #define TASK_EXEC_DOMAIN 32
 #define TASK_NEED_RESCHED 40
-#define TASK_SIZE 1064
+#define TASK_SIZE 1072
 #define STACK_SIZE 16384
 #define HAE_CACHE 0
 #define HAE_REG 8
diff -urN linux-2.2.15-pre15/include/asm-alpha/core_tsunami.h linux/include/asm-alpha/core_tsunami.h
--- linux-2.2.15-pre15/include/asm-alpha/core_tsunami.h	Mon Aug  9 12:05:05 1999
+++ linux/include/asm-alpha/core_tsunami.h	Mon Dec  3 22:01:48 2001
@@ -320,7 +320,7 @@
 /*
  * I/O functions:
  *
- * TSUNAMI, the 21??? PCI/memory support chipset for the EV6 (21264)
+ * TSUNAMI, the 21272 PCI/memory support chipset for the EV6 (21264)
  * can only use linear accesses to get at PCI memory and I/O spaces.
  */
 
diff -urN linux-2.2.15-pre15/include/asm-alpha/fpu.h linux/include/asm-alpha/fpu.h
--- linux-2.2.15-pre15/include/asm-alpha/fpu.h	Wed Aug 25 17:29:49 1999
+++ linux/include/asm-alpha/fpu.h	Mon Dec  3 22:01:48 2001
@@ -27,7 +27,7 @@
 #define FPCR_DYN_PLUS	 (0x3UL << FPCR_DYN_SHIFT)	/* towards +INF */
 #define FPCR_DYN_MASK	 (0x3UL << FPCR_DYN_SHIFT)
 
-#define FPCR_MASK	0xfffe000000000000
+#define FPCR_MASK	0xffff800000000000
 
 /*
  * IEEE trap enables are implemented in software.  These per-thread
@@ -67,7 +67,8 @@
 				 IEEE_STATUS_OVF | IEEE_STATUS_UNF |	\
 				 IEEE_STATUS_INE | IEEE_STATUS_DNO)
 
-#define IEEE_SW_MASK		(IEEE_TRAP_ENABLE_MASK | IEEE_STATUS_MASK | IEEE_MAP_MASK)
+#define IEEE_SW_MASK		(IEEE_TRAP_ENABLE_MASK |		\
+				 IEEE_STATUS_MASK | IEEE_MAP_MASK)
 
 #define IEEE_CURRENT_RM_SHIFT	32
 #define IEEE_CURRENT_RM_MASK	(3UL<<IEEE_CURRENT_RM_SHIFT)
@@ -78,7 +79,12 @@
 
 /*
  * Convert the software IEEE trap enable and status bits into the
- * hardware fpcr format.
+ * hardware fpcr format. 
+ *
+ * Digital Unix engineers receive my thanks for not defining the
+ * software bits identical to the hardware bits.  The chip designers
+ * receive my thanks for making all the not-implemented fpcr bits
+ * RAZ forcing us to use system calls to read/write this value.
  */
 
 static inline unsigned long
@@ -86,11 +92,13 @@
 {
 	unsigned long fp;
 	fp = (sw & IEEE_STATUS_MASK) << 35;
-	fp |= sw & IEEE_STATUS_MASK ? FPCR_SUM : 0;
+	fp |= (sw & IEEE_MAP_DMZ) << 36;
+	fp |= (sw & IEEE_STATUS_MASK ? FPCR_SUM : 0);
 	fp |= (~sw & (IEEE_TRAP_ENABLE_INV
 		      | IEEE_TRAP_ENABLE_DZE
 		      | IEEE_TRAP_ENABLE_OVF)) << 48;
 	fp |= (~sw & (IEEE_TRAP_ENABLE_UNF | IEEE_TRAP_ENABLE_INE)) << 57;
+	fp |= (sw & IEEE_MAP_UMZ ? FPCR_UNDZ | FPCR_UNFD : 0);
 	fp |= (~sw & IEEE_TRAP_ENABLE_DNO) << 41;
 	return fp;
 }
@@ -100,10 +108,12 @@
 {
 	unsigned long sw;
 	sw = (fp >> 35) & IEEE_STATUS_MASK;
+	sw |= (fp >> 36) & IEEE_MAP_DMZ;
 	sw |= (~fp >> 48) & (IEEE_TRAP_ENABLE_INV
 			     | IEEE_TRAP_ENABLE_DZE
 			     | IEEE_TRAP_ENABLE_OVF);
 	sw |= (~fp >> 57) & (IEEE_TRAP_ENABLE_UNF | IEEE_TRAP_ENABLE_INE);
+	sw |= (fp >> 47) & IEEE_MAP_UMZ;
 	sw |= (~fp >> 41) & IEEE_TRAP_ENABLE_DNO;
 	return sw;
 }
@@ -115,26 +125,59 @@
    never generates arithmetic faults and (b) call_pal instructions
    are implied trap barriers.  */
 
-static inline unsigned long rdfpcr(void)
+static inline unsigned long
+rdfpcr(void)
 {
 	unsigned long tmp, ret;
+
+#if defined(__alpha_cix__) || defined(__alpha_fix__)
+	__asm__ ("ftoit $f0,%0\n\t"
+		 "mf_fpcr $f0\n\t"
+		 "ftoit $f0,%1\n\t"
+		 "itoft %0,$f0"
+		 : "=r"(tmp), "=r"(ret));
+#else
 	__asm__ ("stt $f0,%0\n\t"
 		 "mf_fpcr $f0\n\t"
 		 "stt $f0,%1\n\t"
 		 "ldt $f0,%0"
-		: "=m"(tmp), "=m"(ret));
+		 : "=m"(tmp), "=m"(ret));
+#endif
+
 	return ret;
 }
 
-static inline void wrfpcr(unsigned long val)
+static inline void
+wrfpcr(unsigned long val)
 {
 	unsigned long tmp;
+
+#if defined(__alpha_cix__) || defined(__alpha_fix__)
+	__asm__ ("ftoit $f0,%0\n\t"
+		 "itoft %1,$f0\n\t"
+		 "mt_fpcr $f0\n\t"
+		 "itoft %0,$f0"
+		 : "=&r"(tmp) : "r"(val));
+#else
 	__asm__ __volatile__ (
 		"stt $f0,%0\n\t"
 		"ldt $f0,%1\n\t"
 		"mt_fpcr $f0\n\t"
 		"ldt $f0,%0"
 		: "=m"(tmp) : "m"(val));
+#endif
+}
+
+static inline unsigned long
+swcr_update_status(unsigned long swcr, unsigned long fpcr)
+{
+	/* EV6 implements most of the bits in hardware.  Collect
+	   the acrued exception bits from the real fpcr.  */
+	if (implver() == IMPLVER_EV6) {
+		swcr &= ~IEEE_STATUS_MASK;
+		swcr |= (fpcr >> 35) & IEEE_STATUS_MASK;
+	}
+	return swcr;
 }
 
 extern unsigned long alpha_read_fp_reg (unsigned long reg);
diff -urN linux-2.2.15-pre15/include/asm-alpha/gentrap.h linux/include/asm-alpha/gentrap.h
--- linux-2.2.15-pre15/include/asm-alpha/gentrap.h	Sun Sep 24 23:19:08 1995
+++ linux/include/asm-alpha/gentrap.h	Mon Dec  3 22:01:48 2001
@@ -13,7 +13,7 @@
 #define GEN_FLTUND	-5	/* fp underflow */
 #define GEN_FLTINV	-6	/* invalid fp operand */
 #define GEN_FLTINE	-7	/* inexact fp operand */
-#define GEN_DECOVF	-8	/* decimal overflow (for COBOL??) */
+#define GEN_DECOVF	-8	/* decimal overflow (for COBOL?) */
 #define GEN_DECDIV	-9	/* decimal division by zero */
 #define GEN_DECINV	-10	/* invalid decimal operand */
 #define GEN_ROPRAND	-11	/* reserved operand */
diff -urN linux-2.2.15-pre15/include/asm-alpha/hwrpb.h linux/include/asm-alpha/hwrpb.h
--- linux-2.2.15-pre15/include/asm-alpha/hwrpb.h	Tue Jan  4 10:12:24 2000
+++ linux/include/asm-alpha/hwrpb.h	Mon Dec  3 22:01:48 2001
@@ -16,7 +16,7 @@
 #define EV56_CPU		7	/* EV5.6 (21164)	*/
 #define EV6_CPU			8	/* EV6 (21164)		*/
 #define PCA56_CPU		9	/* PCA56 (21164PC)	*/
-#define PCA57_CPU		10	/* PCA57 (21164??)	*/
+#define PCA57_CPU		10	/* PCA57 (21164notyet)	*/
 
 /*
  * DEC system types for Alpha systems.  Found in HWRPB.
diff -urN linux-2.2.15-pre15/include/asm-alpha/pci.h linux/include/asm-alpha/pci.h
--- linux-2.2.15-pre15/include/asm-alpha/pci.h	Thu Jan  7 09:25:02 1999
+++ linux/include/asm-alpha/pci.h	Mon Dec  3 22:01:48 2001
@@ -15,10 +15,11 @@
 struct linux_hose_info {
         struct pci_bus                  pci_bus;
 	struct linux_hose_info         *next;
-	unsigned long                   pci_io_space;
-	unsigned long                   pci_mem_space;
+	unsigned long                   pci_sparse_io_space;
+	unsigned long                   pci_sparse_mem_space;
+	unsigned long                   pci_dense_io_space;
+	unsigned long                   pci_dense_mem_space;
 	unsigned long                   pci_config_space;
-	unsigned long                   pci_sparse_space;
         unsigned int                    pci_first_busno;
         unsigned int                    pci_last_busno;
 	unsigned int                    pci_hose_index;
@@ -44,5 +45,12 @@
 #define DEV_IS_ON_PRIMARY(dev)  ((dev)->bus->number == 0)
 
 #endif /* Multiple busses */
+
+/* Values for the `which' argument to sys_pciconfig_iobase.  */
+#define IOBASE_HOSE             0
+#define IOBASE_SPARSE_MEM       1
+#define IOBASE_DENSE_MEM        2
+#define IOBASE_SPARSE_IO        3
+#define IOBASE_DENSE_IO         4
 
 #endif /* __ALPHA_PCI_H */
diff -urN linux-2.2.15-pre15/include/asm-alpha/unistd.h linux/include/asm-alpha/unistd.h
--- linux-2.2.15-pre15/include/asm-alpha/unistd.h	Thu Jan 21 11:26:30 1999
+++ linux/include/asm-alpha/unistd.h	Mon Dec  3 22:01:48 2001
@@ -308,6 +308,12 @@
 #define __NR_capget			368
 #define __NR_capset			369
 #define __NR_sendfile			370
+#define __NR_setresgid			371	/* implemented in 2.3 */
+#define __NR_getresgid			372	/* implemented in 2.3 */
+#define __NR_dipc			373	/* implemented in 2.3 */
+#define __NR_pivot_root			374	/* implemented in 2.3 */
+#define __NR_mincore			375	/* implemented in 2.3 */
+#define __NR_pciconfig_iobase		376
 
 #if defined(__LIBRARY__) && defined(__GNUC__)
 
diff -urN linux-2.2.15-pre15/include/linux/i2o.h linux/include/linux/i2o.h
--- linux-2.2.15-pre15/include/linux/i2o.h	Mon Dec  3 22:01:41 2001
+++ linux/include/linux/i2o.h	Mon Dec  3 22:01:48 2001
@@ -329,7 +329,8 @@
 {
 	int irq;
 #ifdef CONFIG_MTRR
-	int mtrr_reg;
+	int mtrr_reg0;
+	int mtrr_reg1;
 #endif
 };
 
diff -urN linux-2.2.15-pre15/include/linux/sched.h linux/include/linux/sched.h
--- linux-2.2.15-pre15/include/linux/sched.h	Mon Dec  3 22:01:41 2001
+++ linux/include/linux/sched.h	Mon Dec  3 22:01:48 2001
@@ -499,6 +499,7 @@
 #define wake_up_interruptible(x)	__wake_up((x),TASK_INTERRUPTIBLE)
 
 extern int in_group_p(gid_t grp);
+extern int in_egroup_p(gid_t grp);
 
 extern void flush_signals(struct task_struct *);
 extern void flush_signal_handlers(struct task_struct *);
diff -urN linux-2.2.15-pre15/kernel/ksyms.c linux/kernel/ksyms.c
--- linux-2.2.15-pre15/kernel/ksyms.c	Mon Dec  3 22:01:41 2001
+++ linux/kernel/ksyms.c	Mon Dec  3 22:01:48 2001
@@ -116,6 +116,7 @@
 
 /* filesystem internal functions */
 EXPORT_SYMBOL(in_group_p);
+EXPORT_SYMBOL(in_egroup_p);
 EXPORT_SYMBOL(update_atime);
 EXPORT_SYMBOL(get_super);
 EXPORT_SYMBOL(get_fs_type);
diff -urN linux-2.2.15-pre15/kernel/sys.c linux/kernel/sys.c
--- linux-2.2.15-pre15/kernel/sys.c	Mon Jun  7 16:18:16 1999
+++ linux/kernel/sys.c	Mon Dec  3 22:01:48 2001
@@ -807,6 +807,27 @@
 	return 1;
 }
 
+/* Like in_group_p, but testing against egid, not fsgid */
+
+int in_egroup_p(gid_t grp)
+{
+	if (grp != current->egid) {
+		int i = current->ngroups;
+		if (i) {
+			gid_t *groups = current->groups;
+			do {
+				if (*groups == grp)
+					goto out;
+				groups++;
+				i--;
+			} while (i);
+		}
+		return 0;
+	}
+out:
+	return 1;
+}
+
 /*
  * This should really be a blocking read-write lock
  * rather than a semaphore. Anybody want to implement
diff -urN linux-2.2.15-pre15/kernel/sysctl.c linux/kernel/sysctl.c
--- linux-2.2.15-pre15/kernel/sysctl.c	Tue Jan  4 10:12:26 2000
+++ linux/kernel/sysctl.c	Mon Dec  3 22:01:48 2001
@@ -348,26 +348,6 @@
 	return error;
 }
 
-/* Like in_group_p, but testing against egid, not fsgid */
-static int in_egroup_p(gid_t grp)
-{
-	if (grp != current->egid) {
-		int i = current->ngroups;
-		if (i) {
-			gid_t *groups = current->groups;
-			do {
-				if (*groups == grp)
-					goto out;
-				groups++;
-				i--;
-			} while (i);
-		}
-		return 0;
-	}
-out:
-	return 1;
-}
-
 /* ctl_perm does NOT grant the superuser all rights automatically, because
    some sysctl variables are readonly even to root. */
 
diff -urN linux-2.2.15-pre15/net/ipv4/ip_masq_ftp.c linux/net/ipv4/ip_masq_ftp.c
--- linux-2.2.15-pre15/net/ipv4/ip_masq_ftp.c	Mon Oct  5 12:28:09 1998
+++ linux/net/ipv4/ip_masq_ftp.c	Mon Dec  3 22:01:48 2001
@@ -16,7 +16,7 @@
  * 	Juan Jose Ciarlante	:	Litl bits for 2.1
  *	Juan Jose Ciarlante	:	use ip_masq_listen() 
  *	Juan Jose Ciarlante	: 	use private app_data for own flag(s)
- *
+ *  Bjarni R. Einarsson :	Added protection against "extended FTP ALG attack"
  *
  *
  *	This program is free software; you can redistribute it and/or
@@ -34,7 +34,21 @@
  *	/etc/conf.modules (or /etc/modules.conf depending on your config)
  *	where modload will pick it up should you use modload to load your
  *	modules.
- *	
+ * 
+ * Protection against the "extended FTP ALG vulnerability".
+ *	This vulnerability was reported in:
+ *
+ *	http://www.securityfocus.com/templates/archive.pike?list=82&date=2000-03-08&msg=38C8C8EE.544524B1@enternet.se
+ * 
+ *	The protection here is very simplistic, but it at least denies access 
+ *	to all ports under 1024, and allows the user to specify an additional 
+ *	list of high ports on the insmod command line, like this:
+ *		noport=x1,x2,x3, ...
+ *	Up to MAX_MASQ_APP_PORTS (normally 12) ports may be specified, the 
+ *	default blocks access to the X server (port 6000) only.
+ * 
+ *	Patch by Bjarni R. Einarsson <bre@netverjar.is>.  The original patch is
+ *	available at: http://bre.klaki.net/programs/ip_masq_ftp.2000-03-20.diff
  */
 
 #include <linux/config.h>
@@ -61,6 +75,13 @@
 struct ip_masq_app *masq_incarnations[MAX_MASQ_APP_PORTS];
 
 /*
+ * List of ports (up to MAX_MASQ_APP_PORTS) we don't allow ftp-data 
+ * connections to.  Default is to block connections to port 6000 (X servers).
+ * This is in addition to all ports under 1024.
+ */
+static int noport[MAX_MASQ_APP_PORTS] = {6000, 0}; /* I rely on the trailing items being set to zero */
+
+/*
  *	Debug level
  */
 #ifdef CONFIG_IP_MASQ_DEBUG
@@ -69,6 +90,7 @@
 #endif
 
 MODULE_PARM(ports, "1-" __MODULE_STRING(MAX_MASQ_APP_PORTS) "i");
+MODULE_PARM(noport, "1-" __MODULE_STRING(MAX_MASQ_APP_PORTS) "i");
 
 /*	Dummy variable */
 static int masq_ftp_pasv;
@@ -100,7 +122,7 @@
 	struct ip_masq *n_ms;
 	char buf[24];		/* xxx.xxx.xxx.xxx,ppp,ppp\000 */
         unsigned buf_len;
-	int diff;
+	int diff, i, unsafe;
 
         skb = *skb_p;
 	iph = skb->nh.iph;
@@ -140,6 +162,20 @@
 
 		from = (p1<<24) | (p2<<16) | (p3<<8) | p4;
 		port = (p5<<8) | p6;
+
+		if (port < 1024) 
+		{
+			IP_MASQ_DEBUG(1-debug, "Unsafe PORT %X:%X detected, ignored\n",from,port);
+			continue;
+		}
+
+		for (unsafe = i = 0; (i < MAX_MASQ_APP_PORTS) && (noport[i]); i++)
+		  if (port == noport[i])
+		{
+			IP_MASQ_DEBUG(1-debug, "Unsafe PORT %X:%X detected, ignored\n",from,port);
+			unsafe = 1;
+		}
+		if (unsafe) continue;
 
 		IP_MASQ_DEBUG(1-debug, "PORT %X:%X detected\n",from,port);
 
diff -urN linux-2.2.15-pre15/net/ipv4/tcp.c linux/net/ipv4/tcp.c
--- linux-2.2.15-pre15/net/ipv4/tcp.c	Mon Dec  3 22:01:41 2001
+++ linux/net/ipv4/tcp.c	Mon Dec  3 22:01:48 2001
@@ -5,7 +5,7 @@
  *
  *		Implementation of the Transmission Control Protocol(TCP).
  *
- * Version:	$Id: tcp.c,v 1.140.2.9 2000/02/07 20:20:00 davem Exp $
+ * Version:	$Id: tcp.c,v 1.140.2.10 2000/03/21 20:54:13 davem Exp $
  *
  * Authors:	Ross Biro, <bir7@leland.Stanford.Edu>
  *		Fred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG>
@@ -1448,11 +1448,12 @@
 		return;
 
 	/* If we've already sent a FIN, or it's a closed state, skip this. */
-	if ((1 << sk->state) & (TCPF_ESTABLISHED|TCPF_SYN_RECV|TCPF_SYN_SENT)) {
+	if ((1 << sk->state) &
+	    (TCPF_ESTABLISHED|TCPF_SYN_SENT|TCPF_SYN_RECV|TCPF_CLOSE_WAIT)) {
 		lock_sock(sk);
 
 		/* Clear out any half completed packets.  FIN if needed. */
-		if (tcp_close_state(sk,sk->state == TCP_CLOSE_WAIT))
+		if (tcp_close_state(sk,0))
 			tcp_send_fin(sk);
 
 		release_sock(sk);
diff -urN linux-2.2.15-pre15/net/unix/af_unix.c linux/net/unix/af_unix.c
--- linux-2.2.15-pre15/net/unix/af_unix.c	Mon Aug  9 12:05:10 1999
+++ linux/net/unix/af_unix.c	Mon Dec  3 22:01:48 2001
@@ -969,6 +969,10 @@
 			return -ENOTCONN;
 	}
 
+	err = -EMSGSIZE;
+	if (len > sk->sndbuf)
+		goto out;
+
 	if (sock->passcred && !sk->protinfo.af_unix.addr)
 		unix_autobind(sock);
 
