[comp.sys.sun] SCSI programming

mike@cimcor.sp.unisys.com (Michael Grenier) (10/08/90)

I have a Sony Optical Disk connectioned to a Sparcstation 1 (OS 4.0.3) but
there is one big problem. (Actually, the disk is ESDI connected to
somebody's ESDI to SCSI board).

I cannot seem to get any bad block management to work! The drive supports
an ISO standard bad block handling in its firmware but I need to send a
mode select to enable this feature every time it gets powered up (unlike
Wren's for instance). 

I've written SCSI device drivers and am not afraid of some programing.
Moreover, the /usr/etc/format command demonstrates that it is possible for
a user program to send arbitary mode select commands so....how do I do it.
Sun's ioctls on this seem totally undocumented. Help!

--------

OK, plan 2. Lets try to use Suns bad block management. 

The format command will return an illegal request error if I try to format
the drive.  I cannot retreive the original defect list nor can I set one.
(We are able to format the drive on another system just fine).  The
format.dat parameters have been played with endlessly but to no avail.
Not the the documentation here is very good either.  Its fairly obvious
what mode select fields are getting set with the MD21 controller and a
Wren drive, but there appears to be not good way to set arbitary fields in
the mode select/format commands for drives in general. 

--------

OK, plan 3. Build a file system on the drive anyway and move any bad
blocks discovered into unused files. This is a bad plan but I was
desperate.

Lets say a bad block is discovered and I get media errors on the console.
I use the icheck command to figure out which block it is, lets say 290161.
When I use the fsck command, it might say 290128 (while still saying
290161 on the console). This is weird considering that my partition starts
on track 0. I can fsck on /dev/sd2c (the overall disk) and it still
reports a different bad block then the console. 

OK, so I'll map out both. I tried using ncheck to figure out which file
contained the bad block. I get too different files for the two bad blocks
(fsck and console message), so I make sure not to access either one (it
reports some obscure file I never use anyway).  The bad block gets hit
constantly anyway! I really appears that one of the commands is lying and
I'm not dealing with the correct file!

-----

Plan 4.

Take the drive and put it on a 368 UNIX box with the Public Domain ST01
scsi adapter driver. This allows me to send any mode select command to
turn on internal bad block mapping. We then export the partition with NFS.

This requires management to spend money for NFS on our ESIX system since
Sun doesn't support RFS. (and R&D money at the end of the year is quite
scarce!).

---

   Arrgggg..

     -Mike Grenier
     mike@sp.unisys.com (if the drive sortof works)
     mike@cimcor.mn.org  (Home, otherwise  :-)
     612-456-7869