Advanced Search
Apple Developer Connection
Member Login Log In | Not a Member? Contact ADC

Previous Book Contents Book Index Next

Inside Macintosh: Files /
Chapter 2 - File Manager / Data Organization in Memory

Volume Control Blocks

Each time a volume is mounted, the File Manager reads its volume information from the master directory block and uses the information to build a new volume control block (VCB) in the volume control block queue (unless an ejected or offline volume is being remounted). The File Manager also creates a volume buffer in the system heap. When a volume is placed offline, its buffer is released. When a volume is unmounted, its VCB is removed from the VCB queue as well.

Assembly-Language Note
The global variable VCBQHdr contains the header of the VCB queue. The global variable DefVCBPtr points to the VCB of the default volume.
The size and structure of a VCB may be different in future versions of Macintosh system software. To ensure that you are reading the correct version of a VCB, check the vcbSigWord field; it should contain the value $4244.
The volume control block queue is a standard Operating System queue that's maintained in the system heap. It contains a volume control block for each mounted volume. A volume control block is a nonrelocatable block that contains volume-specific information. The structure of a volume control block is defined by the VCB data type.

TYPE VCB             =           {volume control block}
   qLink:            QElemPtr;   {next queue entry}
   qType:            Integer;    {queue type}
   vcbFlags:         Integer;    {volume flags}
   vcbSigWord:       Integer;    {volume signature}
   vcbCrDate:        LongInt;    {date and time of volume creation}
   vcbLsMod:         LongInt;    {date and time of last modification}
   vcbAtrb:          Integer;    {volume attributes}
   vcbNmFls:         Integer;    {number of files in root directory}
   vcbVBMSt:         Integer;    {first block of volume bitmap}
   vcbAllocPtr:      Integer;    {start of next allocation search}
   vcbNmAlBlks:      Integer;    {number of allocation blocks in volume}
   vcbAlBlkSiz:      LongInt;    {size (in bytes) of allocation blocks}
   vcbClpSiz:        LongInt;    {default clump size}
   vcbAlBlSt:        Integer;    {first allocation block in volume}
   vcbNxtCNID:       LongInt;    {next unused catalog node ID}
   vcbFreeBks:       Integer;    {number of unused allocation blocks}
   vcbVN:            String[27]; {volume name}
   vcbDrvNum:        Integer;    {drive number}
   vcbDRefNum:       Integer;    {driver reference number}
   vcbFSID:          Integer;    {file-system identifier}
   vcbVRefNum:       Integer;    {volume reference number}
   vcbMAdr:          Ptr;        {used internally}
   vcbBufAdr:        Ptr;        {used internally}
   vcbMLen:          Integer;    {used internally}
   vcbDirIndex:      Integer;    {used internally}
   vcbDirBlk:        Integer;    {used internally}
   vcbVolBkUp:       LongInt;    {date and time of last backup}
   vcbVSeqNum:       Integer;    {volume backup sequence number}
   vcbWrCnt:         LongInt;    {volume write count}
   vcbXTClpSiz:      LongInt;    {clump size for extents overflow file}
   vcbCTClpSiz:      LongInt;    {clump size for catalog file}
   vcbNmRtDirs:      Integer;    {number of directories in root dir.}
   vcbFilCnt:        LongInt;    {number of files in volume}
   vcbDirCnt:        LongInt;    {number of directories in volume}
   vcbFndrInfo:      ARRAY[1..8] OF LongInt;
                                 {information used by the Finder}
   vcbVCSize:        Integer;    {used internally}
   vcbVBMCSiz:       Integer;    {used internally}
   vcbCtlCSiz:       Integer;    {used internally}
   vcbXTAlBks:       Integer;    {size of extents overflow file}
   vcbCTAlBks:       Integer;    {size of catalog file}
   vcbXTRef:         Integer;    {ref. num. for extents overflow file}
   vcbCTRef:         Integer;    {ref. num. for catalog file}
   vcbCtlBuf:        Ptr;        {ptr. to extents and catalog caches}
   vcbDirIDM:        LongInt;    {directory last searched}
   vcbOffsM:         Integer;    {offspring index at last search}
The values in the vcbNmAlBlks and vcbFreeBks fields are unsigned integers (that is, they can range from 0 to 65,535, not from -32,768 to 32,767). Because Pascal does not support unsigned data types, you need to use the technique illustrated in "Determining the Amount of Free Space on a Volume" on page 2-46 to read the values in these fields correctly.
Field Description
A pointer to the next entry in the VCB queue. You can get a pointer to the header of the VCB queue by calling the File Manager utility function GetVCBQHdr.
The queue type. When the volume is mounted and the VCB is created, this field is cleared. Thereafter, bit 7 of this field is set whenever a file on that volume is opened.
Volume flags. Bit 15 is set if the volume information has been changed by a File Manager call since the volume was last affected by a FlushVol call.
The volume signature. For HFS volumes, this field contains $4244.
The date and time of volume creation (initialization).
The date and time of last modification. This is not necessarily when the volume was last flushed.
Volume attributes. The bits have these meanings:
 6Set if the volume is busy (one or more files are open)
 7Set if the volume is locked by hardware
 15Set if the volume is locked by software
The number of files in the root directory.
The first block of the volume bitmap.
The start block of the next allocation search. Used internally.
The number of allocation blocks in the volume.
The allocation block size (in bytes). This value must always be a multiple of 512 bytes.
The default clump size.
The first allocation block in the volume.
The next unused catalog node ID (directory ID or file ID).
The number of unused allocation blocks on the volume.
The volume name. This field consists of a length byte followed
by 27 bytes. Note that the volume name can occupy at most
27 characters; this is an exception to the normal file and directory name limit of 31 characters.
The drive number of the drive on which the volume is located. When a mounted volume is placed offline or ejected, vcbDrvNum is set to 0.
The driver reference number of the driver used to access the volume. When a volume is ejected, vcbDRefNum is set to the previous value of vcbDrvNum (and hence is a positive number). When a volume is placed offline, vcbDRefNum is set to the
negative of the previous value of vcbDrvNum (and hence is
a negative number).
An identifier for the file system handling the volume; it's zero for volumes handled by the File Manager and nonzero for volumes handled by other file systems.
The volume reference number.
Used internally.
Used internally.
Used internally.
Used internally.
Used internally.
The date and time of the last volume backup.
Used internally.
The volume write count.
The clump size of the extents overflow file.
The clump size of the catalog file.
The number of directories in the root directory.
The number of files on the volume.
The number of directories on the volume.
Information used by the Finder.
Used internally.
Used internally.
Used internally.
The size (in blocks) of the extents overflow file.
The size (in blocks) of the catalog file.
The path reference number for the extents overflow file.
The path reference number for the catalog file.
A pointer to the extents and catalog caches.
The directory last searched.
The offspring index at the last search.

Previous Book Contents Book Index Next

© Apple Computer, Inc.
2 JUL 1996

Get information on Apple products.
Visit the Apple Store online or at retail locations.

Copyright © 2004 Apple Computer, Inc.
All rights reserved. | Terms of use | Privacy Notice