--- hwtools-0.5.orig/debian/postrm
+++ hwtools-0.5/debian/postrm
@@ -0,0 +1,8 @@
+#!/bin/sh -e
+
+if [ "$1" = "purge" ]; then
+    update-rc.d hwtools remove >/dev/null
+    if [ -f /etc/rc.boot/hwtools ]; then
+        rm /etc/rc.boot/hwtools
+    fi
+fi
--- hwtools-0.5.orig/debian/changelog
+++ hwtools-0.5/debian/changelog
@@ -0,0 +1,151 @@
+hwtools (0.5-0.1) frozen unstable; urgency=low
+
+  * Now uses wrapper script for /usr/sbin/irqtune
+    closes: #57535, #55654, #42483, #47446
+  * scanport #include fix, without this it won't build.
+  * scsi-spin st_rdev fix and casting fix, without this it won't build,
+    closes: #57080
+  * Upgraded memtest86 from 1.4 to 2.2, since 1.4 doesn't even build
+    anymore, incremented hwtools version number, closes: #58336
+  * scsidev patched to use SCSI_DISK0_MAJOR instead of SCSI_DISK_MAJOR
+    to build successfully against 2.2.x kernels
+  * qic02conf no longer directly includes linux/tpqic02.h, again, to get it
+    to build.
+  * FHS documentation structure 
+  * postinst now points users to /usr/share/doc/hwtools instead of
+    /usr/doc/hwtools
+  * irqtune.8.gz -> undocumented.8.gz symlink created
+
+ -- Robert Woodcock <rcw@debian.org>  Fri, 25 Feb 2000 19:56:05 -0800
+
+hwtools (0.4-2) unstable; urgency=low
+
+  * Included scsidev patch from Rainer Clasen <bj@ncc.cicely.de>:
+    + if /var is on a SCSI disk that scsidev has to identify first,
+      it can't use the /var/run/testdev file. Moved that file to
+      /dev/scsi/.testdev , and put it, and /dev/scsi directory in a
+      #define.
+    + fixed the PROBE_HOST ioctl. 
+    + changes to the verbosity switch.
+    This closes: #42209 .
+  * Moved the rc.boot script to init.d/hwtools.sh . Made symlink
+    /etc/rcS.d/S60hwtools -> ../init.d/hwtools , with update-rc.d
+    in postinst/postrm. Added preinst to handle the upgrade, too.
+  * Some small fixes in debian/rules
+  * Renamed scsi-spin.c to scsi-spin.C, and replaced g++ with gcc on
+    compilation, so the unneeded libstdc++ dependency is gone.
+
+ -- Josip Rodin <jrodin@jagor.srce.hr>  Mon,  2 Aug 1999 20:45:03 +0200
+
+hwtools (0.4-1) unstable; urgency=medium
+
+  * Package is orphaned, changed the maintainer to Debian QA Group.
+  * Completely redid the packaging (using debhelper), fixing a few bugs.
+  * Reduced the diff size to normal by updating the .orig archive with
+    latest version of irqtune. I think I didn't overwrite any Debian
+    patches, but there is a small possibility.
+  * Applied several patches from the BTS, from Rob Browning, Michael
+    Booth and Jim Studt. Didn't apply Kai Henningsen's one because it
+    seems that Rob's already fixed those errors.
+  * Replaced all instances of /tmp/<something> in all files containing
+    them, with /var/run/<something>, to prevent any symlink /tmp races.
+    That is the main reason why the urgency is set to medium.
+  * New upstream version of memtest86, 1.4a.
+  * New programs included:
+    + sraw: benchmark raw SCSI I/O rates bypassing the buffer cache.
+    + scsistop: low-level SCSI drive start/stop program.
+    + scsi-spin: program to manually spin up and down a SCSI device.
+  * Documented inclusion of qic02conf (program that sets hardware
+    parameters of the QIC-02 interface), together with a lot of
+    cosmetic (but practical) changes in debian/* files.
+
+ -- Josip Rodin <jrodin@jagor.srce.hr>  Sun, 25 Apr 1999 15:48:31 +0200
+
+hwtools (0.3-4) unstable; urgency=low
+
+  * #15041 typo in /etc/rc.boot/hwtools
+  * #15043 install qic02conf
+  * #7520, #14890, #15042, #15944 fixed in 0.3-2
+  * #17574 copyright
+  * #11857 scsi-config /tmp
+  * #15039, #15040 New upstream release
+
+ -- Christoph Lameter <clameter@debian.org>  Mon, 16 Feb 1998 19:54:06 -0800
+
+hwtools (0.3-3) unstable; urgency=low
+
+  * dpkg-shlibdeps broke down on irqtune.o.... and the substvars was not
+    updated. 0.3-2/1 depended still on libc5. sigh.
+
+ -- Christoph Lameter <clameter@debian.org>  Thu, 13 Nov 1997 13:19:55 +0000
+
+hwtools (0.3-2) unstable; urgency=low
+
+  * Scsiinfo stuff was installed the wrong way.
+
+ -- Christoph Lameter <clameter@debian.org>  Thu, 13 Nov 1997 13:00:13 +0000
+
+hwtools (0.3-1) unstable; urgency=low
+
+  * newest irqtune fails with the newest insmod and has been moved out of the
+    searchpath until the author tells me how its supposed to work. New release
+    as soon as that is cleared up (#8661 #11494 #12393 #13099 #13582)
+  * #9860 #10323 Manpage is now included for scsiinfo (#6503 still no manpage
+    for inb scanport and irqtune)
+  * #7531 Do not suggest wish
+  * #11493 Bug was fixed by fixing dpkg
+  * Fix location of scsi-config #13584 #7514 #9848 #11858
+  * All tools upgraded to newest upstream releases
+  * libc6
+  * Former Maintainers of the package have disappeared. Last upload was
+    done by me though. So I am taking the package again.
+
+ -- Christoph Lameter <clameter@debian.org>  Tue, 11 Nov 1997 22:10:23 +0000
+
+hwtools (0.2-5) unstable; urgency=low
+
+  * Patch from Sven Rudoplh integrated
+
+ -- Christoph Lameter <clameter@debian.org>  Mon, 10 Feb 1997 15:30:49 -0800
+
+hwtools (0.2-4) stable unstable; urgency=low
+
+  * irqtune not activated on install #6568, #6434
+  * Rely on debmake to find binaries and dependencies
+
+ -- Christoph Lameter <clameter@debian.org>  Wed, 30 Oct 1996 08:14:03 -0800
+
+hwtools (0.2-3) unstable; urgency=low
+
+  * debmake used to build package
+
+ -- Christoph Lameter <clameter@debian.org>  Tue, 22 Oct 1996 18:12:20 -0700
+
+hwtools (0.2-2) unstable; urgency=low
+  
+  * script to activate irqtune on bootup
+  * script can optionally also activate hdparm
+
+ -- Christoph Lameter <clameter@debian.org>  Sat, 5 Sep 1996 09:00:00 +0800
+
+hwtools (0.2-1) unstable; urgency=low
+  
+  * added scsidev
+  * inb binary generated
+  * upgrade to scsiinfo 1.6
+
+ -- Christoph Lameter <clameter@debian.org>  Sun, 29 Sep 1996 09:00:00 +0800
+
+hwtools (0.1-2) unstable; urgency=low
+  
+  * scanport binary was not included
+  * Documentation updated
+  * irqtune modules moved to /usr/lib/hwtools
+
+ -- Christoph Lameter <clameter@debian.org>  Fri, 27 Sep 1996 09:00:00 +0800
+
+hwtools (0.1-1) unstable; urgency=low
+  
+  * Initial release
+
+ -- Christoph Lameter <clameter@debian.org>  Thu, 26 Sep 1996 09:00:00 +0800
--- hwtools-0.5.orig/debian/init.d
+++ hwtools-0.5/debian/init.d
@@ -0,0 +1,22 @@
+#!/bin/sh
+#
+#	/etc/init.d/hwtools (previously /etc/rc.boot/hwtools)
+#
+
+# Optimize interrupts. You might want to add parameters if you want
+# to favor ttyS1 or ttyS0 or something else.
+if command -v irqtune >/dev/null 2>&1; then
+#   irqtune [PUT ARGS HERE]
+   true
+fi
+
+# hdparm optimization
+# Switches on interrupts during transfers and does multi sector transfers
+if command -v hdparm >/dev/null 2>&1; then
+#   hdparm -q [PUT ARGS HERE]
+   true
+fi
+
+# configure QIC-02 interface
+# see qic02conf(8)
+# qic02conf --card= --port= --dma= --irq=
--- hwtools-0.5.orig/debian/postinst
+++ hwtools-0.5/debian/postinst
@@ -0,0 +1,21 @@
+#!/bin/sh -e
+
+if [ $1 = "configure" ]; then
+  update-rc.d hwtools start 60 S . >/dev/null
+  if [ -f /etc/rc.boot/hwtools -a -f /etc/init.d/hwtools ]; then
+    rm /etc/rc.boot/hwtools
+  fi
+
+  cat << %EOF%
+
+Debian hwtools package:
+  You will most probably want to read /usr/share/doc/hwtools/README.Debian
+  and the rest of the files in that directory, before using any of
+  the programs included in this package.
+
+%EOF%
+
+  if [ -d /usr/doc -a ! -e /usr/doc/hwtools -a -d /usr/share/doc/hwtools ]; then
+		ln -sf ../share/doc/hwtools /usr/doc/hwtools
+  fi
+fi
--- hwtools-0.5.orig/debian/preinst
+++ hwtools-0.5/debian/preinst
@@ -0,0 +1,9 @@
+#!/bin/sh -e
+
+if [ "$1" = "install" -o "$1" = "upgrade" ]; then
+  if [ "$2" ] ; then
+    if [ -f /etc/rc.boot/hwtools -a ! -f /etc/init.d/nviboot ] ; then
+      mv /etc/rc.boot/hwtools /etc/init.d/hwtools
+    fi
+  fi
+fi
--- hwtools-0.5.orig/debian/copyright
+++ hwtools-0.5/debian/copyright
@@ -0,0 +1,18 @@
+This package was first put together by Christoph Lameter, on September 26,
+1996, and updated October 13, 1997. Next update was done by Josip Rodin on
+25 April, 1999.
+
+Original sources come from:
+irqtune:
+	http://www.best.com/~cae/irqtune/
+scsiinfo, scsidev, sraw:
+	ftp://tsx-11.mit.edu/pub/linux/ALPHA/scsi/
+scanport, memtest86, scsifmt, scsistop:
+	ftp://metalab.unc.edu/pub/Linux/system/hardware/
+scsi-spin: Debian native utility,
+	ftp://ftp.debian.org/debian/dists/unstable/utils/
+memtest86:
+	http://reality.sgi.com/cbrady_denver/memtest86/
+
+All programs are licensed under the GNU GPL licence, full text of
+which can be found in /usr/share/common-licenses/GPL.
--- hwtools-0.5.orig/debian/README.Debian
+++ hwtools-0.5/debian/README.Debian
@@ -0,0 +1,27 @@
+Hardware Tools for Debian notes
+-------------------------------
+
+irqtune:
+Please edit /etc/rc.boot/hwtools script to activate irqtune on boot time.
+
+scsidev:
+Some scripting also needs to be done to activate scsidev's features.
+
+memtest86:
+Needs to be run in real mode. For that purpose put a blank floppy in
+your floppy drive and do:
+cp /usr/lib/hwtools/memtest86.bin /dev/fd0
+                                         ^ replace with your setting
+Then boot from that floppy to run the memory test.
+
+scanport:
+There is a DOS executable available in /usr/lib/hwtools/scanport.exe
+with a more limited functionality than the one installed in /usr/sbin
+for Linux. Copy that file to a DOS partition to use it, from DOS.
+
+scsiinfo:
+Comes both with text interface and advanced X interface. Textmode usage
+with "scsiinfo". X-Startup with "scsi-config", but you must have wish
+installed to make it work.
+
+  -- Christoph Lameter <clameter@debian.org>
--- hwtools-0.5.orig/debian/control
+++ hwtools-0.5/debian/control
@@ -0,0 +1,27 @@
+Source: hwtools
+Section: utils
+Priority: optional
+Maintainer: Debian QA Group <debian-qa@lists.debian.org>
+Standards-Version: 2.5.0
+
+Package: hwtools
+Architecture: i386
+Depends: ${shlibs:Depends}
+Suggests: sysutils, hdparm, wish
+Description: Collection of tools for low-level hardware management
+ This package is a collection of tools useful for hardware
+ troubleshooting and optimization (for ix86 machines):
+ .
+  irqtune: adjusts priority of interrupts (improves serial performance),
+  scanport: scans for hardware not already handled by Linux drivers,
+  memtest86: a real mode memory test,
+  scsiinfo: displays SCSI drive low-level information and modifies SCSI
+            drive settings,
+  scsidev: makes permanent SCSI LUN -> devicename connections,
+  scsifmt: low-level SCSI formatter,
+  sraw: benchmarks raw SCSI I/O rates bypassing the buffer cache,
+  scsistop: low-level SCSI drive start/stop program,
+  scsi-spin: program to manually spin up and down a SCSI device.
+ .
+ Be aware that these tools require some knowledge of what are they
+ doing to be used properly, not causing damage to your system.
--- hwtools-0.5.orig/debian/rules
+++ hwtools-0.5/debian/rules
@@ -0,0 +1,101 @@
+#!/usr/bin/make -f
+# Derived from debhelper/dh_make example, and Cristoph Lameter's file. -joy
+
+#export DH_VERBOSE=1
+CFLAGS = -g -O2 -Wall
+
+build: build-stamp
+build-stamp:
+	dh_testdir
+
+	cd irqtune && $(MAKE) kvers sbin
+	cd scanport/src && gcc $(CFLAGS) -s -o scanport scanport.c && gcc $(CFLAGS) -s -o inb inb.c
+	cd memtest86 && $(MAKE)
+	cd scsiinfo && $(MAKE) KERNEL_INCLUDES=-I/usr/src/linux/include
+	cd scsidev && ./configure --prefix=/usr --mandir=/usr/share/man && $(MAKE) CFLAGS="$(CFLAGS)"
+	cd qic02conf && $(MAKE) CFLAGS="$(CFLAGS)"
+	cd sraw && gcc $(CFLAGS) -s -o sraw srawread.c
+	cd scsistop && gcc -I/usr/src/linux/include $(CFLAGS) scsistop-0.3.3.c -o scsistop
+	gcc -I/usr/src/linux/include $(CFLAGS) -o scsi-spin scsi-spin.C
+
+	touch build-stamp
+
+clean:
+	dh_testdir
+	dh_testroot
+	rm -f build-stamp install-stamp
+
+	for i in irqtune memtest86 scsiinfo scsidev qic02conf ; do \
+	   cd $$i && $(MAKE) clean || true && cd .. ; done
+	cd scanport/src && rm -f scanport inb
+	cd sraw && rm -f sraw
+	cd scsistop && rm -f scsistop
+	rm -f scsi-spin
+	rm -f scsidev/Makefile memtest86/memtest.bin
+
+	dh_clean
+
+install: install-stamp
+install-stamp: build-stamp
+	dh_testdir
+	dh_testroot
+	dh_clean -k
+	dh_installdirs dev sbin usr/sbin usr/lib/hwtools usr/lib/scsi \
+        usr/share/man/man5 usr/share/man/man8 usr/share/doc/hwtools
+
+	cd irqtune && $(MAKE) install DESTDIR=../../debian/tmp
+	cp irqtune-wrapper debian/tmp/usr/sbin/irqtune
+	cp -a scanport/src/scanport debian/tmp/sbin
+	cp -a scanport/src/inb debian/tmp/sbin
+	cp -a memtest86/memtest.bin debian/tmp/usr/lib/hwtools/memtest86.bin
+	cd scsiinfo && $(MAKE) install DESTDIR=../debian/tmp
+	cd scsidev && $(MAKE) install prefix=../debian/tmp/usr DESTDIR=../debian/tmp
+	cd qic02conf && $(MAKE) install DESTDIR=../debian/tmp/usr
+	cp -a sraw/sraw debian/tmp/usr/sbin
+	cp -a scsi-spin debian/tmp/usr/sbin
+# DOS executables
+	cp -a scanport/dos/*.exe debian/tmp/usr/lib/hwtools
+	chmod a-x debian/tmp/usr/lib/hwtools/{*.o,*.exe}
+# Documentation
+	cp -a irqtune/README debian/tmp/usr/share/doc/hwtools/README.irqtune
+	cp -a irqtune/README.html debian/tmp/usr/share/doc/hwtools/irqtune.html
+	cp -a scanport/README-inb debian/tmp/usr/share/doc/hwtools/README.inb
+	cp -a scanport/README-scanport debian/tmp/usr/share/doc/hwtools/README.scanport
+	cp -a memtest86/README debian/tmp/usr/share/doc/hwtools/README.memtest86
+	cp -a scsiinfo/0-TODO debian/tmp/usr/share/doc/hwtools/TODO.scsiinfo
+	cp -a scsiinfo/0-CHANGES debian/tmp/usr/share/doc/hwtools/CHANGES.scsiinfo
+	cp -a scsiinfo/0-README.first debian/tmp/usr/share/doc/hwtools/README.scsiinfo
+	cp -a scsidev/README debian/tmp/usr/share/doc/hwtools/README.scsidev
+	cp -a scsi-spin.README debian/tmp/usr/share/doc/hwtools/README.scsi-spin
+
+	touch install-stamp
+
+binary-indep: build install
+# There are no architecture-independent files to be uploaded
+# generated by this package. If there were any they would be
+# made here.
+
+binary-arch: build install
+	dh_testdir
+	dh_testroot
+	dh_installdirs etc/init.d
+	install -m 755 -p debian/init.d debian/tmp/etc/init.d/hwtools
+	dh_installdocs scsidev/scsi.alias
+	dh_installmanpages
+	dh_installchangelogs
+	# dh_undocumented inb.8.gz irqtune.8.gz scanport.8.gz scsi-spin.8.gz sraw.8.gz
+	dh_undocumented inb.8.gz irqtune.8.gz scanport.8.gz scsi-spin.8.gz sraw.8.gz
+	dh_strip
+	dh_compress
+	dh_fixperms
+	dh_installdeb
+	dh_shlibdeps
+	dh_gencontrol
+	dh_md5sums
+	dh_builddeb
+
+source diff:
+	@echo >&2 'source and diff are obsolete - use dpkg-source -b'; false
+
+binary: binary-indep binary-arch
+.PHONY: build clean binary-indep binary-arch binary
--- hwtools-0.5.orig/debian/conffiles
+++ hwtools-0.5/debian/conffiles
@@ -0,0 +1 @@
+/etc/init.d/hwtools
--- hwtools-0.5.orig/irqtune/Makefile
+++ hwtools-0.5/irqtune/Makefile
@@ -22,7 +22,7 @@
 ##
 
 # installation control
-SBIN = /sbin
+SBIN = $(DESTDIR)/usr/lib/hwtools
 INSTALL = simple
 INSTALLER = sbin/irqtune
 
--- hwtools-0.5.orig/irqtune/src/irqtune.c
+++ hwtools-0.5/irqtune/src/irqtune.c
@@ -25,7 +25,7 @@
 
 	proc_ints = "/proc/interrupts";
 	setbuf(stderr,NULL);
-	sprintf(tmpf,"/tmp/irqtune.%d",getpid());
+	sprintf(tmpf,"/var/run/irqtune.%d",getpid());
 
 	/* insure we got "/sbin/irqtune" and not just "irqtune" */
 	cp = strchr(pgmname,'/');
