IOCTL_HAL_QUERY_FORMAT_PARTITION (Windows CE 5.0)

Send Feedback

This IOCTL is called by the Storage Manager, fsdmgr.dll, to allow an OEM to specify whether a specific partition is to be formatted on mount.

Parameters

  • dwIoControlCode
    [in] Set to IOCTL_HAL_QUERY_FORMAT_PARTITION.
  • lpInBuf
    [in] Pointer to a STORAGECONTEXT structure.
  • nInBufSize
    [in] Size of the STORAGECONTEXT structure.
  • lpOutBuf
    [out] Pointer to a BOOL value. The OAL should return TRUE if the partition is to be formatted. Otherwise it should return FALSE.
  • nOutBufSize
    [in] Size of the BOOL value.
  • lpBytesReturned
    [in] Unused.

Return Values

None.

Remarks

Before Filesys.exe calls this IOCTL, 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

OS Versions: Windows CE 5.0 and later.
Header: Pkfuncs.h.

See Also

STORAGECONTEXT

Send Feedback on this topic to the authors

Feedback FAQs

© 2006 Microsoft Corporation. All rights reserved.