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 5 - Disk Initialization Manager / Using the Disk Initialization Manager


Changing Default Volume Characteristics

The Disk Initialization Manager must set certain volume characteristics when it creates an HFS directory on a volume. Default values for these characteristics are stored in an HFS defaults record in ROM. If you wish, you can override those default values by placing a pointer to an HFS defaults record in the low-memory global variable FmtDefaults. The Disk Initialization Manager uses the record stored in ROM whenever this low-memory global variable contains NIL.

IMPORTANT
Most applications do not need to alter the default volume characteristics. This technique is useful primarily for applications, such as backup
utilities, that intelligently adjust the allocation block size and clump
size to maximize the amount of data written to a backup volume.
The HFSDefaults data structure defines the HFS defaults record.

TYPE HFSDefaults =
RECORD
   sigWord:    PACKED ARRAY[0..1] OF Byte;   {signature word}
   abSize:     LongInt;                      {allocation block size in bytes}
   clpSize:    LongInt;                      {clump size in bytes}
   nxFreeFN:   LongInt;                      {next free file number}
   btClpSize:  LongInt;                      {B*-tree clump size in bytes}
   rsrv1:      Integer;                      {reserved}
   rsrv2:      Integer;                      {reserved}
   rsrv3:      Integer;                      {reserved}
END;
Field Description
sigWord
The signature word to be used for newly initialized volumes. By default, this field is set to 'BD' (hexadecimal $4244). You must set this field to 'BD' for the volume to be recognized as an HFS volume.
abSize
The number of bytes in each allocation block on newly initialized volumes. If you set this field to 0, the number of bytes in each allocation block is computed according to the following formula:
               abSize = (1 + (blocks in volume/64K)) * 512 bytes
By default, this field is set to 0.
clpSize
The number of bytes to be used for the clump on newly initialized volumes. By default, this field is set to 4*abSize.
nxFreeFN
The next free file number on newly initialized volumes. By default, this field is set to 16.
btClpSize
The number of bytes to be used for the B*-tree clump on newly initialized volumes. If you set this field to 0, the number of bytes to be used for the B*-tree clump is computed according to the following formula:
               btClpSize = ((blocks in volume)/128) * 512 bytes
By default, this field is set to 0.
rsrv1
Reserved. Set to 0.
rsrv2
Reserved. Set to 0.
rsrv3
Reserved. Set to 0.
The code in Listing 5-5 fills in an HFSDefaults record, stores it in the system heap (so that the record remains in memory after the application terminates), and makes the low-memory global variable FmtDefaults a pointer to that record. Note that changing the default volume characteristics does not affect volumes that you have already initialized, but only volumes to be initialized.

Listing 5-5 Changing default volume characteristics

PROCEDURE ChangeHFSDefaults;
CONST
   FmtDefaults    = $039E;                {address of low-memory global}
TYPE
   HFSDefaultsPtr = ^HFSDefaults;         {pointer to override record}
   HFSDefaultsAdd = ^HFSDefaultsPtr;      {address of above pointer}
VAR
   myDefaults:    HFSDefaultsPtr;
BEGIN                                     {allocate record in system heap}
   myDefaults := HFSDefaultsPtr(NewPtrSysClear(SizeOf(HFSDefaults)));
   WITH myDefaults^ DO
      BEGIN
         ...                              {set fields of record}
      END;
   HFSDefaultsAdd(FmtDefaults)^ := myDefaults;
                                          {change value of global}
END;
If you later want to restore the default settings, you can reset the low-memory global variable FmtDefaults to NIL. Remember to delete any memory you have allocated.


Previous Book Contents Book Index Next

© Apple Computer, Inc.
2 JUL 1996