disk_ioctl

The disk_ioctl function cntrols device specific features and miscellaneous functions other than generic read/write.

DRESULT disk_ioctl (
  BYTE pdrv,     /* [IN] Drive number */
  BYTE cmd,      /* [IN] Control command code */
  void* buff     /* [I/O] Parameter and data buffer */
);

Parameters

pdrv
Physical drive number to identify the target device.
cmd
Command code.
buff
Pointer to the parameter depends on the command code. Do not care if no parameter to be passed.

Return Value

RES_OK (0)
The function succeeded.
RES_ERROR
An error occured.
RES_PARERR
The command code or parameter is invalid.
RES_NOTRDY
The device has not been initialized.

Description

The FatFs module uses only device independent commands described below. Any device dependent functions and user defined functions are not used.

CommandDescription
CTRL_SYNCMake sure that the device has finished pending write process. If the disk I/O module has a write back cache, the dirty buffers must be written back to the media immediately. If each write operation to the media is completed within the disk_write() function, nothing to do for this command.
GET_SECTOR_COUNTReturns number of available sectors on the drive into the DWORD variable pointed by buff. This command is used by only f_mkfs() and f_fdisk() function to determine the volume/partition size to be created.
GET_SECTOR_SIZEReturns sector size of the media into the WORD variable pointed by buff. Valid return values of this command are 512, 1024, 2048 or 4096. This command is never used at fixed sector size configuration, _MAX_SS == _MIN_SS, and it must work at that sector size.
GET_BLOCK_SIZEReturns erase block size of the flash memory in unit of sector into the DWORD variable pointed by buff. The allowable value is from 1 to 32768 in power of 2. Return 1 if the erase block size is unknown or disk media. This command is used by only f_mkfs() function and it attempts to align data area to the erase block boundary.
CTRL_ERASE_SECTORErases a part of the flash memory specified by a DWORD array {<start sector>, <end sector>} pointed by buff. This is similar command to Trim command of ATA device. When this feature is not supported or not a flash memory media, nothing to do for this command. The FatFs does not check the result code and the file function is not affected even if the sectors ware not erased well. This command is called on removing a cluster chain and f_mkfs() function when _USE_ERASE is 1.

QuickInfo

This function is not needed when _FS_READONLY == 1 and _MAX_SS == _MIN_SS.

Return