SUMMARY 10MB/s SCSI-2?

From: Hwa, Michael SSC (Hwa@ssc.sscnet.ucla.edu)
Date: Wed May 18 1994 - 15:26:00 CDT


My original question:
>We have just installed a fast SCSI-2 controller and the disk on our system,
>but I'm not sure if it's really running at its full speed. There is only one
>disk on this Sun's FSBE controller card by the way. So, is there any utility
>or anything can tell me what's the speed it's running? Thanks in advance.
>-Michael Hwa
> hwa@nicco.sscnet.ucla.edu
>

"bonnie" and "iozone" comprise one general means of checking.
Dan Stromberg - OAC/DCS strombrg@uci.edu

scsiinfo ... I think it is at ftp.toronto.edu ...
| Syed Zaeem Hosain P. O. Box 610097 (408) 441-7021 |
| Z Consulting Group San Jose, CA 95161 szh@zcon.com |

Yup, scsiinfo from ftp.cdf.toronto.edu:/pub/scsiinfo/scsiinfo-2.3.shar.gz
John DiMarco jdd@cdf.toronto.edu
Computing Disciplines Facility Systems Manager jdd@cdf.utoronto.ca
University of Toronto EA201B,(416)978-1928

Get scsiinfo from ftp.cdf.toronto.edu:/pub/scsiinfo/scsiinfo-3.1.shar. It
will tell you how fast your controllers and disks are.
Rich Schultz
rich@ccrwest.org

Here's a copy of scsiinfo. I just ran it on my machine and got:
% scsiinfo
esp0: sr0 tgt 6 lun 0:
        Asynchronous Clean CanReconnect
esp0: sd1 tgt 1 lun 0:
        Synchronous(4.445MB/sec) Clean CanReconnect
esp0: sd0 tgt 3 lun 0:
        Synchronous(5.0MB/sec) Clean CanReconnect
Jay Lessert jayl@lattice.com
Lattice Semiconductor Corp. (voice)1.503.681.0118
Hillsboro, OR, USA (fax)1.503.693.0540

======================================================================
#! /bin/sh
# This is a shell archive. Remove anything before this line, then unpack
# it by saving it into a file and typing "sh file". To overwrite existing
# files, type "sh file -c". You can also feed this as standard input via
# unshar, or by typing "sh <file", e.g.. If this archive is complete, you
# will see the following message at the end:
# "End of shell archive."
# Contents: COPYRIGHT MANIFEST README patchlevel.h Makefile scsiinfo.1
# scsiinfo.c utils.c utils.h uscsi.h uscsi.c sunos4.h sunos5.h
# sundev sundev/dmaga.h format.c format.h
# Wrapped by jdd@dev.cdf on Tue Jan 11 11:10:35 1994
PATH=/bin:/usr/bin:/usr/ucb ; export PATH
if test -f 'COPYRIGHT' -a "${1}" != "-c" ; then
  echo shar: Will not clobber existing file \"'COPYRIGHT'\"
else
echo shar: Extracting \"'COPYRIGHT'\" \(911 characters\)
sed "s/^X//" >'COPYRIGHT' <<'END_OF_FILE'
X/*
X * Copyright University of Toronto 1993.
X * Written by John DiMarco
X *
X * Permission is granted to anyone to use this software for any purpose on
X * any computer system, and to alter it and redistribute it freely, subject
X * to the following restrictions:
X *
X * 1. The author and the University of Toronto are not responsible
X * for the consequences of use of this software, no matter how awful,
X * even if they arise from flaws in it.
X *
X * 2. The origin of this software must not be misrepresented, either by
X * explicit claim or by omission. Since few users ever read sources,
X * credits must appear in the documentation.
X *
X * 3. Altered versions must be plainly marked as such, and must not be
X * misrepresented as being the original software. Since few users
X * ever read sources, credits must appear in the documentation.
X *
X * 4. This notice may not be removed or altered.
X */
END_OF_FILE
if test 911 -ne `wc -c <'COPYRIGHT'`; then
    echo shar: \"'COPYRIGHT'\" unpacked with wrong size!
fi
# end of 'COPYRIGHT'
fi
if test -f 'MANIFEST' -a "${1}" != "-c" ; then
  echo shar: Will not clobber existing file \"'MANIFEST'\"
