Finally replace the defunct 4.4BSD scsiformat.c by Peter's wrapper
around scsi(8). I've done extensive testing of it with a spare disk in the past, and it's ready for prime-time now. Submitted by: dufault
This commit is contained in:
parent
2bd5293099
commit
75428542b4
|
@ -1,7 +1,9 @@
|
|||
# @(#)Makefile 5.3 (Berkeley) 6/5/93
|
||||
|
||||
PROG= scsiformat
|
||||
MAN8= scsiformat.0
|
||||
CFLAGS+=-I/sys
|
||||
MAN8= scsiformat.8
|
||||
|
||||
beforeinstall:
|
||||
${INSTALL} -c -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \
|
||||
${.CURDIR}/scsiformat.sh ${DESTDIR}${BINDIR}/scsiformat
|
||||
|
||||
.include <bsd.prog.mk>
|
||||
|
|
|
@ -39,16 +39,24 @@
|
|||
.Nd format SCSI disks and show SCSI parameters
|
||||
.Sh SYNOPSIS
|
||||
.Nm scsiformat
|
||||
.Op Fl r
|
||||
.Op Fl w
|
||||
.Op Fl q
|
||||
.Op Fl p Ar page-control
|
||||
.Ar raw-device-name
|
||||
.Ar device-name
|
||||
.Sh DESCRIPTION
|
||||
The
|
||||
.Nm scsiformat
|
||||
utility can be used to format SCSI disks
|
||||
on systems that support on-line SCSI formatting
|
||||
(currently this is limited to the HP300 and SPARC ports).
|
||||
on systems that support on-line SCSI formatting.
|
||||
It will also show the various parameters set in the SCSI controller.
|
||||
The
|
||||
.Ar device-name
|
||||
should be either a disk name like
|
||||
.Ql sd0 ,
|
||||
or the path name of the control device for a disk, as in
|
||||
.Pa /dev/rsd0.ctl .
|
||||
Using a regular disk device may not work, for example in case of a
|
||||
device where the medium format is corrupted.
|
||||
.Pp
|
||||
The options are as follows:
|
||||
.Bl -tag -width indent
|
||||
|
@ -69,14 +77,24 @@ gets saved settings (those that persist across power cycles).
|
|||
.It Li v
|
||||
shows which parameters are variable.
|
||||
.El
|
||||
.It Fl r
|
||||
Don't format, instead display the disk parameters.
|
||||
.It Fl w
|
||||
Do actually format; by default, only the disk parameters will be
|
||||
displayed.
|
||||
.It Fl q
|
||||
Quiet; supress the mode page output. Only the inquiry string will be
|
||||
printed, so the operator can ensure he's going to format the intented
|
||||
drive.
|
||||
.El
|
||||
.Sh DIAGNOSTICS
|
||||
These should mostly be self-explanatory.
|
||||
A copy of the SCSI standard (or a more readable derivative)
|
||||
may be useful, however.
|
||||
.Sh SEE ALSO
|
||||
.Xr scsi 8 .
|
||||
.Sh HISTORY
|
||||
The
|
||||
.Nm scsiformat
|
||||
utility first appeared in 4.4BSD.
|
||||
This version has been reworked as a wrapper around
|
||||
.Xr scsi 8
|
||||
by Peter Dufault for FreeBSD 2.1 .
|
||||
|
|
|
@ -0,0 +1,143 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
# Copyright (c) 1995 Peter Dufault
|
||||
#
|
||||
# All rights reserved.
|
||||
#
|
||||
# This program is free software.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions
|
||||
# are met:
|
||||
# 1. Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
# 2. Redistributions in binary form must reproduce the above copyright
|
||||
# notice, this list of conditions and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY EXPRESS OR
|
||||
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
# IN NO EVENT SHALL THE DEVELOPERS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#
|
||||
# $Id$
|
||||
#
|
||||
# scsiformat [-wq] [-p page-control] raw-device-name
|
||||
#
|
||||
|
||||
PATH="/sbin:/usr/sbin:/bin:/usr/bin"; export PATH
|
||||
|
||||
READONLY=yes
|
||||
QUIET=no
|
||||
RAW=
|
||||
PAGE=0
|
||||
|
||||
usage()
|
||||
{
|
||||
echo "Usage: scsiformat [-wq] [-p page-control] raw-device-name" 1>&2
|
||||
exit 2
|
||||
}
|
||||
|
||||
while getopts "qwp:" option
|
||||
do
|
||||
case $option in
|
||||
q)
|
||||
QUIET=yes
|
||||
;;
|
||||
w)
|
||||
READONLY=no
|
||||
;;
|
||||
p)
|
||||
case $OPTARG in
|
||||
c)
|
||||
PAGE=0
|
||||
;;
|
||||
d)
|
||||
PAGE=2
|
||||
;;
|
||||
s)
|
||||
PAGE=3
|
||||
;;
|
||||
v)
|
||||
PAGE=1
|
||||
echo "*** note: for variable parameters, 1-bit means 'can write here'"
|
||||
;;
|
||||
*)
|
||||
usage
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
?)
|
||||
usage
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
shift $(($OPTIND - 1))
|
||||
|
||||
if [ $# -ne 1 ] ; then
|
||||
usage
|
||||
fi
|
||||
|
||||
RAW=$1
|
||||
|
||||
if [ "x$RAW" = "x" ] ; then
|
||||
usage
|
||||
fi
|
||||
|
||||
if expr "$RAW" : 'sd[0-9][0-9]*$' > /dev/null ; then
|
||||
# generic disk name given, convert to control device name
|
||||
RAW="/dev/r${RAW}.ctl"
|
||||
fi
|
||||
|
||||
scsi -f $RAW -v -c "12 0 0 0 v 0" 96 -i 96 "s8 z8 z16 z4" || exit $?
|
||||
|
||||
if [ "$QUIET" = "no" ] ; then
|
||||
scsi -f $RAW \
|
||||
-v -c "1A 0 v:2 4:6 0 64 0" $PAGE \
|
||||
-i 72 "{Mode data length} i1 \
|
||||
{Medium type} i1 \
|
||||
{Device Specific Parameter} i1 \
|
||||
{Block descriptor length} i1 \
|
||||
{Density code} i1 \
|
||||
{Number of blocks} i3 \
|
||||
{Reserved} i1 \
|
||||
{Block length} i3 \
|
||||
{PS} b1 \
|
||||
{Reserved} b1 \
|
||||
{Page code} b6 \
|
||||
{Page length} i1 \
|
||||
{Number of Cylinders} i3 \
|
||||
{Number of Heads} i1 \
|
||||
{Starting Cylinder-Write Precompensation} i3 \
|
||||
{Starting Cylinder-Reduced Write Current} i3 \
|
||||
{Drive Step Rate} i2 \
|
||||
{Landing Zone Cylinder} i3 \
|
||||
{Reserved} b6 \
|
||||
{RPL} b2 \
|
||||
{Rotational Offset} i1 \
|
||||
{Reserved} i1 \
|
||||
{Medium Rotation Rate} i2 \
|
||||
{Reserved} i1 \
|
||||
{Reserved} i1 " || exit $?
|
||||
fi # !quiet
|
||||
|
||||
if [ "$READONLY" = "no" ]
|
||||
then
|
||||
# grace period, last chance to hit INTR
|
||||
echo -n "Three seconds until format begins."
|
||||
sleep 1
|
||||
echo -n "."
|
||||
sleep 1
|
||||
echo -n "."
|
||||
sleep 1
|
||||
# formatting may take a huge amount of time, set timeout to 2 hours
|
||||
echo " Formatting... this may take a while."
|
||||
scsi -s 7200 -f $RAW -c "4 0 0 0 0 0"
|
||||
fi
|
Loading…
Reference in New Issue