fdisk.html 4.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  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=iso-8859-1">
  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. <body>
  12. <div class="para func">
  13. <h2>f_fdisk</h2>
  14. <p>The f_fdisk fucntion divides a physical drive.</p>
  15. <pre>
  16. FRESULT f_fdisk (
  17. BYTE <span class="arg">pdrv</span>, <span class="c">/* [IN] Physical drive number */</span>
  18. const DWORD <span class="arg">part[]</span>, <span class="c">/* [IN] Partition size */</span>
  19. void* <span class="arg">work</span> <span class="c">/* [IN] Work area */</span>
  20. );
  21. </pre>
  22. </div>
  23. <div class="para arg">
  24. <h4>Parameters</h4>
  25. <dl class="par">
  26. <dt>pdrv</dt>
  27. <dd>Specifies the <em>physical drive</em> to be divided.</dd>
  28. <dt>part[]</dt>
  29. <dd>Partition map table. It must have four items.</dd>
  30. <dt>work</dt>
  31. <dd>Pointer to the function work area. The size must be at least <tt>_MAX_SS</tt> bytes.</dd>
  32. </dl>
  33. </div>
  34. <div class="para ret">
  35. <h4>Return Values</h4>
  36. <p>
  37. <a href="rc.html#ok">FR_OK</a>,
  38. <a href="rc.html#de">FR_DISK_ERR</a>,
  39. <a href="rc.html#nr">FR_NOT_READY</a>,
  40. <a href="rc.html#wp">FR_WRITE_PROTECTED</a>,
  41. <a href="rc.html#ip">FR_INVALID_PARAMETER</a>
  42. </p>
  43. </div>
  44. <div class="para desc">
  45. <h4>Description</h4>
  46. <p>The <tt>f_fdisk()</tt> 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. Logical volumes in the extended partition is not supported. The <tt class="arg">part[]</tt> 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 percentage of the partition in the entire disk space. If it is larger than 100, it specifies the partition size in unit of sector.</p>
  47. </div>
  48. <div class="para comp">
  49. <h4>QuickInfo</h4>
  50. <p>Available when <tt>_FS_READOLNY == 0</tt>, <tt>_USE_MKFS == 1</tt> and <tt>_MULTI_PARTITION == 1</tt>.</p>
  51. </div>
  52. <div class="para use">
  53. <h4>Example</h4>
  54. <pre>
  55. <span class="c">/* Volume management table defined by user (required when _MULTI_PARTITION == 1) */</span>
  56. PARTITION VolToPart[] = {
  57. {0, 1}, <span class="c">/* Logical drive 0 ==> Physical drive 0, 1st partition */</span>
  58. {0, 2}, <span class="c">/* Logical drive 1 ==> Physical drive 0, 2nd partition */</span>
  59. {1, 0} <span class="c">/* Logical drive 2 ==> Physical drive 1, auto detection */</span>
  60. };
  61. </pre>
  62. <pre>
  63. <span class="c">/* Initialize a brand-new disk drive mapped to physical drive 0 */</span>
  64. FATFS fs;
  65. DWORD plist[] = {50, 50, 0, 0}; <span class="c">/* Divide drive into two partitions */</span>
  66. BYTE work[_MAX_SS];
  67. f_fdisk(0, plist, work); <span class="c">/* Divide physical drive 0 */</span>
  68. f_mount(&amp;fs, "0:", 0); <span class="c">/* Register work area to the logical drive 0 */</span>
  69. f_mkfs("0:", 0, 0); <span class="c">/* Create FAT volume on the logical drive 0. 2nd argument is ignored. */</span>
  70. f_mount(0, "0:", 0); <span class="c">/* Unregister work area from the logical drive 0 */</span>
  71. f_mount(&amp;fs, "1:", 0); <span class="c">/* Register a work area to the logical drive 1 */</span>
  72. f_mkfs("1:", 0, 0); <span class="c">/* Create FAT volume on the logical drive 1. 2nd argument is ignored. */</span>
  73. f_mount(0, "1:", 0); <span class="c">/* Unregister work area from the logical drive 1 */</span>
  74. </pre>
  75. </div>
  76. <div class="para ref">
  77. <h4>See Also</h4>
  78. <p><a href="filename.html#vol">Volume management</a>, <a href="mkfs.html"><tt>f_mkfs</tt></a></p>
  79. </div>
  80. <p class="foot"><a href="../00index_e.html">Return</a></p>
  81. </body>
  82. </html>