1e6865dcdSopenharmony_ci<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> 2e6865dcdSopenharmony_ci<html lang="en"> 3e6865dcdSopenharmony_ci<head> 4e6865dcdSopenharmony_ci<meta http-equiv="Content-Type" content="text/html; charset=utf-8"> 5e6865dcdSopenharmony_ci<meta http-equiv="Content-Style-Type" content="text/css"> 6e6865dcdSopenharmony_ci<link rel="up" title="FatFs" href="../00index_e.html"> 7e6865dcdSopenharmony_ci<link rel="alternate" hreflang="ja" title="Japanese" href="../ja/fdisk.html"> 8e6865dcdSopenharmony_ci<link rel="stylesheet" href="../css_e.css" type="text/css" media="screen" title="ELM Default"> 9e6865dcdSopenharmony_ci<title>FatFs - f_fdisk</title> 10e6865dcdSopenharmony_ci</head> 11e6865dcdSopenharmony_ci 12e6865dcdSopenharmony_ci<body> 13e6865dcdSopenharmony_ci 14e6865dcdSopenharmony_ci<div class="para func"> 15e6865dcdSopenharmony_ci<h2>f_fdisk</h2> 16e6865dcdSopenharmony_ci<p>The f_fdisk fucntion divides a physical drive.</p> 17e6865dcdSopenharmony_ci<pre> 18e6865dcdSopenharmony_ciFRESULT f_fdisk ( 19e6865dcdSopenharmony_ci BYTE <span class="arg">pdrv</span>, <span class="c">/* [IN] Physical drive number */</span> 20e6865dcdSopenharmony_ci const LBA_t <span class="arg">ptbl[]</span>, <span class="c">/* [IN] Partition map table */</span> 21e6865dcdSopenharmony_ci void* <span class="arg">work</span> <span class="c">/* [IN] Work area */</span> 22e6865dcdSopenharmony_ci); 23e6865dcdSopenharmony_ci</pre> 24e6865dcdSopenharmony_ci</div> 25e6865dcdSopenharmony_ci 26e6865dcdSopenharmony_ci<div class="para arg"> 27e6865dcdSopenharmony_ci<h4>Parameters</h4> 28e6865dcdSopenharmony_ci<dl class="par"> 29e6865dcdSopenharmony_ci<dt>pdrv</dt> 30e6865dcdSopenharmony_ci<dd>Specifies the <em>physical drive</em> to be divided. This is not the logical drive number but the drive identifier passed to the low level disk functions.</dd> 31e6865dcdSopenharmony_ci<dt>ptbl</dt> 32e6865dcdSopenharmony_ci<dd>List of partition size to create on the drive. The data type <tt>LBA_t</tt> is an alias of <tt>DWORD</tt> or <tt>QWORD</tt> depends on the configuration option <tt><a href="config.html#fs_lba64">FF_LBA64</a></tt>.</dd> 33e6865dcdSopenharmony_ci<dt>work</dt> 34e6865dcdSopenharmony_ci<dd>Pointer to the function work area. The size must be at least <tt><a href="config.html#max_ss">FF_MAX_SS</a></tt> bytes. When a null pointer is given with <tt><a href="config.html#use_lfn">FF_USE_LFN</a> = 3</tt>, a memory block is obtained in this function for the working buffer.</dd> 35e6865dcdSopenharmony_ci</dl> 36e6865dcdSopenharmony_ci</div> 37e6865dcdSopenharmony_ci 38e6865dcdSopenharmony_ci<div class="para ret"> 39e6865dcdSopenharmony_ci<h4>Return Values</h4> 40e6865dcdSopenharmony_ci<p> 41e6865dcdSopenharmony_ci<a href="rc.html#ok">FR_OK</a>, 42e6865dcdSopenharmony_ci<a href="rc.html#de">FR_DISK_ERR</a>, 43e6865dcdSopenharmony_ci<a href="rc.html#nr">FR_NOT_READY</a>, 44e6865dcdSopenharmony_ci<a href="rc.html#wp">FR_WRITE_PROTECTED</a>, 45e6865dcdSopenharmony_ci<a href="rc.html#ip">FR_INVALID_PARAMETER</a>, 46e6865dcdSopenharmony_ci<a href="rc.html#nc">FR_NOT_ENOUGH_CORE</a> 47e6865dcdSopenharmony_ci</p> 48e6865dcdSopenharmony_ci</div> 49e6865dcdSopenharmony_ci 50e6865dcdSopenharmony_ci<div class="para desc"> 51e6865dcdSopenharmony_ci<h4>Description</h4> 52e6865dcdSopenharmony_ci<p>The <tt>f_fdisk</tt> function creates partitions on the physical drive. The partitioning format can be in generic MBR or GPT. The partition map table specifies how to divide the physical drive. The first item specifies the size of the first partition and the partitions are located on the drive in order of from the first item. When the value of item is less than or equal to 100, it specifies the partition size in percentage of the entire drive space. When it is larger than 100, it specifies number of sectors. The partition map table is terminated by a zero, no space is remaining for next allocation or 4th partition is created in MBR format. If the specified size is larger than remaining space on the drive, the partition is truncated at end of the drive.</p> 53e6865dcdSopenharmony_ci<p>By default, partitions are created in MBR format. It can create upto four primary partitions on a drive. GPT format is used to create the partitions when 64-bit LBA is enabled (<tt>FF_LBA64 = 1</tt>) and the drive size is equal to or larger than <tt><a href="config.html#fs_gptmin">FF_MIN_GPT</a></tt> sectors. It can create over ten partitions on a drive.</p> 54e6865dcdSopenharmony_ci</div> 55e6865dcdSopenharmony_ci 56e6865dcdSopenharmony_ci<div class="para comp"> 57e6865dcdSopenharmony_ci<h4>QuickInfo</h4> 58e6865dcdSopenharmony_ci<p>Available when <tt><a href="config.html#fs_readonly">FF_FS_READOLNY</a> == 0</tt>, <tt><a href="config.html#use_mkfs">FF_USE_MKFS</a> == 1</tt> and <tt><a href="config.html#multi_partition">FF_MULTI_PARTITION</a> == 1</tt>.</p> 59e6865dcdSopenharmony_ci</div> 60e6865dcdSopenharmony_ci 61e6865dcdSopenharmony_ci<div class="para use"> 62e6865dcdSopenharmony_ci<h4>Example</h4> 63e6865dcdSopenharmony_ci<pre> 64e6865dcdSopenharmony_ci <span class="c">/* Volume mapping table defined by user (required when FF_MULTI_PARTITION == 1) */</span> 65e6865dcdSopenharmony_ci 66e6865dcdSopenharmony_ci PARTITION VolToPart[FF_VOLUMES] = { 67e6865dcdSopenharmony_ci {0, 1}, <span class="c">/* "0:" ==> 1st partition in PD#0 */</span> 68e6865dcdSopenharmony_ci {0, 2}, <span class="c">/* "1:" ==> 2nd partition in PD#0 */</span> 69e6865dcdSopenharmony_ci {1, 0} <span class="c">/* "2:" ==> PD#1 as removable drive */</span> 70e6865dcdSopenharmony_ci }; 71e6865dcdSopenharmony_ci</pre> 72e6865dcdSopenharmony_ci<pre> 73e6865dcdSopenharmony_ci <span class="c">/* Initialize a brand-new disk drive mapped to physical drive 0 */</span> 74e6865dcdSopenharmony_ci 75e6865dcdSopenharmony_ci BYTE work[FF_MAX_SS]; <span class="c">/* Working buffer */</span> 76e6865dcdSopenharmony_ci LBA_t plist[] = {50, 50, 0}; <span class="c">/* Divide the drive into two partitions */</span> 77e6865dcdSopenharmony_ci <span class="c">/* {0x10000000, 100}; 256M sectors for 1st partition and left all for 2nd partition */</span> 78e6865dcdSopenharmony_ci <span class="c">/* {20, 20, 20, 0}; 20% for 3 partitions each and remaing space is left not allocated */</span> 79e6865dcdSopenharmony_ci 80e6865dcdSopenharmony_ci <em>f_fdisk</em>(0, plist, work); <span class="c">/* Divide physical drive 0 */</span> 81e6865dcdSopenharmony_ci 82e6865dcdSopenharmony_ci f_mkfs("0:", 0, work, sizeof work); <span class="c">/* Create FAT volume on the logical drive 0 */</span> 83e6865dcdSopenharmony_ci f_mkfs("1:", 0, work, sizeof work); <span class="c">/* Create FAT volume on the logical drive 1 */</span> 84e6865dcdSopenharmony_ci 85e6865dcdSopenharmony_ci</pre> 86e6865dcdSopenharmony_ci</div> 87e6865dcdSopenharmony_ci 88e6865dcdSopenharmony_ci<div class="para ref"> 89e6865dcdSopenharmony_ci<h4>See Also</h4> 90e6865dcdSopenharmony_ci<p><a href="filename.html#vol">Volume management</a>, <a href="mkfs.html"><tt>f_mkfs</tt></a></p> 91e6865dcdSopenharmony_ci</div> 92e6865dcdSopenharmony_ci 93e6865dcdSopenharmony_ci<p class="foot"><a href="../00index_e.html">Return</a></p> 94e6865dcdSopenharmony_ci</body> 95e6865dcdSopenharmony_ci</html> 96