FatFS/doc/en/fdisk.html
savelij13 13034d028c fatfs v0.09 Sep 06,2011:
- f_mkfs() supports multiple partition to finish the multiple partition feature.
- Added f_fdisk(). (_MULTI_PARTITION = 2)
2025-09-11 09:47:39 +03:00

98 lines
3.5 KiB
HTML

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta http-equiv="Content-Style-Type" content="text/css">
<link rel="up" title="FatFs" href="../00index_e.html">
<link rel="alternate" hreflang="ja" title="Japanese" href="../ja/fdisk.html">
<link rel="stylesheet" href="../css_e.css" type="text/css" media="screen" title="ELM Default">
<title>FatFs - f_fdisk</title>
</head>
<body>
<div class="para func">
<h2>f_fdisk</h2>
<p>The f_fdisk fucntion divides a physical drive.</p>
<pre>
FRESULT f_fdisk (
BYTE <em>Drive</em>, <span class="c">/* Physical drive number */</span>
const DWORD <em>Partitions[]</em>, <span class="c">/* Partition size */</span>
void* <em>Work</em> <span class="c">/* Work area */</span>
);
</pre>
</div>
<div class="para arg">
<h4>Parameters</h4>
<dl class="par">
<dt>Drive</dt>
<dd>Specifies the <em>physical drive</em> to be divided.</dd>
<dt>Partitions[]</dt>
<dd>Partition map table. It must have four items.</dd>
<dt>Work</dt>
<dd>Pointer to the function work area. The size must be at least _MAX_SS bytes.</dd>
</dl>
</div>
<div class="para ret">
<h4>Return Values</h4>
<p>
<a href="rc.html#ok">FR_OK</a>,
<a href="rc.html#de">FR_DISK_ERR</a>,
<a href="rc.html#nr">FR_NOT_READY</a>,
<a href="rc.html#wp">FR_WRITE_PROTECTED</a>,
<a href="rc.html#ip">FR_INVALID_PARAMETER</a>
</p>
</div>
<div class="para desc">
<h4>Description</h4>
<p>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.</p>
</div>
<div class="para comp">
<h4>QuickInfo</h4>
<p>Available when <tt>_FS_READOLNY == 0</tt>, <tt>_USE_MKFS == 1</tt> and <tt>_MULTI_PARTITION == 2</tt>.</p>
</div>
<div class="para use">
<h4>Example</h4>
<pre>
<span class="c">/* Volume management table defined by user (required when _MULTI_PARTITION != 0) */</span>
PARTITION VolToPart[] = {
{0, 1}, <span class="c">/* Logical drive 0 ==> Physical drive 0, 1st partition */</span>
{0, 2}, <span class="c">/* Logical drive 1 ==> Physical drive 0, 2nd partition */</span>
{1, 0} <span class="c">/* Logical drive 2 ==> Physical drive 1, auto detection */</span>
};
</pre>
<pre>
<span class="c">/* Initialize a brand-new disk drive mapped to physical drive 0 */</span>
FATFS Fatfs;
DWORD plist[] = {50, 50, 0, 0}; <span class="c">/* Divide drive into two partitions */</span>
BYTE work[_MAX_SS];
f_fdisk(0, plist, work); <span class="c">/* Divide physical drive 0 */</span>
f_mount(0, &amp;Fatfs);
f_mkfs(0, 0, 0); <span class="c">/* Create an FAT volume on the logical drive 0. 2nd argument is ignored. */</span>
f_mount(0, 0);
f_mount(1, &amp;Fatfs);
f_mkfs(1, 0, 0);
f_mount(1, 0);
</pre>
</div>
<div class="para ref">
<h4>See Also</h4>
<p><tt><a href="filename.html#vol">Volume management</a>, <a href="mkfs.html">f_mkfs</a></tt></p>
</div>
<p class="foot"><a href="../00index_e.html">Return</a></p>
</body>
</html>