--- hwtools-0.5.orig/irqtune/src/Makefile
+++ hwtools-0.5/irqtune/src/Makefile
@@ -23,11 +23,11 @@
 # things to install
 TARGETLIST = $(MODULES) irqtune
 
-WARN = -Wall -Werror -Wno-format
-CFLAGS_COM = -O \
+WARN = -Wall -Wno-format # -Werror
+CFLAGS_COM = -O -I/usr/src/linux/include \
 	-I$(IRQTUNE_HOME)/include -I$(IRQTUNE_HOME)/include/P -I$(IRQTUNE_HOME) \
 	$(WARN) $(CFLAGS_EXTRA)
-CKFLAGS = $(CFLAGS_COM) -D__KERNEL__ $(KDEFS)
+CKFLAGS = $(CFLAGS_COM) -D__KERNEL__ $(KDEFS) -DMODVERSIONS
 CFLAGS = $(CFLAGS_COM) $(CDEBUG)
 ifeq "$(CDEBUG)" ""
 STRIP = -s
--- hwtools-0.5.orig/irqtune-wrapper
+++ hwtools-0.5/irqtune-wrapper
@@ -0,0 +1,2 @@
+#!/bin/sh
+/usr/lib/hwtools/irqtune "$@"
--- hwtools-0.5.orig/qic02conf/Makefile
+++ hwtools-0.5/qic02conf/Makefile
@@ -29,4 +29,4 @@
 	-rm -f qic02conf
 
 qic02conf: qic02conf.c
-	gcc -O2 -Wall -s -N -o $@ $<
+	gcc -I/usr/src/linux/include -g -O2 -Wall -s -o $@ $<
--- hwtools-0.5.orig/qic02conf/qic02conf.c
+++ hwtools-0.5/qic02conf/qic02conf.c
@@ -22,8 +22,10 @@
 #include <sys/ioctl.h>
 #include <sys/mtio.h>
 #include <sys/file.h>
+/* This conflicts with mtio.h in newer kernels
+ * -- Robert Woodcock, Feb 25 2000
 #include <linux/tpqic02.h>
-
+ */
 
 char *progname = NULL;
 char *tapedev = NULL;
--- hwtools-0.5.orig/scanport/src/inb.c
+++ hwtools-0.5/scanport/src/inb.c
@@ -19,7 +19,12 @@
 #include <unistd.h>
 #include <stdlib.h>
 #include <stdio.h>
