Path: utzoo!attcan!uunet!mcsun!hp4nl!janus!maarten From: maarten@janus.UUCP (Maarten Carels) Newsgroups: comp.sys.mac.programmer Subject: Re: Telling Floppies from Hard Disks Message-ID: <785@janus.UUCP> Date: 24 Aug 89 12:11:27 GMT References: <1742@cs-spool.calgary.UUCP> <3841@internal.Apple.COM> Reply-To: maarten@fwi.uva.nl (Maarten Carels) Organization: Faculteit Wiskunde & Informatica, Universiteit van Amsterdam Lines: 55 blob@apple.com (Brian Bechtel) writes: >In article <1742@cs-spool.calgary.UUCP> jamesm@cpsc.ucalgary.ca (Mark >James) writes: >> I'm looking for a method to test a volume to see if it is a floppy or a >> hard drive. I have written an INIT to patch PBMountVol to check an ... stuff deleted... >It sounds like what you really want to check is if a device in the drive >queue is removable or not. To do this, examine the four bytes of flags >preceeding the drive queue entry for this device. See Inside Mac >IV-181 & 182 for details. C source is: Then some C source appears, only the relevant parts kept: > d = ... /* pointer to some drive queue element */ > if (d->dQDrive == driveNumber) /* is this the drive we want? */ > { > p = (Ptr)d; > p -= 3; /* to get to the byte with eject info */ > if (*p == 8) **** ^ This is plain wrong, see below > /* non ejectable disk in drive */ > else > /* ejectable disk in drive */ The flag byte tested above contains (IM IV-181): 0 if no disk in drive 1 or 2 if disk in drive 8 if nonejectable disk in drive $fc-$ff if disk was ejected within last 1.5 seconds $48 if disk in drive is nonejectable but driver wants a call if there is 48 in the flags byte, the disk is considered nonejectable by both the Finder and Standard File. Unmounting the disk (dragging to the trash) causes an Eject control call to thye driver, that can be used to clean up after unmounting (such as updating internal data structures of the driver). Code like this (checking for 8, and failing to recognize 48 for non-ejectable disks) causes problems with some disks (such as mine) in programs like DiskExpress, PrintQueue (of Super(Laser)Spool, FEdit, to name some. So, please do not check for only for flags value 8, but also for $48, or test for the specific bit (3). --maarten In real life: Maarten Carels Computer Science Department University of Amsterdam email: maarten@fwi.uva.nl -- In real life: Maarten Carels Computer Science Department University of Amsterdam email: maarten@fwi.uva.nl