aboutsummaryrefslogtreecommitdiff
path: root/archive
diff options
context:
space:
mode:
authorDouglas Gilbert <dgilbert@interlog.com>2007-06-27 02:46:06 +0000
committerDouglas Gilbert <dgilbert@interlog.com>2007-06-27 02:46:06 +0000
commit89097cc5ea7f227cefe5a32806b6c13f849b92d3 (patch)
tree17bedfd4269141b7ff9656a1ffefa966a1a9be15 /archive
parentf078b30e604ad74f9925f6cababa1198d4bab381 (diff)
downloadsg3_utils-89097cc5ea7f227cefe5a32806b6c13f849b92d3.tar.gz
Load sg3_utils-0.99 into trunk/.
git-svn-id: https://svn.bingwo.ca/repos/sg3_utils/trunk@23 6180dd3e-e324-4e3e-922d-17de1ae2f315
Diffstat (limited to 'archive')
-rw-r--r--archive/README5
-rwxr-xr-xarchive/rescan-scsi-bus.sh101
-rw-r--r--archive/sgq_dd.c8
3 files changed, 109 insertions, 5 deletions
diff --git a/archive/README b/archive/README
index d6d6c205..dcb0b51f 100644
--- a/archive/README
+++ b/archive/README
@@ -22,6 +22,9 @@ been set up which builds:
The sg_err.h and llseek.h headers have simply been copied from the parent
directory.
+The very useful rescan-scsi-bus.sh script from Kurt Garloff<kurt@garloff.de>
+is included in this directory.
+
A test program called sg_bus_xfer.c exercises a patch that adds a
SG_FLAG_BUS_ADDR capability. This allows a bus address (e.g. PCI
video card's frame buffer) to be passed through to a SCSI adapter
@@ -29,4 +32,4 @@ to side step various buffer copies. See:
http://www.torque.net/sg/mem2disk.html
Doug Gilbert
-24th January 2002
+27th February 2002
diff --git a/archive/rescan-scsi-bus.sh b/archive/rescan-scsi-bus.sh
new file mode 100755
index 00000000..755bdadb
--- /dev/null
+++ b/archive/rescan-scsi-bus.sh
@@ -0,0 +1,101 @@
+#!/bin/bash
+# Skript to rescan SCSI bus, using the
+# scsi add-single-device mechanism
+# (w) 98/03/19 Kurt Garloff <kurt@garloff.de> (c) GNU GPL
+
+# Return hosts. /proc/scsi/HOSTADAPTER/? must exist
+findhosts ()
+{
+ hosts=
+ for name in /proc/scsi/*/?; do
+ name=${name#/proc/scsi/}
+ if test ! $name = scsi
+ then hosts="$hosts ${name#*/}"
+ echo "Host adapter ${name#*/} (${name%/*}) found."
+ fi
+ done
+}
+
+# Test if SCSI device $host $channen $id $lun exists
+# Outputs description from /proc/scsi/scsi, returns new
+testexist ()
+{
+ grepstr="scsi$host Channel: 0$channel Id: 0*$id Lun: 0$lun"
+ new=`cat /proc/scsi/scsi|grep -e"$grepstr"`
+ if test ! -z "$new"
+ then cat /proc/scsi/scsi|grep -e"$grepstr"
+ cat /proc/scsi/scsi|grep -A2 -e"$grepstr"|tail -2|pr -o4 -l1
+ fi
+}
+
+# Perform search (scan $host)
+dosearch ()
+{
+ for channel in $channelsearch; do
+ for id in $idsearch; do
+ for lun in $lunsearch; do
+ new=
+ devnr="$host $channel $id $lun"
+ echo "Scanning for device $devnr ..."
+ printf "OLD: "
+ testexist
+ if test ! -z "$remove" -a ! -z "$new"
+ then echo "scsi remove-single-device $devnr" >/proc/scsi/scsi
+ echo "scsi add-single-device $devnr" >/proc/scsi/scsi
+ printf "\r\x1b[A\x1b[A\x1b[AOLD: "
+ testexist
+ if test -z "$new"; then printf "\rDEL: \r\n\n\n\n"; let rmvd+=1; fi
+ fi
+ if test -z "$new"
+ then printf "\rNEW: "
+ echo "scsi add-single-device $devnr" >/proc/scsi/scsi
+ testexist
+ if test -z "$new"; then printf "\r\x1b[A"; else let found+=1; fi
+ fi
+ done
+ done
+ done
+}
+
+
+# main
+if test @$1 = @--help -o @$1 = @-h
+ then
+ echo "Usage: rescan-scsi-bus.sh [-l] [-w] [-c] [host [host ...]]"
+ echo " -l activates scanning for LUNs 0 .. 7 [default: 0]"
+ echo " -w enables scanning for device IDs 0 .. 15 [def.: 0 .. 7]"
+ echo " -r enables removing of devices [default: disabled]"
+ echo " -c enables scanning of channels 0 1 [default: 0]"
+ echo " If hosts are given, only these are scanned [default: all]"
+ exit 0
+fi
+
+# defaults
+lunsearch="0"
+idsearch="0 1 2 3 4 5 6 7"
+channelsearch="0"
+remove=""
+
+# Scan options
+opt="$1"
+while test ! -z "$opt" -a -z "${opt##-*}"; do
+ opt=${opt#-}
+ case "$opt" in
+ l) lunsearch="0 1 2 3 4 5 6 7" ;;
+ w) idsearch="0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15" ;;
+ c) channelsearch="0 1" ;;
+ r) remove=1 ;;
+ *) echo "Unknown option -$opt !" ;;
+ esac
+ shift
+ opt="$1"
+done
+
+# Hosts given ?
+if test @$1 = @; then findhosts; else hosts=$*; fi
+
+declare -i found=0
+declare -i rmvd=0
+for host in $hosts; do dosearch; done
+echo "$found new device(s) found. "
+echo "$rmvd device(s) removed. "
diff --git a/archive/sgq_dd.c b/archive/sgq_dd.c
index 7a8a09d7..17be0f43 100644
--- a/archive/sgq_dd.c
+++ b/archive/sgq_dd.c
@@ -48,7 +48,7 @@ typedef unsigned char u_char; /* horrible, for scsi.h */
*/
-static char * version_str = "0.53 20020124";
+static char * version_str = "0.54 20020223";
#define DEF_BLOCK_SIZE 512
#define DEF_BLOCKS_PER_TRANSFER 128
@@ -740,11 +740,11 @@ int main(int argc, char * argv[])
int seek = 0;
int ibs = 0;
int obs = 0;
- char str[512];
+ char str[STR_SZ];
char * key;
char * buf;
- char inf[512];
- char outf[512];
+ char inf[INOUTF_SZ];
+ char outf[INOUTF_SZ];
int res, k;
int in_num_sect = 0;
int out_num_sect = 0;