+#include <errno.h>
+/* This is extraneous and causes build errors here
+ *  -- Robert Woodcock, Feb 25 2000
 #include <asm/io.h>
+ */
+#include <sys/io.h>
 
 void main(int argc, char **argv) {
 
--- hwtools-0.5.orig/scanport/src/scanport.c
+++ hwtools-0.5/scanport/src/scanport.c
@@ -20,7 +20,12 @@
 #include <unistd.h>
 #include <stdlib.h>
 #include <stdio.h>
+#include <errno.h>
+/* This is extraneous and causes build errors here
+ *  -- Robert Woodcock, Feb 25 2000
 #include <asm/io.h>
+ */
+#include <sys/io.h>
 
 void guess_hdwr(int port);
 
--- hwtools-0.5.orig/scsi-spin.C
+++ hwtools-0.5/scsi-spin.C
@@ -0,0 +1,219 @@
+/*
+  File: scsi-spin.c
+  
+  A simple program to manually spin up and down a scsi device.
+
+  Copyright 1998 Rob Browning <rlb@cs.utexas.edu>
+
+  This source is covered by the terms the GNU Public License.
+
+  Some of the original code came from
+    The Linux SCSI programming HOWTO
+    Heiko Ei<DF>feldt heiko@colossus.escape.de
+    v1.5, 7 May 1996
+
+*/
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <unistd.h>
+#include <getopt.h>
+#include <string.h>
+#include <fcntl.h>
+#include <errno.h>
+#include <scsi/sg.h>
+#include <scsi/scsi.h>
+
+#include <linux/major.h>
+#include <sys/sysmacros.h>
+#include <sys/stat.h>
+
+static const int SCSI_CMD_SIZE = 18;
+static const unsigned int scsi_off = sizeof(struct sg_header);
+static unsigned char cmd[scsi_off + SCSI_CMD_SIZE]; /* SCSI command buffer */
+
+/* process a complete SCSI cmd. Use the generic SCSI interface. */
+static int handle_SCSI_cmd(const int fd,
+                           const unsigned cmd_len,      /* command length */
+                           const unsigned in_size,      /* input data size */
+                           const unsigned char *i_buff, /* input buffer */
+                           unsigned out_size,     /* output data size */
+                           unsigned char *o_buff  /* output buffer */
+                           ) {
+  int status = 0;
+  struct sg_header *sg_hd;
+  
+  /* safety checks */
+  if (!cmd_len) return -1;            /* need a cmd_len != 0 */
+  if (!i_buff) return -1;             /* need an input buffer != NULL */
+#ifdef SG_BIG_BUFF
+  if (scsi_off + cmd_len + in_size > SG_BIG_BUFF) return -1;
+  if (scsi_off + out_size > SG_BIG_BUFF) return -1;
+#else
+  if (scsi_off + cmd_len + in_size > 4096) return -1;
+  if (scsi_off + out_size > 4096) return -1;
+#endif
+  
+  if (!o_buff) out_size = 0;      /* no output buffer, no output size */
+  
+  /* generic SCSI device header construction */
+  sg_hd = (struct sg_header *) i_buff;
+  sg_hd->reply_len   = scsi_off + out_size;
+  sg_hd->twelve_byte = cmd_len == 12;
+  sg_hd->result = 0;
+#if     0
+  sg_hd->pack_len    = scsi_off + cmd_len + in_size; /* not necessary */
+  sg_hd->pack_id;     /* not used */
+  sg_hd->other_flags; /* not used */
+#endif
+  
+  /* send command */
+  status = write( fd, i_buff, scsi_off + cmd_len + in_size );
+  if ( status < 0 || status != scsi_off + cmd_len + in_size ||
+       sg_hd->result ) {
+    /* some error happened */
+    fprintf( stderr, "write(generic) result = 0x%x cmd = 0x%x\n",
+             sg_hd->result, i_buff[scsi_off] );
+    perror("");
+    return status;
+  }
+  
+  if(!o_buff) o_buff = (unsigned char *) i_buff;       /* buffer pointer check */
+  
+  /* retrieve result */
+  status = read( fd, o_buff, scsi_off + out_size);
+  if ( status < 0 || status != scsi_off + out_size || sg_hd->result ) {
+    /* some error happened */
+    fprintf( stderr, "read(generic) status = 0x%x, result = 0x%x, "
+             "cmd = 0x%x\n",
+             status, sg_hd->result, o_buff[scsi_off] );
+    fprintf( stderr, "read(generic) sense "
+             "%x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x\n",
+             sg_hd->sense_buffer[0],         sg_hd->sense_buffer[1],
+             sg_hd->sense_buffer[2],         sg_hd->sense_buffer[3],
+             sg_hd->sense_buffer[4],         sg_hd->sense_buffer[5],
+             sg_hd->sense_buffer[6],         sg_hd->sense_buffer[7],
+             sg_hd->sense_buffer[8],         sg_hd->sense_buffer[9],
+             sg_hd->sense_buffer[10],        sg_hd->sense_buffer[11],
+             sg_hd->sense_buffer[12],        sg_hd->sense_buffer[13],
+             sg_hd->sense_buffer[14],        sg_hd->sense_buffer[15]);
+    if (status < 0)
+      perror("");
+  }
+  /* Look if we got what we expected to get */
+  if (status == scsi_off + out_size) status = 0; /* got them all */
+  
+  return status;  /* 0 means no error */
+}
+
+#define START_STOP_CMDLEN  6
+
+static void
+scsi_spin(const int fd, const char desired_state) {
+  unsigned char cmdblk [ START_STOP_CMDLEN ] =
+  { START_STOP,  /* command */
+    0,  /* lun(3 bits)/reserved(4 bits)/immed(1 bit) */
+    0,  /* reserved */
+    0,  /* reserved */
+    desired_state ? 1 : 0,  /* reserved(6)/LoEj(1)/Start(1)*/
+    0 };/* reserved/flag/link */
+  
+  memcpy(cmd + scsi_off, cmdblk, sizeof(cmdblk));
+  
+  /*
+   * +------------------+
+   * | struct sg_header | <- cmd
+   * +------------------+
+   * | copy of cmdblk   | <- cmd + scsi_off
+   * +------------------+
+   */
+  
+  if (handle_SCSI_cmd(fd, sizeof(cmdblk), 0, cmd, 0, NULL )) {
+    fprintf( stderr, "Inquiry failed\n" );
+    exit(2);
+  }
+}
+
+
+
+static void
+usage() {
+  static char usage_string[] = 
+    "usage: scsi-spin ( --up | --down ) device\n"
+    "--up   spin up device.\n"
+    "--up   spin down device.\n";
+
+  fputs(usage_string, stderr);
+}
+
+int
+main(int argc, char *argv[]) {
+  int result = 0;
+  int fd;
+  int opt_up = 0;
+  int opt_down = 0;
+  struct option cmd_line_opts[] = {
+    {"up", 0, &opt_up, 1},
+    {"down", 0, &opt_down, 1},
+    {0, 0, 0, 0},
+  };
+  
+  char c;
+  while((c = getopt_long(argc, argv, "", cmd_line_opts, NULL)) != EOF) {
+    if(c == ':') {
+      usage();
+      exit(1);
+    }
+    if(c == '?') {
+      usage();
+      exit(1);
+    }
+  }
+
+  if(opt_up && opt_down) {
+    fputs("scsi-spin: specified both --up and --down.  "
+          "Is this some kind of test?\n", stderr);
+    usage();
+    exit(1);
+  }
+
+  if(!(opt_up || opt_down)) {
+    fputs("scsi-spin: must specify --up or --down.\n", stderr);
+    usage();
+    exit(1);
+  }
+
+  if(optind != (argc - 1)) {
+    usage();
+    exit(1);
+  }
+
+  fd = open(argv[optind], O_RDWR);
+  if (fd < 0) {
+    fprintf(stderr, "Failure opening %s\n", argv[optind]);
+    exit(1);
+  }
+
+  {
+    struct stat devstat;
+    if(stat(argv[optind], &devstat) == -1) {
+      fprintf(stderr, "stat on %s failed.\n", argv[optind]);
+      close(fd);
+      exit(1);
+    }
+    if(!S_ISCHR(devstat.st_mode) ||
+       major(devstat.st_rdev) != SCSI_GENERIC_MAJOR) {
+      fprintf(stderr, "%s is not a generic SCSI device.\n", argv[optind]);
+      close(fd);
+      exit(1);
+    }
+  }
+
+  if(opt_up)
+    scsi_spin(fd, 1);
+  else
+    scsi_spin(fd, 0);
+
+  close(fd);
+  return result;
+}
--- hwtools-0.5.orig/scsi-spin.README
+++ hwtools-0.5/scsi-spin.README
@@ -0,0 +1,32 @@
+To: submit@bugs.debian.org
+Subject: hwtools: scsi-spin -- an additional program for hwtools...
+From: Rob Browning <rlb@cs.utexas.edu>
+Date: 04 Apr 1998 17:15:14 -0600
+
+Package: hwtools
+Version: 0.3-4
+Severity: wishlist
+
+Here's a small program I wrote called scsi-spin that lets you spin up
+and down scsi drives.  I thought you might consider it for inclusion
+in the debian hwtools package, and perhaps from there into the
+upstream source somewhere.  Thanks...
+
+This command is particularly useful if you've got noisy (or hot)
+drives in a machine that you rarely need to access.  This is *not* the
+same as the kernel patch that's floating around that will
+automatically spin down the drive after some time.  scsi-spin is
+completely manual, and spinning down a drive that's in use, especially
+the one containing the scsi-spin binary, it probably a *really* bad
+idea.
+
+You can build it with GNU make, and this command:
+
+  make CC=g++ CFLAGS="-g -Wall -O2 -I/usr/src/linux/include" scsi-spin
+
+It doesn't really need g++, but I just wanted the extra type
+checking...
+
+-- 
+Rob Browning <rlb@cs.utexas.edu>
+PGP fingerprint = E8 0E 0D 04 F5 21 A0 94  53 2B 97 F5 D6 4E 39 30
--- hwtools-0.5.orig/scsidev/configure.in
+++ hwtools-0.5/scsidev/configure.in
@@ -4,6 +4,6 @@
 AC_CONFIG_HEADER(config.h)
 AC_PROG_CC
 AC_CONST
-AC_CHECK_HEADERS(linux/scsi.h scsi/scsi.h /usr/src/linux/drivers/scsi/scsi.h)
+AC_CHECK_HEADERS(linux/scsi.h scsi/scsi.h /usr/src/linux/drivers/scsi/scsi.h /usr/src/linux/include/scsi/scsi.h)
 AC_PROG_INSTALL
 AC_OUTPUT(Makefile)
--- hwtools-0.5.orig/scsidev/configure
+++ hwtools-0.5/scsidev/configure
@@ -1,7 +1,7 @@
 #! /bin/sh
 
 # Guess values for system-dependent variables and create Makefiles.
-# Generated automatically using autoconf version 2.12 
+# Generated automatically using autoconf version 2.13 
 # Copyright (C) 1992, 93, 94, 95, 96 Free Software Foundation, Inc.
 #
 # This configure script is free software; the Free Software Foundation
@@ -49,6 +49,7 @@
 # Initialize some other variables.
 subdirs=
 MFLAGS= MAKEFLAGS=
+SHELL=${CONFIG_SHELL-/bin/sh}
 # Maximum number of lines to put in a shell here document.
 ac_max_here_lines=12
 
@@ -332,7 +333,7 @@
     verbose=yes ;;
 
   -version | --version | --versio | --versi | --vers)
-    echo "configure generated by autoconf version 2.12"
+    echo "configure generated by autoconf version 2.13"
     exit 0 ;;
 
   -with-* | --with-*)
@@ -502,9 +503,11 @@
 # CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options.
 ac_cpp='$CPP $CPPFLAGS'
 ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5'
-ac_link='${CC-cc} -o conftest $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5'
+ac_link='${CC-cc} -o conftest${ac_exeext} $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5'
 cross_compiling=$ac_cv_prog_cc_cross
 
+ac_exeext=
+ac_objext=o
 if (echo "testing\c"; echo 1,2,3) | grep c >/dev/null; then
   # Stardent Vistra SVR4 grep lacks -e, says ghazi@caip.rutgers.edu.
   if (echo -n testing; echo 1,2,3) | sed s/-n/xn/ | grep xn >/dev/null; then
@@ -522,15 +525,16 @@
 # Extract the first word of "gcc", so it can be a program name with args.
 set dummy gcc; ac_word=$2
 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:526: checking for $ac_word" >&5
+echo "configure:529: checking for $ac_word" >&5
 if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   if test -n "$CC"; then
   ac_cv_prog_CC="$CC" # Let the user override the test.
 else
-  IFS="${IFS= 	}"; ac_save_ifs="$IFS"; IFS="${IFS}:"
-  for ac_dir in $PATH; do
+  IFS="${IFS= 	}"; ac_save_ifs="$IFS"; IFS=":"
+  ac_dummy="$PATH"
+  for ac_dir in $ac_dummy; do
     test -z "$ac_dir" && ac_dir=.
     if test -f $ac_dir/$ac_word; then
       ac_cv_prog_CC="gcc"
@@ -551,16 +555,17 @@
   # Extract the first word of "cc", so it can be a program name with args.
 set dummy cc; ac_word=$2
 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:555: checking for $ac_word" >&5
+echo "configure:559: checking for $ac_word" >&5
 if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   if test -n "$CC"; then
   ac_cv_prog_CC="$CC" # Let the user override the test.
 else
-  IFS="${IFS= 	}"; ac_save_ifs="$IFS"; IFS="${IFS}:"
+  IFS="${IFS= 	}"; ac_save_ifs="$IFS"; IFS=":"
   ac_prog_rejected=no
-  for ac_dir in $PATH; do
+  ac_dummy="$PATH"
+  for ac_dir in $ac_dummy; do
     test -z "$ac_dir" && ac_dir=.
     if test -f $ac_dir/$ac_word; then
       if test "$ac_dir/$ac_word" = "/usr/ucb/cc"; then
@@ -595,25 +600,61 @@
   echo "$ac_t""no" 1>&6
 fi
 
+  if test -z "$CC"; then
+    case "`uname -s`" in
+    *win32* | *WIN32*)
+      # Extract the first word of "cl", so it can be a program name with args.
+set dummy cl; ac_word=$2
+echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
+echo "configure:610: checking for $ac_word" >&5
+if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then
+  echo $ac_n "(cached) $ac_c" 1>&6
+else
+  if test -n "$CC"; then
+  ac_cv_prog_CC="$CC" # Let the user override the test.
+else
+  IFS="${IFS= 	}"; ac_save_ifs="$IFS"; IFS=":"
+  ac_dummy="$PATH"
+  for ac_dir in $ac_dummy; do
+    test -z "$ac_dir" && ac_dir=.
+    if test -f $ac_dir/$ac_word; then
+      ac_cv_prog_CC="cl"
+      break
+    fi
+  done
+  IFS="$ac_save_ifs"
+fi
+fi
+CC="$ac_cv_prog_CC"
+if test -n "$CC"; then
+  echo "$ac_t""$CC" 1>&6
+else
+  echo "$ac_t""no" 1>&6
+fi
+ ;;
+    esac
+  fi
   test -z "$CC" && { echo "configure: error: no acceptable cc found in \$PATH" 1>&2; exit 1; }
 fi
 
 echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works""... $ac_c" 1>&6
-echo "configure:603: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works" >&5
+echo "configure:642: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works" >&5
 
 ac_ext=c
 # CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options.
 ac_cpp='$CPP $CPPFLAGS'
 ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5'
-ac_link='${CC-cc} -o conftest $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5'
+ac_link='${CC-cc} -o conftest${ac_exeext} $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5'
 cross_compiling=$ac_cv_prog_cc_cross
 
-cat > conftest.$ac_ext <<EOF
-#line 613 "configure"
+cat > conftest.$ac_ext << EOF
+
+#line 653 "configure"
 #include "confdefs.h"
+
 main(){return(0);}
 EOF
