mkfs.html 4.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  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/mkfs.html">
  8. <link rel="stylesheet" href="../css_e.css" type="text/css" media="screen" title="ELM Default">
  9. <title>FatFs - f_mkfs</title>
  10. </head>
  11. <body>
  12. <div class="para func">
  13. <h2>f_mkfs</h2>
  14. <p>The f_mkfs fucntion creates an FAT file system on the logical drive.</p>
  15. <pre>
  16. FRESULT f_mkfs (
  17. const TCHAR* <span class="arg">path</span>, <span class="c">/* [IN] Logical drive number */</span>
  18. BYTE <span class="arg">sfd</span>, <span class="c">/* [IN] Partitioning rule */</span>
  19. UINT <span class="arg">au</span> <span class="c">/* [IN] Size of the allocation unit */</span>
  20. );
  21. </pre>
  22. </div>
  23. <div class="para arg">
  24. <h4>Parameters</h4>
  25. <dl class="par">
  26. <dt>path</dt>
  27. <dd>Pinter to the null-terminated string that specifies the <a href="filename.html">logical drive</a> to be formatted. If there is no drive number, it means the default drive.</dd>
  28. <dt>sfd</dt>
  29. <dd>Specifies partitioning rule (FDISK(0) or SFD(1)). This argument will be ignored on some case.</dd>
  30. <dt>au</dt>
  31. <dd>Specifies size of the allocation unit (cluter) in unit of byte. The value must be sector size * n (n is 1 to 128 and power of 2). When a zero is given, the cluster size is determined depends on the volume size.</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#id">FR_INVALID_DRIVE</a>,
  42. <a href="rc.html#ne">FR_NOT_ENABLED</a>,
  43. <a href="rc.html#ma">FR_MKFS_ABORTED</a>,
  44. <a href="rc.html#ip">FR_INVALID_PARAMETER</a>
  45. </p>
  46. </div>
  47. <div class="para desc">
  48. <h4>Description</h4>
  49. <p>The <tt>f_mkfs()</tt> function creates an FAT volume on the logical drive. When FDISK format is specified, a primary partition occupies the entire disk space is created and then an FAT volume is created on the partition. When SFD format is specified, the FAT volume starts from the first sector of the physical drive.</p>
  50. <p>If the logical drive has been bound to any partition (1-4) by multiple partition feature (<tt>_MULTI_PARTITION</tt>), the FAT volume is created into the specified partition. In this case, the second argument <tt class="arg">sfd</tt> is ignored. The physical drive must have been partitioned with <tt>f_fdisk()</tt> function or any other partitioning tool prior to use this function.</p>
  51. <p>Note that there are two partitioning rules, FDISK and SFD. The FDISK partitioning is usually used for harddisk, MMC, SDC, CFC and U Disk. It can divide a physical drive into one or more partitions with a partition table on the MBR. However Windows does not support multiple partition on the removable media. The SFD is non-partitioned method. The FAT volume starts from the first sector on the physical drive without partition table. It is usually used for floppy disk, Microdrive, optical disk and super-floppy media.</p>
  52. <p>The FAT sub-type, FAT12/FAT16/FAT32, is determined by number of clusters on the volume and nothing else, according to the FAT specification issued by Microsoft. Thus which FAT sub-type is selected, is depends on the volume size and the specified cluster size. The cluster size affects performance of the file system and large cluster increases the performance.</p>
  53. <p>When the number of clusters gets near the FAT sub-type boundaries, the function can fail with <tt>FR_MKFS_ABORTED</tt>.</p>
  54. </div>
  55. <div class="para comp">
  56. <h4>QuickInfo</h4>
  57. <p>Available when <tt>_FS_READOLNY == 0</tt> and <tt>_USE_MKFS == 1</tt>.</p>
  58. </div>
  59. <div class="para ref">
  60. <h4>See Also</h4>
  61. <p><tt><a href="filename.html#vol">Volume management</a>, <a href="fdisk.html">f_fdisk</a></tt></p>
  62. </div>
  63. <p class="foot"><a href="../00index_e.html">Return</a></p>
  64. </body>
  65. </html>