mirror of
https://github.com/portapack-mayhem/mayhem-firmware.git
synced 2024-12-15 12:38:11 +00:00
110 lines
5.4 KiB
HTML
110 lines
5.4 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/mkfs.html">
|
||
|
<link rel="stylesheet" href="../css_e.css" type="text/css" media="screen" title="ELM Default">
|
||
|
<title>FatFs - f_mkfs</title>
|
||
|
</head>
|
||
|
|
||
|
<body>
|
||
|
|
||
|
<div class="para func">
|
||
|
<h2>f_mkfs</h2>
|
||
|
<p>The f_mkfs fucntion creates an FAT file system on the logical drive.</p>
|
||
|
<pre>
|
||
|
FRESULT f_mkfs (
|
||
|
const TCHAR* <span class="arg">path</span>, <span class="c">/* [IN] Logical drive number */</span>
|
||
|
BYTE <span class="arg">sfd</span>, <span class="c">/* [IN] Partitioning rule */</span>
|
||
|
UINT <span class="arg">au</span> <span class="c">/* [IN] Size of the allocation unit */</span>
|
||
|
);
|
||
|
</pre>
|
||
|
</div>
|
||
|
|
||
|
<div class="para arg">
|
||
|
<h4>Parameters</h4>
|
||
|
<dl class="par">
|
||
|
<dt>path</dt>
|
||
|
<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>
|
||
|
<dt>sfd</dt>
|
||
|
<dd>Specifies partitioning rule (FDISK(0) or SFD(1)). This argument will be ignored on some case.</dd>
|
||
|
<dt>au</dt>
|
||
|
<dd>Specifies size of the allocation unit (cluter) in number of bytes or sectors. When the value is from 1 to 128, it specifies number of sectors. When the value is <tt>>= _MIN_SS</tt>, it specifies number of bytes. If any invalid value, zero or not power of 2, is given, the cluster size is automatically determined depends on the volume size.</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#id">FR_INVALID_DRIVE</a>,
|
||
|
<a href="rc.html#ne">FR_NOT_ENABLED</a>,
|
||
|
<a href="rc.html#ma">FR_MKFS_ABORTED</a>,
|
||
|
<a href="rc.html#ip">FR_INVALID_PARAMETER</a>
|
||
|
</p>
|
||
|
</div>
|
||
|
|
||
|
<div class="para desc">
|
||
|
<h4>Description</h4>
|
||
|
<p>The <tt>f_mkfs()</tt> function creates an FAT volume on the specified logical drive. When FDISK format is specified, a primary partition occupies entire space of the physical drive 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>
|
||
|
<p>If the logical drive is bound to the specific partition (1-4) by multiple partition feature (<tt>_MULTI_PARTITION</tt>), the FAT volume is created into the 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 tools prior to create the FAT volume with this function.</p>
|
||
|
<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 disk. 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 any type of super-floppy media.</p>
|
||
|
<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 read/write throughput and space usage efficiency. Larger cluster size increases the read/write throughput and decreases the space usage efficiency of the volume.</p>
|
||
|
<p>In case of the number of clusters gets near the FAT sub-type boundaries, the function can fail with <tt>FR_MKFS_ABORTED</tt>.</p>
|
||
|
</div>
|
||
|
|
||
|
<div class="para comp">
|
||
|
<h4>QuickInfo</h4>
|
||
|
<p>Available when <tt>_FS_READOLNY == 0</tt> and <tt>_USE_MKFS == 1</tt>.</p>
|
||
|
</div>
|
||
|
|
||
|
<div class="para use">
|
||
|
<h4>Example</h4>
|
||
|
<pre>
|
||
|
<span class="c">/* Format the default drive */</span>
|
||
|
int main (void)
|
||
|
{
|
||
|
FATFS fs; <span class="c">/* File system object (volume work area) */</span>
|
||
|
FIL fil; <span class="c">/* File object */</span>
|
||
|
FRESULT res; <span class="c">/* API result code */</span>
|
||
|
UINT bw; <span class="c">/* Bytes written */</span>
|
||
|
|
||
|
|
||
|
<span class="c">/* Register work area */</span>
|
||
|
f_mount(&fs, "", 0);
|
||
|
|
||
|
<span class="c">/* Create FAT volume with default cluster size */</span>
|
||
|
res = f_mkfs("", 0, 0);
|
||
|
if (res) ...
|
||
|
|
||
|
<span class="c">/* Create a file as new */</span>
|
||
|
res = f_open(&fil, "hello.txt", FA_CREATE_NEW | FA_WRITE);
|
||
|
if (res) ...
|
||
|
|
||
|
<span class="c">/* Write a message */</span>
|
||
|
f_write(&fil, "Hello, World!\r\n", 15, &bw);
|
||
|
if (bw != 15) ...
|
||
|
|
||
|
<span class="c">/* Close the file */</span>
|
||
|
f_close(&fil);
|
||
|
|
||
|
<span class="c">/* Unregister work area */</span>
|
||
|
f_mount(0, "", 0);
|
||
|
|
||
|
</pre>
|
||
|
</div>
|
||
|
|
||
|
<div class="para ref">
|
||
|
<h4>See Also</h4>
|
||
|
<p><tt><a href="filename.html#vol">Volume management</a>, <a href="fdisk.html">f_fdisk</a></tt></p>
|
||
|
</div>
|
||
|
|
||
|
<p class="foot"><a href="../00index_e.html">Return</a></p>
|
||
|
</body>
|
||
|
</html>
|