Platform SDK: Win32 API

SetDPB_GetSetRootDirClus (FAT32)

Allows the first cluster of the root directory of a FAT32 drive to be read and changed. This call is invalid on FAT12 and FAT16 drives.

This sub-function is called when the SetDPB_Function member of the SDPDFormatStruc structure is set to 4.

Parameters

SetDPB_Value1
This member in the SPDPFormatStruc specifies the SET behavior. If the value is 0xFFFFFFFF, then no changes are made and the current root directory first cluster number is returned in SetDPB_Value2.

The value is range checked. It must be >=2 and <= the maximum valid cluster number for the drive.

SetDPB_Value2
This member in the SPDPFormatStruc is used as a return value where the previous root directory first cluster is held. When SetDPB_Value1 is 0xFFFFFFFF, the previous cluster is also the current root directory cluster.

Return Values

If the function is unsuccessful, the function sets the carry flag and returns ERROR_GEN_FAILURE (error code 31) to AX. Receiving ERROR_GEN_FAILURE as the return value indicates that a disk error occurred during the attempt to write. In this case, the DPB mirror property is changed, but not properly written to disk. If the function fails, it is recommended that the caller re-write the value returned to SetDBP_Value2 to attempt to undo the change.

Remarks

Since the start cluster of the root directory is also stored in the BPB of the boot sector(s) of the drive, this call re-writes these boot sectors as a side effect.

Note that the device driver may also contain these values as part of its current device parameters. This call will have no effect on the FAT Mirror properties held by the device driver. Because of this, it is recommended to immediately follow the set form of the call with a SetDeviceParameters Generic IOCTL call. This sets the current BPB that the BuildBPB routine of the device returns.

The assembler calling sequence for all Int 21h 7304h sub-functions is almost identical. See the main listing for a sample. (Int 21h Function 7304h Set_DPBForFormat)