• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
2<html lang="en">
3<head>
4<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
5<meta http-equiv="Content-Style-Type" content="text/css">
6<link rel="up" title="FatFs" href="../00index_e.html">
7<link rel="alternate" hreflang="ja" title="Japanese" href="../ja/fdisk.html">
8<link rel="stylesheet" href="../css_e.css" type="text/css" media="screen" title="ELM Default">
9<title>FatFs - f_fdisk</title>
10</head>
11
12<body>
13
14<div class="para func">
15<h2>f_fdisk</h2>
16<p>The f_fdisk fucntion divides a physical drive.</p>
17<pre>
18FRESULT f_fdisk (
19  BYTE  <span class="arg">pdrv</span>,         <span class="c">/* [IN] Physical drive number */</span>
20  const LBA_t <span class="arg">ptbl[]</span>, <span class="c">/* [IN] Partition map table */</span>
21  void* <span class="arg">work</span>          <span class="c">/* [IN] Work area */</span>
22);
23</pre>
24</div>
25
26<div class="para arg">
27<h4>Parameters</h4>
28<dl class="par">
29<dt>pdrv</dt>
30<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>
31<dt>ptbl</dt>
32<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>
33<dt>work</dt>
34<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>
35</dl>
36</div>
37
38<div class="para ret">
39<h4>Return Values</h4>
40<p>
41<a href="rc.html#ok">FR_OK</a>,
42<a href="rc.html#de">FR_DISK_ERR</a>,
43<a href="rc.html#nr">FR_NOT_READY</a>,
44<a href="rc.html#wp">FR_WRITE_PROTECTED</a>,
45<a href="rc.html#ip">FR_INVALID_PARAMETER</a>,
46<a href="rc.html#nc">FR_NOT_ENOUGH_CORE</a>
47</p>
48</div>
49
50<div class="para desc">
51<h4>Description</h4>
52<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>
53<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>
54</div>
55
56<div class="para comp">
57<h4>QuickInfo</h4>
58<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>
59</div>
60
61<div class="para use">
62<h4>Example</h4>
63<pre>
64    <span class="c">/* Volume mapping table defined by user (required when FF_MULTI_PARTITION == 1) */</span>
65
66    PARTITION VolToPart[FF_VOLUMES] = {
67        {0, 1},    <span class="c">/* "0:" ==> 1st partition in PD#0 */</span>
68        {0, 2},    <span class="c">/* "1:" ==> 2nd partition in PD#0 */</span>
69        {1, 0}     <span class="c">/* "2:" ==> PD#1 as removable drive */</span>
70    };
71</pre>
72<pre>
73    <span class="c">/* Initialize a brand-new disk drive mapped to physical drive 0 */</span>
74
75    BYTE work[FF_MAX_SS];         <span class="c">/* Working buffer */</span>
76    LBA_t plist[] = {50, 50, 0};  <span class="c">/* Divide the drive into two partitions */</span>
77                 <span class="c">/* {0x10000000, 100}; 256M sectors for 1st partition and left all for 2nd partition */</span>
78                 <span class="c">/* {20, 20, 20, 0}; 20% for 3 partitions each and remaing space is left not allocated */</span>
79
80    <em>f_fdisk</em>(0, plist, work);                    <span class="c">/* Divide physical drive 0 */</span>
81
82    f_mkfs("0:", 0, work, sizeof work); <span class="c">/* Create FAT volume on the logical drive 0 */</span>
83    f_mkfs("1:", 0, work, sizeof work); <span class="c">/* Create FAT volume on the logical drive 1 */</span>
84
85</pre>
86</div>
87
88<div class="para ref">
89<h4>See Also</h4>
90<p><a href="filename.html#vol">Volume management</a>, <a href="mkfs.html"><tt>f_mkfs</tt></a></p>
91</div>
92
93<p class="foot"><a href="../00index_e.html">Return</a></p>
94</body>
95</html>
96