-if { (eval echo configure:617: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:658: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   ac_cv_prog_cc_works=yes
   # If we can't run a trivial program, we are probably using a cross compiler.
   if (./conftest; exit) 2>/dev/null; then
@@ -627,18 +668,24 @@
   ac_cv_prog_cc_works=no
 fi
 rm -fr conftest*
+ac_ext=c
+# CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options.
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5'
+ac_link='${CC-cc} -o conftest${ac_exeext} $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5'
+cross_compiling=$ac_cv_prog_cc_cross
 
 echo "$ac_t""$ac_cv_prog_cc_works" 1>&6
 if test $ac_cv_prog_cc_works = no; then
   { echo "configure: error: installation or configuration problem: C compiler cannot create executables." 1>&2; exit 1; }
 fi
 echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler""... $ac_c" 1>&6
-echo "configure:637: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler" >&5
+echo "configure:684: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler" >&5
 echo "$ac_t""$ac_cv_prog_cc_cross" 1>&6
 cross_compiling=$ac_cv_prog_cc_cross
 
 echo $ac_n "checking whether we are using GNU C""... $ac_c" 1>&6
-echo "configure:642: checking whether we are using GNU C" >&5
+echo "configure:689: checking whether we are using GNU C" >&5
 if eval "test \"`echo '$''{'ac_cv_prog_gcc'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -647,7 +694,7 @@
   yes;
 #endif
 EOF
-if { ac_try='${CC-cc} -E conftest.c'; { (eval echo configure:651: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then
+if { ac_try='${CC-cc} -E conftest.c'; { (eval echo configure:698: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then
   ac_cv_prog_gcc=yes
 else
   ac_cv_prog_gcc=no
@@ -658,11 +705,15 @@
 
 if test $ac_cv_prog_gcc = yes; then
   GCC=yes
-  ac_test_CFLAGS="${CFLAGS+set}"
-  ac_save_CFLAGS="$CFLAGS"
-  CFLAGS=
-  echo $ac_n "checking whether ${CC-cc} accepts -g""... $ac_c" 1>&6
-echo "configure:666: checking whether ${CC-cc} accepts -g" >&5
+else
+  GCC=
+fi
+
+ac_test_CFLAGS="${CFLAGS+set}"
+ac_save_CFLAGS="$CFLAGS"
+CFLAGS=
+echo $ac_n "checking whether ${CC-cc} accepts -g""... $ac_c" 1>&6
+echo "configure:717: checking whether ${CC-cc} accepts -g" >&5
 if eval "test \"`echo '$''{'ac_cv_prog_cc_g'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -677,25 +728,29 @@
 fi
 
 echo "$ac_t""$ac_cv_prog_cc_g" 1>&6
-  if test "$ac_test_CFLAGS" = set; then
-    CFLAGS="$ac_save_CFLAGS"
-  elif test $ac_cv_prog_cc_g = yes; then
+if test "$ac_test_CFLAGS" = set; then
+  CFLAGS="$ac_save_CFLAGS"
+elif test $ac_cv_prog_cc_g = yes; then
+  if test "$GCC" = yes; then
     CFLAGS="-g -O2"
   else
-    CFLAGS="-O2"
+    CFLAGS="-g"
   fi
 else
-  GCC=
-  test "${CFLAGS+set}" = set || CFLAGS="-g"
+  if test "$GCC" = yes; then
+    CFLAGS="-O2"
+  else
+    CFLAGS=
+  fi
 fi
 
 echo $ac_n "checking for working const""... $ac_c" 1>&6
-echo "configure:694: checking for working const" >&5
+echo "configure:749: checking for working const" >&5
 if eval "test \"`echo '$''{'ac_cv_c_const'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 699 "configure"
+#line 754 "configure"
 #include "confdefs.h"
 
 int main() {
@@ -744,7 +799,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:748: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:803: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   ac_cv_c_const=yes
 else
@@ -765,7 +820,7 @@
 fi
 
 echo $ac_n "checking how to run the C preprocessor""... $ac_c" 1>&6
-echo "configure:769: checking how to run the C preprocessor" >&5
+echo "configure:824: checking how to run the C preprocessor" >&5
 # On Suns, sometimes $CPP names a directory.
 if test -n "$CPP" && test -d "$CPP"; then
   CPP=
@@ -780,14 +835,14 @@
   # On the NeXT, cc -E runs the code through the compiler's parser,
   # not just through cpp.
   cat > conftest.$ac_ext <<EOF
-#line 784 "configure"
+#line 839 "configure"
 #include "confdefs.h"
 #include <assert.h>
 Syntax Error
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:790: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
-ac_err=`grep -v '^ *+' conftest.out`
+{ (eval echo configure:845: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
 if test -z "$ac_err"; then
   :
 else
@@ -797,14 +852,31 @@
   rm -rf conftest*
   CPP="${CC-cc} -E -traditional-cpp"
   cat > conftest.$ac_ext <<EOF
-#line 801 "configure"
+#line 856 "configure"
+#include "confdefs.h"
+#include <assert.h>
+Syntax Error
+EOF
+ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
+{ (eval echo configure:862: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
+if test -z "$ac_err"; then
+  :
+else
+  echo "$ac_err" >&5
+  echo "configure: failed program was:" >&5
+  cat conftest.$ac_ext >&5
+  rm -rf conftest*
+  CPP="${CC-cc} -nologo -E"
+  cat > conftest.$ac_ext <<EOF
+#line 873 "configure"
 #include "confdefs.h"
 #include <assert.h>
 Syntax Error
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:807: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
-ac_err=`grep -v '^ *+' conftest.out`
+{ (eval echo configure:879: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
 if test -z "$ac_err"; then
   :
 else
@@ -817,6 +889,8 @@
 rm -f conftest*
 fi
 rm -f conftest*
+fi
+rm -f conftest*
   ac_cv_prog_CPP="$CPP"
 fi
   CPP="$ac_cv_prog_CPP"
@@ -825,22 +899,22 @@
 fi
 echo "$ac_t""$CPP" 1>&6
 
-for ac_hdr in linux/scsi.h scsi/scsi.h /usr/src/linux/drivers/scsi/scsi.h
+for ac_hdr in linux/scsi.h scsi/scsi.h /usr/src/linux/drivers/scsi/scsi.h /usr/src/linux/include/scsi/scsi.h
 do
 ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
-echo "configure:833: checking for $ac_hdr" >&5
+echo "configure:907: checking for $ac_hdr" >&5
 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 838 "configure"
+#line 912 "configure"
 #include "confdefs.h"
 #include <$ac_hdr>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:843: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
-ac_err=`grep -v '^ *+' conftest.out`
+{ (eval echo configure:917: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
 if test -z "$ac_err"; then
   rm -rf conftest*
   eval "ac_cv_header_$ac_safe=yes"
@@ -891,28 +965,30 @@
 # SunOS /usr/etc/install
 # IRIX /sbin/install
 # AIX /bin/install
+# AIX 4 /usr/bin/installbsd, which doesn't work without a -g flag
 # AFS /usr/afsws/bin/install, which mishandles nonexistent args
 # SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff"
 # ./install, which can be erroneously created by make from ./install.sh.
 echo $ac_n "checking for a BSD compatible install""... $ac_c" 1>&6
-echo "configure:899: checking for a BSD compatible install" >&5
+echo "configure:974: checking for a BSD compatible install" >&5
 if test -z "$INSTALL"; then
 if eval "test \"`echo '$''{'ac_cv_path_install'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
-    IFS="${IFS= 	}"; ac_save_IFS="$IFS"; IFS="${IFS}:"
+    IFS="${IFS= 	}"; ac_save_IFS="$IFS"; IFS=":"
   for ac_dir in $PATH; do
     # Account for people who put trailing slashes in PATH elements.
     case "$ac_dir/" in
     /|./|.//|/etc/*|/usr/sbin/*|/usr/etc/*|/sbin/*|/usr/afsws/bin/*|/usr/ucb/*) ;;
     *)
       # OSF1 and SCO ODT 3.0 have their own names for install.
-      for ac_prog in ginstall installbsd scoinst install; do
+      # Don't use installbsd from OSF since it installs stuff as root
+      # by default.
+      for ac_prog in ginstall scoinst install; do
         if test -f $ac_dir/$ac_prog; then
 	  if test $ac_prog = install &&
             grep dspmsg $ac_dir/$ac_prog >/dev/null 2>&1; then
 	    # AIX install.  It has an incompatible calling convention.
-	    # OSF/1 installbsd also uses dspmsg, but is usable.
 	    :
 	  else
 	    ac_cv_path_install="$ac_dir/$ac_prog -c"
@@ -942,6 +1018,8 @@
 # It thinks the first close brace ends the variable substitution.
 test -z "$INSTALL_PROGRAM" && INSTALL_PROGRAM='${INSTALL}'
 
+test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL_PROGRAM}'
+
 test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644'
 
 trap '' 1 2 15
@@ -967,7 +1045,7 @@
 # Ultrix sh set writes to stderr and can't be redirected directly,
 # and sets the high bit in the cache file unless we assign to the vars.
 (set) 2>&1 |
-  case `(ac_space=' '; set) 2>&1` in
+  case `(ac_space=' '; set | grep ac_space) 2>&1` in
   *ac_space=\ *)
     # `set' does not quote correctly, so add quotes (double-quote substitution
     # turns \\\\ into \\, and sed turns \\ into \).
@@ -1034,7 +1112,7 @@
     echo "running \${CONFIG_SHELL-/bin/sh} $0 $ac_configure_args --no-create --no-recursion"
     exec \${CONFIG_SHELL-/bin/sh} $0 $ac_configure_args --no-create --no-recursion ;;
   -version | --version | --versio | --versi | --vers | --ver | --ve | --v)
-    echo "$CONFIG_STATUS generated by autoconf version 2.12"
+    echo "$CONFIG_STATUS generated by autoconf version 2.13"
     exit 0 ;;
   -help | --help | --hel | --he | --h)
     echo "\$ac_cs_usage"; exit 0 ;;
@@ -1054,9 +1132,11 @@
  s/@@/%@/; s/@@/@%/; s/@g\$/%g/' > conftest.subs <<\\CEOF
 $ac_vpsub
 $extrasub
+s%@SHELL@%$SHELL%g
 s%@CFLAGS@%$CFLAGS%g
 s%@CPPFLAGS@%$CPPFLAGS%g
 s%@CXXFLAGS@%$CXXFLAGS%g
+s%@FFLAGS@%$FFLAGS%g
 s%@DEFS@%$DEFS%g
 s%@LDFLAGS@%$LDFLAGS%g
 s%@LIBS@%$LIBS%g
@@ -1078,6 +1158,7 @@
 s%@CC@%$CC%g
 s%@CPP@%$CPP%g
 s%@INSTALL_PROGRAM@%$INSTALL_PROGRAM%g
+s%@INSTALL_SCRIPT@%$INSTALL_SCRIPT%g
 s%@INSTALL_DATA@%$INSTALL_DATA%g
 
 CEOF
--- hwtools-0.5.orig/scsidev/Makefile.in
+++ hwtools-0.5/scsidev/Makefile.in
@@ -19,15 +19,15 @@
 prefix = @prefix@
 exec_prefix = $(prefix)
 
-bindir = $(exec_prefix)/bin
+bindir = $(exec_prefix)/sbin
 
 # Where to put the manual pages.
-mandir = $(prefix)/man/man8
+mandir = $(prefix)/share/man/man8
 # Extension (not including `.') for the manual page filenames.
 manext = 8
 
 #### End of system configuration section. ####
-CFLAGS=@CFLAGS@ -g # -DDEBUG
+CFLAGS=@CFLAGS@ # -DDEBUG
 
 World: scsidev
 
@@ -46,7 +46,7 @@
 install: scsidev
 	cp scsidev $(bindir)
 	cp scsidev.8 $(mandir)
-	if [ ! -d /dev/scsi ]; then mkdir /dev/scsi; fi
+	if [ ! -d $(DESTDIR)/dev/scsi ]; then mkdir $(DESTDIR)/dev/scsi; fi
 
 dist:
 	(mydir=`basename \`pwd\``;\
@@ -56,6 +56,4 @@
 
 clean:
 	rm -f *~ *.o scsidev
-	/bin/rm -f config.status config.log config.cache config.h
-
-
+	rm -f config.status config.log config.cache config.h
--- hwtools-0.5.orig/scsidev/scsidev.c
+++ hwtools-0.5/scsidev/scsidev.c
@@ -1,5 +1,4 @@
 #include <stdio.h>
-#include <linux/fs.h>
 #include <sys/sysmacros.h>
 #include <fcntl.h>
 #include <linux/major.h>
@@ -8,7 +7,16 @@
 #include <errno.h>
 #include <strings.h>
 
+#include <sys/ioctl.h>
+#include <sys/param.h>
+#include <assert.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <limits.h>
+
+#ifdef LINT
 static char rcsid[] ="$Id: scsidev.c,v 1.2 1997/03/29 15:45:50 eric Exp $";
+#endif
 
 #include "config.h"
 
@@ -16,18 +24,17 @@
 #include <scsi/scsi.h>
 #else							/* } { */
 #ifdef HAVE_LINUX_SCSI_H				/* { */
-#include <linux/scsi.h>
+#include <linux/scsi/scsi.h>
 #else							/* } { */
-#ifdef HAVE__USR_SRC_LINUX_DRIVERS_SCSI_SCSI_H 		/* { */
-#include "/usr/src/linux/drivers/scsi/scsi.h"
-#else							/* } { */
-#error "Unable to include scsi.h"
-#endif							/* } */
+#include "/usr/src/linux/include/scsi/scsi.h"
 #endif							/* } */
 #endif							/* } */
 
 #include <getopt.h>
 
+#define SCSIDIR	"/dev/scsi"
+#define TESTDEVNAME ".testdev"
+
 int use_symlink = 0;
 int filemode = 0600;
 int verbose = 0;
@@ -35,7 +42,7 @@
 
 
 /*
- * This program builds entries in /dev/scsi that have names that are tied
+ * This program builds entries in SCSIDIR that have names that are tied
  * to the actual device number and lun.   This is pretty solid as long as
  * you have only one scsi controller, but with multiple scsi controllers
  * this all falls down.  The problem is that you can have multiple controllers
@@ -73,6 +80,7 @@
  * Used to maintain a list of the nodes that we have seen
  * which we know to be OK and active.
  */
+void
 register_dev(char * name, int major, int minor, int hnum, 
 	     int hid, int chan, int id, 
 	     int lun, int part, struct regnames * alias)
@@ -81,6 +89,7 @@
   char * pnt;
 
   rpnt = (struct regnames *) malloc(sizeof(struct regnames));
+  assert(rpnt != 0);
   pnt = strrchr(name, '/');
   rpnt->name = strdup(pnt + 1);
   rpnt->major = major;
@@ -109,22 +118,20 @@
  */
 void sanitize_sdev()
 {
-  struct dirent * de;
-  char filename[60];
   DIR * sdir;
   struct regnames * rpnt;
   struct stat statbuf;
   int status;
 
   /*
-   * Next, delete all of the existing entries in the /dev/scsi directory.
+   * Next, delete all of the existing entries in the SCSIDIR directory.
    * The idea is that if we have added/removed devices, the numbers might have
    * changed.
    */
-  sdir = opendir("/dev/scsi");
-  while(1==1)
+  sdir = opendir(SCSIDIR);
+  while(1)
     {
-      de = readdir(sdir);
+      struct dirent * de = readdir(sdir);
       if(de == NULL) break;
       /*
        * OK, we have the name.  See whether this is something
@@ -139,8 +146,10 @@
 	}
       if( rpnt == NULL )
 	{
-	  strcpy(filename, "/dev/scsi/");
-	  strcat(filename, de->d_name);
+          char *filename = malloc((strlen(SCSIDIR) +
+                                   strlen(de->d_name) + 2) * sizeof(char));
+          assert(filename != NULL);
+	  sprintf(filename,"%s/%s",SCSIDIR,de->d_name);
 	  status = stat(filename, &statbuf);
 	  if(    status == 0
 	      && (S_ISCHR(statbuf.st_mode) || S_ISBLK(statbuf.st_mode)))
@@ -158,6 +167,7 @@
 	      chown(filename, statbuf.st_uid, statbuf.st_gid);
 
 	    }
+          free(filename);
 	}
     }
   closedir(sdir);
@@ -167,27 +177,30 @@
 
 void flush_sdev()
 {
-  struct dirent * de;
-  char filename[60];
   DIR * sdir;
   /*
-   * Next, delete all of the existing entries in the /dev/scsi directory.
+   * Next, delete all of the existing entries in the SCSIDIR directory.
    * The idea is that if we have added/removed devices, the numbers might have
    * changed.
    */
-  sdir = opendir("/dev/scsi");
-  while(1==1)
+  sdir = opendir(SCSIDIR);
+  while(1)
     {
-      de = readdir(sdir);
+      char *filename = NULL;
+      struct dirent *de = readdir(sdir);
       if(de == NULL) break;
       if(de->d_name[0] != 's' && de->d_name[0] != 'r') continue;
-      strcpy(filename, "/dev/scsi/");
-      strcat(filename, de->d_name);
+      filename = malloc((strlen(SCSIDIR) + strlen(de->d_name) + 2) *
+                        sizeof(char));
+      assert(filename != NULL);
+      sprintf(filename, "%s/%s", SCSIDIR, de->d_name);
       unlink(filename);
+      free(filename);
+      filename = NULL;
     }
   closedir(sdir);
-  printf("Flushed old /dev/scsi entries...\n", de->d_name);
-
+  if( verbose >= 1 )
+	  printf("Flushed old %s entries...\n", SCSIDIR);
 }
 
 /*
@@ -264,37 +277,41 @@
 {
   int chan;
   int fd;
-  char hostname[60];
+  char hostname[512];
   int newmode;
-  int recreate;
   int h_id;
   int id[2];
   int lun;
   int minor = 0;
-  int uid, gid;
   struct stat statbuf;
   int scsi_id;
-  char scsidev[64];
-  char linkto[64];
+  char scsidev[MAXPATHLEN]; /* This isn't ideal, but it'll do for now. */
+  char linkto[MAXPATHLEN];  /* This isn't ideal, but it'll do for now. */
+  char testdev[MAXPATHLEN];
   int status;
 
-  status = stat("/tmp/testdev", &statbuf);
+
+  /* put testdev in in the SCSIDIR -
+     /var may reside on a not yet mounted partition */
+  sprintf(testdev,"%s/%s", SCSIDIR, TESTDEVNAME);
+  
+  status = stat(testdev, &statbuf);
   if(status == 0)
     {
-      unlink("/tmp/testdev");
+      unlink(testdev);
     }
 
-  status = stat("/dev/scsi", &statbuf);
+  status = stat(SCSIDIR, &statbuf);
   if(status == -1)
       return;
 
-  while(1==1)
+  while(1)
     {
-      status = mknod("/tmp/testdev",0600 | devtype ,
+      status = mknod(testdev,0600 | devtype ,
 		     makedev(major,minor));
-      fd = open("/tmp/testdev", mode);
+      fd = open(testdev, mode);
       if(fd == -1) {
-	if( verbose == 2 )
+	if( verbose >= 3 )
 	  {
 	    fprintf(stderr,"open(%x/%x) returned %d (%d)\n",
 		    major, minor, fd, errno);
@@ -304,19 +321,19 @@
 	 * somewhere (there could be sparse partition tables).  For anything
 	 * else, stop as soon as we find something non-existant.
 	 */
-	if(   (major == SCSI_DISK_MAJOR)
-	      && minor < 128)
+	if(   (major == SCSI_DISK0_MAJOR)
+	      && minor < 256)
 	  {
 	    minor++;
-	    unlink ("/tmp/testdev");
+	    unlink (testdev);
 	    continue;
-	  } else if ( major != SCSI_DISK_MAJOR )
+	  } else if ( major != SCSI_DISK0_MAJOR )
 	    break;
       }
       status = ioctl(fd, SCSI_IOCTL_GET_IDLUN, &id);
 
       if(status == -1)	{
-	if( verbose == 2 )
+	if( verbose >= 3 )
 	  {
 	    fprintf(stderr,"probe(%x/%x) returned %d (%d)\n",
 		    major, minor, status, errno);
@@ -325,21 +342,26 @@
 	break;
       }
 
+      /* don't forget to set the buffersize */
+      *(int *)hostname = sizeof(hostname) -1;
       status = ioctl(fd, SCSI_IOCTL_PROBE_HOST, hostname);
       close(fd);
-
+      /* terminate a possible truncated string correctly */
+      hostname[sizeof(hostname) -1] = (char) 0;
+      
       if(status == -1)	break;
 
-#if 0
-      printf("Found scsi device %x with idlun %x\n", makedev(major, minor), id);
-#endif
+      if( verbose >=2 )
+	printf("Found scsi device %x with idlun %x %x\n", makedev(major, minor), id[0], id[1]);
+
       h_id = id[0] >> 24;
       chan = (id[0] >> 16) & 0xff;
       lun = (id[0] >> 8 ) & 0xff;
       scsi_id = id[0] & 0xff;
-      if(major == SCSI_DISK_MAJOR && (minor & 0xf))
+      if(major == SCSI_DISK0_MAJOR && (minor & 0xf))
 	{
-	  sprintf(scsidev,"/dev/scsi/s%ch%d-%xc%di%dl%dp%d",
+	  sprintf(scsidev,"%s/s%ch%d-%xc%di%dl%dp%d",
+		  SCSIDIR,
 		  devchar,
 		  h_id,
 		  id[1],
@@ -350,7 +372,8 @@
 		       h_id, id[1], chan, scsi_id, 
 		       lun, (minor & 0xf), NULL);
       } else {
-	sprintf(scsidev,"/dev/scsi/s%ch%d-%xc%di%dl%d",
+	sprintf(scsidev,"%s/s%ch%d-%xc%di%dl%d",
+		SCSIDIR,
 		devchar,
 		h_id,
 		id[1],
@@ -360,7 +383,8 @@
 	register_dev(scsidev, major, minor, 
 		     h_id, id[1], chan, scsi_id, lun, -1, NULL);
       }
-      printf("Found scsi device %s %s\n", scsidev, hostname);
+      if( verbose >= 2 )
+        printf("Found scsi device %s %s\n", scsidev, hostname);
 
       if( use_symlink )
 	{
@@ -369,7 +393,7 @@
 	   */
 	  switch(major)
 	    {
-	    case SCSI_DISK_MAJOR:
+	    case SCSI_DISK0_MAJOR:
 	      if( minor & 0xf)
 		sprintf(linkto, "/dev/sd%c%d", 
 			(minor >> 4) + 'a', (minor & 0xf)); 
@@ -419,7 +443,8 @@
 	  
 	  if( major == SCSI_TAPE_MAJOR )
 	    {
-	      sprintf(scsidev,"/dev/scsi/rs%ch%d-%xc%di%dl%d",
+	      sprintf(scsidev,"%s/rs%ch%d-%xc%di%dl%d",
+		      SCSIDIR,
 		      devchar,
 		      h_id,
 		      id[1],
@@ -461,7 +486,8 @@
 
 	  if( major == SCSI_TAPE_MAJOR )
 	    {
-	      sprintf(scsidev,"/dev/scsi/rs%ch%d-%xc%di%dl%d",
+	      sprintf(scsidev,"%s/rs%ch%d-%xc%di%dl%d",
+		      SCSIDIR,
 		      devchar,
 		      h_id,
 		      id[1],
@@ -475,145 +501,40 @@
 	    }
 	}
       
-      unlink("/tmp/testdev");
+      unlink(testdev);
       minor += 1;
     }
-  unlink("/tmp/testdev");
-}
-
-
-/*
- * Build a /dev/scsi tree that contains the correct device entries.
- */
-
-usage()
-{
-  fprintf(stderr,"scsidev v1.3\n");
-  fprintf(stderr,"Usage: scsidev [-f] [-l] [-v] [-m mode]\n");
+  unlink(testdev);
 }
 
-main(int argc, char * argv[])
-{
-  char c;
-  int force = 0;
-  int show_serial = 0;
-  struct stat statbuf;
-  struct regnames * rpnt;
-  int status;
-
-  status = stat("/dev/scsi", &statbuf);
-  if(    status == -1
-      || !S_ISDIR(statbuf.st_mode))
-    {
-      fprintf(stderr,"/dev/scsi either does not exist, or is not a directory\n");
-      exit(0);
-    }
-  while ((c = getopt(argc, argv, "flvsm:")) != EOF)
-    {
-      switch (c)
-	{
-	case 'f':
-	  force = 1;
-	  break;
-	case 'm':
-	  filemode = strtoul(optarg, 0, 0);
-	  break;
-	case 'l':
-	  use_symlink = 1;
-	  break;
-	case 's':
-	  show_serial = 1;
-	  break;
-	case 'v':
-	  verbose++;
-	  break;
-	default:
-	  usage();
-	  exit(1);
-	  break;
-	}
-    }
-
-  if( force ) flush_sdev();
-
-#ifdef DEBUG
-  register_dev("/dev/scsi/sdh4-334c0i0l0",   8,  0, 6, 0x334, 0, 0, 0, -1, NULL);
-  register_dev("/dev/scsi/sdh4-334c0i0l0p1", 8,  1, 6, 0x334, 0, 0, 0,  1, NULL);
-  register_dev("/dev/scsi/sdh4-334c0i0l0p2",8,  2,6, 0x334, 0, 0, 0,  2, NULL);
-  register_dev("/dev/scsi/sdh4-334c0i0l0p3",8,  3,6, 0x334, 0, 0, 0,  3, NULL);
-  register_dev("/dev/scsi/sgh4-334c0i0l0", 21,  0,6, 0x334, 0, 0, 0, -1, NULL);
-  register_dev("/dev/scsi/sgh4-334c0i2l0", 21,  1,6, 0x334, 0, 2, 0, -1, NULL);
-  register_dev("/dev/scsi/sgh4-334c0i5l0", 21,  2,6, 0x334, 0, 5, 0, -1, NULL);
-  register_dev("/dev/scsi/srh4-334c0i2l0", 11,  0,6, 0x334, 0, 2, 0, -1, NULL);
-  register_dev("/dev/scsi/sth4-334c0i5l0",  9,  0,6, 0x334, 0, 5, 0, -1, NULL);
-  register_dev("/dev/scsi/rsth4-334c0i5l0", 9,128,6, 0x334, 0, 5, 0, -1, NULL);
-#else
-  build_sdev(SCSI_DISK_MAJOR,    O_RDONLY, S_IFBLK, 'd');
-  build_sdev(SCSI_CDROM_MAJOR,   O_RDONLY, S_IFBLK, 'r');
-  build_sdev(SCSI_TAPE_MAJOR,    O_RDONLY, S_IFCHR, 't');
-  build_sdev(SCSI_GENERIC_MAJOR, O_RDWR,   S_IFCHR, 'g');
-#endif
-
-  if( show_serial )
-    {
-      for (rpnt = reglist; rpnt; rpnt = rpnt->next)
-	{
-	  if( rpnt->partition != -1 ) continue;
-	  if( rpnt->major == SCSI_TAPE_MAJOR
-	      && (rpnt->minor & 0x80) != 0 ) continue;
-
-	  if( rpnt->serial == NULL )  get_serial_number(rpnt);
-	  if( rpnt->serial == no_serial )
-	    printf("Device  %s has no serial number\n", rpnt->name);
-	  else
-	    printf("Serial number of %s: \"%s\"\n", rpnt->name, rpnt->serial);
-	}
-    }
-  /*
-   * Now, read the configuration file and see whether there
-   * are any special device names we want to try and match.
-   */
-  build_special();
-
-  if( !force )
-    {
-      sanitize_sdev();
-    }
-
-}
-
-char * get_string (char * pnt, char **result)
+char *
+get_string (char * pnt, char **result)
 {
   char quote = 0;
 
-  while (*pnt == ' ' || *pnt == '\t') pnt++;
-
-  if( *pnt == '"' ) 
-    {
-      quote = *pnt++;
-    }
+  while (*pnt && (*pnt == ' ' || *pnt == '\t')) pnt++;
 
-  if( *pnt == '\'' ) 
-    {
-      quote = *pnt++;
-    }
-
-  *result = pnt;
-
-  if( quote != 0 )
-    {
-      while( *pnt != quote ) pnt++;
-      *pnt++ = 0;
-    }
-  else
-    {
-      while( *pnt != ',' && *pnt != ' ' && *pnt != '\t' ) pnt++;
-      *pnt++ = 0;
-    }
-
-  while (*pnt == ' ' || *pnt == '\t') pnt++;
-  if(*pnt == ',') pnt++;
-  while (*pnt == ' ' || *pnt == '\t') pnt++;
+  if(*pnt) {
+    if( *pnt == '"' ) quote = *pnt++;
+    if( *pnt == '\'' ) quote = *pnt++;
+    
+    *result = pnt;
+    
+    if( quote != 0 )
+      {
+        while( *pnt && *pnt != quote ) pnt++;
+        *pnt++ = 0;
+      }
+    else
+      {
+        while( *pnt && *pnt != ',' && *pnt != ' ' && *pnt != '\t' ) pnt++;
+        *pnt++ = 0;
+      }
+    
+    while (*pnt && (*pnt == ' ' || *pnt == '\t')) pnt++;
+    if(*pnt == ',') pnt++;
+    while (*pnt && (*pnt == ' ' || *pnt == '\t')) pnt++;
+  }
   return pnt;
 }
 
@@ -670,6 +591,173 @@
 }
 
 /*
+ * Note that this does the same thing as an inquiry, but
+ * it also grabs the serial number too.  Some devices complain
+ * if you ask for the serial number, so we have a version with and
+ * without.
+ */
+void
+get_serial_number(struct regnames * rpnt)
+{
+#ifdef DEBUG
+  /*
+   * Fill in some entries, just so I can test this on a non-scsi system.
+   */
+  if(rpnt->id == 0 )  rpnt->serial = strdup("DX908FK");
+  else  rpnt->serial = no_serial;
+#else
+  int status, i;
+  unsigned char *cmd;
+  unsigned char * pagestart;
+  unsigned char buffer[2048]; /* Doubled from 1024.  Just trying to be sure. */
+  char path[MAXPATHLEN]; /* This isn't ideal, but it'll do for now. */
+  int infile;
+  struct regnames * rpnt1;
+
+  memset(buffer, 0, sizeof(buffer));
+  
+  *( (int *)  buffer )		= 0;	/* length of input data */
+
+  /* length of buffer = buffer size - 2 (for these length bytes)
+                                    - 6 (for the cmd length) */
+  *(((int *) buffer) + 1) = sizeof(buffer)/sizeof(*buffer) - (2 + 6);
+
+  cmd = (char *) ( ((int *) buffer) + 2 );
+  
+  cmd[0] = 0x12;			/* INQUIRY */
+  cmd[1] = 0x01;			/* lun=0, evpd=1 */
+  cmd[2] = 0x80;			/* page code = 0x80, serial number */
+  cmd[3] = 0x00;			/* (reserved) */
+  cmd[4] = 0xff;			/* allocation length */
+  cmd[5] = 0x00;			/* control */
+
+  sprintf(path, "%s/%s", SCSIDIR, rpnt->name);
+  infile = open(path, O_RDONLY);
+  if( infile == -1 ) return;
+  status = ioctl( infile, 1 /* SCSI_IOCTL_SEND_COMMAND */, buffer );
+  close(infile);
+
+  if(status) rpnt->serial = no_serial;
+
+  pagestart = buffer + 8;
+
+  rpnt->serial = (char *) malloc(pagestart[3] + 1);
+  memcpy(rpnt->serial, pagestart+4, pagestart[3]);
+
+  /*
+   * NULL terminate and trim trailing whitespace.
+   */
+  rpnt->serial[pagestart[3]] = '\0';
+  for(i = pagestart[3] - 1; i >= 0 && rpnt->serial[i] == ' '; i-- )
+      rpnt->serial[i] = '\0';
+
+  /*
+   * Copy information to identical nodes to avoid excessive probing.
+   */
+  for( rpnt1 = reglist; rpnt1; rpnt1 = rpnt1->next )
+    {
+      if( rpnt1 == rpnt ) continue;
+      if( rpnt1->alias != NULL ) continue;
+      if( rpnt1->id != rpnt->id ) continue;
+      if( rpnt1->chan != rpnt->chan ) continue;
+      if( rpnt1->hostnum != rpnt->hostnum ) continue;
+      if( rpnt1->hostid != rpnt->hostid ) continue;
+      if( rpnt1->serial == NULL ) rpnt1->serial = rpnt->serial;
+    }
+#endif
+}
+
+void
+inquire(struct regnames * rpnt)
+{
+#ifdef DEBUG
+  /*
+   * Fill in some entries just so that I can test this.
+   */
+  if(rpnt->id == 0 ) {
+    rpnt->manufacturer = strdup("CONNER");
+    rpnt->model=strdup("CFP4207S");
+  } else if(rpnt->id == 2 ) {
+    rpnt->manufacturer = strdup("HP");
+    rpnt->model=strdup("C4324/C4325");
+  } else if(rpnt->id == 5 ) {
+    rpnt->manufacturer = strdup("WANGTEK");
+    rpnt->model=strdup("5150ES");
+  }
+#else
+  int status, i;
+  char c;
+  unsigned char *cmd;
+  unsigned char * pagestart;
+  unsigned char buffer[2048]; /* Doubled from 1024.  Just trying to be sure. */
+  char path[MAXPATHLEN]; /* This isn't ideal, but it'll do for now. */
+  struct regnames * rpnt1;
+  int infile;
+
+  memset(buffer, 0, sizeof(buffer));
+  
+  *( (int *)  buffer )		= 0;	/* length of input data */
+
+  /* length of buffer = buffer size - 2 (for these length bytes)
+                                    - 6 (for the cmd length) */
+  *(((int *) buffer) + 1) = sizeof(buffer)/sizeof(*buffer) - (2 + 6);
+
+  cmd = (char *) ( ((int *) buffer) + 2 );
+  
+  cmd[0] = 0x12;			/* INQUIRY */
+  cmd[1] = 0x00;			/* lun=0, evpd=0 */
+  cmd[2] = 0x00;			/* page code = 0 */
+  cmd[3] = 0x00;			/* (reserved) */
+  cmd[4] = 0xff;			/* allocation length */
+  cmd[5] = 0x00;			/* control */
+
+  sprintf(path, "%s/%s", SCSIDIR, rpnt->name);
+  infile = open(path, O_RDONLY);
+  if( infile == -1 ) return;
+
+  status = ioctl( infile, 1 /* SCSI_IOCTL_SEND_COMMAND */, buffer );
+
+  close(infile);
+
+  if(status) return;
+  
+  pagestart = buffer + 8;
+  
+  for( i = 15; i >= 8 && pagestart[i] == ' '; i-- ) 
+    pagestart[i] = 0;
+  
+  c = pagestart[16];
+  pagestart[16] = 0;
+  rpnt->manufacturer = strdup(pagestart+8);
+  pagestart[16] = c;
+
+  for( i = 31; i >= 16 && pagestart[i] == ' '; i-- ) 
+    pagestart[i] = 0;
+  c = pagestart[32];
+  pagestart[32] = 0;
+  rpnt->model = strdup(pagestart+16);
+  pagestart[32] = c;
+
+  /*
+   * Copy information to identical nodes to avoid excessive probing.
+   */
+  for( rpnt1 = reglist; rpnt1; rpnt1 = rpnt1->next )
+    {
+      if( rpnt1 == rpnt ) continue;
+      if( rpnt1->alias != NULL ) continue;
+      if( rpnt1->id != rpnt->id ) continue;
+      if( rpnt1->chan != rpnt->chan ) continue;
+      if( rpnt1->hostnum != rpnt->hostnum ) continue;
+      if( rpnt1->hostid != rpnt->hostid ) continue;
+      if( rpnt1->manufacturer == NULL ) 
+	rpnt1->manufacturer = rpnt->manufacturer;
+      if( rpnt1->model == NULL ) rpnt1->model = rpnt->model;
+    }
+  return;
+#endif
+}
+
+/*
  * The configuration file is designed to be something that can match
  * any number of fields.  Thus we need to be able to specify a large
  * number of different things in the hope that we can uniquely match
@@ -687,14 +775,16 @@
  * NAME="string"
  * DEVTYPE="disk", "tape", "generic", or "cdrom".
  */
+void
 build_special()
 {
   FILE *	configfile;
-  char buffer[256];
+  char * buffer = NULL;
+  char * buffer_length = 0;
   char * pnt;
   char * pnt1;
   struct regnames * rpnt, *match;
-  char scsidev[64];
+  char scsidev[MAXPATHLEN]; /* This isn't ideal, but it'll do for now. */
   int type;
 
   int lun, chan, id, part, hostid, hostnum;
@@ -708,9 +798,9 @@
   configfile = fopen("/etc/scsi.alias", "r");
 #endif
   line = 0;
-  while(1==1)
+  while(1)
     {
-      fgets(buffer, sizeof(buffer), configfile);
+      if(getline(&buffer, &buffer_length, configfile) == -1) break;
       line++;
       if( feof(configfile)) break;
 
@@ -741,7 +831,7 @@
       if( *pnt == '\0' ) continue;
       if( *pnt == '#' ) continue;
 
-      while(1==1)
+      while(1)
 	{
 	  pnt1 = pnt;
 	  while (*pnt1 != '=' && *pnt1 != '\0') pnt1++;
@@ -794,7 +884,7 @@
 	    }
 	  else
 	    {
-	      fprintf(stderr,"Unrecognized specifier \"%s\" on line\n", pnt,
+	      fprintf(stderr,"Unrecognized specifier \"%s\" on line %d\n", pnt,
 		      line);
 	      break;
 	    }
@@ -815,7 +905,7 @@
 	  continue;
 	}
       if( strcmp(devtype, "disk") == 0 )
-	devtype_i = SCSI_DISK_MAJOR;
+	devtype_i = SCSI_DISK0_MAJOR;
       else if( strcmp(devtype, "cdrom") == 0)
 	devtype_i = SCSI_CDROM_MAJOR;
       else if( strcmp(devtype, "tape") == 0)
@@ -836,6 +926,7 @@
       match = NULL;
       for (rpnt = reglist; rpnt; rpnt = rpnt->next)
 	{
+
 	  /*
 	   * Check the integers first.  Some of the strings we have to
 	   * request, and we want to avoid this if possible.
@@ -908,9 +999,10 @@
 	   * OK, we have a unique match.  Create the device entries,
 	   * as requested.
 	   */
-	  fprintf(stderr,"Building alias device entries for %s...\n", name);
+	  if( verbose >=1 )
+		  printf("Building alias device entries for %s...\n", name);
 
-	  if( devtype_i == SCSI_DISK_MAJOR
+	  if( devtype_i == SCSI_DISK0_MAJOR
 	      || devtype_i == SCSI_CDROM_MAJOR )
 	    type = S_IFBLK;
 	  else
@@ -920,7 +1012,7 @@
 	   * If this is just an ordinary single device type,
 	   * Just create it.
 	   */
-	  sprintf(scsidev, "/dev/scsi/%s", name);
+	  sprintf(scsidev, "%s/%s", SCSIDIR, name);
 	  update_device(scsidev, type, 
 			match->major, match->minor);
 	  register_dev(scsidev, match->major, match->minor | 0x80, 
@@ -928,14 +1020,14 @@
 
 	  if( devtype_i == SCSI_TAPE_MAJOR )
 	    {
-	      sprintf(scsidev, "/dev/scsi/r%s", name);
+	      sprintf(scsidev, "%s/r%s", SCSIDIR, name);
 	      update_device(scsidev, S_IFCHR, 
 			    match->major, (match->minor | 0x80) );
 	      register_dev(scsidev, match->major, match->minor | 0x80, 
 			   0, 0, 0, 0, 0, 0, match);
 	    }
 
-	  if(    devtype_i == SCSI_DISK_MAJOR
+	  if(    devtype_i == SCSI_DISK0_MAJOR
 		 && match->partition == -1 )
 	    {
 	      /*
@@ -956,7 +1048,7 @@
 		  if( rpnt->hostnum != match->hostnum ) continue;
 		  if (rpnt->hostid != match->hostid ) continue;
 
-		  sprintf(scsidev, "/dev/scsi/%s-p%d", name, 
+		  sprintf(scsidev, "%s/%s-p%d", SCSIDIR, name, 
 			  rpnt->partition);
 		  update_device(scsidev, S_IFBLK, 
 				match->major, rpnt->minor);
@@ -970,168 +1062,113 @@
 	  fprintf(stderr,"Unable to match device for line %d\n", line);
 	}
     }
-
   fclose(configfile);
+  if(buffer) free(buffer);
 }
 
-/*
- * Note that this does the same thing as an inquiry, but
- * it also grabs the serial number too.  Some devices complain
- * if you ask for the serial number, so we have a version with and
- * without.
- */
-int get_serial_number(struct regnames * rpnt)
-{
-#ifdef DEBUG
-  /*
-   * Fill in some entries, just so I can test this on a non-scsi system.
-   */
-  if(rpnt->id == 0 )  rpnt->serial = strdup("DX908FK");
-  else  rpnt->serial = no_serial;
-#else
-  int status, i;
-  unsigned char *cmd;
-  unsigned char * pagestart;
-  unsigned char buffer[1024];
-  char path[64];
-  int infile;
-  struct regnames * rpnt1;
-
-  memset(buffer, 0, sizeof(buffer));
-  
-  *( (int *)  buffer )		= 0;	/* length of input data */
-  *( ((int *) buffer) + 1 )	= 1024;	/* length of output buffer */
-
-  cmd = (char *) ( ((int *) buffer) + 2 );
-  
-  cmd[0] = 0x12;			/* INQUIRY */
-  cmd[1] = 0x01;			/* lun=0, evpd=1 */
-  cmd[2] = 0x80;			/* page code = 0x80, serial number */
-  cmd[3] = 0x00;			/* (reserved) */
-  cmd[4] = 0xff;			/* allocation length */
-  cmd[5] = 0x00;			/* control */
-
-  strcpy(path, "/dev/scsi/");
-  strcat(path, rpnt->name);
-  infile = open(path, O_RDONLY);
-  if( infile == -1 ) return;
-  status = ioctl( infile, 1 /* SCSI_IOCTL_SEND_COMMAND */, buffer );
-  close(infile);
 
-  if(status) rpnt->serial = no_serial;
-
-  pagestart = buffer + 8;
 
-  rpnt->serial = (char *) malloc(pagestart[3] + 1);
-  memcpy(rpnt->serial, pagestart+4, pagestart[3]);
-
-  /*
-   * NULL terminate and trim trailing whitespace.
-   */
-  rpnt->serial[pagestart[3]] = '\0';
-  for(i = pagestart[3] - 1; i >= 0 && rpnt->serial[i] == ' '; i-- )
-      rpnt->serial[i] = '\0';
+/*
+ * Build a SCSIDIR tree that contains the correct device entries.
+ */
 
-  /*
-   * Copy information to identical nodes to avoid excessive probing.
-   */
-  for( rpnt1 = reglist; rpnt1; rpnt1 = rpnt1->next )
-    {
-      if( rpnt1 == rpnt ) continue;
-      if( rpnt1->alias != NULL ) continue;
-      if( rpnt1->id != rpnt->id ) continue;
-      if( rpnt1->chan != rpnt->chan ) continue;
-      if( rpnt1->hostnum != rpnt->hostnum ) continue;
-      if( rpnt1->hostid != rpnt->hostid ) continue;
-      if( rpnt1->serial == NULL ) rpnt1->serial = rpnt->serial;
-    }
-#endif
+void
+usage()
+{
+  fprintf(stderr,"scsidev v1.5\n");
+  fprintf(stderr,"Usage: scsidev [-f] [-l] [-v] [-m mode]\n");
 }
 
-int inquire(struct regnames * rpnt)
+int
+main(int argc, char * argv[])
 {
-#ifdef DEBUG
-  /*
-   * Fill in some entries just so that I can test this.
-   */
-  if(rpnt->id == 0 ) {
-    rpnt->manufacturer = strdup("CONNER");
-    rpnt->model=strdup("CFP4207S");
-  } else if(rpnt->id == 2 ) {
-    rpnt->manufacturer = strdup("HP");
-    rpnt->model=strdup("C4324/C4325");
-  } else if(rpnt->id == 5 ) {
-    rpnt->manufacturer = strdup("WANGTEK");
-    rpnt->model=strdup("5150ES");
-  }
-#else
-  int status, i;
   char c;
-  unsigned char *cmd;
-  unsigned char * pagestart;
-  unsigned char tmp;
-  unsigned char buffer[1024];
-  char path[64];
-  struct regnames * rpnt1;
-  int infile;
-
-  memset(buffer, 0, sizeof(buffer));
-  
-  *( (int *)  buffer )		= 0;	/* length of input data */
-  *( ((int *) buffer) + 1 )	= 1024;	/* length of output buffer */
-
-  cmd = (char *) ( ((int *) buffer) + 2 );
-  
-  cmd[0] = 0x12;			/* INQUIRY */
-  cmd[1] = 0x00;			/* lun=0, evpd=0 */
-  cmd[2] = 0x00;			/* page code = 0 */
-  cmd[3] = 0x00;			/* (reserved) */
-  cmd[4] = 0xff;			/* allocation length */
-  cmd[5] = 0x00;			/* control */
-
-  strcpy(path, "/dev/scsi/");
-  strcat(path, rpnt->name);
-  infile = open(path, O_RDONLY);
-  if( infile == -1 ) return;
-
-  status = ioctl( infile, 1 /* SCSI_IOCTL_SEND_COMMAND */, buffer );
-
-  close(infile);
-
-  if(status) return;
+  int force = 0;
+  int show_serial = 0;
+  struct stat statbuf;
+  struct regnames * rpnt;
+  int status;
 
-  pagestart = buffer + 8;
+  status = stat(SCSIDIR, &statbuf);
+  if(    status == -1
+      || !S_ISDIR(statbuf.st_mode))
+    {
+      fprintf(stderr,"%s either does not exist, or is not a directory\n",
+	      SCSIDIR);
+      exit(0);
+    }
+  while ((c = getopt(argc, argv, "flvsm:")) != EOF)
+    {
+      switch (c)
+	{
+	case 'f':
+	  force = 1;
+	  break;
+	case 'm':
+	  filemode = strtoul(optarg, 0, 0);
+	  break;
+	case 'l':
+	  use_symlink = 1;
+	  break;
+	case 's':
+	  show_serial = 1;
+	  break;
+	case 'v':
+	  verbose++;
+	  break;
+	default:
+	  usage();
+	  exit(1);
+	  break;
+	}
+    }
 
-  for( i = 15; i >= 8 && pagestart[i] == ' '; i-- ) 
-    pagestart[i] = 0;
+  if( force ) flush_sdev();
 
-  c = pagestart[16];
-  pagestart[16] = 0;
-  rpnt->manufacturer = strdup(pagestart+8);
-  pagestart[16] = c;
+#ifdef DEBUG
+  register_dev("/dev/scsi/sdh4-334c0i0l0",   8,  0, 6, 0x334, 0, 0, 0, -1, NULL);
+  register_dev("/dev/scsi/sdh4-334c0i0l0p1", 8,  1, 6, 0x334, 0, 0, 0,  1, NULL);
+  register_dev("/dev/scsi/sdh4-334c0i0l0p2",8,  2,6, 0x334, 0, 0, 0,  2, NULL);
+  register_dev("/dev/scsi/sdh4-334c0i0l0p3",8,  3,6, 0x334, 0, 0, 0,  3, NULL);
+  register_dev("/dev/scsi/sgh4-334c0i0l0", 21,  0,6, 0x334, 0, 0, 0, -1, NULL);
+  register_dev("/dev/scsi/sgh4-334c0i2l0", 21,  1,6, 0x334, 0, 2, 0, -1, NULL);
+  register_dev("/dev/scsi/sgh4-334c0i5l0", 21,  2,6, 0x334, 0, 5, 0, -1, NULL);
+  register_dev("/dev/scsi/srh4-334c0i2l0", 11,  0,6, 0x334, 0, 2, 0, -1, NULL);
+  register_dev("/dev/scsi/sth4-334c0i5l0",  9,  0,6, 0x334, 0, 5, 0, -1, NULL);
+  register_dev("/dev/scsi/rsth4-334c0i5l0", 9,128,6, 0x334, 0, 5, 0, -1, NULL);
+#else
+  build_sdev(SCSI_DISK0_MAJOR,    O_RDONLY, S_IFBLK, 'd');
+  build_sdev(SCSI_CDROM_MAJOR,   O_RDONLY, S_IFBLK, 'r');
+  build_sdev(SCSI_TAPE_MAJOR,    O_RDONLY, S_IFCHR, 't');
+  build_sdev(SCSI_GENERIC_MAJOR, O_RDWR,   S_IFCHR, 'g');
+#endif
 
-  for( i = 31; i >= 16 && pagestart[i] == ' '; i-- ) 
-    pagestart[i] = 0;
-  c = pagestart[32];
-  pagestart[32] = 0;
-  rpnt->model = strdup(pagestart+16);
-  pagestart[32] = c;
+  if( show_serial )
+    {
+      for (rpnt = reglist; rpnt; rpnt = rpnt->next)
+	{
+	  if( rpnt->partition != -1 ) continue;
+	  if( rpnt->major == SCSI_TAPE_MAJOR
+	      && (rpnt->minor & 0x80) != 0 ) continue;
 
+	  if( rpnt->serial == NULL )  get_serial_number(rpnt);
+	  if( rpnt->serial == no_serial )
+	    printf("Device  %s has no serial number\n", rpnt->name);
+	  else
+	    printf("Serial number of %s: \"%s\"\n", rpnt->name, rpnt->serial);
+	}
+    }
   /*
-   * Copy information to identical nodes to avoid excessive probing.
+   * Now, read the configuration file and see whether there
+   * are any special device names we want to try and match.
    */
-  for( rpnt1 = reglist; rpnt1; rpnt1 = rpnt1->next )
+  build_special();
+
+  if( !force )
     {
-      if( rpnt1 == rpnt ) continue;
-      if( rpnt1->alias != NULL ) continue;
-      if( rpnt1->id != rpnt->id ) continue;
-      if( rpnt1->chan != rpnt->chan ) continue;
-      if( rpnt1->hostnum != rpnt->hostnum ) continue;
-      if( rpnt1->hostid != rpnt->hostid ) continue;
-      if( rpnt1->manufacturer == NULL ) 
-	rpnt1->manufacturer = rpnt->manufacturer;
-      if( rpnt1->model == NULL ) rpnt1->model = rpnt->model;
+      sanitize_sdev();
     }
-  return;
-#endif
+
+  return 0;
 }
+
--- hwtools-0.5.orig/scsiinfo/Makefile
+++ hwtools-0.5/scsiinfo/Makefile
@@ -1,11 +1,11 @@
-CFLAGS=-O2 -fomit-frame-pointer -Wall -fno-strength-reduce
+CFLAGS=${KERNEL_INCLUDES} -g -O2 -Wall -fomit-frame-pointer -fno-strength-reduce -D_GNU_SOURCE
 #CFLAGS=-g -Wall -fno-strength-reduce
 LDFLAGS=-s
 
 #do not modify this without changing the tcl/tk scripts
 
-BINDIR=/usr/lib/scsi
-MANDIR=/usr/man
+BINDIR=$(DESTDIR)/usr/lib/scsi
+MANDIR=$(DESTDIR)/usr/share/man
 WISHEXECS=tk/cache tk/control tk/disconnect tk/error tk/format\
 	tk/inquiry tk/notch tk/peripheral tk/rigid tk/save-changes tk/verify\
 	tk/save-file tk/overview
@@ -16,11 +16,12 @@
 all: $(TARGETS)
 
 install: $(TARGETS) $(WISHEXECS) scsi-config tk_scsiformat
-	cp scsiinfo scsiformat /usr/bin
-	if [ ! -d $(BINDIR) ]; then mkdir -p $(BINDIR); fi
+	test -d $(DESTDIR)/usr/sbin || mkdir -p $(DESTDIR)/usr/sbin
+	test -d $(BINDIR) || mkdir -p $(BINDIR)
+	cp scsiinfo scsiformat $(DESTDIR)/usr/sbin
 	cp tworands $(BINDIR)
-	install-wish $(BINDIR) $(WISHEXECS)
-	install-wish /usr/bin scsi-config tk_scsiformat
+	./install-wish $(BINDIR) $(WISHEXECS)
+	./install-wish $(DESTDIR)/usr/sbin scsi-config tk_scsiformat
 	cp tk/generic $(BINDIR)
 	cp man8/* $(MANDIR)/man8
 
--- hwtools-0.5.orig/scsiinfo/scsi-config
+++ hwtools-0.5/scsiinfo/scsi-config
@@ -42,11 +42,11 @@
     pack .select.h.l .select.h.m -side left -padx 10
     pack .select.h .select.f -pady 10
     pack .select
-    exec /usr/bin/scsiinfo -l > /tmp/devices
-    if {[catch {set file [open /tmp/devices r]}] == 1} return;
+    exec /usr/sbin/scsiinfo -l > /var/run/devices
+    if {[catch {set file [open /var/run/devices r]}] == 1} return;
     gets $file line
     close $file
-    exec rm /tmp/devices
+    exec rm /var/run/devices
     set n 0
     foreach x $line { 
        radiobutton .select.$n -text "$x" -width 10   -variable sdevice -value $x -anchor w
@@ -102,7 +102,7 @@
 	.defects.f.msg delete 1.0 end
 	raise .defects
    }
-   catch {exec /usr/bin/scsiinfo -d $flag $sdevice} results
+   catch {exec /usr/sbin/scsiinfo -d $flag $sdevice} results
    .defects.f.msg insert end "$results"
    tkwait window .defects
 }
@@ -117,14 +117,14 @@
 frame .f_top
 
 set line {}
-exec /usr/bin/scsiinfo -X -L $sdevice > /tmp/cachepage
-if {[catch {set file [open /tmp/cachepage r]}] == 1} return;
+exec /usr/sbin/scsiinfo -X -L $sdevice > /var/run/cachepage
+if {[catch {set file [open /var/run/cachepage r]}] == 1} return;
 gets $file line
 set pages_sup [lindex $line 0]
 set pages_notch [lindex $line 1]
 set curr_not [lindex $line 2]
 close $file
-exec rm /tmp/cachepage
+exec rm /var/run/cachepage
 
 button .f_top.info -text "Device Info" -command "exec /usr/lib/scsi/inquiry $sdevice" \
 	-activebackground green
@@ -202,12 +202,12 @@
 
   exec /usr/lib/scsi/notch $sdevice
   set line {}
-  exec /usr/bin/scsiinfo -X -L $sdevice > /tmp/cachepage
-  if {[catch {set file [open /tmp/cachepage r]}] == 1} return;
+  exec /usr/sbin/scsiinfo -X -L $sdevice > /var/run/cachepage
+  if {[catch {set file [open /var/run/cachepage r]}] == 1} return;
   gets $file line
   set curr_not [lindex $line 2]
   close $file
-  exec rm /tmp/cachepage
+  exec rm /var/run/cachepage
   .notchinfo.notchnum configure -text $curr_not
 }
 
--- hwtools-0.5.orig/scsiinfo/scsiinfo.c
+++ hwtools-0.5/scsiinfo/scsiinfo.c
@@ -500,7 +500,7 @@
     unsigned char *pagestart;
 
     if (save_mode)
-	printf("/usr/bin/scsiinfo -gXR %s ", device_name);
+	printf("scsiinfo -gXR %s ", device_name);
 
     SETUP_MODE_PAGE(4, 9);
 
@@ -532,7 +532,7 @@
     unsigned char *pagestart;
 
     if (save_mode)
-	printf("/usr/bin/scsiinfo -DXR %s ", device_name);
+	printf("scsiinfo -DXR %s ", device_name);
 
     SETUP_MODE_PAGE(2, 7);
 
@@ -562,7 +562,7 @@
     unsigned char *pagestart;
 
     if (save_mode)
-	printf("/usr/bin/scsiinfo -CXR %s ", device_name);
+	printf("scsiinfo -CXR %s ", device_name);
 
     SETUP_MODE_PAGE(10, 9);
 
@@ -594,7 +594,7 @@
     unsigned char *pagestart;
 
     if (save_mode)
-	printf("/usr/bin/scsiinfo -eXR %s ", device_name);
+	printf("scsiinfo -eXR %s ", device_name);
 
     SETUP_MODE_PAGE(1, 14);
     if (!x_interface && !replace) {
@@ -629,7 +629,7 @@
     unsigned char *pagestart;
 
     if (save_mode)
-	printf("/usr/bin/scsiinfo -nXR %s ", device_name);
+	printf("scsiinfo -nXR %s ", device_name);
 
     SETUP_MODE_PAGE(0xc, 7);
 
@@ -770,7 +770,7 @@
     unsigned char *pagestart;
 
     if (save_mode)
-	printf("/usr/bin/scsiinfo -cXR %s ", device_name);
+	printf("scsiinfo -cXR %s ", device_name);
 
     SETUP_MODE_PAGE(8, 9);
 
@@ -801,7 +801,7 @@
     unsigned char *pagestart;
 
     if (save_mode)
-	printf("/usr/bin/scsiinfo -fXR %s ", device_name);
+	printf("scsiinfo -fXR %s ", device_name);
 
     SETUP_MODE_PAGE(3, 13);
 
@@ -837,7 +837,7 @@
     unsigned char *pagestart;
 
     if (save_mode)
-	printf("/usr/bin/scsiinfo -VXR %s ", device_name);
+	printf("scsiinfo -VXR %s ", device_name);
 
     SETUP_MODE_PAGE(7, 7);
 
@@ -877,7 +877,7 @@
     char *name;
 
     if (save_mode)
-	printf("/usr/bin/scsiinfo -pXR %s ", device_name);
+	printf("scsiinfo -pXR %s ", device_name);
 
     SETUP_MODE_PAGE(9, 2);
 
@@ -1064,8 +1064,8 @@
     unsigned char *pagestart;
 
     if (save_mode) {
-	printf("set -- `/usr/bin/scsiinfo -nX %s`\n", device_name);
-	printf("/usr/bin/scsiinfo -nXR %s $1 $2 $3 %d $5 $6 $7\n", device_name, notch);
+	printf("set -- `scsiinfo -nX %s`\n", device_name);
+	printf("scsiinfo -nXR %s $1 $2 $3 %d $5 $6 $7\n", device_name, notch);
     }
     SETUP_MODE_PAGE(0xc, 0);
     putnbyte(pagestart + 6, notch, 2);
--- hwtools-0.5.orig/scsiinfo/tk/inquiry
+++ hwtools-0.5/scsiinfo/tk/inquiry
@@ -154,8 +154,8 @@
     global text_list
     global switch
     set line {}
-    exec /usr/bin/scsiinfo -X $switch $option $device > /tmp/cachepage
-    if {[catch {set file [open /tmp/cachepage r]}] == 1} return;
+    exec /usr/sbin/scsiinfo -X $switch $option $device > /var/run/cachepage
+    if {[catch {set file [open /var/run/cachepage r]}] == 1} return;
     gets $file line
     set first [lindex $line 0]
     set second [lindex $line 1]
@@ -185,7 +185,7 @@
     .revision.text insert end $line
     .revision.text configure -state disabled
     close $file
-    exec rm /tmp/cachepage
+    exec rm /var/run/cachepage
 }
 
 read_page $argv "-X"
--- hwtools-0.5.orig/scsiinfo/tk/generic
+++ hwtools-0.5/scsiinfo/tk/generic
@@ -48,11 +48,11 @@
     global text_list
     global switch
     set line {}
-    exec /usr/bin/scsiinfo -X $switch $option $device > /tmp/cachepage 2> /dev/null
-    if {[catch {set file [open /tmp/cachepage r]}] == 1} return;
+    exec /usr/sbin/scsiinfo -X $switch $option $device > /var/run/cachepage 2> /dev/null
+    if {[catch {set file [open /var/run/cachepage r]}] == 1} return;
     gets $file line
     close $file
-    exec rm /tmp/cachepage
+    exec rm /var/run/cachepage
     set first [lindex $line 0]
     set second [lindex $line 1]
     set lineno 0
@@ -73,11 +73,11 @@
     global text_list
     global switch
     set line {}
-    exec /usr/bin/scsiinfo -X -m $switch $device > /tmp/cachepage
-    if {[catch {set file [open /tmp/cachepage r]}] == 1} return;
+    exec /usr/sbin/scsiinfo -X -m $switch $device > /var/run/cachepage
+    if {[catch {set file [open /var/run/cachepage r]}] == 1} return;
     gets $file line
     close $file
-    exec rm /tmp/cachepage
+    exec rm /var/run/cachepage
     set lineno 0
     foreach x $button_list { 
         if { [ string compare [lindex $line $lineno] "0" ] == 0} then { .$x configure -state disabled }
@@ -109,10 +109,10 @@
 	set r3 [concat $r3 [.$x.text get 1.0 end]]
         set lineno [expr $lineno+1]
     }
-    set file [open /tmp/wrscsi w]
-    puts $file "/usr/bin/scsiinfo $r3"
+    set file [open /var/run/wrscsi w]
+    puts $file "/usr/sbin/scsiinfo $r3"
     close $file
-    exec sh < /tmp/wrscsi
-    exec rm /tmp/wrscsi
+    exec sh < /var/run/wrscsi
+    exec rm /var/run/wrscsi
 }
 
--- hwtools-0.5.orig/scsiinfo/tk/save-changes
+++ hwtools-0.5/scsiinfo/tk/save-changes
@@ -21,6 +21,6 @@
 
 # This should do it.  Do not come and complain to me if this
 # does not work
-exec /usr/bin/scsiinfo -R -S -X $argv 
+exec /usr/sbin/scsiinfo -R -S -X $argv 
 exit
 
--- hwtools-0.5.orig/scsiinfo/tk/peripheral
+++ hwtools-0.5/scsiinfo/tk/peripheral
@@ -29,12 +29,12 @@
     global text_list
     global switch
     set line {}
-    exec /usr/bin/scsiinfo -X $switch $option $device > /tmp/cachepage 2> /dev/null
-    if {[catch {set file [open /tmp/cachepage r]}] == 1} return;
+    exec /usr/sbin/scsiinfo -X $switch $option $device > /var/run/cachepage 2> /dev/null
+    if {[catch {set file [open /var/run/cachepage r]}] == 1} return;
     gets $file line
     gets $file asciidesc
     close $file
-    exec rm /tmp/cachepage
+    exec rm /var/run/cachepage
 
     .ident.text delete 1.0 end
     .ident.text insert end [lindex $line 0]
@@ -51,11 +51,11 @@
     global text_list
     global switch
     set line {}
-    exec /usr/bin/scsiinfo -X -m $switch $device > /tmp/cachepage
-    if {[catch {set file [open /tmp/cachepage r]}] == 1} return;
+    exec /usr/sbin/scsiinfo -X -m $switch $device > /var/run/cachepage
+    if {[catch {set file [open /var/run/cachepage r]}] == 1} return;
     gets $file line
     close $file
-    exec rm /tmp/cachepage
+    exec rm /var/run/cachepage
 
     if { [ string compare [lindex $line 0] "0" ] == 0} \
       then { .ident.text configure -state disabled } \
@@ -82,11 +82,11 @@
     set r3 [concat $r3 @[.vendor.text get 1.0 end]]
 
 
-    set file [open /tmp/wrscsi w]
-    puts $file "/usr/bin/scsiinfo $r3"
+    set file [open /var/run/wrscsi w]
+    puts $file "/usr/sbin/scsiinfo $r3"
     close $file
-    exec sh < /tmp/wrscsi
-    exec rm /tmp/wrscsi
+    exec sh < /var/run/wrscsi
+    exec rm /var/run/wrscsi
 }
 
 
--- hwtools-0.5.orig/scsiinfo/tk/save-file
+++ hwtools-0.5/scsiinfo/tk/save-file
@@ -23,7 +23,7 @@
 set base [exec basename $sdevice]
 
 .win.fname.text delete 1.0 end
-.win.fname.text insert end "/tmp/scsi-config.$base"
+.win.fname.text insert end "/var/run/scsi-config.$base"
 
 frame .win.f
 radiobutton .win.cur -text "Current values" -width 20 -variable flag -value "-LXR" -anchor w
@@ -36,7 +36,7 @@
 	-activebackground red -activeforeground white
 button .win.f.continue -width 10 -text "Save" \
 	-activebackground green \
-	-command {global fname; set fname [.win.fname.text get 1.0 end]; destroy .win}
+	-command {global fname; set fname [.win.fname.text get 1.0 "end -1 chars"]; destroy .win}
 pack .win.f.continue .win.f.quit -side left -padx 30 -ipadx 2 -ipady 2
 pack .win.f -pady 10
 pack .win
--- hwtools-0.5.orig/scsiinfo/scsiformat.c
+++ hwtools-0.5/scsiinfo/scsiformat.c
@@ -45,8 +45,8 @@
 #include <sys/wait.h>
 #include <sys/stat.h>
 #include <sys/ioctl.h>
-#include <linux/swap.h>
-#include <linux/fs.h>
+#include <sys/swap.h>
+#include <sys/mount.h>
 #include <linux/hdreg.h>
 #include <linux/genhd.h>
 
@@ -67,7 +67,7 @@
 
 pid_t child = -1;
 time_t start;
-char tmpfname[] = "/tmp/scsiformat.XX:XX:XX:XX:XXXXXXXX";
+char tmpfname[] = "/var/run/scsiformat.XX:XX:XX:XX:XXXXXXXX";
 char *devicename, *linebuf, *givendevice;
 long scsiunid[2];
 
@@ -527,7 +527,7 @@
 	  "		will need about n seconds and provides some progress indication\n"
 	  "		according to that. -b0 does not print any process indication.\n"
 	  "	-T	just test for a running format command and output statistics.\n"
-	  "		A file /tmp/scsiformat.* is used to hold the starting time of\n"
+	  "		A file /var/run/scsiformat.* is used to hold the starting time of\n"
 	  "		the format operation. If formatting completes, this file is\n"
 	  "		removed by scsiformat. The exit state is true as long as\n"
 	  "		the format operation is still in progress.\n"
@@ -736,7 +736,7 @@
 	if (!par_deflistform) {
 	    fprintf(fh, "\nUser supplied defect logical blocks:\n");
 	    for (i = off = 0; off < par_defectlen; i++, off += 4) {
-		fprintf(fh, " %9lu", ntohl(par_defects[i]));
+		fprintf(fh, " %9u", ntohl(par_defects[i]));
 		if ((i & 7) == 7) {
 		    fprintf(fh, "\n");
 		    flag = 1;
@@ -747,7 +747,7 @@
 	    fprintf(fh, "\nUser supplied defects in Cylinder:Head:%s format:\n",
 	     par_deflistform == 5 ? "PhysicalSector" : "BytesFromIndex");
 	    for (i = off = 0; off < par_defectlen; i += 2, off += 8) {
-		sprintf(buffer, " %lu:%lu:%ld", ntohl(par_defects[i]) >> 8,
+		sprintf(buffer, " %u:%u:%ld", ntohl(par_defects[i]) >> 8,
 			ntohl(par_defects[i]) & 255, (long) ntohl(par_defects[i + 1]));
 		fprintf(fh, "%20s", buffer);
 		if ((i & 3) == 3) {
--- hwtools-0.5.orig/scsiinfo/tk_scsiformat
+++ hwtools-0.5/scsiinfo/tk_scsiformat
@@ -802,7 +802,7 @@
    pack .conf.f_bot -side top -padx 15
    pack .conf.dismiss -side top -pady 10
 
-   set format_cmd "/usr/bin/scsiformat $par_erase -i$par_inter"
+   set format_cmd "/usr/sbin/scsiformat $par_erase -i$par_inter"
 
    regsub -all "\x0a" [string trim $par_defects] " " tmpstr
    regsub -all " +" $tmpstr "," tmpstr
@@ -874,15 +874,15 @@
    set security "-F'Ene Mene Meck, und Du bist weg!'"
    append fcmd " $security -t0 -X $sdevice"
    
-   if { [catch {exec sh -c "$fcmd" >& /tmp/scsiformat.[pid] } err] != 0 } then {
-        set fd [open /tmp/scsiformat.[pid] r]
+   if { [catch {exec sh -c "$fcmd" >& /var/run/scsiformat.[pid] } err] != 0 } then {
+        set fd [open /var/run/scsiformat.[pid] r]
 	set err "$err\x0a[read $fd]"
 	close $fd
-        exec rm /tmp/scsiformat.[pid]
+        exec rm /var/run/scsiformat.[pid]
 	show_err scsiformat $err
 	return;
    }
-   exec rm /tmp/scsiformat.[pid]
+   exec rm /var/run/scsiformat.[pid]
    set format_initiator 1
    show_busy
 }
@@ -928,7 +928,7 @@
 proc query_prog {} {
    global sdevice errorCode wasbusy format_initiator par_mkfs
 
-   set check_cmd "/usr/bin/scsiformat -T -t1 -X $sdevice"
+   set check_cmd "/usr/sbin/scsiformat -T -t1 -X $sdevice"
 
    if { [winfo exists .showprog] != 1 } {
 	return;
@@ -1075,7 +1075,7 @@
     pack .select.h.l .select.h.m -side left -padx 10
     pack .select.h -pady 10
     pack .select
-    set line [exec /usr/bin/scsiinfo -l]
+    set line [exec /usr/sbin/scsiinfo -l]
     set n 0
     foreach x $line { 
         if {[string first "/dev/sd" "$x"] != 0} continue;
--- hwtools-0.5.orig/sraw/srawread.c
+++ hwtools-0.5/sraw/srawread.c
@@ -89,6 +89,8 @@
 #include <unistd.h>
 #include <sys/times.h>
 #include <linux/hdreg.h>
+#include <stdlib.h>
+#include <sys/ioctl.h>
 
 FILE *infile, *ptable;
 unsigned char buffer[2*64*1024];
