Compartilhar via


IOCTL_HAL_QUERY_FORMAT_PARTITION (Compact 2013)

10/16/2014

This I/O control message is called by Storage Manager, fsdmgr.dll, to enable an OEM to specify whether the specified partition is to be formatted on mount. Send this message with OEMIoControl.

Syntax

BOOL OEMIoControl(
    DWORD dwIoControlCode,    // use IOCTL_HAL_QUERY_FORMAT_PARTITION
    LPVOID lpInBuffer,        // pointer to input buffer
    DWORD nInBufferSize,      // input buffer size
    LPVOID lpOutBuffer,       // pointer to output buffer
    DWORD nOutBufferSize,     // output buffer size
    LPDWORD lpBytesReturned   // number of bytes returned
);

Parameters

  • dwIoControlCode
    [in] Control code for the operation. Use IOCTL_HAL_QUERY_FORMAT_PARTITION for this operation.
  • nInBufferSize
    [in] Size of the STORAGECONTEXT structure.
  • lpOutBuffer
    [out] Pointer to a BOOL value. The OAL should return TRUE if the partition is to be formatted; otherwise it should return FALSE.
  • nOutBufferSize
    [in] Size of the BOOL value.
  • lpBytesReturned
    [in] Unused.

Return Values

None.

Remarks

Before Filesys.exe calls this I/O control, it checks the CheckForFormat registry value in the storage profile for your block driver. This IOCTL will not be called if CheckForFormat has not been set.

By examining the contents of the STORAGECONTEXT structure pointed to by lpInBuf, an OEM can determine whether or not to format the partition based on private criteria.

The following example shows the registry setting for the MyStorageProfile profile in a FATFS partition.

[HKEY_LOCAL_MACHINE\System\StorageManager\Profiles\MyStorageProfile\FATFS]
    "CheckForFormat"=dword:1

Example

The following example shows a typical OAL implementation for handling IOCTL_HAL_QUERY_FORMAT_PARTITION. While this example examines the mount flags MountAsBootable and MountAsRoot, an OEM can examine the STORAGECONTEXT structure in any way to determine if a format is necessary.

BOOL OEMIoControl (DWORD ioctl, void* pInBuf, DWORD cbInBuf, void* pOutBuf, DWORD cbOutBuf, DWORD *pcbReturned)
{
    switch (ioctl)
    {
  // ...
  // format a given storage partition        
  //
        case IOCTL_HAL_QUERY_FORMAT_PARTITION:
        {
            STORAGECONTEXT* pContext = (STORAGECONTEXT*)pInBuf;
            
            // validate parameters
            if (sizeof(STORAGECONTEXT) != cbInBuf || !pInBuf ||
                sizeof(BOOL) != cbOutBuf || !pOutBuf) {
                SetLastError(ERROR_INVALID_PARAMETER);
                return FALSE;
            }
            // by default, do not format any partitions
            *(BOOL*)pOutBuf = FALSE; 
  //
  // format the root file system? (MountAsRoot=dword:1)
  //
            if (g_fFormatRootFS && (AFS_FLAG_ROOTFS & pContext->dwFlags)) {
                *(BOOL*)pOutBuf = TRUE;
            }
  //
  // format the bootable file system? (MountAsBootable=dword:1)
  //
            if (g_fFormatBootableFS && (AFS_FLAG_BOOTABLE & pContext->dwFlags)) {
                *(BOOL*)pOutBuf = TRUE; 
            }
            return TRUE;
        }
 // ...
    }
}

Requirements

Header

pkfuncs.h

See Also

Reference

Filesys.exe IOCTLs