Legacy Documentclose button

Important: The information in this document is obsolete and should not be used for new development.

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.
WARNING
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}
RECORD
   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}
END;
Note
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
qLink
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.
qType
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.
vcbFlags
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.
vcbSigWord
The volume signature. For HFS volumes, this field contains $4244.
vcbCrDate
The date and time of volume creation (initialization).
vcbLsMod
The date and time of last modification. This is not necessarily when the volume was last flushed.
vcbAtrb
Volume attributes. The bits have these meanings:
 BitMeaning
 0-5Reserved
 6Set if the volume is busy (one or more files are open)
 7Set if the volume is locked by hardware
 8-14Reserved
 15Set if the volume is locked by software
vcbNmFls
The number of files in the root directory.
vcbVBMSt
The first block of the volume bitmap.
vcbAllocPtr
The start block of the next allocation search. Used internally.
vcbNmAlBlks
The number of allocation blocks in the volume.
vcbAlBlkSiz
The allocation block size (in bytes). This value must always be a multiple of 512 bytes.
vcbClpSiz
The default clump size.
vcbAlBlSt
The first allocation block in the volume.
vcbNxtCNID
The next unused catalog node ID (directory ID or file ID).
vcbFreeBks
The number of unused allocation blocks on the volume.
vcbVN
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.
vcbDrvNum
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.
vcbDRefNum
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).
vcbFSID
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.
vcbVRefNum
The volume reference number.
vcbMAdr
Used internally.
vcbBufAdr
Used internally.
vcbMLen
Used internally.
vcbDirIndex
Used internally.
vcbDirBlk
Used internally.
vcbVolBkUp
The date and time of the last volume backup.
vcbVSeqNum
Used internally.
vcbWrCnt
The volume write count.
vcbXTClpSiz
The clump size of the extents overflow file.
vcbCTClpSiz
The clump size of the catalog file.
vcbNmRtDirs
The number of directories in the root directory.
vcbFilCnt
The number of files on the volume.
vcbDirCnt
The number of directories on the volume.
vcbFndrInfo
Information used by the Finder.
vcbVCSize
Used internally.
vcbVBMCSiz
Used internally.
vcbCtlCSiz
Used internally.
vcbXTAlBks
The size (in blocks) of the extents overflow file.
vcbCTAlBks
The size (in blocks) of the catalog file.
vcbXTRef
The path reference number for the extents overflow file.
vcbCTRef
The path reference number for the catalog file.
vcbCtlBuf
A pointer to the extents and catalog caches.
vcbDirIDM
The directory last searched.
vcbOffsM
The offspring index at the last search.

Previous Book Contents Book Index Next

© Apple Computer, Inc.
2 JUL 1996