else
echo shar: Extracting \"'MANIFEST'\" \(493 characters\)
sed "s/^X//" >'MANIFEST' <<'END_OF_FILE'
XCOPYRIGHT Copyright notice
XMANIFEST This file
XMakefile makefile
XREADME Read this file first
Xpatchlevel.h Patch level/version
Xscsiinfo.1 scsiinfo manual page
Xscsiinfo.c scsiinfo main source
Xsunos4.h SunOS 4.1.x dependent code
Xsunos5.h SunOS 5.x dependent code
Xuscsi.c User SCSI routines
Xuscsi.h header file for uscsi.c
Xutils.c misc utilities
Xutils.h header file for utils.c
Xsundev/dmaga.h Empty file to fool cpp
Xformat.c Format informat
Xformat.h header file for format.c
END_OF_FILE
if test 493 -ne `wc -c <'MANIFEST'`; then
    echo shar: \"'MANIFEST'\" unpacked with wrong size!
fi
# end of 'MANIFEST'
fi
if test -f 'README' -a "${1}" != "-c" ; then
  echo shar: Will not clobber existing file \"'README'\"
else
echo shar: Extracting \"'README'\" \(4987 characters\)
sed "s/^X//" >'README' <<'END_OF_FILE'
XDecember 21, 1993
X
XSCSIINFO displays information about SCSI devices attached to a given
Xsystem, as seen by the Sun ESP device driver. For each target known to the
XSCSI host adapter, scsinfo reports whether it is synchronous or
Xasynchronous, whether or not the tranfers to/from the target are clean or
Xsusceptible to noise, and whether or not the target can disconnect and
Xreconnect. When a target supports synchronous transfer, the negotiated maximu
m
Xtransfer rate (in MB/sec) is reported.
X
XIn version 3.0 and up, scsiinfo supports querying SCSI disks for geometry and
Xformatting information, and optionally generates a format.dat entry based
Xon these values.
X
XIn version 2.0 and up, scsinfo supports querying SCSI devices for vendor,
Xproduct, and revision information, in the style of the Openboot prom's
Xprobe-scsi and probe-scsi-all.
X
XSCSI Notes:
X
XThe negotiated maxiumum synchronous transfer rate normally will be the
Xlesser of the maximum rate supported by the adapter and the maximum rate
Xsupported by the device, but it can be lower than this under various
Xcircumstances. This rate is typically negotiated at reboot (SunOS 4.1 and
X4.1.1 report it for each synchronous device), but it can also be
Xrenegotiated during operations if necessary.
X
XSCSIINFO notes:
X - tested on SunOS 4.1.1 through 4.1.3, SunOS 5.2 and 5.3.
X - "-s" option most useful for SunOS 4.1.2 and above, since in
X these versions of the OS, the SCSI driver no longer reports the
X transfer rates it negotiates with synchronous SCSI devices on boot.
X - Does nothing on suns without ESP host adapters or without openboot
X prom support.
X - Supports multiple ESP host adapters
X - Scsiinfo needs to be recompiled on any (even minor) OS releases tha
t
X changed the format of the esp structure. For example, a 4.1.1
X binary will not work on 4.1.2 or 4.1.3.
X - Scsiinfo can only probe a SCSI device when the following conditions
X are met:
X - the device's device-driver supports user-mode SCSI commands
.
X - scsiinfo can find the device's character special file.
X - the character special file is readable.
X - nothing has an exclusive open on the character special file
.
X Sun's tape driver doesn't support user-mode SCSI commands. Sun's
X disk drivers do. Sun's CD-ROM driver only does when there is
X valid media in the drive. In Solaris 2.2 or greater, /usr/sbin/vold
,
X if it is running, may hold an exclusive open on the CD-ROM device,
X preventing a probe from succeeding. If scsiinfo cannot probe a driv
e,
X it returns a message saying why the probe failed.
X - The format.dat entries generated by SCSIINFO are certainly not
X perfect. Firstly, SCSIINFO just guesses at the bpt figure (bpt =
X bits per track), because there's no standard way of querying the
X drive for this figure. Secondly, some drives are overly optimistic
X in their estimation of the number of blocks available; if a
X format.dat entry runs into problems, try reducing ncyl until it
X works. Finally, some drives simply don't return a valid rpm figure;
X if this is the case, SCSIINFO will report an error and make a
X guess of 3600rpm, which may not be correct.
X
XInstallation:
X 1. Edit the Makefile to taste.
X 2. Compile.
X 3. scsiinfo needs to be able to read /dev/kmem. For use by users
X without read permissions on /dev/kmem, it can be made setgid
X kmem or setgid sys. "make install" will install it setgid kmem.
X 4. If SCSI probing (scsiinfo -p) or drive format querying (scsiinfo
X -f or -F) is to work for a given device, scsiinfo will need to
X be able to access the device via a raw/character device file in
X /dev (or /devices/... in Solaris 2.x).
X 5. When probing for disks, scsiinfo attempts to access the raw
X device for the third ("c") partition. This device file must be
X readable! If users other than root are to use SCSI probing,
X scsiinfo can be installed setuid root (or setgroupid or setuid to
X a group or user that can read the devices, like "operator").
X
XPorting notes:
X - It will be almost impossible to port to 4.0.x without source, sin
ce
X there are no suitable include files.
X - The esp driver has tended to change quite a bit between releases;
X the code is written to be as portable as possible, but future
X (greater than 5.3) versions of SunOS 5.x may break something.
X
XBug reports, fixes, enhancements, etc. are welcome.
X
XJohn
X--
XJohn DiMarco jdd@cdf.toronto.edu
XComputing Disciplines Facility Systems Manager jdd@cdf.utoronto.ca
XUniversity of Toronto EA201B,(416)978-192
8
END_OF_FILE
if test 4987 -ne `wc -c <'README'`; then
    echo shar: \"'README'\" unpacked with wrong size!
