The f_fdisk fucntion divides a physical drive.
FRESULT f_fdisk ( BYTE pdrv, /* [IN] Physical drive number */ const DWORD* szt, /* [IN] Partition map table */ void* work /* [IN] Work area */ );
FR_OK, FR_DISK_ERR, FR_NOT_READY, FR_WRITE_PROTECTED, FR_INVALID_PARAMETER
The f_fdisk function creates partitions on the physical drive. The partitioning format is in generic FDISK format, so that it can create upto four primary partitions. Logical volumes in the extended partition is not supported. The partition map table with four items 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 specifies the partition size in percentage of the entire drive space. If it is larger than 100, it specifies the partition size in unit of sector. The partitions are located on the drive in order of from first item.
Available when FF_FS_READOLNY == 0, FF_USE_MKFS == 1 and FF_MULTI_PARTITION == 1.
/* Volume management table defined by user (required when FF_MULTI_PARTITION == 1) */ PARTITION VolToPart[] = { {0, 1}, /* "0:" ==> Physical drive 0, 1st partition */ {0, 2}, /* "1:" ==> Physical drive 0, 2nd partition */ {1, 0} /* "2:" ==> Physical drive 1, auto detection */ };
/* Initialize a brand-new disk drive mapped to physical drive 0 */ DWORD plist[] = {50, 50, 0, 0}; /* Divide drive into two partitions */ BYTE work[FF_MAX_SS]; f_fdisk(0, plist, work); /* Divide physical drive 0 */ f_mkfs("0:", FM_ANY, work, sizeof work); /* Create FAT volume on the logical drive 0 */ f_mkfs("1:", FM_ANY, work, sizeof work); /* Create FAT volume on the logical drive 1 */