[comp.sys.mac.programmer] trapping for floppy disk

mcmac@hubcap.clemson.edu (Scott McAlister) (03/20/91)

I am working on an init that traps on MountVol.  What I want to do
is to distinguish between floppies and hard disks.  Can anybody help 
me out?  Sample code would be appreciated.  Thanks in advance.


-- Scott

==================================================
| Scott McAlister     | mcmac@hubcap.clemson.edu |
| CS Senior           |                          |
| Clemson University  |                          |
| Home address:  390 Boggs Rd.                   |
|                Pickens, SC  29671              |
==================================================

mcmac@hubcap.clemson.edu (Scott McAlister) (03/20/91)

I forgot to say that I am using Think C 4.02, if that helps.

--scott

mandel@vax.anes.tulane.edu (Jeff E Mandel MD MS) (03/25/91)

In article <1991Mar19.164204.8847@hubcap.clemson.edu>, mcmac@hubcap.clemson.edu (Scott McAlister) writes:
>I am working on an init that traps on MountVol.  What I want to do
>is to distinguish between floppies and hard disks.  Can anybody help 
>me out?  Sample code would be appreciated.  Thanks in advance.
>
I had to figure this out once, and I seem to recall deciphering it from the
Volume Control Block's vcbDrvNum field. I believe (but it may ONLY be a belief)
that this was always 1 or 2 for floppies. In any event, if you have to be
absolutely safe, you can walk the Drive Queue and check the flag bytes of the
Drive Queue Element for that drive number; byte 1 will tell you if the volume
is ejectable. See Inside Mac Vol IV pp 176-182 for confusion in greater depth.


Jeff E Mandel MD MS
Asst. Professor of Anesthesiology
Tulane University School of Medicine
New Orleans, LA
mandel@vax.anes.tulane.edu

time@ice.com (Tim Endres) (03/25/91)

In article <6761@rex.cs.tulane.edu>, mandel@vax.anes.tulane.edu (Jeff E Mandel MD MS) writes:
> >I am working on an init that traps on MountVol.  What I want to do
> >is to distinguish between floppies and hard disks.  Can anybody help 
> >me out?  Sample code would be appreciated.  Thanks in advance.
> >
> I had to figure this out once, and I seem to recall deciphering it from the
> Volume Control Block's vcbDrvNum field. I believe (but it may ONLY be a belief)
> that this was always 1 or 2 for floppies. In any event, if you have to be
> absolutely safe, you can walk the Drive Queue and check the flag bytes of the
> Drive Queue Element for that drive number; byte 1 will tell you if the volume
> is ejectable. See Inside Mac Vol IV pp 176-182 for confusion in greater depth.

And won't the driver's Status call { PBStatus(drvStsCode) } give you
the same information?

-------------------------------------------------------------
Tim Endres                |  time@ice.com
ICE Engineering           |  uupsi!ice.com!time
8840 Main Street          |  Voice            FAX
Whitmore Lake MI. 48189   |  (313) 449 8288   (313) 449 9208

mandel@vax.anes.tulane.edu (Jeff E Mandel MD MS) (03/25/91)

In article <1CE00001.bcochit@tbomb.ice.com>, time@ice.com (Tim Endres) writes:
>
>
>And won't the driver's Status call { PBStatus(drvStsCode) } give you
>the same information?
>
Actually, better. I wrote my code a long time ago, possibly before Inside Mac
V. 5. In any event, calling the disk driver PBControl with csCode 23 seems to
be what you want, as it tells you everything about the physical properties of
the drive. Of course, you still have to look in the VCB to get the driver
reference number. See IM vol. V p470-1.


Jeff E Mandel MD MS
Asst. Professor of Anesthesiology
Tulane University School of Medicine
New Orleans, LA
mandel@vax.anes.tulane.edu

gurgle@well.sf.ca.us (Pete Gontier) (03/26/91)

In article <6761@rex.cs.tulane.edu> mandel@vax.anes.tulane.edu writes:
>In article <1991Mar19.164204.8847@hubcap.clemson.edu>, mcmac@hubcap.clemson.edu (Scott McAlister) writes:
>>I am working on an init that traps on MountVol.  What I want to do
>>is to distinguish between floppies and hard disks.  Can anybody help 
>>me out?  Sample code would be appreciated.  Thanks in advance.

>I had to figure this out once, and I seem to recall deciphering it from the
>Volume Control Block's vcbDrvNum field. I believe (but it may ONLY be a belief)
>that this was always 1 or 2 for floppies. In any event, if you have to be
>absolutely safe, you can walk the Drive Queue and check the flag bytes of the
>Drive Queue Element for that drive number; byte 1 will tell you if the volume
>is ejectable. See Inside Mac Vol IV pp 176-182 for confusion in greater depth.

Erm... I was waiting for an answer to this one, as well, and I don't
think this is it.

The problem is that at MountVol time, the volume isn't mounted. It's
possible to tail-patch MountVol -- AFTER MountVol, at least you have
a vRefNum and you can run the VCB's looking for it. Then you can get
the handle/pointer to the driver itself and look for its name. "\p.Sony"
is a foolproof way of getting an indication you've a floppy on your
hands, as long as it's smaller than 20M (the original Apple HD20 used
the Sony driver).

However, tail-patching is a no-no. If you head-patch MountVol, you get
the drive number as a parameter, and you can use the strategy proposed
by mandel@vax.anes.tulane.edu once you have the drive number. But I
wouldn't guess that it's fool-proof. I wonder what the drive number of
the ROM disk in some of the newer model Macs is...
-- 
 Pete Gontier, gurgle@well.sf.ca.us
 Software Imagineer, Kiwi Software, Inc.