fi
# end of 'README'
fi
if test -f 'patchlevel.h' -a "${1}" != "-c" ; then
  echo shar: Will not clobber existing file \"'patchlevel.h'\"
else
echo shar: Extracting \"'patchlevel.h'\" \(71 characters\)
sed "s/^X//" >'patchlevel.h' <<'END_OF_FILE'
X#ifndef lint
Xstatic char patchlevel[] = "scsiinfo version 3.1";
X#endif
END_OF_FILE
if test 71 -ne `wc -c <'patchlevel.h'`; then
    echo shar: \"'patchlevel.h'\" unpacked with wrong size!
fi
# end of 'patchlevel.h'
fi
if test -f 'Makefile' -a "${1}" != "-c" ; then
  echo shar: Will not clobber existing file \"'Makefile'\"
else
echo shar: Extracting \"'Makefile'\" \(1443 characters\)
sed "s/^X//" >'Makefile' <<'END_OF_FILE'
XCC = cc
XINCLUDEDIRS = -I.
X
X# Add -lelf for Solaris 2.x
XLIBRARIES = -lkvm # -lelf
X
XSUNOS_VERSION:sh = /usr/bin/uname -r
X
XDEFS = -DSUNOS_VERSION=\"$(SUNOS_VERSION)\"
X
XCFLAGS = $(DEFS) -O $(INCLUDEDIRS)
XLDFLAGS =
XLINTFLAGS = $(DEFS) -ha $(INCLUDEDIRS)
XSRCS = scsiinfo.c utils.c uscsi.c format.c
XOBJS = $(SRCS:.c=.o)
XRM = /bin/rm -rf
XINSTALL = /usr/bin/install # /usr/ucb/install for Solaris 2.x
XETCDIR = /local/etc
XMANDIR = /local/man/man1
X#
X# Set MODE to 4755, if you want this to run setuid root.
X# -p may not work otherwise. By default, scsiinfo is set to run setgid
X# kmem, which allows only root to use -p, but everything else to work
X# for other users.
X#
XMODE = 2755
XOWNER = root
XGROUP = kmem # sys for Solaris 2.x,
X
Xall:: scsiinfo
X
Xscsiinfo: $(OBJS)
X $(RM) $@
X $(CC) $(LDFLAGS) -o $@ $(OBJS) $(LIBRARIES)
Xlint:
X lint $(LINTFLAGS) $(SRCS)
Xlintport:
X lint -p $(LINTFLAGS) $(SRCS)
Xclean:
X rm -f $(OBJS) scsiinfo
Xdepend:
X makedepend -- $(CFLAGS) -- $(SRCS)
X
Xinstall: scsiinfo
X $(INSTALL) -s -m $(MODE) -o $(OWNER) -g $(GROUP) scsiinfo $(ETCDIR)
X
Xinstall.man: scsiinfo.1
X $(INSTALL) -m 644 scsiinfo.1 $(MANDIR)
X
Xshar:
X shar COPYRIGHT MANIFEST README patchlevel.h Makefile scsiinfo.1 \
X scsiinfo.c utils.c utils.h uscsi.h uscsi.c \
X sunos4.h sunos5.h sundev sundev/dmaga.h \
X format.c format.h >scsiinfo.shar
X
X# DO NOT DELETE THIS LINE -- make depend depends on it.
Xscsiinfo.o: patchlevel.h sunos4.h sunos5.h utils.h uscsi.h format.h
END_OF_FILE
if test 1443 -ne `wc -c <'Makefile'`; then
    echo shar: \"'Makefile'\" unpacked with wrong size!
fi
# end of 'Makefile'
fi
if test -f 'scsiinfo.1' -a "${1}" != "-c" ; then
  echo shar: Will not clobber existing file \"'scsiinfo.1'\"
