f_fdisk

The f_fdisk fucntion divides a physical drive.

FRESULT f_fdisk (
  BYTE  Drive,              /* Physical drive number */
  const DWORD Partitions[], /* Partition size */
  void* Work                /* Work area */
);

Parameters

Drive
Specifies the physical drive to be divided.
Partitions[]
Partition map table. It must have four items.
Work
Pointer to the function work area. The size must be at least _MAX_SS bytes.

Return Values

FR_OK, FR_DISK_ERR, FR_NOT_READY, FR_WRITE_PROTECTED, FR_INVALID_PARAMETER

Description

The f_fdisk function creates a partition table into the MBR of the physical drive. The partitioning rule is in generic FDISK format so that it can create upto four primary partitions. Extended partition is not supported. The Partitions[] specifies how to divide the physical drive. The first item specifies the size of first primary partition and fourth item specifies the fourth primary partition. If the value is less than or equal to 100, it means percentage of the partition in the entire disk space. If it is larger than 100, it means partition size in unit of sector.

QuickInfo

Available when _FS_READOLNY == 0, _USE_MKFS == 1 and _MULTI_PARTITION == 2.

Example

    /* Volume management table defined by user (required when _MULTI_PARTITION != 0) */

    PARTITION VolToPart[] = {
        {0, 1},    /* Logical drive 0 ==> Physical drive 0, 1st partition */
        {0, 2},    /* Logical drive 1 ==> Physical drive 0, 2nd partition */
        {1, 0}     /* Logical drive 2 ==> Physical drive 1, auto detection */
    };
    /* Initialize a brand-new disk drive mapped to physical drive 0 */

    FATFS Fatfs;
    DWORD plist[] = {50, 50, 0, 0};  /* Divide drive into two partitions */
    BYTE work[_MAX_SS];

    f_fdisk(0, plist, work);  /* Divide physical drive 0 */

    f_mount(0, &Fatfs);
    f_mkfs(0, 0, 0);          /* Create an FAT volume on the logical drive 0. 2nd argument is ignored. */
    f_mount(0, 0);

    f_mount(1, &Fatfs);
    f_mkfs(1, 0, 0);
    f_mount(1, 0);

See Also

Volume management, f_mkfs

Return