From: bwilliam@iat.holonet.net (Bill Williams)
Subject: Re: How do I mount a SCSI device?
Organization: HoloNet (BBS: 510-704-1058)
Distribution: comp
Date: Mon, 7 Sep 1992 09:39:41 GMT

>>mount all SCSI devices it finds in the chain.....
 
 
 
Do not write a mounting program unless you do it correctly. To do
 it correctly is too much work. I'll demonstrate:
 
Steps include
 
1: Finding all devices on the bus that are FIXED STORAGE, OPTICAL, and CD-ROM
while ignoring things like Voice Navigators and Scanners. Requires 
knowledge of the SCSI Manager.
 
2: Unmounting all currently existing unmountable volumes supported by the
existing drivers for safety (plus you won't be able to unmount the system
volume or the current app volume)
 
3: Finding the first VALID HFS SCSI driver form the devices from the DDM
Driver Descriptor Map, in Block0 structure of disk (first block) Plus
reading just the first 512 bytes of the SCSI Block even if its logical 
block size is larger than 512 bytes.

Then via block zero you can deduce which of several Partition map entries
in the PARTITION MAP partition is the desired driver. Then you need to
officially validate the checksum found in the partition map entry
describing the driver you are seeking via IM 5 if the partition map name
begins with 'MACI' in upper OR lower case
 
4: once found you need to load the driver into memory and check its memory
against its checksum for safety. Also you need to load it into a non
relocatable area of the system heap, and GUARANTEE THAT THE SYSTEM HEAP
 CAN AFFORD to accept a further loss of space (if not in System 7 with
expandable system 7 heaps). Size of driver is stored in partition map
entry but be careful not to multiply the logical block size (its units)
by the "ddSize" of the DDM since Apple structures are all internally
 stored using 512 byte logical blocks.
 
5: once the driver is ready and found, you need to jumpstart the driver as
if it was being called by the normal bootup processes of the Mac after
ILLEGALLY TAKING OVER THE CURRENT SCSI SLOT SPACE in the driver for that
device using Apples official current regular (non "Cousin It") guidlines:
(unit_Table_Ptr = (DCtlHandle *)UTableBase;
unit_Table_Ptr += 32 + device_ID;/* Point at SCSI ID direct slot */)

 
void Mount_SCSI_Drive(long scsi_Address, Ptr driver_Start)
{
  asm {
    movem.l    d0-d7/a0-a6,-(sp)
    suba.l     a0,a0
    moveq.l    #0,d7
    move.l     scsi_Address,d5
    bset.l     #31,d5    ;To indicate not being called at boot time
    move.l     driver_Start,a1
    jsr        (a1)
    movem.l    (sp)+,d0-d7/a0-a6
  } /* asm */
  
} /* pascal void Mount_SCSI_Device(INTEGER_32 scsi_Address... */
 
 
6: The Driver, not you,has the duty of cycling through partition entries
so Thats all there is. Thats it. They will mount.
 
 
 
Problems with ANY technique such as mounting like this include:
Having drivers ORPANED IN MEMORY! This is because no
SCSI drivers currently have to support a "Close" command and WILL BE
ORPAHANED. They may be may be doing evil background tasks, VBL tasks,
or have nasty shutdown manager calls installed. Taking over a SCSI Slot
space is naughty.

 
Conclusion: DO NOT WRITE a "SCSI Probe", nor use SCSI Probe. However the
steps just listed in this article are all properly done in the "SCSI
Director* Assistant 1.5.1" CDEV that has various names and was available
from 18 different companies including APS,Club Mac,VCP, etc etc. 
 
PS "SCSI Probe 3.x" violates most rules and does things such as mounting
 OFFLINE devices that are OFFLINE and not Normal Device Queue Entries 
(such as RAM Disks that are closed down with raw memory addresses in the
 entry, MS-DOS volumes, etc.  KaBOOM.
 
BWilliams

(If you need to speak to me use EMail since I never usually read
Mac oriented usenet stuff... but I may start)

Xref: sparky comp.sys.mac.programmer:15115 comp.sys.mac.misc:16142