else
echo shar: Extracting \"'scsiinfo.1'\" \(4277 characters\)
sed "s/^X//" >'scsiinfo.1' <<'END_OF_FILE'
X.TH scsiinfo 1 "Nov 12, 1993"
X.SH scsiinfo
Xscsiinfo \- obtain information about scsi devices attached to a Sun system
X.SH SYNOPSIS
X.B scsiinfo
X[
X.B \-c
X]
X[
X.B \-s
X]
X[
X.B \-p
X]
X[
X.B \-q
X]
X[
X.B \-f raw_disk_device
X]
X[
X.B \-F raw_disk_device
X]
X[
X.B \-o
X]
X.SH DESCRIPTION
X.B scsiinfo
Xdisplays information about SCSI devices attached to a given system, as seen
Xby the Sun ESP device driver. For each target known to the SCSI host adapter,
X.B scsinfo
Xreports whether it is synchronous or asynchronous, whether or not the
Xtranfers to/from the target are clean or susceptible to noise, and whether
Xor not the target can disconnect and reconnect. When a target supports
Xsynchronous transfer, the negotiated maximum transfer rate (in MB/sec) is
Xreported. Furthermore,
X.B scsiinfo
Xcan query SCSI devices for vendor, product, and revision information. Finally
,
X.B scsiinfo
Xcan query a SCSI disk for format and geometry information, and
Xgenerate a suitable format.dat entry for it.
X.SH OPTIONS
X.IP \fB\-c\fP
XIn addition, provide type and speed (clock rate) information about the ESP
Xcontrollers on the machine.
X.IP \fB\-s\fP
XReport "Target now Synchronous" messages for all synchronous devices in
Xthe style of the SunOS 4.1 and 4.1.1 kernels at bootup.
X.IP \fB\-p\fP
XProbe SCSI devices, report their type, whether or not they are removable or
Xnon-removable, and report the device's vendor, product, and revision data.
XThis option provides much the same information as the Openboot prom's
X"probe-scsi-all" command. This option may require special privileges, dependi
ng
Xon how
X.B scsiinfo
Xis installed.
X.IP \fB\-q\fP
XQuiet mode. Do not display transfer information for the specified devices.
XUseful in shell scripts when only the return status is desired.
X.IP \fB\-f raw_disk_device \fP
XReport disk format and geometry information. The raw disk device to be querie
d
X(eg /dev/rsd0c or /dev/rdsk/c0t0d0/s2) must be specified.
X.IP \fB\-F raw_disk_device \fP
XQuery the specified raw disk device for format and geometry information, and
Xconstruct a format.dat entry for it.
X.IP \fB\-o\fP
XWhen querying a drive for format settings (using \fB\-f\fP or \fB\-F\fP),
Xreport the original manufacturer's defined settings, instead of the settings
Xcurrently in effect. This is useful if the drive is not formatted correctly
Xor at all.
X.SH SEE ALSO
XSunOS 4.x: devinfo(8S), SunOS 5.x: prtconf(1M)
X.SH DIAGNOSTICS
XThe return status of
X.B scsiinfo
Xindicates the number of devices detected whose connections have been determin
ed
Xby the kernel to be noisy.
X.B scsiinfo
Xreturns -1 (255) if unable to read the kernel or if run on an unsupported
Xarchitecture.
X.SH HISTORY
XWritten by John DiMarco (jdd@cdf.toronto.edu) at the University of Toronto
X.SH LIMITATIONS
XOnly machines with Sun ESP SCSI host adapters and Openboot proms are supporte
d.
XThese include sun4c, sun4d, and sun4m machines.
X.PP
XSCSI devices that do not have loaded drivers or which have drivers that
Xdo not support Sun's user SCSI interface, cannot be probed by scsiinfo -p.
XIn particular, CD-ROM devices using the Sun driver apparently cannot be probe
d
Xunless a CD is loaded.
X.PP
XSince the user-mode SCSI interface requires read access to a raw character
Xdevice, probing and format/geometry querying will only work if the user runni
ng
X.B scsiinfo
Xcan read the appropriate device file, or if
X.B scsiinfo
Xis installed setgid or setuid to a group or user that has the appropriate
Xprivileges. If
X.B scsiinfo
Xcannot probe a device, it will report the reason.
X.PP
XOptions other than
X.B -o
Xhave no effect when
X.B -f
Xor
X.B -F
Xis specified.
X.B -o
Xhas no effect if
X.B -f
Xor
X.B -F
Xis not specified.
X.PP
XWhen generating a format.dat entry,
X.B scsiinfo
Xjust guesses the bpt (bits per track) figure, since it isn't possible to
Xquery the drive for this.
X.PP
XWhen queried for format and geometry information, some disks drives report
Xincorrect values for rpm (rotations per minute).
X.B scsiinfo
Xwill use 3600 if the reported value is obviously wrong. Furthermore,
Xsome disk drives are overly optimistic when reporting physical capacity,
Xwhich causes
X.B scsiinfo
Xto generate an format.dat entry for the drive that causes format to report
Xerrors when labelling. If this occurs, decrease the value of ncyl until
Xthe problem goes away.
END_OF_FILE
if test 4277 -ne `wc -c <'scsiinfo.1'`; then
    echo shar: \"'scsiinfo.1'\" unpacked with wrong size!
