Important: The information in this document is obsolete and should not be used for new development.
The Drive Queue
The File Manager maintains a list of all disk drives connected to the computer. It maintains this list in the drive queue, which is a standard operating system queue. The drive queue is initially created at system startup time. Elements are added to the queue at system startup time or when you call theAddDrive
procedure. The drive queue can support any number of drives, limited only by memory space. Each element in the drive queue contains information about the corresponding drive; the structure of a drive queue element is defined by theDrvQEl
data type.
TYPE DrvQEl = RECORD qLink: QElemPtr; {next queue entry} qType: Integer; {flag for dQDrvSz and dQDrvSz2} dQDrive: Integer; {drive number} dQRefNum: Integer; {driver reference number} dQFSID: Integer; {file-system identifier} dQDrvSz: Integer; {number of logical blocks on drive} dQDrvSz2: Integer; {additional field for large drives} END;The File Manager also maintains four flag bytes preceding each drive queue element. These bytes contain the following information:
Field Description
qLink
- A pointer to the next entry in the drive queue.
qType
- Used to specify the size of the drive. If the value of
qType
is 0,
the number of logical blocks on the drive is contained in thedQDrvSz
field alone. If the value ofqType
is 1, bothdQDrvSz
anddQDrvSz2
are used to store the number of blocks; in that case,dQDrvSz2
contains the high-order word of this number
anddQDrvSz
contains the low-order word.dQDrive
- The drive number of the drive.
dQRefNum
- The driver reference number of the driver controlling the device on which the volume is mounted.
dQFSID
- An identifier for the file system handling the volume in the drive; it's zero for volumes handled by the File Manager and nonzero for volumes handled by other file systems.
dQDrvSz
- The number of logical blocks on the drive.
dQDrvSz2
- An additional field to handle large drives. This field is used only if the
qType
field contains 1.
Byte Contents 0 Bit 7=1 if the volume on the drive is locked 1 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 2 Used internally during system startup 3 Bit 7=0 if disk is single-sided You can read these flags by subtracting 4 bytes from the beginning of a drive queue element, as illustrated in Listing 2-11.
Listing 2-11 Reading a drive queue element's flag bytes
FUNCTION GetDriveFlags (myDQElemPtr: DrvQElPtr): LongInt; TYPE FlagPtr = ^LongInt; {pointer to the queue element flag bytes} VAR myQFlagsPtr: FlagPtr; BEGIN {Just subtract 4 from the queue element pointer.} myQFlagsPtr := FlagPtr(ORD4(myDQElemPtr) - 4); GetDriveFlags := myQFlagsPtr^; END;TheGetDriveFlags
function defined Listing 2-11 takes a pointer to a drive queue element as a parameter. You can get a queue element pointer for a particular volume by walking the drive queue until you find a queue element whosedQDrive
field contains the same value as thevcbDrvNum
field of that volume's VCB. You can get a pointer to the header of the drive queue by calling the File Manager functionGetDrvQHdr
.Note that the bit numbers given in this section use the standard MC68000 numbering scheme; to access the correct bit using some Pascal routines, you must reverse that numbering. For example, if you use the Toolbox
BitTst
routine to determine whether a particular disk is single-sided, you must test bit 24 (that is, 31 minus 7) of the returned long integer. If you use the built-in Pascal functionBTST
, however, you can test the indicated bit directly.
- Assembly-Language Note
- The global variable
DrvQHdr
contains the header of the drive queue.