mkfs.html 3.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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="stylesheet" href="../css_e.css" type="text/css" media="screen" title="ELM Default">
  8. <title>FatFs - f_mkfs</title>
  9. </head>
  10. <body>
  11. <div class="para">
  12. <h2>f_mkfs</h2>
  13. <p>The f_mkfs fucntion creates a file system on the drive.</p>
  14. <pre>
  15. FRESULT f_mkfs (
  16. BYTE <em>Drive</em>, /* Logical drive number */
  17. BYTE <em>PartitioningRule</em>, /* Partitioning rule */
  18. WORD <em>AllocSize</em> /* Allocation unit size */
  19. );
  20. </pre>
  21. </div>
  22. <div class="para">
  23. <h4>Parameters</h4>
  24. <dl class="par">
  25. <dt>Drive</dt>
  26. <dd>Logical drive number (0-9) to be formatted.</dd>
  27. <dt>PartitioningRule</dt>
  28. <dd>When 0 is given, a partition table is created into first sector on the drive and then the file system is created on the partition. This is called FDISK format. When 1 is given, the file system starts from the first sector without partition table. This is often called super floppy (SFD) format.</dd>
  29. <dt>AllocSize</dt>
  30. <dd>Specifies allocation unit size (number of bytes per cluster). The value must be power of 2 in range of from 512 to 32768.</dd>
  31. </dl>
  32. </div>
  33. <div class="para">
  34. <h4>Return Values</h4>
  35. <dl class="ret">
  36. <dt>FR_OK (0)</dt>
  37. <dd>The function succeeded.</dd>
  38. <dt>FR_INVALID_DRIVE</dt>
  39. <dd>The drive number is invalid.</dd>
  40. <dt>FR_NOT_READY</dt>
  41. <dd>The drive cannot work due to any reason.</dd>
  42. <dt>FR_WRITE_PROTECTED</dt>
  43. <dd>The drive is write protected.</dd>
  44. <dt>FR_NOT_ENABLED</dt>
  45. <dd>The logical drive has no work area.</dd>
  46. <dt>FR_RW_ERROR</dt>
  47. <dd>The function failed due to a disk error or an internal error.</dd>
  48. <dt>FR_MKFS_ABORTED</dt>
  49. <dd>The function aborted before start in format due to a reason as follows.
  50. <ul>
  51. <li>The disk size is too small.</li>
  52. <li>Invalid parameter was given to any parameter.</li>
  53. <li>Not allowable cluster size for this drive. This can occure when number of clusters becomes around 0xFF7 and 0xFFF7.</li>
  54. </ul>
  55. </dd>
  56. </dl>
  57. </div>
  58. <div class="para">
  59. <h4>Description</h4>
  60. <p>The f_mkfs function creates a FAT file system on the drive. There are two partitioning rules, FDISK and SFD, for removable media. It can be selected with an argument. The FDISK format is recommended for most case. This function currently does not support multiple partition, so that existing partitions on the physical dirve will be deleted and re-created a partition occupies entire disk space.</p>
  61. <p>The FAT sub-type, FAT12/FAT16/FAT32, is determined by only how many clusters on the drive and nothing else, according to the FAT specification issued by Microsoft. Thus which FAT sub-type is selected, is depends on the drive size and specified cluster size. The cluster size affects performance of file system and large cluster increases the performance, so that 32768 bytes per cluster is recommended for most case except for small drive.</p>
  62. <p>This function is supported on only FatFs with _USE_MKFS option.<p>
  63. </div>
  64. <p class="foot"><a href="../00index_e.html">Return</a></p>
  65. </body>
  66. </html>