fi
# end of 'scsiinfo.1'
fi
if test -f 'scsiinfo.c' -a "${1}" != "-c" ; then
  echo shar: Will not clobber existing file \"'scsiinfo.c'\"
else
echo shar: Extracting \"'scsiinfo.c'\" \(10147 characters\)
sed "s/^X//" >'scsiinfo.c' <<'END_OF_FILE'
X/*
X * scsiinfo.c - determine SCSI info.
X * Only ESP SCSI host adapters are supported.
X *
X * Author: John DiMarco, University of Toronto, CDF
X * jdd@cdf.toronto.edu
X */
X
X#ifndef lint
Xstatic char rcsid[] = "$Header: /u/jdd/src/jdd/scsiinfo/RCS/scsiinfo.c,v 3.1
1994/01/11 16:06:14 jdd Exp $";
X#endif
X
X/*
X * $Log: scsiinfo.c,v $
X * Revision 3.1 1994/01/11 16:06:14 jdd
X * added -o option, minor cleanup.
X *
X * Revision 3.0 1993/12/21 20:59:29 jdd
X * updates for format stuff
X *
X * Revision 3.0 1993/12/21 20:59:29 jdd
X * updates for format stuff
X *
X * Revision 1.6 1993/12/02 01:18:48 jdd
X * report reason why probe failed
X *
X * Revision 1.5 1993/11/15 21:57:26 jdd
X * More informative error messages, check for unsupported architecture,
X * check for OS version mismatch
X *
X * Revision 1.4 1993/11/12 20:36:47 jdd
X * Only count noisy devices with lun=0
X *
X * Revision 1.3 1993/11/12 20:28:30 jdd
X * almost complete rewrite for 2.0
X * list devices via devinfo tree, rather than looping through all
X * scsi targets. Support for -p, -q options. Split OS dependent
X * stuff off into sunos4.h, sunos5.h, general cleanup
X *
X * Revision 1.2 1993/05/17 22:39:26 jdd
X * -v option is really -c.
X * Added patchlevel.h
X *
X * Revision 1.1 1993/05/17 17:03:13 jdd
X * Initial revision
X *
X *
X */
X
X#include "patchlevel.h"
X#include "uscsi.h"
X#include "format.h"
X#include <stdio.h>
X
X#ifdef FILENAME_MAX /* defined in stdio.h only for SunOS >=5.x */
X#define SYSV
X#endif
X
X#include <sys/param.h>
X#include <values.h>
X#include <sys/types.h>
X#include <sys/stat.h>
X#include <nlist.h>
X#include <kvm.h>
X#include <fcntl.h>
X#include <sys/utsname.h>
X#include "utils.h"
X
X#define MAXESP 255
X
Xkvm_t *kd;
X#define getkvm(a,b,l) kvm_read(kd,a,(char *)b,l)
X
Xchar *kernel_getstring();
X
X/* include OS-dependent stuff */
X#ifdef SYSV
X#include <sunos5.h>
X#else
X#include <sunos4.h>
X#endif
X
Xchar *devicepath;
X
Xextern char *calloc();
X
Xchar *progname;
Xint d;
X
Xint controller=0; /* give controller information */
Xint bootstyle=0; /* Use SunOS4.x boot style "...now Synchronous..." format *
/
Xint probe=0; /* Probe SCSI device if possible */
Xint quiet=0; /* Quiet mode: don't report synch messages */
Xint noisycount=0; /* number of noisy devices */
Xint formatinfo=0; /* Report format info */
Xint formatdat=0; /* Generate format.dat */
Xint original=0; /* Use manufacturer's original settings for format info */
X
Xvoid usage()
X{
X fprintf(stderr,
X "Usage: %s [-o][-c][-s][-p][-q][-f diskdevice][-F diskdevice]\n",
X progname);
X exit(2);
X}
X
Xchar *espType(typecode)
Xint typecode;
X{
X /* see /usr/include/[sys/]scsi/adapters/espreg.h */
X switch(typecode){
X case 0: return("ESP100/NCR53C90");
X break;
X case 1: return("ESP100A/NCR53C90A");
X break;
X case 2: return("ESP236");
X break;
X case 3: return("FAS100/100A");
X break;
X case 4: return("FAS236");
X break;
X case 5: return("FAST");
X break;
X default: return("unknown");
X break;
X }
X}
X
X#define BUFFSIZE 80
X
Xchar *kernel_getstring(address)
Xu_long address;
X{
X static char buff[BUFFSIZE];
X
X if(-1==getkvm(address, buff, sizeof(buff))){
X Error("kernel_getstring");
X }
X buff[BUFFSIZE-1]='\0'; /* just in case it's not null-terminated */
X return(buff);
X}
X
Xu_int get_speed(esp, i)
Xstruct esp *esp;
Xint i; /* target index */
X{
X u_int cycletime, speed;
X
X /*
X * Synch cycle time in milliseconds is the
X * number of ticks in the period multiplied
X * by the tick rate. e_clock_conv is the
X * esp's tick rate in units of 5MHz.
X */
X cycletime = esp->e_clock_conv ? (esp->e_period[i] *
X (1000/(5*esp->e_clock_conv))) : 0;
X
X /*
X * Compute speed in thousanths of MBs/sec.
X */
X speed = cycletime?((((1000*1000*1000)/cycletime)+999)/1000):0;
X
X return(speed);
X}
X
Xvoid controller_message(cnum, esp)
Xint cnum;
Xstruct esp *esp;
X{
X printf("esp%d:", cnum);
X printf(" type %d (%s)", (u_int)esp->e_type,
X espType(esp->e_type));
X printf(" speed %dMHz", (u_int)esp->e_clock_conv*5);
X printf("\n");
X}
X
Xvoid boot_synch_message(espnum, i, speed)
Xint espnum;
Xint i; /* target index */
Xu_int speed;
X{
X if(speed) printf(
X "esp%d:\tTarget %d now Synchronous at %d.%d mb/s max transmit rate\n",
X espnum, i, speed/1000, speed%1000);
X}
X
Xvoid synch_message(esp, i, speed)
Xstruct esp *esp;
Xint i;
Xu_int speed;
X{
X if(speed && (esp->e_sync_known & (1<<i))){
X printf("Synchronous(%d.%dMB/sec)", speed/1000, speed%1000);
X } else {
X printf("Asynchronous");
X }
X if(esp->e_weak & (1<<i)){
X printf(" Noisy");
X } else {
X printf(" Clean");
X }
X if(esp->e_nodisc & (1<<i)){
X printf(" CannotReconnect");
X } else {
X printf(" CanReconnect");
X }
X}
X
Xint device_OK(pathname)
Xchar *pathname;
X{
X /*
X * true if pathname is an existing character device,
X * false otherwise
X */
X struct stat sb;
X if(-1==stat(pathname, &sb)) return(0);
X return(S_ISCHR(sb.st_mode));
X}
X
Xmain(argc, argv)
Xint argc;
Xchar *argv[];
X{
X int c, j, i;
X int errflg = 0;
X extern int optind;
X extern char *optarg;
X struct esp esp[1], *esp_p, *esp_softc;
X u_long addr;
X u_int nesp;
X char *dname;
X struct utsname un;
X char *diskdevice;
X
X progname = argv[0];
X while ((c = getopt(argc, argv, "odcspqf:F:")) != EOF)
X switch (c) {
X case 'd':
X ++d;
X break;
X case 'c':
X /* output controller information */
X controller++;
X break;
X case 's':
X /* Use SunOS4.x boot-style "now Synchronous" format */
X bootstyle++;
X break;
X case 'p':
X /* probe probe-able devices */
X probe++;
X break;
X case 'q':
X /* quiet mode */
X quiet++;
X break;
X case 'f':
X /* output format info */
X formatinfo++;
X diskdevice=optarg;
X break;
X case 'F':
X /* output format.dat */
X formatinfo++;
X formatdat++;
X diskdevice=optarg;
X break;
X case 'o':
X /* use manufacturer's original settings for fmt info *
/
X original++;
X break;
X default:
X /* parameter error */
X errflg++;
X break;
X }
X if (errflg) {
X usage();
X }
X
X /* check OS version and machinetype, quit now if mismatch */
X uname(&un);
X
X
X if(formatinfo){
X format(formatdat, un.release, diskdevice, original);
X exit(0);
X }
X
X if(!STREQ(SUNOS_VERSION, un.release)){
X Error(
X"Version mismatch: compiled for SunOS %s, this is SunOS %s.",
X SUNOS_VERSION, un.release);
X }
X if((0!=strncmp(un.machine, "sun4", 4)) || strlen(un.machine)<5 ){
X Error( "%s kernel architecture not supported.", un.machine);
X }
X
X if(NULL==(kd=kvm_open(NULL, NULL, NULL, O_RDONLY, progname))){
X Error("Cannot read kernel, giving up.");
X }
X if(0!=kvm_nlist(kd, nl)){
X Error("Cannot read a required kernel symbol.");
X }
X if(-1==getkvm(nl[N_ESP_SOFTC].n_value, &addr, sizeof(addr))){
X Error("kvm_read: esp_softc");
X }
X
X if((u_long)NULL==addr) exit(0); /* no esp's */
X esp_softc=esp_p=(struct esp *)addr;
X
X if(-1==getkvm(addr, esp, sizeof(struct esp))){
X Error("kvm_read: initial esp");
X }
X
X nesp=get_nesp();
X if(0==nesp) exit(0);
X
X for(j=0;j<nesp;j++){
X struct dev_info di, dii, *next, *nextt;
X if(NULL==(char *)addr) break;
X if(-1==getkvm(addr, esp, sizeof(struct esp))){
X Error("kvm_read: #%d esp", j);
X }
X
X /*
X * grab the devinfo structure for the esp controller. CNUM
X * requires it, and we need it to determine the device names.
X */
X if(-1==getkvm((u_long)esp->e_dev, &devi, sizeof(devi))){
X Error("kvm_read: #%d esp devinfo", j);
X }
X
X if(probe) devicepath = get_devicepath(j);
X
X esp->e_dev=(dev_info_t)&devi; /* for CNUM */
X
X if(controller) controller_message(CNUM, esp);
X
X init_scsitarget();
X
X /*
X * Now, traverse esp's devinfo child list, looking for
X * attached drivers (i.e. DDI_CF2 is true). If we find
X * an attached driver, we presume it is an active device.
X */
X
X for(next=ddi_get_child(&devi);
X NULL!=next;
X next=ddi_get_next_sibling(&di)){
X char *devicename, *addrname;
X int target, lun;
X
X if(-1==getkvm((u_long)next,
X &di, sizeof(di))){
X Error("kvm_read: #%d esp devinfo child", j);
X }
X
X if(!DDI_CF2(&di)) continue; /* skip */
X
X /*
X * Get the device name and address, and
X * compute the device path for it
X */
X
X /* get device name */
X dname=s(kernel_getstring(
X (u_long)ddi_get_name(&di)));
X /* ... and address */
X addrname=s(get_addr(&di));
X
X if(probe) {
X /* compute device name */
X if(STREQ("sd", dname)){
X /* disk device */
X devicename = cat(
X devicepath, "/",
X DEV_PREFIX, dname,
X DEV_INFIX, addrname,
X DISK_SUFFIX, NULL);
X } else {
X devicename = cat(
X devicepath, "/",
X DEV_PREFIX,
X dname, DEV_INFIX,
X addrname,
X DEV_SUFFIX, NULL);
X }
X }
X
X if(-1==get_scsiaddr(dname, &di, &target, &lun)){
X Error("scsiaddr: #%d", j);
X }
X
X if(0==lun && (esp->e_weak & (1<<target))) noisycount++
;
X
X if(!quiet){
X if(bootstyle) {
X if(lun==0){
X boot_synch_message(CNUM,
X target,
X get_speed(esp, target)
);
X }
X } else {
X printf(
X "esp%d: %s%s tgt %d lun %d:\n\t",
X CNUM, dname, addrname,
X target, lun);
X synch_message(esp, target,
X get_speed(esp, target));
X printf("\n");
X }
X }
X if(probe){
X printf("\t");
X if(-1==(scsi_probe(devicename, lun))){
X switch(errno){
X case EACCES:
X printf(
X"<<< SCSI probe failed: no permission to access device special file >>>\n");
X break;
X case ENOTTY:
X case EIO:
X printf(
X"<<< SCSI probe failed: device driver doesn't support probing >>>\n");
X break;
X case ENXIO:
X printf(
X"<<< SCSI probe failed: device not accessible (media not loaded?) >>>\n");
X break;
X case EBUSY:
X printf(
X"<<< SCSI probe failed: device is busy >>>\n");
X break;
X case ENOENT:
X printf(
X"<<< SCSI probe failed: device special file not available >>>\n");
X break;
X default:
X perror("scsi probe failed");
X printf("errno %d\n", errno);
X break;
X }
X } else {
X printf("\n");
X }
X free(devicename);
X }
X free(addrname);
X free(dname);
X }
X
X#ifdef OLD_SUNOS
X /* SunOS 4.1.1 and previous, table */
X addr=(u_long)(++esp_p);
X#else
X /* SunOS 4.1.2 and later, linked list */
X addr=(u_long)esp->e_next;
X#endif
X
X }
X exit(noisycount);
X}
END_OF_FILE
if test 10147 -ne `wc -c <'scsiinfo.c'`; then
    echo shar: \"'scsiinfo.c'\" unpacked with wrong size!
