## disk_ioctl

The disk_ioctl function cntrols device specified features and miscellaneous functions other than disk read/write.

    DRESULT disk_ioctl (
      BYTE Drive,      /* Drive number */
      BYTE Command,    /* Control command code */
      void* Buffer     /* Parameter and data buffer */
    );

#### Parameters

Drive
  Specifies the drive number (0-9).
Command
  Specifies the command code.
Buffer
  Pointer to the parameter buffer depends on the command code. When it is not used, specify a NULL pointer.

#### Return Value

RES_OK (0)
  The function succeeded.
RES_ERROR
  Any error occured.
RES_PARERR
  Invalid command code.
RES_NOTRDY
  The disk drive has not been initialized.

#### Description

The FatFs module uses only device independent commands described below. Any device dependent function is not used.

Command | Description
--- | ---
CTRL_SYNC | Make sure that the disk drive has finished pending write process. When the disk I/O module has a write back cache, flush the dirty sector immediately. This command is not used in read-only configuration.
GET_SECTOR_SIZE | Returns sector size of the drive into the WORD variable pointed by `Buffer`. This command is not used in fixed sector size configuration, `_MAX_SS` is 512.
GET_SECTOR_COUNT | Returns number of available sectors on the drive into the DWORD variable pointed by `Buffer`. This command is used by only f_mkfs function to determine the volume size to be created.
GET_BLOCK_SIZE | Returns erase block size of the flash memory in unit of sector into the DWORD variable pointed by `Buffer`. The allowable value is 1 to 32768 in power of 2. Return 1 if the erase block size is unknown or disk devices. This command is used by only f_mkfs function and it attempts to align data area to the erase block boundary.

CTRL_ERASE_SECTOR

Erases a part of the flash memory specified by a DWORD array {<start sector>, <end sector>} pointed by `Buffer`. When this feature is not supported or not a flash memory media, this command has no effect. The FatFs does not check the result code and the file function is not affected even if the sectors are not erased well. This command is called on removing a cluster chain when `_USE_ERASE` is 1.

Return