Date: Mon, 1 May 1995 08:22:01 -0400 (EDT) From: Peter Dufault <dufault@hda.com> To: bmk@dtr.com Cc: john@starfire.mn.org, questions@FreeBSD.org Subject: Re: formatting a scsi disk Message-ID: <199505011222.IAA21137@hda.com> In-Reply-To: <199505011151.EAA14572@dtr.com> from "bmk@dtr.com" at May 1, 95 04:51:29 am
next in thread | previous in thread | raw e-mail | index | archive | help
bmk@dtr.com writes:
>
>
> > bmk@dtr.com writes:
> > >
> > > Can't get it to work here, any clues?
>
> > It turns out that commands with no data have never worked via "scsi"
> > (yikes). That is fixed in -current, and I'm on to two new problems:
>
> > 1. We need to be able to specify the timeout (the default is 2
> > seconds, which is not going to work well for formatting your disks)
>
> > 2. We need to account for disks that can't be opened by the disk driver
> > before formatting.
>
> So... I guess my next question is how can I reformat a problematic SCSI
> disk since I'm running SNAP-0412 and not current. The controller is a
> Buslogic 445 - and they don't provide a SCSI format utility.
>
> If it's necessary, I can format the disk on an Adaptec 1542 (which does
> have a formatter), but I'd rather not do that, since it'd involve
> disassembling two machines.
Try this. It should work if you can open the disk. If you can't
you'll have to either upgrade to -current when I fix that problem (and I
haven't yet) or you'll have to use your 1542.
This will do a "Test Unit Ready".
You have to change the "0 0 0 0 0 0" to "4 0 0 0 0 0" to get a format.
Let me know how it works out.
#include <stdlib.h>
#include <sys/scsiio.h>
#include <errno.h>
#include <sys/file.h>
#include <scsi.h>
int main(int argc, char *argv[])
{
int fid;
scsireq_t *scsireq;
if (argc != 2) {
fprintf(stderr, "Usage: %s device\n", argv[0]);
exit(-1);
}
if ( (fid = scsi_open(argv[1], O_RDWR)) == -1) {
perror(argv[1]);
exit(errno);
}
scsireq = scsireq_build(scsireq_new(), 0, 0, 0,
"0 0 0 0 0 0", /* Change to "4 0 0 0 0 0" for format */
0);
scsireq->timeout = 20 * 60 * 1000; /* 20 minutes in ms */
if (scsireq_enter(fid, scsireq) == -1) {
scsi_debug(stderr, -1, scsireq);
exit(errno);
}
exit(0);
}
--
Peter Dufault Real Time Machine Control and Simulation
HD Associates, Inc. Voice: 508 433 6936
dufault@hda.com Fax: 508 433 5267
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199505011222.IAA21137>