fi
# end of 'scsiinfo.c'
fi
if test -f 'utils.c' -a "${1}" != "-c" ; then
  echo shar: Will not clobber existing file \"'utils.c'\"
else
echo shar: Extracting \"'utils.c'\" \(4969 characters\)
sed "s/^X//" >'utils.c' <<'END_OF_FILE'
X/*
X * utils.c: miscellaneous utilities
X *
X * Author: John DiMarco, University of Toronto, CDF
X * jdd@cdf.toronto.edu
X */
X
X/*
X * $Log: utils.c,v $
X * Revision 1.2 1993/11/12 20:30:59 jdd
X * cleanup, changed return status of Error
X *
X */
X
X#include <stdio.h>
X#ifdef FILENAME_MAX
X#include <string.h>
X#else
X#include <strings.h>
X#endif
X#include <varargs.h>
X#include "utils.h"
X
X#ifdef lint
X#undef va_arg(x,y)
X#define va_arg(x,y) (y)NULL
X#endif
X
Xextern char *progname;
Xextern int d;
X
Xextern char *malloc(), *realloc();
X
X/*
X * Error(): behaves like fprintf(stderr, ...) followed by exit(-1), except
X * that the 'programname: ' preceeds the print, and a newline
X * follows it.
X */
X/*VARARGS*/
Xvoid Error(va_alist)
Xva_dcl
X{
X va_list args;
X char *format;
X
X va_start(args);
X format = va_arg(args, char *);
X fprintf(stderr, "%s: ", progname);
X vfprintf(stderr, format, args);
X fprintf(stderr, "\n");
X va_end(args);
X (void)exit(-1);
X}
X
X/*
X * dfprintf(): behaves like fprintf, except the first argument must be a
X * debugging level. The message will only be printed if "d"
X * is equal to or greater than the debugging level.
X */
X/*VARARGS*/
Xvoid dfprintf(va_alist)
Xva_dcl
X{
X va_list args;
X int debugLevel;
X FILE *stream;
X char *format;
X
X va_start(args);
X debugLevel = va_arg(args, int);
X stream = va_arg(args, FILE *);
X format = va_arg(args, char *);
X if(d >= debugLevel){
X vfprintf(stream, format, args);
X }
X va_end(args);
X}
X
X/*
X * Warning(): behaves like Error, except returns rather than exits.
X */
X/*VARARGS*/
Xvoid Warning(va_alist)
Xva_dcl
X{
X va_list args;
X char *format;
X
X va_start(args);
X format = va_arg(args, char *);
X fprintf(stderr, "%s: ", progname);
X vfprintf(stderr, format, args);
X fprintf(stderr, "\n");
X va_end(args);
X}
X
XFILE *efopen(file, mode)
Xchar *file, *mode;
X{
X FILE *fp;
X if (NULL!=(fp=fopen(file,mode)))
X return(fp);
X Error("can't open file \"%s\" mode \"%s\"", file, mode);
X /*NOTREACHED*/
X}
X
Xvoid efclose(f)
XFILE *f;
X{
X if(EOF==fclose(f))
X Error("can't close file");
X /*NOTREACHED*/
X}
X
X/*
X * mylib_malloc(): Checks if it gets a NULL pointer, calls Error if so.
X */
Xchar *mylib_malloc(size, file, line)
Xunsigned size;
Xchar *file;
Xint line;
X{
X char *result;
X
X result = malloc(size);
X if(NULL==result){
X Error("Out of memory at line %d in \"%s\".", line, file);
X }
X return(result);
X}
X
X/*
X * mylib_realloc(): Checks if it gets a NULL pointer, calls Error if so.
X */
Xchar *mylib_realloc(ptr, size, file, line)
Xchar *ptr, *file;
Xunsigned size;
Xint line;
X{
X char *result;
X
X result = realloc(ptr, size);
X if(NULL==result){
X Error("Out of memory at line %d in \"%s\".", line, file);
X }
X return(result);
X}
X
X/*
X * mylib_scopy(): Takes a string and creates a new physical copy of it.
X */
Xchar *mylib_scopy(string, file, line)
Xchar *string, *file;
Xint line;
X{
X char *result;
X
X result = malloc((unsigned)strlen(string)+1);
X
X if(NULL==result){
X Error("Out of memory at line %d in \"%s\".", line, file);
X }
X (void)strcpy(result, string);
X return(result);
X}
X



This archive was generated by hypermail 2.1.2 : Fri Sep 28 2001 - 23:09:01 CDT