fatfs v0.09 Sep 06,2011:
- f_mkfs() supports multiple partition to finish the multiple partition feature. - Added f_fdisk(). (_MULTI_PARTITION = 2)
This commit is contained in:
		
							parent
							
								
									5fa1073a5a
								
							
						
					
					
						commit
						13034d028c
					
				| @ -59,11 +59,12 @@ | ||||
| <li><a href="en/chmod.html">f_chmod</a> - Change attribute</li> | ||||
| <li><a href="en/utime.html">f_utime</a> - Change timestamp</li> | ||||
| <li><a href="en/rename.html">f_rename</a> - Rename/Move a file or directory</li> | ||||
| <li><a href="en/mkfs.html">f_mkfs</a> - Create a file system on the drive</li> | ||||
| <li><a href="en/forward.html">f_forward</a> - Forward file data to the stream directly</li> | ||||
| <li><a href="en/chdir.html">f_chdir</a> - Change current directory</li> | ||||
| <li><a href="en/chdrive.html">f_chdrive</a> - Change current drive</li> | ||||
| <li><a href="en/getcwd.html">f_getcwd</a> - Retrieve the current directory</li> | ||||
| <li><a href="en/forward.html">f_forward</a> - Forward file data to the stream directly</li> | ||||
| <li><a href="en/mkfs.html">f_mkfs</a> - Create a file system on the drive</li> | ||||
| <li><a href="en/fdisk.html">f_fdisk</a> - Divide a physical drive</li> | ||||
| <li><a href="en/gets.html">f_gets</a> - Read a string</li> | ||||
| <li><a href="en/putc.html">f_putc</a> - Write a character</li> | ||||
| <li><a href="en/puts.html">f_puts</a> - Write a string</li> | ||||
| @ -95,17 +96,19 @@ | ||||
| <p>The FatFs module is a free software opened for education, research and development. You can use, modify and/or redistribute it for personal projects or commercial products without any restriction under your responsibility. For further information, refer to the application note.</p> | ||||
| <ul> | ||||
| <li><a href="http://elm-chan.org/fsw/ff/bd/"><em>FatFs User Forum</em></a></li> | ||||
| <li>Read first: <a href="en/appnote.html">FatFs module application note</a></li> | ||||
| <li>Read first: <a href="en/appnote.html">FatFs module application note</a> <span class="mfd">July 28, 2012</span></li> | ||||
| <li><a href="http://nemuisan.blog.bai.ne.jp/">Nemuisan's Blog</a> (Well written implementations for STM32F/SDIO and LPC2300/MCI)</li> | ||||
| <li><a href="http://www.siwawi.arubi.uni-kl.de/avr_projects/arm_projects/arm_memcards/index.html">ARM-Projects by Martin THOMAS</a> (examples for LPC2000, AT91SAM and STM32)</li> | ||||
| <li><a href="http://www.microsoft.com/whdc/system/platform/firmware/fatgen.mspx">FAT32 Specification by Microsoft</a> (The reference document on FAT file system)</li> | ||||
| <li><a href="http://elm-chan.org/docs/mmc/mmc_e.html">How to Use MMC/SDC</a></li> | ||||
| <li><a href="img/rwtest.png">Benchmark 1</a> (ATmega64/9.2MHz with MMC via SPI, HDD/CFC via GPIO)</li> | ||||
| <li><a href="img/rwtest2.png">Benchmark 2</a> (LPC2368/72MHz with MMC via MCI)</li> | ||||
| <li><a href="http://members.jcom.home.ne.jp/felm/fd.mp4">Demo movie of an application</a> (this project is in ffsample.zip/lpc23xx)</li> | ||||
| </ul> | ||||
| </div> | ||||
| 
 | ||||
| 
 | ||||
| <hr> | ||||
| <p class="foot"><a href="http://elm-chan.org/fsw/ff/00index_e.html">FatFs Home Page</a></p> | ||||
| <p class="foot"><a href="../../fsw_e.html">Return</a></p> | ||||
| </body> | ||||
| </html> | ||||
|  | ||||
| @ -58,11 +58,12 @@ | ||||
| <li><a href="ja/chmod.html">f_chmod</a> - ファイル/ディレクトリの属性の変更</li> | ||||
| <li><a href="ja/utime.html">f_utime</a> - ファイル/ディレクトリのタイムスタンプの変更</li> | ||||
| <li><a href="ja/rename.html">f_rename</a> - ファイル/ディレクトリの名前変更・移動</li> | ||||
| <li><a href="ja/mkfs.html">f_mkfs</a> - ディスクのフォーマット</li> | ||||
| <li><a href="ja/chdir.html">f_chdir</a> - カレント・ディレクトリの変更</li> | ||||
| <li><a href="ja/chdrive.html">f_chdrive</a> - カレント・ドライブの変更</li> | ||||
| <li><a href="ja/getcwd.html">f_getcwd</a> - カレント・ディレクトリの取得</li> | ||||
| <li><a href="ja/forward.html">f_forward</a> - ファイル・データをストリーム関数に転送</li> | ||||
| <li><a href="ja/mkfs.html">f_mkfs</a> - 論理ドライブのフォーマット</li> | ||||
| <li><a href="ja/fdisk.html">f_fdisk</a> - 物理ドライブの分割</li> | ||||
| <li><a href="ja/gets.html">f_gets</a> - 文字列の読み出し</li> | ||||
| <li><a href="ja/putc.html">f_putc</a> - 文字の書き込み</li> | ||||
| <li><a href="ja/puts.html">f_puts</a> - 文字列の書き込み</li> | ||||
| @ -79,10 +80,10 @@ | ||||
| <h3>下位レイヤ・インターフェース</h3> | ||||
| <p>FatFsモジュールは、物理ドライブ等へのアクセスのため、下位レイヤに少なくとも次のインターフェースを要求します。使用する記録メディアに対応したディスクI/Oモジュールは、ユーザによって用意される必要があります。OS関連機能を有効にしたときは、加えてプロセス・メモリ関連関数も必要になります。資料にドライバを含むサンプル・プロジェクトあり。</p> | ||||
| <ul> | ||||
| <li><a href="ja/dinit.html">disk_initialize</a> - ディスク・ドライブの初期化</li> | ||||
| <li><a href="ja/dstat.html">disk_status</a> - ディスク・ドライブの状態取得</li> | ||||
| <li><a href="ja/dread.html">disk_read</a> - ディスクからの読み込み</li> | ||||
| <li><a href="ja/dwrite.html">disk_write</a> - ディスクへの書き込み</li> | ||||
| <li><a href="ja/dinit.html">disk_initialize</a> - ドライブの初期化</li> | ||||
| <li><a href="ja/dstat.html">disk_status</a> - ドライブの状態取得</li> | ||||
| <li><a href="ja/dread.html">disk_read</a> - データの読み出し</li> | ||||
| <li><a href="ja/dwrite.html">disk_write</a> - データの書き込み</li> | ||||
| <li><a href="ja/dioctl.html">disk_ioctl</a> - その他のドライブ制御</li> | ||||
| <li><a href="ja/fattime.html">get_fattime</a> - 日付・時刻の取得</li> | ||||
| </ul> | ||||
| @ -94,7 +95,8 @@ | ||||
| <p>FatFsモジュールはフリー・ソフトウェアとして教育・研究・開発用に公開しています。どのような利用目的(個人利用から商用まで)でも使用・改変・配布について一切の制限はありませんが、全て利用者の責任の下での利用とします。詳しくはアプリケーション・ノートを参照してください。</p> | ||||
| <ul> | ||||
| <li><a href="http://elm-chan.org/fsw/ff/bd/"><em>FatFsユーザ・フォーラム</em></a></li> | ||||
| <li>最初に読め: <a href="ja/appnote.html">FatFsモジュール・アプリケーション・ノート</a></li> | ||||
| <li>最初に読め: <a href="ja/appnote.html">FatFsモジュール・アプリケーション・ノート</a> <span class="mfd">2012. 7. 28</span></li> | ||||
| <li><a href="http://nemuisan.blog.bai.ne.jp/">ねむいさんのぶろぐ</a> (Well written implementations for STM32F/SDIO and LPC2300/MCI)</li> | ||||
| <li><a href="http://www.siwawi.arubi.uni-kl.de/avr_projects/arm_projects/arm_memcards/index.html">ARM-Projects by Martin THOMAS</a> (examples for LPC2000, AT91SAM and STM32)</li> | ||||
| <li><a href="http://www.microsoft.com/whdc/system/platform/firmware/fatgen.mspx">FATファイル・システム仕様書 by Microsoft</a> (FATの理解・実装に必要な唯一のリファレンス)</li> | ||||
| <li><a href="http://elm-chan.org/docs/fat.html">FATファイル・システム概要</a> (↑を読むためのガイド)</li> | ||||
| @ -106,6 +108,6 @@ | ||||
| 
 | ||||
| 
 | ||||
| <hr> | ||||
| <p class="foot"><a href="http://elm-chan.org/fsw/ff/00index_j.html">FatFs Home Page</a></p> | ||||
| <p class="foot"><a href="../../fsw.html">戻る</a></p> | ||||
| </body> | ||||
| </html> | ||||
|  | ||||
| @ -3,7 +3,7 @@ body {margin: 8px; background-color: #e0ffff; font-color: black; font-family: se | ||||
| a:link {color: blue;} | ||||
| a:visited {color: darkmagenta;} | ||||
| a:hover {background-color: #a0ffff;} | ||||
| a:active {color: darkmagenta; position: relative; top: 1px; left: 1px;} | ||||
| a:active {color: darkmagenta; overflow: hidden; outline:none; position: relative; top: 1px; left: 1px;} | ||||
| abbr {border-width: 1px;} | ||||
| 
 | ||||
| p {margin: 0 0 0.3em 1em;} | ||||
|  | ||||
| @ -6,7 +6,7 @@ body {margin: 8px; background-color: #e0ffff; font-color: black; font-family:" | ||||
| a:link {color: blue;} | ||||
| a:visited {color: darkmagenta;} | ||||
| a:hover {background-color: #a0ffff;} | ||||
| a:active {color: darkmagenta; position: relative; top: 1px; left: 1px;} | ||||
| a:active {color: darkmagenta; overflow: hidden; outline:none; position: relative; top: 1px; left: 1px;} | ||||
| abbr {border-width: 1px;} | ||||
| 
 | ||||
| p {text-indent: 1em; margin: 0 0 0.3em 0.5em;} | ||||
| @ -57,6 +57,6 @@ td {background-color: white; border: 1px solid black; padding: 0 3px; vertical-a | ||||
| table.lst td:first-child {font-family: monospace; white-space: nowrap;} | ||||
| table.lst2 td {font-family: monospace; white-space: nowrap;} | ||||
| table caption {font-family: sans-serif; font-weight: bold;} | ||||
| tr.lst3 td { border-width: 2px 1px 1px; } | ||||
| tr.lst3 td {border-width: 2px 1px 1px; } | ||||
| 
 | ||||
| p.foot {clear: both; text-indent: 0; margin: 1em 0.5em 1em;} | ||||
|  | ||||
| @ -39,6 +39,10 @@ The FatFs module is a middleware which is written in ANSI C (C89). There is no p | ||||
| The FatFs module assumes that size of char/short/long are 8/16/32 bit and int is 16 or 32 bit. These correspondence are defined in integer.h. This will not be a problem on most compilers. When any conflict with existing definitions is occured, you must resolve it with care.</li> | ||||
| </ul> | ||||
| 
 | ||||
| <h4>System organizations</h4> | ||||
| <p>The dependency diagram shown below is a typical configuration of the embedded system with FatFs module.</p> | ||||
| <img src="../img/modules.png" width="507" height="224" alt="dependency diagram"> | ||||
| 
 | ||||
| <h4>Which function is required?</h4> | ||||
| <p>You need to provide only low level disk I/O functions that required by FatFs module and nothing else. If a working disk module for the target is already existing, you need to write only glue functions to attach it to the FatFs module. If not, you need to port any other disk module or write it from scratch. All defined functions are not that always required. For example, disk write function is not required in read-only configuration. Following table shows which function is required depends on configuration options.</p> | ||||
| <table class="lst2"> | ||||
| @ -68,15 +72,15 @@ The FatFs module assumes that size of char/short/long are 8/16/32 bit and int is | ||||
| </div> | ||||
| 
 | ||||
| <div class="para" id="memory"> | ||||
| <h3>Memory Usage (R0.08b)</h3> | ||||
| <h3>Memory Usage (R0.09)</h3> | ||||
| <table class="lst2"> | ||||
| <tr><th></th><th>ARM7<small><br>32bit</small></th><th>ARM7<small><br>Thumb</small></th><th>Cortex-M3<small><br>Thumb-2</small></th><th>AVR</th><th>H8/300H</th><th>PIC24</th><th>RL78</th><th>V850ES</th><th>SH-2A</th><th>RX62N</th><th>IA-32</th></tr> | ||||
| <tr><th></th><th>ARM7<small><br>32bit</small></th><th>ARM7<small><br>Thumb</small></th><th>Cortex-M3<small><br>Thumb-2</small></th><th>AVR</th><th>H8/300H</th><th>PIC24</th><th>RL78</th><th>V850ES</th><th>SH-2A</th><th>RX600</th><th>IA-32</th></tr> | ||||
| <tr><td>Compiler</td><td>GCC</td><td>GCC</td><td>GCC</td><td>GCC</td><td>CH38</td><td>C30</td><td>CC78K0R</td><td>CA850</td><td>SHC</td><td>RXC</td><td>VC6</td></tr> | ||||
| <tr><td>_WORD_ACCESS</td><td>0</td><td>0</td><td>0</td><td>1</td><td>0</td><td>0</td><td>0</td><td>1</td><td>0</td><td>1</td><td>1</td></tr> | ||||
| <tr class="lst3"><td>text (Full, R/W)</td><td>10495</td><td>7205</td><td>6661</td><td>12646</td><td>10686</td><td>11430</td><td>12967</td><td>7732</td><td>8752</td><td>5747</td><td>7545</td></tr> | ||||
| <tr> <td>text (Min, R/W)</td><td>6523</td><td>4749</td><td>4335</td><td>8306</td><td>6986</td><td>7413</td><td>8745</td><td>4938</td><td>5576</td><td>3746</td><td>4923</td></tr> | ||||
| <tr><td>text (Full, R/O)</td><td>4539</td><td>3183</td><td>2893</td><td>5960</td><td>4876</td><td>5250</td><td>6060</td><td>3554</td><td>3804</td><td>2659</td><td>3450</td></tr> | ||||
| <tr> <td>text (Min, R/O)</td><td>3307</td><td>2495</td><td>2191</td><td>4366</td><td>3770</td><td>3939</td><td>4604</td><td>2684</td><td>2940</td><td>2025</td><td>2664</td></tr> | ||||
| <tr class="lst3"><td>text (Full, R/W)</td><td>10459</td><td>7201</td><td>6623</td><td>12646</td><td>10686</td><td>11466</td><td>12967</td><td>7732</td><td>8752</td><td>5747</td><td>7545</td></tr> | ||||
| <tr><td>text (Min, R/W)</td><td>6503</td><td>4745</td><td>4297</td><td>8306</td><td>6986</td><td>7440</td><td>8745</td><td>4938</td><td>5576</td><td>3746</td><td>4923</td></tr> | ||||
| <tr><td>text (Full, R/O)</td><td>4535</td><td>3181</td><td>2869</td><td>5960</td><td>4876</td><td>5286</td><td>6060</td><td>3554</td><td>3804</td><td>2659</td><td>3450</td></tr> | ||||
| <tr><td>text (Min, R/O)</td><td>3303</td><td>2493</td><td>2171</td><td>4366</td><td>3770</td><td>3984</td><td>4604</td><td>2684</td><td>2940</td><td>2025</td><td>2664</td></tr> | ||||
| <tr><td>bss</td><td>D*4 + 2</td><td>D*4 + 2</td><td>D*4 + 2</td><td>D*2 + 2</td><td>D*4 + 2</td><td>D*2 + 2</td><td>D*2 + 2</td><td>D*4 + 2</td><td>D*4 + 2</td><td>D*4 + 2</td><td>D*4 + 2</td></tr> | ||||
| <tr><td>Work area<br>(_FS_TINY == 0)</td><td>V*560 +<br>F*550</td><td>V*560 +<br>F*550</td><td>V*560 +<br>F*550</td><td>V*560 +<br>F*544</td><td>V*560 +<br>F*550</td><td>V*560 +<br>F*544</td><td>V*560 +<br>F*544</td><td>V*560 +<br>F*544</td><td>V*560 +<br>F*550</td><td>V*560 +<br>F*550</td><td>V*560 +<br>F*550</td></tr> | ||||
| <tr><td>Work area<br>(_FS_TINY == 1)</td><td>V*560 +<br>F*36</td><td>V*560 +<br>F*36</td><td>V*560 +<br>F*36</td><td>V*560 +<br>F*32</td><td>V*560 +<br>F*36</td><td>V*560 +<br>F*32</td><td>V*560 +<br>F*32</td><td>V*560 +<br>F*36</td><td>V*560 +<br>F*36</td><td>V*560 +<br>F*36</td><td>V*560 +<br>F*36</td></tr> | ||||
| @ -104,34 +108,35 @@ _FS_SHARE        0 (Disable shareing control) | ||||
| <h3>Module Size Reduction</h3> | ||||
| <p>Follwing table shows which API function is removed by configuration options for the module size reduction.</p> | ||||
| <table class="lst2"> | ||||
| <tr><td rowspan="2">Function</td><td colspan="4">_FS_MINIMIZE</td><td colspan="2">_FS_READONLY</td><td colspan="2">_USE_STRFUNC</td><td colspan="3">_FS_RPATH</td><td colspan="2">_USE_MKFS</td><td colspan="2">_USE_FORWARD</td></tr> | ||||
| <tr><td>0</td><td>1</td><td>2</td><td>3</td><td>0</td><td>1</td><td>0  </td><td>1/2</td><td>0</td><td>1</td><td>2</td><td>0</td><td>1</td><td>0</td><td>1</td></tr> | ||||
| <tr class="lst3"><td>f_mount</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr> | ||||
| <tr><td>f_open</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr> | ||||
| <tr><td>f_close</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr> | ||||
| <tr><td>f_read</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr> | ||||
| <tr><td>f_write</td><td></td><td></td><td></td><td></td><td></td><td>x</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr> | ||||
| <tr><td>f_sync</td><td></td><td></td><td></td><td></td><td></td><td>x</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr> | ||||
| <tr><td>f_lseek</td><td></td><td></td><td></td><td>x</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr> | ||||
| <tr><td>f_opendir</td><td></td><td></td><td>x</td><td>x</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr> | ||||
| <tr><td>f_readdir</td><td></td><td></td><td>x</td><td>x</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr> | ||||
| <tr><td>f_stat</td><td></td><td>x</td><td>x</td><td>x</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr> | ||||
| <tr><td>f_getfree</td><td></td><td>x</td><td>x</td><td>x</td><td></td><td>x</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr> | ||||
| <tr><td>f_truncate</td><td></td><td>x</td><td>x</td><td>x</td><td></td><td>x</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr> | ||||
| <tr><td>f_unlink</td><td></td><td>x</td><td>x</td><td>x</td><td></td><td>x</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr> | ||||
| <tr><td>f_mkdir</td><td></td><td>x</td><td>x</td><td>x</td><td></td><td>x</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr> | ||||
| <tr><td>f_chmod</td><td></td><td>x</td><td>x</td><td>x</td><td></td><td>x</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr> | ||||
| <tr><td>f_utime</td><td></td><td>x</td><td>x</td><td>x</td><td></td><td>x</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr> | ||||
| <tr><td>f_rename</td><td></td><td>x</td><td>x</td><td>x</td><td></td><td>x</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr> | ||||
| <tr><td>f_chdir</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td>x</td><td></td><td></td><td></td><td></td><td></td><td></td></tr> | ||||
| <tr><td>f_chdrive</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td>x</td><td></td><td></td><td></td><td></td><td></td><td></td></tr> | ||||
| <tr><td>f_getcwd</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td>x</td><td>x</td><td></td><td></td><td></td><td></td><td></td></tr> | ||||
| <tr><td>f_mkfs</td><td></td><td></td><td></td><td></td><td></td><td>x</td><td></td><td></td><td></td><td></td><td></td><td>x</td><td></td><td></td><td></td></tr> | ||||
| <tr><td>f_forward</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td>x</td><td></td></tr> | ||||
| <tr><td>f_putc</td><td></td><td></td><td></td><td></td><td></td><td>x</td><td>x</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr> | ||||
| <tr><td>f_puts</td><td></td><td></td><td></td><td></td><td></td><td>x</td><td>x</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr> | ||||
| <tr><td>f_printf</td><td></td><td></td><td></td><td></td><td></td><td>x</td><td>x</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr> | ||||
| <tr><td>f_gets</td><td></td><td></td><td></td><td></td><td></td><td></td><td>x</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr> | ||||
| <tr><td rowspan="2">Function</td><td colspan="4">_FS_MINIMIZE</td><td colspan="2">_FS_READONLY</td><td colspan="2">_USE_STRFUNC</td><td colspan="3">_FS_RPATH</td><td colspan="2">_USE_MKFS</td><td colspan="2">_USE_FORWARD</td><td colspan="2">_MULTI_PARTITION</td></tr> | ||||
| <tr><td>0</td><td>1</td><td>2</td><td>3</td><td>0</td><td>1</td><td>0  </td><td>1/2</td><td>0</td><td>1</td><td>2</td><td>0</td><td>1</td><td>0</td><td>1</td><td>0/1</td><td>2</td></tr> | ||||
| <tr class="lst3"><td>f_mount</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr> | ||||
| <tr><td>f_open</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr> | ||||
| <tr><td>f_close</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr> | ||||
| <tr><td>f_read</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr> | ||||
| <tr><td>f_write</td><td></td><td></td><td></td><td></td><td></td><td>x</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr> | ||||
| <tr><td>f_sync</td><td></td><td></td><td></td><td></td><td></td><td>x</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr> | ||||
| <tr><td>f_lseek</td><td></td><td></td><td></td><td>x</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr> | ||||
| <tr><td>f_opendir</td><td></td><td></td><td>x</td><td>x</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr> | ||||
| <tr><td>f_readdir</td><td></td><td></td><td>x</td><td>x</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr> | ||||
| <tr><td>f_stat</td><td></td><td>x</td><td>x</td><td>x</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr> | ||||
| <tr><td>f_getfree</td><td></td><td>x</td><td>x</td><td>x</td><td></td><td>x</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr> | ||||
| <tr><td>f_truncate</td><td></td><td>x</td><td>x</td><td>x</td><td></td><td>x</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr> | ||||
| <tr><td>f_unlink</td><td></td><td>x</td><td>x</td><td>x</td><td></td><td>x</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr> | ||||
| <tr><td>f_mkdir</td><td></td><td>x</td><td>x</td><td>x</td><td></td><td>x</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr> | ||||
| <tr><td>f_chmod</td><td></td><td>x</td><td>x</td><td>x</td><td></td><td>x</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr> | ||||
| <tr><td>f_utime</td><td></td><td>x</td><td>x</td><td>x</td><td></td><td>x</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr> | ||||
| <tr><td>f_rename</td><td></td><td>x</td><td>x</td><td>x</td><td></td><td>x</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr> | ||||
| <tr><td>f_chdir</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td>x</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr> | ||||
| <tr><td>f_chdrive</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td>x</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr> | ||||
| <tr><td>f_getcwd</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td>x</td><td>x</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr> | ||||
| <tr><td>f_mkfs</td><td></td><td></td><td></td><td></td><td></td><td>x</td><td></td><td></td><td></td><td></td><td></td><td>x</td><td></td><td></td><td></td><td></td><td></td></tr> | ||||
| <tr><td>f_fdisk</td><td></td><td></td><td></td><td></td><td></td><td>x</td><td></td><td></td><td></td><td></td><td></td><td>x</td><td></td><td></td><td></td><td>x</td><td></td></tr> | ||||
| <tr><td>f_forward</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td>x</td><td></td><td></td><td></td></tr> | ||||
| <tr><td>f_putc</td><td></td><td></td><td></td><td></td><td></td><td>x</td><td>x</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr> | ||||
| <tr><td>f_puts</td><td></td><td></td><td></td><td></td><td></td><td>x</td><td>x</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr> | ||||
| <tr><td>f_printf</td><td></td><td></td><td></td><td></td><td></td><td>x</td><td>x</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr> | ||||
| <tr><td>f_gets</td><td></td><td></td><td></td><td></td><td></td><td></td><td>x</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr> | ||||
| </table> | ||||
| </div> | ||||
| 
 | ||||
| @ -148,7 +153,7 @@ _FS_SHARE        0 (Disable shareing control) | ||||
| <tr><td>950(Big5)</td><td>+111K</td></tr> | ||||
| </table> | ||||
| <p>When the LFN feature is enabled, the module size will be increased depends on the selected code page. Right table shows how many bytes increased when LFN feature is enabled with some code pages. We are the East-Asians have tens of thousands of characters. Unfortunately, it requires a huge OEM-Unicode bidirectional conversion table and the module size will be drastically increased that shown in the table. As the result, the FatFs with LFN feature with DBCS will not able to be implemented to most 8-bit microcontrollers. <small>This is the reason why I had not been interested in implementing the LFN feature for a long time :-)</small></p> | ||||
| <p>Note that the LFN feature on the FAT file system is a patent of Microsoft Corporation. This is not the case on FAT32. When enable LFN feature on the commercial products, a license from Microsoft may be required depends on the final destination.</p> | ||||
| <p>Note that the LFN feature on the FAT file system is a patent of Microsoft Corporation. This is not the case on FAT32 but most FAT32 drivers include the LFN feature. FatFs can swich the LFN feature by configuration option. When enable LFN feature on the commercial products, a license from Microsoft may be required depends on the final destination.</p> | ||||
| </div> | ||||
| 
 | ||||
| <div class="para" id="unicode"> | ||||
| @ -158,7 +163,7 @@ _FS_SHARE        0 (Disable shareing control) | ||||
| 
 | ||||
| <div class="para" id="reentrant"> | ||||
| <h3>Re-entrancy</h3> | ||||
| <p>The file operations to the different volume is always re-entrant ant can work simultaneously. The file operations to the same volume is not re-entrant but it can also be configured to thread-safe with <tt>_FS_REENTRANT</tt> option. In this case, also the OS dependent synchronization object control functions, ff_cre_syncobj, ff_del_syncobj, ff_req_grant and ff_rel_grant must be added to the project.</p> | ||||
| <p>The file operations to the different volume is always re-entrant and can work simultaneously. The file operations to the same volume is not re-entrant but it can also be configured to thread-safe with <tt>_FS_REENTRANT</tt> option. In this case, also the OS dependent synchronization object control functions, ff_cre_syncobj, ff_del_syncobj, ff_req_grant and ff_rel_grant must be added to the project.</p> | ||||
| <p>When a file function is called while the volume is in use by any other task, the file function is suspended until that task leaves file function. If wait time exceeded a period defined by <tt>_TIMEOUT</tt>, the file function will abort with <tt>FR_TIMEOUT</tt>. The timeout feature might not be supported on some RTOS.</p> | ||||
| <p>There is an exception on f_mount and f_mkfs function. These functions are not re-entrant to the same volume. When use these functions, all other task must close the corresponding file on the volume and avoid to access the volume.</p> | ||||
| <p>Note that this section describes on the re-entrancy of the FatFs module itself but also the low level disk I/O layer must be re-entrant.</p> | ||||
| @ -174,7 +179,7 @@ _FS_SHARE        0 (Disable shareing control) | ||||
| <h3>Performance Effective File Access</h3> | ||||
| <p>For good performance on reading/writing files on the small embedded system, application programmer should consider what process is done in the FatFs module. The file data on the disk is transferred in following sequence by f_read function.</p> | ||||
| <p>Figure 1. Sector miss-aligned read (short)<br> | ||||
| <img src="../img/f1.png" width="490" height="73" alt=""> | ||||
| <img src="../img/f1.png" width="490" height="110" alt=""> | ||||
| </p> | ||||
| <p>Figure 2. Sector miss-aligned read (long)<br> | ||||
| <img src="../img/f2.png" width="490" height="140" alt=""> | ||||
| @ -195,9 +200,9 @@ _FS_SHARE        0 (Disable shareing control) | ||||
| Figure 6. Comparison between Multiple/Single Sector Write<br> | ||||
| <img src="../img/f6.png" width="630" height="148" alt="fig.6"> | ||||
| </div> | ||||
| <p>The write throughput of the flash memory media becomes the worst at single sector write and it increases proportional to the number of sectors per a write transaction. This effect more appers at more fast bus clock and its ratio often becomes grater than ten. The number of write transaction also affects the life time of the media. Therefore the application program should write the data in large block as possible. The ideal block size is cluster size or power of 2 bytes and the byte offset should be aligned to the block. Of course all layers between the application and the media must support multiple sector write feature, however most of open-source disk drivers lack it. Do not split a multiple sector write request into single sector writes or the write throughput gets poor. Note that FatFs module and its sample disk drivers supprt multiple sector read/write.</p> | ||||
| <p>The write throughput of the flash memory media becomes the worst at single sector write and it increases proportional to the number of sectors per a write transaction. This effect more appers at more fast bus clock and its ratio often becomes grater than ten. The number of write transaction also affects the life time of the media. Therefore the application program should write the data in large block as possible. The ideal block size is cluster size or power of 2 bytes and the byte offset should be aligned to the block. Of course all layers between the application and the media must support multiple sector write feature, however most of open-source disk drivers lack it. Do not split a multiple sector write request into single sector writes or the write throughput gets poor. Note that FatFs module and its sample disk drivers supprt multiple sector read/write feature.</p> | ||||
| <h4>Forcing Memory Erase</h4> | ||||
| <p>When remove a file via f_remove function, the data clusters occupied by the file are maeked 'free' on the FAT. But the data sectors containing the file data are not that applied any process so that the file data left occupies a part of the media as live blocks. If the file data is forced erased on removing the file, the number of free blocks on the media will be increased. This may skip internal block erase operation to the data block on next write. As the result the write performance might be improved. To enable this feature, set <tt>_USE_ERASE</tt> to 1. Note that this is a feature with expectation of internal process of the flash memory media. It may not always effective and f_remove function will take a time on removing a large file.</p> | ||||
| <p>When remove a file with f_remove function, the data clusters occupied by the file are marked 'free' on the FAT. But the data sectors containing the file data are not that applied any process, so that the file data left occupies a part of the flash memory array as live blocks. If the file data is forced erased on removing the file, the number of free blocks on the flash memory will be increased. This may skip internal block erase operation to the data block on next write. As the result the write performance might be improved. To enable this feature, set <tt>_USE_ERASE</tt> to 1. Note that this is a feature with expectation of internal process of the flash memory media. It may not always effective and f_remove function will take a time on removing a large file.</p> | ||||
| </div> | ||||
| 
 | ||||
| <div class="para" id="critical"> | ||||
| @ -227,7 +232,7 @@ Figure 5. Minimized critical section<br> | ||||
| <h3>About FatFs License</h3> | ||||
| <p>This is a copy of the FatFs license document that included in the source codes.</p> | ||||
| <pre>/*----------------------------------------------------------------------------/ | ||||
| /  FatFs - FAT file system module  R0.08b                    (C)ChaN, 2011 | ||||
| /  FatFs - FAT file system module  R0.09                     (C)ChaN, 2011 | ||||
| /-----------------------------------------------------------------------------/ | ||||
| / FatFs module is a generic FAT file system module for small embedded systems. | ||||
| / This is a free software that opened for education, research and commercial | ||||
|  | ||||
| @ -38,7 +38,7 @@ DSTATUS disk_initialize ( | ||||
| <div class="para desc"> | ||||
| <h4>Description</h4> | ||||
| <p>The disk_initialize function initializes a physical drive and put it ready to read/write. When the function succeeded, <tt>STA_NOINIT</tt> flag in the return value is cleard.</p> | ||||
| <p><em>Application program should not call this function, or FAT structure on the volume can be collapted. To re-initialize the file system, use f_mount function.</em>This function is called on volume mount process in the FatFs module to manage the media change.</p> | ||||
| <p><em>Application program MUST NOT call this function, or FAT structure on the volume can be corrapted. To re-initialize the file system, use f_mount function.</em>This function is called on volume mount process in the FatFs module to manage the media change.</p> | ||||
| </div> | ||||
| 
 | ||||
| <p class="foot"><a href="../00index_e.html">Return</a></p> | ||||
|  | ||||
| @ -35,11 +35,11 @@ DSTATUS disk_status ( | ||||
| <p>The disk status is returned in combination of following flags. FatFs refers only <tt>STA_NOINIT</tt> and <tt>STA_PROTECTED</tt>.</p> | ||||
| <dl class="ret"> | ||||
| <dt>STA_NOINIT</dt> | ||||
| <dd>Indicates that the disk drive has not been initialized. This flag is set on: system reset, disk removal and disk_initialize function failed, and cleared on: disk_initialize function succeeded.</dd> | ||||
| <dd>Indicates that the disk drive is not initialized. This flag is set on system reset, media removal, media change and disk_initialize function failed. The flag is cleared on disk_initialize function succeeded. Media change that occurs asynchronously must be captured and reflect it to the status flags, or auto-mount feature will not work correctly. When media change detection is not supported, application program should clear the file system object with f_mount function after the media change.</dd> | ||||
| <dt>STA_NODISK</dt> | ||||
| <dd>Indicates that no medium in the drive. This is always cleared on fixed disk drive.</dd> | ||||
| <dt>STA_PROTECTED</dt> | ||||
| <dd>Indicates that the medium is write protected. This is always cleared on the drive that does not support write protect notch. Not valid when <tt>STA_NODISK</tt> is set.</dd> | ||||
| <dd>Indicates that the medium is write protected. This is always cleared on the drive that does not support write protect notch. Not valid while <tt>STA_NODISK</tt> is set.</dd> | ||||
| </dl> | ||||
| </div> | ||||
| 
 | ||||
|  | ||||
							
								
								
									
										97
									
								
								doc/en/fdisk.html
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										97
									
								
								doc/en/fdisk.html
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,97 @@ | ||||
| <!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/fdisk.html"> | ||||
| <link rel="stylesheet" href="../css_e.css" type="text/css" media="screen" title="ELM Default"> | ||||
| <title>FatFs - f_fdisk</title> | ||||
| </head> | ||||
| 
 | ||||
| <body> | ||||
| 
 | ||||
| <div class="para func"> | ||||
| <h2>f_fdisk</h2> | ||||
| <p>The f_fdisk fucntion divides a physical drive.</p> | ||||
| <pre> | ||||
| FRESULT f_fdisk ( | ||||
|   BYTE  <em>Drive</em>,              <span class="c">/* Physical drive number */</span> | ||||
|   const DWORD <em>Partitions[]</em>, <span class="c">/* Partition size */</span> | ||||
|   void* <em>Work</em>                <span class="c">/* Work area */</span> | ||||
| ); | ||||
| </pre> | ||||
| </div> | ||||
| 
 | ||||
| <div class="para arg"> | ||||
| <h4>Parameters</h4> | ||||
| <dl class="par"> | ||||
| <dt>Drive</dt> | ||||
| <dd>Specifies the <em>physical drive</em> to be divided.</dd> | ||||
| <dt>Partitions[]</dt> | ||||
| <dd>Partition map table. It must have four items.</dd> | ||||
| <dt>Work</dt> | ||||
| <dd>Pointer to the function work area. The size must be at least _MAX_SS bytes.</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#ip">FR_INVALID_PARAMETER</a> | ||||
| </p> | ||||
| </div> | ||||
| 
 | ||||
| <div class="para desc"> | ||||
| <h4>Description</h4> | ||||
| <p>The f_fdisk 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. Extended partition is not supported. The Partitions[] 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 means percentage of the partition in the entire disk space. If it is larger than 100, it means partition size in unit of sector.</p> | ||||
| </div> | ||||
| 
 | ||||
| <div class="para comp"> | ||||
| <h4>QuickInfo</h4> | ||||
| <p>Available when <tt>_FS_READOLNY == 0</tt>, <tt>_USE_MKFS == 1</tt> and <tt>_MULTI_PARTITION == 2</tt>.</p> | ||||
| </div> | ||||
| 
 | ||||
| <div class="para use"> | ||||
| <h4>Example</h4> | ||||
| <pre> | ||||
|     <span class="c">/* Volume management table defined by user (required when _MULTI_PARTITION != 0) */</span> | ||||
| 
 | ||||
|     PARTITION VolToPart[] = { | ||||
|         {0, 1},    <span class="c">/* Logical drive 0 ==> Physical drive 0, 1st partition */</span> | ||||
|         {0, 2},    <span class="c">/* Logical drive 1 ==> Physical drive 0, 2nd partition */</span> | ||||
|         {1, 0}     <span class="c">/* Logical drive 2 ==> Physical drive 1, auto detection */</span> | ||||
|     }; | ||||
| </pre> | ||||
| <pre> | ||||
|     <span class="c">/* Initialize a brand-new disk drive mapped to physical drive 0 */</span> | ||||
| 
 | ||||
|     FATFS Fatfs; | ||||
|     DWORD plist[] = {50, 50, 0, 0};  <span class="c">/* Divide drive into two partitions */</span> | ||||
|     BYTE work[_MAX_SS]; | ||||
| 
 | ||||
|     f_fdisk(0, plist, work);  <span class="c">/* Divide physical drive 0 */</span> | ||||
| 
 | ||||
|     f_mount(0, &Fatfs); | ||||
|     f_mkfs(0, 0, 0);          <span class="c">/* Create an FAT volume on the logical drive 0. 2nd argument is ignored. */</span> | ||||
|     f_mount(0, 0); | ||||
| 
 | ||||
|     f_mount(1, &Fatfs); | ||||
|     f_mkfs(1, 0, 0); | ||||
|     f_mount(1, 0); | ||||
| 
 | ||||
| </pre> | ||||
| </div> | ||||
| 
 | ||||
| <div class="para ref"> | ||||
| <h4>See Also</h4> | ||||
| <p><tt><a href="filename.html#vol">Volume management</a>, <a href="mkfs.html">f_mkfs</a></tt></p> | ||||
| </div> | ||||
| 
 | ||||
| <p class="foot"><a href="../00index_e.html">Return</a></p> | ||||
| </body> | ||||
| </html> | ||||
| @ -12,7 +12,7 @@ | ||||
| <body> | ||||
| <h1>Path Names</h1> | ||||
| 
 | ||||
| <div class="para"> | ||||
| <div class="para" id="nam"> | ||||
| <h3>Format of the path names</h3> | ||||
| <p>The path name format on the FatFs module is similer to the filename specs of DOS/Windos as follows:</p> | ||||
| <p><tt>"[drive#:][/]directory/file"</tt></p> | ||||
| @ -38,7 +38,7 @@ | ||||
| </div> | ||||
| 
 | ||||
| <p><br></p> | ||||
| <div class="para"> | ||||
| <div class="para" id="uni"> | ||||
| <h3>Unicode API</h3> | ||||
| <p>The path names are input/output in either ANSI/OEM code (SBCS/DBCS) or Unicode depends on the configuration options. The type of arguments that specifies the file names are defined as <tt>TCHAR</tt> which is an alias of <tt>char</tt> in default. The code set of the file name string is the ANSI/OEM code set specifid by <tt>_CODE_PAGE</tt>. When <tt>_LFN_UNICODE</tt> is set to 1 under LFN configuration, the type of the <tt>TCHAR</tt> is switched to <tt>unsigned short</tt> (UCS-2 character) to support Unicode. In this case, the LFN feature is fully supported and the Unicode specific characters, such as ✝☪✡☸☭, can also be used for the path name. It also affects data types and encoding of the string I/O functions. To define literal strings, <tt>_T(s)</tt> and <tt>_TEXT(s)</tt> macro are available to select either ANSI/OEM or Unicode automatically. The code shown below is an example to define the literal strings.</p> | ||||
| <pre> | ||||
| @ -49,25 +49,24 @@ | ||||
| </div> | ||||
| 
 | ||||
| <p><br></p> | ||||
| <div class="para"> | ||||
| <div class="para" id="vol"> | ||||
| <h3>Correspondence between logical and physical drives</h3> | ||||
| <p>The FatFs module has work areas that called <em>file system object</em> for each volume (logical drive). In default, the logical drive is bound to the physical drive that has same drive number, and the first partition is mounted. When <tt>_MULTI_PARTITION == 1</tt> is specified in configuration option, each individual logical drive can be bound to any physical drive/partition. In this case, a drive number resolution table must be defined as follows:</p> | ||||
| <p>The FatFs module has work areas that called <em>file system object</em> for each volume (logical drive). In default, each logical drive is bound to the physical drive that has same drive number. It attempts to mount a volume as SFD format and first FDISK partition. When <tt>_MULTI_PARTITION >= 1</tt> is specified in configuration option, each individual logical drive is bound to any physical drive/partition. In this case, a volume management table must be defined by user. It is used to resolve relationship between logical drives and partitions as follows:</p> | ||||
| <pre> | ||||
| Example: Logical drive 0-2 are assigned to three pri-partitions on the physical drive 0 (fixed disk) | ||||
|          Logical drive 3 is assigned to physical drive 1 (removable disk) | ||||
| 
 | ||||
| const PARTITION Drives[] = { | ||||
|     {0, 0},     <span class="c">/* Logical drive 0 ==> Physical drive 0, 1st partition */</span> | ||||
|     {0, 1},     <span class="c">/* Logical drive 1 ==> Physical drive 0, 2nd partition */</span> | ||||
|     {0, 2},     <span class="c">/* Logical drive 2 ==> Physical drive 0, 3rd partition */</span> | ||||
|     {1, 0}      <span class="c">/* Logical drive 3 ==> Physical drive 1 */</span> | ||||
| PARTITION VolToPart[] = { | ||||
|     {0, 1},     <span class="c">/* Logical drive 0 ==> Physical drive 0, 1st partition */</span> | ||||
|     {0, 2},     <span class="c">/* Logical drive 1 ==> Physical drive 0, 2nd partition */</span> | ||||
|     {0, 3},     <span class="c">/* Logical drive 2 ==> Physical drive 0, 3rd partition */</span> | ||||
|     {1, 0}      <span class="c">/* Logical drive 3 ==> Physical drive 1 (auto detection) */</span> | ||||
| }; | ||||
| </pre> | ||||
| <p>There are some considerations when use <tt>_MULTI_PARTITION</tt> configuration.</p> | ||||
| <ul> | ||||
| <li>Only pri-partition (0-3) can be mounted.</li> | ||||
| <li>When the physical drive has no partition table (SFD format), the partition number is ignored.</li> | ||||
| <li>The physical drive that has two or more logical drives must be a fixed drive.</li> | ||||
| <li>Only four pri-partitions can be mounted. Extended partition is not supported.</li> | ||||
| <li>The physical drive that has two or more partitions must be non-removable class.</li> | ||||
| </ul> | ||||
| </div> | ||||
| 
 | ||||
|  | ||||
| @ -49,13 +49,13 @@ FRESULT f_lseek ( | ||||
| 
 | ||||
| <div class="para desc"> | ||||
| <h4>Description</h4> | ||||
| <p>The f_lseek function moves the file read/write pointer of an open file. The offset can be specified in only origin from top of the file. When an offset above the file size is specified in write mode, the file size is increased to the offset and the data in the expanded area is undefined. This is suitable to create a large file quickly, for fast write operation. After the f_lseek function succeeded, member fptr in the file object should be checked in order to make sure the read/write pointer has been moved correctry. In case of fptr is not the expected value, either of followings has been occured.</p> | ||||
| <p>The f_lseek function moves the file read/write pointer of an open file. The offset can be specified in only origin from top of the file. When an offset above the file size is specified in write mode, the file size is increased to the offset and the data in the expanded area is undefined. This is suitable to create a large file quickly, for fast write operation. After the f_lseek function succeeded, current read/write pointer should be checked in order to make sure the read/write pointer has been moved correctry. In case of the current read/write pointer is not the expected value, either of followings has been occured.</p> | ||||
| <ul> | ||||
| <li>End of file. The specified Offset was clipped at the file size because the file has been opened in read-only mode.</li> | ||||
| <li>End of file. The specified Offset was clipped at end of the file because the file has been opened in read-only mode.</li> | ||||
| <li>Disk full. There is insufficient free space on the volume to expand the file size.</li> | ||||
| </ul> | ||||
| <p>Fast seek mode is enabled when <tt>_USE_FASTSEEK</tt> is set to 1 and <tt>cltbl</tt> member in the file object is not NULL. This feature enables fast backward/long seek operations without FAT access by cluster link map table (CLMT) stored in the user defined table. It is also applied to f_read/f_write functions. In this mode, the file size cannot be increased by f_write/f_lseek functions.</p> | ||||
| <p>The CLMT must be created in the user defined DWORD array prior to use fast seek feature. To create the CLMT, set pointer to the DWORD array to <tt>cltbl</tt> member in the file object, set the array size in unit of items into the first item and call the f_lseek function with <tt>Offset = CREATE_LINKMAP</tt>. After the function succeeded and CLMT is created, no FAT access is occured in subsequent f_read/f_write/f_lseek functions to the file. If the function failed with <tt>FR_NOT_ENOUGH_CORE</tt>, the given array size is insufficient for the file and the required items is returned into the first item of the array. The required array size is (number of fragments + 1) * 2 items. For example, when the file is fragmented in 5, 12 items will be required for the CLMT. </p> | ||||
| <p>Fast seek feature is enabled when <tt>_USE_FASTSEEK</tt> is set to 1 and the member <tt>cltbl</tt> in the file object is not NULL. This feature enables fast backward/long seek operations without FAT access by cluster link map table (CLMT) stored in the user defined table. It is also applied to f_read/f_write functions. In this mode, the file size cannot be increased by f_write/f_lseek functions.</p> | ||||
| <p>The CLMT must be created in the user defined DWORD array prior to use fast seek feature. To create the CLMT, set pointer to the DWORD array to the member <tt>cltbl</tt> in the file object, set the array size in unit of items into the first item and call the f_lseek function with <tt>Offset = CREATE_LINKMAP</tt>. After the function succeeded and CLMT is created, no FAT access is occured in subsequent f_read/f_write/f_lseek functions to the file. If the function failed with <tt>FR_NOT_ENOUGH_CORE</tt>, the given array size is insufficient for the file and the required items is returned into the first item of the array. The required array size is (number of fragments + 1) * 2 items. For example, when the file is fragmented in 5, 12 items will be required for the CLMT. </p> | ||||
| </div> | ||||
| 
 | ||||
| 
 | ||||
| @ -69,7 +69,7 @@ FRESULT f_lseek ( | ||||
| <h4>Example</h4> | ||||
| <pre> | ||||
|     <span class="c">/* Open file */</span> | ||||
|     file = malloc(sizeof(FIL)); | ||||
|     file = malloc(sizeof (FIL)); | ||||
|     if (!file) ... | ||||
|     res = f_open(file, "file.dat", FA_READ|FA_WRITE); | ||||
|     if (res) ... | ||||
| @ -86,15 +86,16 @@ FRESULT f_lseek ( | ||||
|     <span class="c">/* Rewind 2000 bytes (take care on overflow) */</span> | ||||
|     res = f_lseek(file, f_tell(file) - 2000); | ||||
| </pre> | ||||
| <pre>    <span class="c">/* Cluster pre-allocation (to prevent buffer overrun on streaming write) */</span> | ||||
| <pre> | ||||
|     <span class="c">/* Cluster pre-allocation (to prevent buffer overrun on streaming write) */</span> | ||||
| 
 | ||||
|     res = f_open(file, recfile, FA_CREATE_NEW | FA_WRITE); <span class="c">/* Create a file */</span> | ||||
| 
 | ||||
|     res = f_lseek(file, PRE_SIZE);           <span class="c">/* Pre-allocate clusters */</span> | ||||
|     if (res || f_tell(file) != PRE_SIZE) ... <span class="c">/* Check if the file size has been increased correctly */</span> | ||||
|     res = f_lseek(file, PRE_SIZE);           <span class="c">/* Expand file size (cluster pre-allocation) */</span> | ||||
|     if (res || f_tell(file) != PRE_SIZE) ... <span class="c">/* Check if the file has been expanded */</span> | ||||
| 
 | ||||
|     res = f_lseek(file, DATA_START);         <span class="c">/* Record data stream without cluster allocation delay */</span> | ||||
|     ... | ||||
|     res = f_lseek(file, DATA_START);         <span class="c">/* Record data stream WITHOUT cluster allocation delay */</span> | ||||
|     ...                                      <span class="c">/* DATA_START and write block size should be aligned to sector boundary */</span> | ||||
| 
 | ||||
|     res = f_truncate(file);                  <span class="c">/* Truncate unused area */</span> | ||||
|     res = f_lseek(file, 0);                  <span class="c">/* Put file header */</span> | ||||
| @ -102,14 +103,15 @@ FRESULT f_lseek ( | ||||
| 
 | ||||
|     res = f_close(file); | ||||
| </pre> | ||||
| <pre>    <span class="c">/* Using fast seek feature */</span> | ||||
| <pre> | ||||
|     <span class="c">/* Using fast seek feature */</span> | ||||
| 
 | ||||
|     DWORD lktbl[SZ_TBL];                   <span class="c">/* Link map table buffer */</span> | ||||
| 
 | ||||
|     res = f_lseek(file, ofs1);             <span class="c">/* This is normal seek (file.cltbl is nulled on file open) */</span> | ||||
| 
 | ||||
|     file.cltbl = lktbl;                    <span class="c">/* Enable fast seek feature */</span> | ||||
|     lktbl[0] = SZ_TBL;                     <span class="c">/* Set table size to the first item */</span> | ||||
|     lktbl[0] = SZ_TBL;                     <span class="c">/* Set table size */</span> | ||||
|     res = f_lseek(file, CREATE_LINKMAP);   <span class="c">/* Create CLMT */</span> | ||||
|     ... | ||||
| 
 | ||||
|  | ||||
| @ -13,7 +13,7 @@ | ||||
| 
 | ||||
| <div class="para func"> | ||||
| <h2>f_mkfs</h2> | ||||
| <p>The f_mkfs fucntion creates a file system on the drive.</p> | ||||
| <p>The f_mkfs fucntion creates an FAT file system on the logical drive.</p> | ||||
| <pre> | ||||
| FRESULT f_mkfs ( | ||||
|   BYTE  <em>Drive</em>,            <span class="c">/* Logical drive number */</span> | ||||
| @ -29,9 +29,9 @@ FRESULT f_mkfs ( | ||||
| <dt>Drive</dt> | ||||
| <dd>Logical drive number (0-9) to be formatted.</dd> | ||||
| <dt>PartitioningRule</dt> | ||||
| <dd>When 0 is given, a partition table is created into the master boot record and a primary DOS partition is created and then an FAT volume is created on the partition. This is called FDISK format and used for harddisk and memory cards. When 1 is given, the FAT volume starts from the first sector on the drive without partition table. This is called <abbr title="Super Floppy Disk">SFD</abbr> format and used for floppy disk and most optical disk.</dd> | ||||
| <dd>Specifies partitioning rule, FDISK(0) or SFD(1). This argument is ignored on some case.</dd> | ||||
| <dt>AllocSize</dt> | ||||
| <dd>Force the allocation unit (cluter) size in unit of byte. The value must be power of 2 and between the sector size and 128 times sector size. When invalid value is specified, the cluster size is determined depends on the volume size.</dd> | ||||
| <dd>Force the allocation unit (cluter) size in unit of byte. The value must be power of 2 and between the sector size and 128 * sector size. When a zero is given, the cluster size is determined depends on the volume size.</dd> | ||||
| </dl> | ||||
| </div> | ||||
| 
 | ||||
| @ -44,23 +44,29 @@ FRESULT f_mkfs ( | ||||
| <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#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 f_mkfs function creates an FAT volume on the drive. There are two partitioning rules, FDISK and SFD, for removable media. The FDISK format is recommended for the most case. This function currently <em>does not support multiple partition</em>, so that existing partitions on the physical dirve will be deleted and re-created a new partition occupies entire disk space.</p> | ||||
| <p>The f_mkfs function creates an FAT volume on the logical drive. When FDISK is specified, a primary partition occupies the entire disk space is created and then an FAT volume is created on the partition. When SFD is specified, the FAT volume starts from the first sector of the physical drive.</p> | ||||
| <p>If the logical drive is being 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 is ignored. The physical drive must be partitioned with f_fdisk function or any other partitioning tool prior to use this function.</p> | ||||
| <p>Note that there are two partitioning rules, FDISK and SFD. The FDISK format is usually used for harddisk, MMC, SDC and CFC. It can divide a physical drive into one or more partitions with a partition table on the MBR. The SFD format is non-partitioned method. The FAT volume starts from the first sector on the physical drive without partition table. It is used for floppy disk, Microdrive, optical disk and 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 performance of the file system and large cluster increases the performance.</p> | ||||
| <p>When the number of clusters gets near the FAT sub-type boundaries, the function can fail with FR_MKFS_ABORTED.</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 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> | ||||
|  | ||||
| @ -44,7 +44,7 @@ FRESULT f_mount ( | ||||
| <div class="para desc"> | ||||
| <h4>Description</h4> | ||||
| <p>The f_mount function registers/unregisters a work area to the FatFs module. The work area must be given to the each volume with this function prior to use any other file function. To unregister a work area, specify a NULL to the <em>FileSystemObject</em>, and then the work area can be discarded.</p> | ||||
| <p>This function always succeeds regardless of the drive status. No media access is occured in this function. It only initializes the given work area and registers its address to the internal table. The volume mount process is performed on first file access after f_mount function or media change.</p> | ||||
| <p>This function always succeeds regardless of the drive status. No media access is occured in this function. It only clears the given work area and registers its address to the internal table. The volume mount process is performed on first file access after f_mount function or media change.</p> | ||||
| </div> | ||||
| 
 | ||||
| 
 | ||||
|  | ||||
| @ -34,8 +34,8 @@ FRESULT f_open ( | ||||
| <dd>Specifies the type of access and open method for the file. It is specified by a combination of following flags.<br> | ||||
| <table class="lst"> | ||||
| <tr><th>Value</th><th>Description</th></tr> | ||||
| <tr><td>FA_READ</td><td>Specifies read access to the object. Data can be read from the file.<br>Combine with <tt>FA_WRITE</tt> for read-write access.</td></tr> | ||||
| <tr><td>FA_WRITE</td><td>Specifies write access to the object. Data can be written to the file.<br>Combine with <tt>FA_READ</tt> for read-write access.</td></tr> | ||||
| <tr><td>FA_READ</td><td>Specifies read access to the object. Data can be read from the file. Combine with <tt>FA_WRITE</tt> for read-write access.</td></tr> | ||||
| <tr><td>FA_WRITE</td><td>Specifies write access to the object. Data can be written to the file. Combine with <tt>FA_READ</tt> for read-write access.</td></tr> | ||||
| <tr><td>FA_OPEN_EXISTING</td><td>Opens the file. The function fails if the file is not existing. (Default)</td></tr> | ||||
| <tr><td>FA_OPEN_ALWAYS</td><td>Opens the file if it is existing. If not, a new file is created.<br> | ||||
| To append data to the file, use <a href="lseek.html">f_lseek</a> function after file open in this method.</td></tr> | ||||
| @ -73,9 +73,9 @@ To append data to the file, use <a href="lseek.html">f_lseek</a> function after | ||||
| 
 | ||||
| <div class="para desc"> | ||||
| <h4>Description</h4> | ||||
| <p>A file object is created when the function succeeded. The file object is used for subsequent read/write functions to refer to the file. When close an open file object, use <a href="close.html">f_close</a> function. If the modified file is not closed, the file data can be collapsed.</p> | ||||
| <p>If duplicated file open is needed, read <a href="appnote.html#dup">here</a> carefully.</p> | ||||
| <p>Before using any file function, a work area (file system object) must be registered to the logical drive with <a href="mount.html">f_mount</a> function. All file functions can work after this procedure.</p> | ||||
| <p>After f_open function succeeded, the file object is valid. The file object is used for subsequent read/write functions to identify the file. When close an open file object, use <a href="close.html">f_close</a> function. If the modified file is not closed, the file data can be collapsed.</p> | ||||
| <p>If duplicated file open is needed, read <a href="appnote.html#dup">here</a> carefully. However duplicated open of a file with write mode flags is always prohibited.</p> | ||||
| <p>Before using any file function, a work area (file system object) must be registered to the logical drive with <a href="mount.html">f_mount</a> function. All API functions except for <a href="fdisk.html">f_fdisk</a> function can work after this procedure.</p> | ||||
| </div> | ||||
| 
 | ||||
| 
 | ||||
| @ -111,7 +111,7 @@ void main (void) | ||||
| 
 | ||||
|     <span class="c">/* Copy source to destination */</span> | ||||
|     for (;;) { | ||||
|         res = f_read(&fsrc, buffer, sizeof(buffer), &br);    <span class="c">/* Read a chunk of src file */</span> | ||||
|         res = f_read(&fsrc, buffer, sizeof buffer, &br);     <span class="c">/* Read a chunk of src file */</span> | ||||
|         if (res || br == 0) break; <span class="c">/* error or eof */</span> | ||||
|         res = f_write(&fdst, buffer, br, &bw);               <span class="c">/* Write it to the dst file */</span> | ||||
|         if (res || bw < br) break; <span class="c">/* error or disk full */</span> | ||||
|  | ||||
| @ -35,8 +35,8 @@ int f_putc ( | ||||
| 
 | ||||
| <div class="para ret"> | ||||
| <h4>Return Values</h4> | ||||
| <p>When the character was written successfuly, the function returns the character. When the function failed due to disk full or any error, an <tt>EOF (-1)</tt> will be returned.</p> | ||||
| <p>When the FatFs is configured to Unicode API (<tt>_LFN_UNICODE == 1</tt>), the UCS-2 character is written to the file in UTF-8 encoding. If not the case, the byte will be written directly.</p> | ||||
| <p>When the character was written successfuly, the function returns 1. When the function failed due to disk full or any error, an <tt>EOF (-1)</tt> will be returned.</p> | ||||
| <p>When the FatFs is configured to Unicode API (<tt>_LFN_UNICODE == 1</tt>), the UTF-16 character is written to the file in UTF-8 encoding. If not the case, the byte will be written directly.</p> | ||||
| </div> | ||||
| 
 | ||||
| 
 | ||||
|  | ||||
| @ -35,8 +35,8 @@ int f_puts ( | ||||
| 
 | ||||
| <div class="para ret"> | ||||
| <h4>Return Value</h4> | ||||
| <p>When the function succeeded, number of characters written that is not minus value is returned. When the function failed due to disk full or any error, an <tt>EOF (-1)</tt> will be returned.</p> | ||||
| <p>When the FatFs is configured to Unicode API (<tt>_LFN_UNICODE == 1</tt>), the UCS-2 string is written to the file in UTF-8 encoding. If not the case, the byte stream will be written directly.</p> | ||||
| <p>When the function succeeded, number of characters written that is not minus value is returned. When the write operation is aborted due to disk full or any error, an <tt>EOF (-1)</tt> will be returned.</p> | ||||
| <p>When the FatFs is configured to Unicode API (<tt>_LFN_UNICODE == 1</tt>), the UTF-16 string is written to the file in UTF-8 encoding. If not the case, the byte stream will be written directly.</p> | ||||
| </div> | ||||
| 
 | ||||
| 
 | ||||
|  | ||||
| @ -23,6 +23,7 @@ | ||||
| <ul> | ||||
| <li>There is any error of the FAT structure on the volume.</li> | ||||
| <li>Work area (file system object, file object or etc...) is broken by stack overflow or any other application. This is the reason in most case.</li> | ||||
| <li>An <tt>FR_DISK_ERR</tt> has occured on the file object.</li> | ||||
| </ul> | ||||
| </dd> | ||||
| <dt id="nr">FR_NOT_READY</dt> | ||||
| @ -77,6 +78,8 @@ | ||||
| </dd> | ||||
| <dt id="tf">FR_TOO_MANY_OPEN_FILES</dt> | ||||
| <dd>Number of open files has been reached maximum value and no more file can be opened. (Related option: _FS_SHARE)</dd> | ||||
| <dt id="ip">FR_INVALID_PARAMETER</dt> | ||||
| <dd>The given parameter is invalid or there is any inconsistent.</dd> | ||||
| </dl> | ||||
| 
 | ||||
| </body> | ||||
|  | ||||
| @ -76,7 +76,7 @@ FRESULT scan_files ( | ||||
| <span class="k">#if</span> _USE_LFN | ||||
|     static char lfn[_MAX_LFN + 1]; | ||||
|     fno.lfname = lfn; | ||||
|     fno.lfsize = sizeof(lfn); | ||||
|     fno.lfsize = sizeof lfn; | ||||
| <span class="k">#endif</span> | ||||
| 
 | ||||
| 
 | ||||
|  | ||||
| @ -13,12 +13,12 @@ | ||||
| 
 | ||||
| <div class="para"> | ||||
| <h2>DIR</h2> | ||||
| <p>The <tt>DIR</tt> structure is used for the work area to read a directory by f_oepndir, f_readdir function. There is no member that can be changed by application.</p> | ||||
| <p>The <tt>DIR</tt> structure is used for the work area to read a directory by f_oepndir, f_readdir function. There is no member that can be changed by application program.</p> | ||||
| <pre> | ||||
| <span class="k">typedef</span> <span class="k">struct</span> { | ||||
|     FATFS*  fs;         <span class="c">/* Pointer to the owner file system object */</span> | ||||
|     WORD    id;         <span class="c">/* Owner file system mount ID */</span> | ||||
|     WORD    index;      <span class="c">/* Directory index number to be read/write next */</span> | ||||
|     WORD    index;      <span class="c">/* Index of directory entry to start to search next */</span> | ||||
|     DWORD   sclust;     <span class="c">/* Table start cluster (0:Root dir) */</span> | ||||
|     DWORD   clust;      <span class="c">/* Current cluster */</span> | ||||
|     DWORD   sect;       <span class="c">/* Current sector */</span> | ||||
| @ -26,7 +26,7 @@ | ||||
|     BYTE*   fn;         <span class="c">/* Pointer to the SFN (in/out) {file[8],ext[3],status[1]} */</span> | ||||
| <span class="k">#if</span> _USE_LFN | ||||
|     WCHAR*  lfn;        <span class="c">/* Pointer to the LFN working buffer */</span> | ||||
|     WORD    lfn_idx;    <span class="c">/* Last matched LFN index (0xFFFF:No LFN) */</span> | ||||
|     WORD    lfn_idx;    <span class="c">/* Index of last matched LFN entry (0xFFFF:No LFN) */</span> | ||||
| <span class="k">#endif</span> | ||||
| } DIR; | ||||
| </pre> | ||||
|  | ||||
| @ -25,7 +25,7 @@ | ||||
|     WORD    id;           <span class="c">/* File system mount ID */</span> | ||||
|     WORD    n_rootdir;    <span class="c">/* Number of root directory entries (FAT12/16) */</span> | ||||
| <span class="k">#if</span> _MAX_SS != 512 | ||||
|     WORD    ssize;        <span class="c">/* Sector size (512,1024,2048,4096) */</span> | ||||
|     WORD    ssize;        <span class="c">/* Sector size (512,1024,2048 or 4096) */</span> | ||||
| <span class="k">#endif</span> | ||||
| <span class="k">#if</span> _FS_REENTRANT | ||||
|     _SYNC_t sobj;         <span class="c">/* Identifier of sync object */</span> | ||||
| @ -38,13 +38,13 @@ | ||||
| <span class="k">#if</span> _FS_RPATH | ||||
|     DWORD   cdir;         <span class="c">/* Current directory cluster (0:root) */</span> | ||||
| <span class="k">#endif</span> | ||||
|     DWORD   n_fatent;     <span class="c">/* Number of FAT entries (= number of clusters + 2) */</span> | ||||
|     DWORD   n_fatent;     <span class="c">/* Number of FAT entries (== Number of clusters + 2) */</span> | ||||
|     DWORD   fsize;        <span class="c">/* Sectors per FAT */</span> | ||||
|     DWORD   fatbase;      <span class="c">/* FAT area start sector */</span> | ||||
|     DWORD   dirbase;      <span class="c">/* Root directory area start sector (FAT32: cluster#) */</span> | ||||
|     DWORD   dirbase;      <span class="c">/* Root directory area start sector (FAT32: Cluster#) */</span> | ||||
|     DWORD   database;     <span class="c">/* Data area start sector */</span> | ||||
|     DWORD   winsect;      <span class="c">/* Current sector appearing in the win[] */</span> | ||||
|     BYTE    win[_MAX_SS]; <span class="c">/* Disk access window for Directory, FAT (and Data on tiny cfg) */</span> | ||||
|     BYTE    win[_MAX_SS]; <span class="c">/* Disk access window for Directory, FAT (and file data on tiny cfg) */</span> | ||||
| } FATFS; | ||||
| </pre> | ||||
| </div> | ||||
|  | ||||
| @ -54,7 +54,7 @@ FRESULT f_stat ( | ||||
| 
 | ||||
| <div class="para desc"> | ||||
| <h4>Description</h4> | ||||
| <p>The f_stat gets the information of a file or directory. For details of the infomation, refer to the <tt>FILINFO</tt> structure and <a href="readdir.html">f_readdir</a> function. This function is not supported in minimization level of >= 1.</p> | ||||
| <p>The f_stat gets the size, timestamp and attribute of a file or directory. For details of the infomation, refer to the <tt>FILINFO</tt> structure and <a href="readdir.html">f_readdir</a> function. This function is not supported in minimization level of >= 1.</p> | ||||
| </div> | ||||
| 
 | ||||
| 
 | ||||
|  | ||||
| @ -45,7 +45,7 @@ FRESULT f_sync ( | ||||
| 
 | ||||
| <div class="para desc"> | ||||
| <h4>Description</h4> | ||||
| <p>The f_sync function performs the same process as f_close function but the file is left opened and can continue read/write/seek operations to the file. This is suitable for the applications that open files for a long time in write mode, such as data logger. Performing f_sync of periodic or immediataly after f_write can minimize the risk of data loss due to a sudden blackout or an unintentional disk removal. However f_sync immediataly before f_close has no advantage because f_close performs f_sync in it. In other words, the differnce between those functions is that the file object is invalidated or not. </p> | ||||
| <p>The f_sync function performs the same process as f_close function but the file is left opened and can continue read/write/seek operations to the file. This is suitable for the applications that open files for a long time in write mode, such as data logger. Performing f_sync of periodic or immediataly after f_write can minimize the risk of data loss due to a sudden blackout or an unintentional media removal. However f_sync immediataly before f_close has no advantage because f_close performs f_sync in it. In other words, the differnce between those functions is that the file object is invalidated or not. </p> | ||||
| </div> | ||||
| 
 | ||||
| 
 | ||||
|  | ||||
| @ -58,9 +58,9 @@ FRESULT f_unlink ( | ||||
| <p> | ||||
| If condition of the object to be removed is applicable to the following terms, the function will fail with error. | ||||
| <ul> | ||||
| <li>The object must not have read-only attribute (AM_RDO) or the function will be rejected with FR_DENIED.</li> | ||||
| <li>The directory must be empty and must not be current directory or the function will be rejected with FR_DENIED.</li> | ||||
| <li>The file must not being opened or the <em>FAT volume can be collapted</em>. It will able to be rejected with FR_LOCKED when <a href="appnote.html#dup">file shareing control</a> is enabled.</li> | ||||
| <li>The object must not have read-only attribute (AM_RDO) or the function will be rejected with <tt>FR_DENIED</tt>.</li> | ||||
| <li>The directory must be empty and must not be current directory or the function will be rejected with <tt>FR_DENIED</tt>.</li> | ||||
| <li>The file must not have been opened or the <em>FAT volume can be collapted</em>. It will able to be rejected with <tt>FR_LOCKED</tt> when <a href="appnote.html#dup">file shareing control</a> is enabled.</li> | ||||
| </ul> | ||||
| </div> | ||||
| 
 | ||||
|  | ||||
							
								
								
									
										
											BIN
										
									
								
								doc/img/f1.png
									
									
									
									
									
								
							
							
						
						
									
										
											BIN
										
									
								
								doc/img/f1.png
									
									
									
									
									
								
							
										
											Binary file not shown.
										
									
								
							| Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 1.4 KiB | 
							
								
								
									
										
											BIN
										
									
								
								doc/img/layers3.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								doc/img/layers3.png
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							| After Width: | Height: | Size: 2.3 KiB | 
							
								
								
									
										
											BIN
										
									
								
								doc/img/rwtest3.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								doc/img/rwtest3.png
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							| After Width: | Height: | Size: 2.9 KiB | 
| @ -30,14 +30,20 @@ | ||||
| 
 | ||||
| <div class="para" id="port"> | ||||
| <h3>ポーティングの際に配慮すべきこと</h3> | ||||
| 
 | ||||
| <h4>移植の際の前提条件</h4> | ||||
| <p>FatFsモジュールは移植性に関して次の点を前提としています。</p> | ||||
| <ul> | ||||
| <li>処理系はANSI C準拠であること。<br> | ||||
| FatFsモジュールはANSI C(C89)準拠で記述されているので、ANSI Cに準拠したまともなコンパイラなら特に処理系依存になる点はありません。</li> | ||||
| <li>char/short/longのサイズは、それぞれ8/16/32ビットで、intは16または32ビットであること。<br> | ||||
| サイズを明示する整数の型が integer.h 内で定義されています。整数の型とサイズに関しては、まっとうな処理系なら問題ないはずですが、既存の定義と衝突した場合はユーザによって解決されなければなりません。</li> | ||||
| サイズを明示する整数型が integer.h 内で定義されています。整数の型とサイズに関しては、まっとうな処理系なら問題ないはずですが、既存の定義と衝突した場合はユーザによって解決されなければなりません。</li> | ||||
| </ul> | ||||
| 
 | ||||
| <h4>システム構成</h4> | ||||
| <p>下に示す依存関係図は、FatFsモジュール利用の組み込みシステムにおける代表的な構成を示します。</p> | ||||
| <img src="../img/modules.png" width="507" height="224" alt="システム構成図"> | ||||
| 
 | ||||
| <h4>ユーザの作成する関数</h4> | ||||
| <p>必要なのは FatFsモジュールの要求するディスク関数を用意することだけで、それ以外にすることはありません。既に動作しているディスク関数があるならその APIを FatFsに合わせるだけで済みますが、無い場合はほかから移植するか、最初から書くかする必要があります。定義されている全ての関数が常に必要なわけではありません。例えば、リード・オンリー構成では書き込み系関数は必要ありません。次の表に構成オプションと要求される関数の対応を示します。</p> | ||||
| <table class="lst2"> | ||||
| @ -67,16 +73,16 @@ FatFsモジュールはANSI C(C89)準拠で記述されているので、ANSI C | ||||
| </div> | ||||
| 
 | ||||
| <div class="para" id="memory"> | ||||
| <h3>メモリ使用量 (R0.08b)</h3> | ||||
| <h3>メモリ使用量 (R0.09)</h3> | ||||
| <p>次の表にいくつかのターゲットにおけるメモリ使用量の例を示します。テスト時の構成オプションはその下の通りです。数値の単位はバイトで、<em>V</em>は同時マウント・ボリューム数、<em>F</em>は同時オープン・ファイル数を示します。コンパイラの最適化オプションはコード・サイズとしています。</p> | ||||
| <table class="lst2"> | ||||
| <tr><th></th><th>ARM7<small><br>32bit</small></th><th>ARM7<small><br>Thumb</small></th><th>Cortex-M3<small><br>Thumb-2</small></th><th>AVR</th><th>H8/300H</th><th>PIC24</th><th>RL78</th><th>V850ES</th><th>SH-2A</th><th>RX62N</th><th>IA-32</th></tr> | ||||
| <tr><th></th><th>ARM7<small><br>32bit</small></th><th>ARM7<small><br>Thumb</small></th><th>Cortex-M3<small><br>Thumb-2</small></th><th>AVR</th><th>H8/300H</th><th>PIC24</th><th>RL78</th><th>V850ES</th><th>SH-2A</th><th>RX600</th><th>IA-32</th></tr> | ||||
| <tr><td>Compiler</td><td>GCC</td><td>GCC</td><td>GCC</td><td>GCC</td><td>CH38</td><td>C30</td><td>CC78K0R</td><td>CA850</td><td>SHC</td><td>RXC</td><td>VC6</td></tr> | ||||
| <tr><td>_WORD_ACCESS</td><td>0</td><td>0</td><td>0</td><td>1</td><td>0</td><td>0</td><td>0</td><td>1</td><td>0</td><td>1</td><td>1</td></tr> | ||||
| <tr class="lst3"><td>text (Full, R/W)</td><td>10495</td><td>7205</td><td>6661</td><td>12646</td><td>10686</td><td>11430</td><td>12967</td><td>7732</td><td>8752</td><td>5747</td><td>7545</td></tr> | ||||
| <tr> <td>text (Min, R/W)</td><td>6523</td><td>4749</td><td>4335</td><td>8306</td><td>6986</td><td>7413</td><td>8745</td><td>4938</td><td>5576</td><td>3746</td><td>4923</td></tr> | ||||
| <tr><td>text (Full, R/O)</td><td>4539</td><td>3183</td><td>2893</td><td>5960</td><td>4876</td><td>5250</td><td>6060</td><td>3554</td><td>3804</td><td>2659</td><td>3450</td></tr> | ||||
| <tr> <td>text (Min, R/O)</td><td>3307</td><td>2495</td><td>2191</td><td>4366</td><td>3770</td><td>3939</td><td>4604</td><td>2684</td><td>2940</td><td>2025</td><td>2664</td></tr> | ||||
| <tr class="lst3"><td>text (Full, R/W)</td><td>10459</td><td>7201</td><td>6623</td><td>12646</td><td>10686</td><td>11466</td><td>12967</td><td>7732</td><td>8752</td><td>5747</td><td>7545</td></tr> | ||||
| <tr><td>text (Min, R/W)</td><td>6503</td><td>4745</td><td>4297</td><td>8306</td><td>6986</td><td>7440</td><td>8745</td><td>4938</td><td>5576</td><td>3746</td><td>4923</td></tr> | ||||
| <tr><td>text (Full, R/O)</td><td>4535</td><td>3181</td><td>2869</td><td>5960</td><td>4876</td><td>5286</td><td>6060</td><td>3554</td><td>3804</td><td>2659</td><td>3450</td></tr> | ||||
| <tr><td>text (Min, R/O)</td><td>3303</td><td>2493</td><td>2171</td><td>4366</td><td>3770</td><td>3984</td><td>4604</td><td>2684</td><td>2940</td><td>2025</td><td>2664</td></tr> | ||||
| <tr><td>bss</td><td>D*4 + 2</td><td>D*4 + 2</td><td>D*4 + 2</td><td>D*2 + 2</td><td>D*4 + 2</td><td>D*2 + 2</td><td>D*2 + 2</td><td>D*4 + 2</td><td>D*4 + 2</td><td>D*4 + 2</td><td>D*4 + 2</td></tr> | ||||
| <tr><td>Work area<br>(_FS_TINY == 0)</td><td>V*560 +<br>F*550</td><td>V*560 +<br>F*550</td><td>V*560 +<br>F*550</td><td>V*560 +<br>F*544</td><td>V*560 +<br>F*550</td><td>V*560 +<br>F*544</td><td>V*560 +<br>F*544</td><td>V*560 +<br>F*544</td><td>V*560 +<br>F*550</td><td>V*560 +<br>F*550</td><td>V*560 +<br>F*550</td></tr> | ||||
| <tr><td>Work area<br>(_FS_TINY == 1)</td><td>V*560 +<br>F*36</td><td>V*560 +<br>F*36</td><td>V*560 +<br>F*36</td><td>V*560 +<br>F*32</td><td>V*560 +<br>F*36</td><td>V*560 +<br>F*32</td><td>V*560 +<br>F*32</td><td>V*560 +<br>F*36</td><td>V*560 +<br>F*36</td><td>V*560 +<br>F*36</td><td>V*560 +<br>F*36</td></tr> | ||||
| @ -103,34 +109,35 @@ _FS_SHARE        0 (Disable shareing control) | ||||
| <h3>モジュール・サイズの縮小</h3> | ||||
| <p>次の表は構成オプションの設定値によりどの機能が削除されるかを示します。</p> | ||||
| <table class="lst2"> | ||||
| <tr><td rowspan="2">Function</td><td colspan="4">_FS_MINIMIZE</td><td colspan="2">_FS_READONLY</td><td colspan="2">_USE_STRFUNC</td><td colspan="3">_FS_RPATH</td><td colspan="2">_USE_MKFS</td><td colspan="2">_USE_FORWARD</td></tr> | ||||
| <tr><td>0</td><td>1</td><td>2</td><td>3</td><td>0</td><td>1</td><td>0  </td><td>1/2</td><td>0</td><td>1</td><td>2</td><td>0</td><td>1</td><td>0</td><td>1</td></tr> | ||||
| <tr class="lst3"><td>f_mount</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr> | ||||
| <tr><td>f_open</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr> | ||||
| <tr><td>f_close</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr> | ||||
| <tr><td>f_read</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr> | ||||
| <tr><td>f_write</td><td></td><td></td><td></td><td></td><td></td><td>x</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr> | ||||
| <tr><td>f_sync</td><td></td><td></td><td></td><td></td><td></td><td>x</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr> | ||||
| <tr><td>f_lseek</td><td></td><td></td><td></td><td>x</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr> | ||||
| <tr><td>f_opendir</td><td></td><td></td><td>x</td><td>x</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr> | ||||
| <tr><td>f_readdir</td><td></td><td></td><td>x</td><td>x</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr> | ||||
| <tr><td>f_stat</td><td></td><td>x</td><td>x</td><td>x</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr> | ||||
| <tr><td>f_getfree</td><td></td><td>x</td><td>x</td><td>x</td><td></td><td>x</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr> | ||||
| <tr><td>f_truncate</td><td></td><td>x</td><td>x</td><td>x</td><td></td><td>x</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr> | ||||
| <tr><td>f_unlink</td><td></td><td>x</td><td>x</td><td>x</td><td></td><td>x</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr> | ||||
| <tr><td>f_mkdir</td><td></td><td>x</td><td>x</td><td>x</td><td></td><td>x</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr> | ||||
| <tr><td>f_chmod</td><td></td><td>x</td><td>x</td><td>x</td><td></td><td>x</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr> | ||||
| <tr><td>f_utime</td><td></td><td>x</td><td>x</td><td>x</td><td></td><td>x</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr> | ||||
| <tr><td>f_rename</td><td></td><td>x</td><td>x</td><td>x</td><td></td><td>x</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr> | ||||
| <tr><td>f_chdir</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td>x</td><td></td><td></td><td></td><td></td><td></td><td></td></tr> | ||||
| <tr><td>f_chdrive</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td>x</td><td></td><td></td><td></td><td></td><td></td><td></td></tr> | ||||
| <tr><td>f_getcwd</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td>x</td><td>x</td><td></td><td></td><td></td><td></td><td></td></tr> | ||||
| <tr><td>f_mkfs</td><td></td><td></td><td></td><td></td><td></td><td>x</td><td></td><td></td><td></td><td></td><td></td><td>x</td><td></td><td></td><td></td></tr> | ||||
| <tr><td>f_forward</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td>x</td><td></td></tr> | ||||
| <tr><td>f_putc</td><td></td><td></td><td></td><td></td><td></td><td>x</td><td>x</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr> | ||||
| <tr><td>f_puts</td><td></td><td></td><td></td><td></td><td></td><td>x</td><td>x</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr> | ||||
| <tr><td>f_printf</td><td></td><td></td><td></td><td></td><td></td><td>x</td><td>x</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr> | ||||
| <tr><td>f_gets</td><td></td><td></td><td></td><td></td><td></td><td></td><td>x</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr> | ||||
| <tr><td rowspan="2">Function</td><td colspan="4">_FS_MINIMIZE</td><td colspan="2">_FS_READONLY</td><td colspan="2">_USE_STRFUNC</td><td colspan="3">_FS_RPATH</td><td colspan="2">_USE_MKFS</td><td colspan="2">_USE_FORWARD</td><td colspan="2">_MULTI_PARTITION</td></tr> | ||||
| <tr><td>0</td><td>1</td><td>2</td><td>3</td><td>0</td><td>1</td><td>0  </td><td>1/2</td><td>0</td><td>1</td><td>2</td><td>0</td><td>1</td><td>0</td><td>1</td><td>0/1</td><td>2</td></tr> | ||||
| <tr class="lst3"><td>f_mount</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr> | ||||
| <tr><td>f_open</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr> | ||||
| <tr><td>f_close</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr> | ||||
| <tr><td>f_read</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr> | ||||
| <tr><td>f_write</td><td></td><td></td><td></td><td></td><td></td><td>x</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr> | ||||
| <tr><td>f_sync</td><td></td><td></td><td></td><td></td><td></td><td>x</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr> | ||||
| <tr><td>f_lseek</td><td></td><td></td><td></td><td>x</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr> | ||||
| <tr><td>f_opendir</td><td></td><td></td><td>x</td><td>x</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr> | ||||
| <tr><td>f_readdir</td><td></td><td></td><td>x</td><td>x</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr> | ||||
| <tr><td>f_stat</td><td></td><td>x</td><td>x</td><td>x</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr> | ||||
| <tr><td>f_getfree</td><td></td><td>x</td><td>x</td><td>x</td><td></td><td>x</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr> | ||||
| <tr><td>f_truncate</td><td></td><td>x</td><td>x</td><td>x</td><td></td><td>x</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr> | ||||
| <tr><td>f_unlink</td><td></td><td>x</td><td>x</td><td>x</td><td></td><td>x</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr> | ||||
| <tr><td>f_mkdir</td><td></td><td>x</td><td>x</td><td>x</td><td></td><td>x</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr> | ||||
| <tr><td>f_chmod</td><td></td><td>x</td><td>x</td><td>x</td><td></td><td>x</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr> | ||||
| <tr><td>f_utime</td><td></td><td>x</td><td>x</td><td>x</td><td></td><td>x</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr> | ||||
| <tr><td>f_rename</td><td></td><td>x</td><td>x</td><td>x</td><td></td><td>x</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr> | ||||
| <tr><td>f_chdir</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td>x</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr> | ||||
| <tr><td>f_chdrive</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td>x</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr> | ||||
| <tr><td>f_getcwd</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td>x</td><td>x</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr> | ||||
| <tr><td>f_mkfs</td><td></td><td></td><td></td><td></td><td></td><td>x</td><td></td><td></td><td></td><td></td><td></td><td>x</td><td></td><td></td><td></td><td></td><td></td></tr> | ||||
| <tr><td>f_fdisk</td><td></td><td></td><td></td><td></td><td></td><td>x</td><td></td><td></td><td></td><td></td><td></td><td>x</td><td></td><td></td><td></td><td>x</td><td></td></tr> | ||||
| <tr><td>f_forward</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td>x</td><td></td><td></td><td></td></tr> | ||||
| <tr><td>f_putc</td><td></td><td></td><td></td><td></td><td></td><td>x</td><td>x</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr> | ||||
| <tr><td>f_puts</td><td></td><td></td><td></td><td></td><td></td><td>x</td><td>x</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr> | ||||
| <tr><td>f_printf</td><td></td><td></td><td></td><td></td><td></td><td>x</td><td>x</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr> | ||||
| <tr><td>f_gets</td><td></td><td></td><td></td><td></td><td></td><td></td><td>x</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr> | ||||
| </table> | ||||
| </div> | ||||
| 
 | ||||
| @ -148,7 +155,7 @@ _FS_SHARE        0 (Disable shareing control) | ||||
| <tr><td>950(Big5)</td><td>+111497</td></tr> | ||||
| </table> | ||||
| <p>LFN機能の上手な使い方は、それを使わないということです。実際、組み込み用途ではLFN機能がどうしても必要になるということはほとんど無いはずです。LFNを有効にすると、選択されたコード・ページに応じてモジュール・サイズが増大されます。右の表に各コード・ページにおけるLFNを有効にしたときのモジュール・サイズの違いを示します。私たち日本人、中国人および韓国人は数万の文字を持ちます。不幸なことに、それは巨大なOEM-Unicode相互変換テーブルを要求し、モジュール・サイズは劇的に増大されます。その結果、LFNを有効にしたFatFsモジュールは、AVRを含む殆どの8ビット・マイコンにインプリメントされることができません。<small>これは長い間私がLFNをインプリメントすることに興味を持ってこなかった理由です。</small></p> | ||||
| <p>注: マイクロソフト社はFATファイル・システムについていくつかの特許を保有しています。いずれもLFNの実装に関するもので、LFN機能に対して$0.25/unitのライセンス料を要求しています。FAT32は無関係です。このため、商用製品でLFN機能有効にするときは、最終仕向地によってはライセンスが必要かも知れません。</p> | ||||
| <p>注: マイクロソフト社はFATファイル・システムについていくつかの特許を保有しています。いずれもLFNの実装に関するもので、LFN機能に対して$0.25/unitのライセンス料を要求しています。最近のFAT32ドライバの多くはLFN機能を含んでいるため、それらの使用に当たってライセンスが必要になりますが、FatFsではLFN機能の有効・無効を任意に構成できます。このため、商用製品でLFN機能を有効にするときは、最終仕向地によってはライセンスが必要かも知れません。</p> | ||||
| </div> | ||||
| 
 | ||||
| <div class="para" id="jap"> | ||||
| @ -179,7 +186,7 @@ _FS_SHARE        0 (Disable shareing control) | ||||
| <h3>効率的なファイル・アクセス</h3> | ||||
| <p>小規模な組込システムでのファイルの読み書きにおける効率の良いアクセスのため、アプリケーション・プログラマはFatFsモジュールの中でどのような処理が行われているか考慮すべきです。ストレージ上のデータはf_read関数により次のシーケンスで転送されます。</p> | ||||
| <p>図1. セクタ・ミスアラインド・リード (ショート)<br> | ||||
| <img src="../img/f1.png" width="490" height="73" alt="fig.1"> | ||||
| <img src="../img/f1.png" width="490" height="110" alt="fig.1"> | ||||
| </p> | ||||
| <p>図2. セクタ・ミスアラインド・リード (ロング)<br> | ||||
| <img src="../img/f2.png" width="490" height="140" alt="fig.2"> | ||||
| @ -232,7 +239,7 @@ _FS_SHARE        0 (Disable shareing control) | ||||
| <h3>FatFsのライセンスについて</h3> | ||||
| <p>ソース・ファイルのヘッダにライセンス条件が記述されているので、利用の際はそれに従うこと。英語を読めない方のために以下に日本語訳を示しておきます。</p> | ||||
| <pre>/*----------------------------------------------------------------------------/ | ||||
| /  FatFs - FAT file system module  R0.08b                   (C)ChaN, 2011 | ||||
| /  FatFs - FAT file system module  R0.09                    (C)ChaN, 2011 | ||||
| /-----------------------------------------------------------------------------/ | ||||
| / FatFsモジュールは、小規模な組み込みシステム向けの汎用FATファイルシステム・ | ||||
| / モジュールです。これはフリー・ソフトウェアとして、教育・研究・開発のために | ||||
|  | ||||
| @ -38,7 +38,7 @@ DSTATUS disk_initialize ( | ||||
| <div class="para desc"> | ||||
| <h4>解説</h4> | ||||
| <p>ディスク・ドライブを初期化します。関数が成功すると、戻り値の<tt>STA_NOINIT</tt>フラグがクリアされます。</p> | ||||
| <p><em>アプリケーションからこの関数を呼び出すと、FATボリュームが破壊される可能性があります。エラー等により再初期化が必要なときは、<tt>f_mount()</tt>を使用します。</em>FatFsモジュールは、自動マウント動作により、必要に応じてこの関数を呼び出します。</p> | ||||
| <p><em>アプリケーションからはこの関数を呼び出してはなりません。さもないと、FATボリュームが破壊されます。エラー等により再初期化が必要なときは、<tt>f_mount()</tt>を使用してください。</em>FatFsモジュールは、自動マウント動作により、必要に応じてこの関数を呼び出します。</p> | ||||
| </div> | ||||
| 
 | ||||
| <p class="foot"><a href="../00index_j.html">戻る</a></p> | ||||
|  | ||||
							
								
								
									
										97
									
								
								doc/ja/fdisk.html
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										97
									
								
								doc/ja/fdisk.html
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,97 @@ | ||||
| <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> | ||||
| <html lang="ja"> | ||||
| <head> | ||||
| <meta http-equiv="Content-Type" content="text/html; charset=Shift_JIS"> | ||||
| <meta http-equiv="Content-Style-Type" content="text/css"> | ||||
| <link rel="up" title="FatFs" href="../00index_j.html"> | ||||
| <link rel="alternate" hreflang="en" title="English" href="../en/fdisk.html"> | ||||
| <link rel="stylesheet" href="../css_j.css" type="text/css" media="screen" title="ELM Default"> | ||||
| <title>FatFs - f_fdisk</title> | ||||
| </head> | ||||
| 
 | ||||
| <body> | ||||
| 
 | ||||
| <div class="para func"> | ||||
| <h2>f_fdisk</h2> | ||||
| <p>物理ドライブを分割します。</p> | ||||
| <pre> | ||||
| FRESULT f_fdisk ( | ||||
|   BYTE  <em>Drive</em>,              <span class="c">/* 物理ドライブ番号 */</span> | ||||
|   const DWORD <em>Partitions[]</em>, <span class="c">/* 区画マップ・テーブル */</span> | ||||
|   void* <em>Work</em>                <span class="c">/* ワークエリア */</span> | ||||
| ); | ||||
| </pre> | ||||
| </div> | ||||
| 
 | ||||
| <div class="para arg"> | ||||
| <h4>引数</h4> | ||||
| <dl class="par"> | ||||
| <dt>Drive</dt> | ||||
| <dd>分割する<em>物理ドライブ</em>を指定します。</dd> | ||||
| <dt>Partitions[]</dt> | ||||
| <dd>区画マップ・テーブルへのポインタを指定します。</dd> | ||||
| <dt>Work</dt> | ||||
| <dd>ワークエリアへのポインタを指定します。サイズは<tt>_MAX_SS</tt>バイト必要です。</dd> | ||||
| </dl> | ||||
| </div> | ||||
| 
 | ||||
| <div class="para ret"> | ||||
| <h4>戻り値</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#ip">FR_INVALID_PARAMETER</a> | ||||
| </p> | ||||
| </div> | ||||
| 
 | ||||
| <div class="para desc"> | ||||
| <h4>説明</h4> | ||||
| <p>f_fdisk関数は、指定された物理ドライブのMBRに区画テーブルを作成します。区画分けは一般的なFDISK形式で行うため、最大4つの基本区画を作成することができます。拡張区画には対応していません。区画マップテーブル Partitions[] にはドライブをどのように分割するか指定して渡します。この配列は4つの項目から成り、先頭の項目が1番目の、最後の項目が4番目の区画のサイズを示します。値が100以下の場合、ドライブの総容量に対する割合をパーセント単位で指定します。100を超える値の場合はセクタ数の直接指定になります。</p> | ||||
| </div> | ||||
| 
 | ||||
| <div class="para comp"> | ||||
| <h4>対応情報</h4> | ||||
| <p><tt>_FS_READOLNY == 0</tt> で <tt>_USE_MKFS == 1</tt> で <tt>_MULTI_PARTITION == 2</tt> のとき使用可能です。</p> | ||||
| </div> | ||||
| 
 | ||||
| <div class="para use"> | ||||
| <h4>使用例</h4> | ||||
| <pre> | ||||
|     <span class="c">/* ユーザ定義のボリューム管理テーブル (_MULTI_PARTITION != 0 のとき必要) */</span> | ||||
| 
 | ||||
|     PARTITION VolToPart[] = { | ||||
|         {0, 1},    <span class="c">/* 論理ドライブ 0 ==> 物理ドライブ 0, 第1区画 */</span> | ||||
|         {0, 2},    <span class="c">/* 論理ドライブ 1 ==> 物理ドライブ 0, 第2区画 */</span> | ||||
|         {1, 0}     <span class="c">/* 論理ドライブ 2 ==> 物理ドライブ 1, 自動検出 */</span> | ||||
|     }; | ||||
| </pre> | ||||
| <pre> | ||||
|     <span class="c">/* 新しい物理ドライブ(0)の初期化 */</span> | ||||
| 
 | ||||
|     FATFS Fatfs; | ||||
|     DWORD plist[] = {50, 50, 0, 0};  <span class="c">/* 2分割 */</span> | ||||
|     BYTE work[_MAX_SS]; | ||||
| 
 | ||||
|     f_fdisk(0, plist, work);  <span class="c">/* 物理ドライブ 0 の分割 */</span> | ||||
| 
 | ||||
|     f_mount(0, &Fatfs); | ||||
|     f_mkfs(0, 0, 0);          <span class="c">/* 論理ドライブ 0 の初期化. 第二引数は無視される.  */</span> | ||||
|     f_mount(0, 0); | ||||
| 
 | ||||
|     f_mount(1, &Fatfs); | ||||
|     f_mkfs(1, 0, 0); | ||||
|     f_mount(1, 0); | ||||
| 
 | ||||
| </pre> | ||||
| </div> | ||||
| 
 | ||||
| <div class="para ref"> | ||||
| <h4>See Also</h4> | ||||
| <p><tt><a href="filename.html#vol">Volume management</a>, <a href="mkfs.html">f_mkfs</a></tt></p> | ||||
| </div> | ||||
| 
 | ||||
| <p class="foot"><a href="../00index_j.html">Return</a></p> | ||||
| </body> | ||||
| </html> | ||||
| @ -11,12 +11,12 @@ | ||||
| 
 | ||||
| <body> | ||||
| <h1>パス名のフォーマット</h1> | ||||
| <div class="para"> | ||||
| <div class="para" id="nam"> | ||||
| <h3>ファイル・ディレクトリ名</h3> | ||||
| <p>FatFsモジュールでのファイル、ディレクトリ、ドライブの指定方法はDOS/Windows APIとほぼ同じです。パス名のフォーマットは次の通りです。</p> | ||||
| <p><tt>"[論理ドライブ番号:][/]ディレクトリ名/ファイル名"</tt></p> | ||||
| <p>FatFsモジュールは長いファイル名(LFN)および8.3形式ファイル名(SFN)に対応しています。LFNは、<tt>(_USE_LFN > 0)</tt>のとき使用可能になります。ディレクトリ・セパレータにはDOS/Windows APIと同じく / と \ を使用します。連続したセパレータは無視され1個として扱われます。唯一の違いは、論理ドライブの指定だけです。論理ドライブ番号は、'0'~'9'の一文字の数字とコロンで指定し、省略した場合はデフォルト・ドライブ(0またはカレント・ドライブ)が選択されます。</p> | ||||
| <p>Nul文字と制御文字(\0~\x1F)は、パス名の終端として認識されます。パス名に先行あるいは中に含まれるスペースは、LFN構成では名前の一部として有効ですが、非LFN構成ではパス名の終端として認識されます。</p> | ||||
| <p>Nul文字と制御文字(\0~\x1F)は、パス名の終端として認識されます。パス名に先行あるいは中に含まれるスペースは、LFN構成では名前の一部として有効ですが、非LFN構成ではスペースはパス名の終端として認識されます。</p> | ||||
| <p>標準構成<tt>(_FS_RPATH == 0)</tt>のときは、全てのオブジェクトがルート・ディレクトリから辿る絶対パスで指定されます。OS指向なカレント・ディレクトリという概念は無く、またドット・ディレクトリ("."や"..")は使用できません。パス名先頭のセパレータは無視されます。デフォルト・ドライブ番号は常に0になります。</p> | ||||
| <p>相対パスを有効<tt>(_FS_RPATH == 1)</tt>にしたときは、先行するセパレータの有無によって検索開始ディレクトリが変わり、セパレータがある場合はルート・ディレクトリから、無い場合は<a href="chdir.html">f_chdir関数</a>で設定されるカレント・ディレクトリからになります。またパス名にドット・ディレクトリが使用できます。デフォルト・ドライブ番号は<a href="chdrive.html">f_chdrive関数</a>で設定された値となります。</p> | ||||
| <table class="lst2"> | ||||
| @ -36,7 +36,7 @@ | ||||
| </div> | ||||
| 
 | ||||
| <p><br></p> | ||||
| <div class="para"> | ||||
| <div class="para" id="uni"> | ||||
| <h3>Unicode API</h3> | ||||
| <p>ファイル関数の入出力のうちファイル名やパス名を指定する引数の型は、<tt>TCHAR</tt>で定義されていますが、これは<tt>char</tt>のエリアスになっています。そして、<tt>_CODE_PAGE</tt>で指定される ANSI/OEMコード(SBCSまたはDBCS)の文字列として扱われます。ファイル名入出力をUnicodeとする構成(LFN構成で、かつ<tt>_LFN_UNICODE</tt>を 1)にしたときは、<tt>TCHAR</tt>はワイド文字(<tt>unsigned short</tt>)に切り替わり、パス名にUnicodeを使用するようになります。これにより LFNフル対応となり、ANSI/OEMコードにない文字(たとえば ✝☪✡☸☭など)も使用できます。この設定は文字列入出力関数のデータ型とエンコーディングにも影響を与えます。リテラル文字列を定義するとき、次に示すように<tt>_T(s)</tt>および<tt>_TEXT(s)</tt>マクロを使ってANSI/OEMとUnicodeを自動切り替えすることができます。</p> | ||||
| <pre> | ||||
| @ -47,25 +47,24 @@ | ||||
| </div> | ||||
| 
 | ||||
| <p><br></p> | ||||
| <div class="para"> | ||||
| <div class="para" id="vol"> | ||||
| <h3>論理ドライブ(ボリューム)と物理ドライブ(ディスク装置)の対応</h3> | ||||
| <p>デフォルトの構成では、それぞれの論理ドライブは同じ番号の物理ドライブに1:1で結びつけられていて、物理ドライブの先頭の区画にあるボリュームがマウントされます。<tt>_MULTI_PARTITION</tt>に 1を指定すると、個々の論理ドライブに対して個別に物理ドライブ番号・区画を指定できるようになります。この構成では、論理ドライブと区画の対応を解決するためのテーブルを次に示すように定義する必要があります。</p> | ||||
| <p>デフォルトの構成では、それぞれの論理ドライブは同じ番号の物理ドライブに1:1で結びつけられていて、SFDとしてまたは第1区画のボリュームがマウントされます。<tt>_MULTI_PARTITION</tt>に 1以上を指定すると、個々の論理ドライブに対して個別に物理ドライブ番号・区画を指定できるようになります。この構成では、論理ドライブと区画の対応を解決するためのテーブルを次に示すように定義する必要があります。</p> | ||||
| <pre> | ||||
| 例:論理ドライブ0~2を物理ドライブ0(固定ディスク)の3つの基本区画に割り当て、 | ||||
|    論理ドライブ3を物理ドライブ1(リムーバブル・ディスク)に割り当てる場合。 | ||||
| 
 | ||||
| const PARTITION Drives[] = { | ||||
|     {0, 0},     <span class="c">/* Logical drive 0 ==> Physical drive 0, 1st partition */</span> | ||||
|     {0, 1},     <span class="c">/* Logical drive 1 ==> Physical drive 0, 2nd partition */</span> | ||||
|     {0, 2},     <span class="c">/* Logical drive 2 ==> Physical drive 0, 3rd partition */</span> | ||||
|     {1, 0}      <span class="c">/* Logical drive 3 ==> Physical drive 1 */</span> | ||||
| PARTITION VolToPart[] = { | ||||
|     {0, 1},     <span class="c">/* 論理ドライブ 0 ==> 物理ドライブ 0, 第1区画 */</span> | ||||
|     {0, 2},     <span class="c">/* 論理ドライブ 1 ==> 物理ドライブ 0, 第2区画 */</span> | ||||
|     {0, 3},     <span class="c">/* 論理ドライブ 2 ==> 物理ドライブ 0, 第3区画 */</span> | ||||
|     {1, 0}      <span class="c">/* 論理ドライブ 3 ==> 物理ドライブ 1, 自動検出 */</span> | ||||
| }; | ||||
| </pre> | ||||
| <p>複数区画指定を使用する場合、次の点に注意しなければなりません。 | ||||
| <ul> | ||||
| <li>指定可能な区画は基本区画(0~3)のみ。</li> | ||||
| <li>物理ドライブがSFD形式(区画テーブル無し)の場合、区画指定は無視される。</li> | ||||
| <li>複数の論理ドライブを持つ物理ドライブは、固定ディスクでなければならない。</li> | ||||
| <li>マウント可能な区画は基本区画のみで、拡張区画内には対応しない。</li> | ||||
| <li>複数の区画を持つ物理ドライブは、非リムーバブルでなければならない。</li> | ||||
| </ul> | ||||
| 
 | ||||
| </body> | ||||
|  | ||||
| @ -54,8 +54,8 @@ FRESULT f_lseek ( | ||||
| <li>非書き込みモードまたは高速シーク・モードのため、ファイル・サイズでクリップされた。</li> | ||||
| <li>ファイル拡張中にディスクが満杯になった。</li> | ||||
| </ul> | ||||
| <p><tt>_USE_FASTSEEK</tt>に1が指定されていて、且つファイル・オブジェクトの<tt>cltbl</tt>メンバがNULL以外(ファイルを開いたときはNULL)のとき、高速シーク・モードになります。これはファイルのクラスタ配置情報(CLMT)をメモリ上に保持しておくことにより、FATにアクセスすることなく後方シークやロング・シークを高速に行う機能です。高速シーク・モードは、f_read/f_wtite関数にも適用されます。高速シーク・モードではf_wtite/f_lseek関数によるファイル・サイズの拡張はできません。</p> | ||||
| <p>高速シーク動作を行う前に、CLMTを作成しておく必要があります。これを作成するには、まず<tt>cltbl</tt>メンバにCLMT格納バッファ(DWORD配列)へのポインタをセットします。そして、配列の先頭要素にその配列の要素数を入れ、f_lseek関数を<tt>Offset</tt>に<tt>CREATE_LINKMAP</tt>を指定して実行します。関数が成功するとCLMTが作成され、以降のf_read/f_write/f_lseek関数ではFATへのアクセスは発生しません。<tt>FR_NOT_ENOUGH_CORE</tt>で失敗したときは配列サイズが不足で、先頭要素には実際に必要となる要素数が返されます。必要な要素数は、(ファイルの分割数 + 1) * 2 です。たとえば、ファイルが5つに分断されているときに必要な要素数は、12となります。</p> | ||||
| <p><tt>_USE_FASTSEEK</tt>が1で、且つファイル・オブジェクトの<tt>cltbl</tt>メンバがNULL以外(f_open()でNULLに設定される)のとき、高速シーク・モードになります。これはファイルのクラスタ配置情報(CLMT)をメモリ上に保持しておくことにより、FATにアクセスすることなく後方シークやロング・シークを高速に行う機能です。高速シーク・モードは、f_read/f_wtite関数の動作にも適用されます。高速シーク・モードではf_wtite/f_lseek関数によるファイル・サイズの拡張はできません。</p> | ||||
| <p>高速シーク動作を行う前に、CLMTを作成しておく必要があります。これを作成するには、まずCLMT格納バッファ(DWORD配列)を準備し、<tt>cltbl</tt>メンバにそのポインタをセットします。そして、配列の先頭要素にその配列のサイズ(要素数)を入れ、f_lseek関数を<tt>Offset</tt>に<tt>CREATE_LINKMAP</tt>を指定して呼び出します。関数が成功するとCLMTが作成され、以降のf_read/f_write/f_lseek関数ではFATへのアクセスは発生しません。<tt>FR_NOT_ENOUGH_CORE</tt>で失敗したときは配列サイズが不足で、先頭要素には実際に必要となる要素数が返されます。必要な要素数は、(ファイルの分割数 + 1) * 2 です。たとえば、ファイルが5つのフラグメントに分断されているときに必要な要素数は、12となります。</p> | ||||
| </div> | ||||
| 
 | ||||
| 
 | ||||
| @ -75,30 +75,30 @@ FRESULT f_lseek ( | ||||
|     if (res) ... | ||||
| 
 | ||||
|     <span class="c">/* ファイル・オフセット5000へ移動 */</span> | ||||
|     res = f_lseek(file, 5000, 0); | ||||
|     res = f_lseek(file, 5000); | ||||
| 
 | ||||
|     <span class="c">/* ファイル終端へ移動(ファイル追記の準備) */</span> | ||||
|     res = f_lseek(file, f_size(file), 0); | ||||
|     res = f_lseek(file, f_size(file)); | ||||
| 
 | ||||
|     <span class="c">/* 3000バイト進める */</span> | ||||
|     res = f_lseek(file, f_tell(file) + 3000, 0); | ||||
|     res = f_lseek(file, f_tell(file) + 3000); | ||||
| 
 | ||||
|     <span class="c">/* 2000バイト戻す (オーバーフローに注意) */</span> | ||||
|     res = f_lseek(file, f_tell(file) - 2000, 0); | ||||
|     res = f_lseek(file, f_tell(file) - 2000); | ||||
| </pre> | ||||
| <pre> | ||||
|     <span class="c">/* クラスタ先行割り当て (ストリーミング・ライト時のバッファ・オーバーラン防止) */</span> | ||||
| 
 | ||||
|     res = f_open(file, "record.wav", FA_CREATE_NEW | FA_WRITE);  <span class="c">/* ファイル作成 */</span> | ||||
| 
 | ||||
|     res = f_lseek(file, MAX_SIZE, 0);        <span class="c">/* 十分なクラスタの先行割り当て */</span> | ||||
|     res = f_lseek(file, MAX_SIZE);           <span class="c">/* 十分なクラスタの先行割り当て */</span> | ||||
|     if (res || f_tell(file) != PRE_SIZE) ... <span class="c">/* 正しくファイルが拡張されたかチェック */</span> | ||||
| 
 | ||||
|     res = f_lseek(file, DATA_START, 0);      <span class="c">/* データ・ストリームの記録(アロケーションディレイ無し) */</span> | ||||
|     res = f_lseek(file, DATA_START);         <span class="c">/* データ・ストリームの記録(アロケーションディレイ無し) */</span> | ||||
|     ... | ||||
| 
 | ||||
|     res = f_truncate(file);                  <span class="c">/* 不要領域の切り捨て */</span> | ||||
|     res = f_lseek(file, 0, 0);               <span class="c">/* ヘッダの記録 */</span> | ||||
|     res = f_lseek(file, 0);                  <span class="c">/* ヘッダの記録 */</span> | ||||
|     ... | ||||
| 
 | ||||
|     res = f_close(file); | ||||
|  | ||||
| @ -13,7 +13,7 @@ | ||||
| 
 | ||||
| <div class="para func"> | ||||
| <h2>f_mkfs</h2> | ||||
| <p>物理ドライブ上にFATボリュームを作成(フォーマット)します。</p> | ||||
| <p>論理ドライブ上にFATボリュームを作成(フォーマット)します。</p> | ||||
| <pre> | ||||
| FRESULT f_mkfs ( | ||||
|   BYTE  <em>Drive</em>,              <span class="c">/* 論理ドライブ番号 */</span> | ||||
| @ -29,9 +29,9 @@ FRESULT f_mkfs ( | ||||
| <dt>Drive</dt> | ||||
| <dd>フォーマットする論理ドライブ(0-9)。</dd> | ||||
| <dt>PartitioningRule</dt> | ||||
| <dd>0を指定すると、ドライブの全領域を占める基本DOS区画を作成したあと、そこにFATボリュームを作成します(FDISKフォーマット)。1を指定すると、区画テーブルを作成せず物理ドライブの先頭セクタから直接ファイル・システムを作成します(super floppy (SFD) フォーマット)。</dd> | ||||
| <dd>パーテーション形式(0(FDISK) または1(SFD))を指定します。</dd> | ||||
| <dt>AllocSize</dt> | ||||
| <dd>クラスタ・サイズをバイト単位で指定します。2の累乗、且つセクタ・サイズ以上、且つセクタ・サイズの128倍以下でなければなりません。無効な値を指定した場合、ドライブ・サイズに応じたデフォルトのクラスタ・サイズが選択されます。特に指定しない場合は、0を指定して自動選択とします。</dd> | ||||
| <dd>クラスタ・サイズをバイト単位で指定します。2の累乗、且つセクタ・サイズ以上、且つセクタ・サイズの128倍以下でなければなりません。0を指定した場合、ボリュームのサイズに応じたデフォルトのクラスタ・サイズが選択されます。</dd> | ||||
| </dl> | ||||
| </div> | ||||
| 
 | ||||
| @ -42,14 +42,17 @@ FRESULT f_mkfs ( | ||||
| <a href="rc.html#de">FR_DISK_ERR</a>, | ||||
| <a href="rc.html#nr">FR_NOT_READY</a>, | ||||
| <a href="rc.html#ne">FR_NOT_ENABLED</a>, | ||||
| <a href="rc.html#ma">FR_MKFS_ABORTED</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>説明</h4> | ||||
| <p>f_mkfs関数は物理ドライブ上にFATボリュームを作成します。リムーバブル・メディアのパーテーショニング・ルールとしてはFDISK形式とSFD形式があり、メモリ・カードではFDISK形式が普通です。この関数は<em>複数区画には対応していない</em>ので、その物理ドライブの既存の区画は全て削除され、全体が一つの区画になります。</p> | ||||
| <p>FATタイプ(FAT12/FAT16/FAT32)は、その論理ドライブ上の<em>クラスタ数によってのみ決定</em>される決まり[FAT仕様書より]になっていて、それ以外の要因はありません。したがって、どのFATタイプになるかはドライブ・サイズとクラスタ・サイズに依存します。クラスタ・サイズは大きくするほど性能が上がり、逆にディスク利用効率は落ちます。</p> | ||||
| <p>f_mkfs関数は物理ドライブ上にFATボリュームを作成します。第二引数でFDISK形式が指定された場合は、物理ドライブ全体を占める基本区画(パーテーション)が作成され、その中にFATボリュームが作成されます。SFD形式では、FATボリュームは物理ドライブの先頭からベタで作成されます。</p> | ||||
| <p>マルチパーテーション機能<tt>(_MULTI_PARTITION)</tt>により、指定された論理ドライブが特定の区画(1~4)に結び付けられている場合、その区画の中にFATボリュームが作成されます。この場合、第二引数は無視され、また対応する物理ドライブはこれに先立ち、f_fdisk関数または他のツールで適切に区画設定されている必要があります。</p> | ||||
| <p>パーテーション形式には、FDISK形式とSFD形式の二通りありがあります。FDISK形式は、ハードディスク、MMC、SDC、CFCなどで使用されます。FDISK形式では一台の物理ドライブ上に一つまたは複数の区画を作成することができます。管理情報はMBR(物理ドライブの先頭セクタ)に記録されます。SFD形式は単に何の分割も行わない形式で、ボリュームは物理ドライブの先頭セクタから開始します。SFD形式は、フロッピーディスク、マイクロドライブ、光学ディスク、およびその他スーパーフロッピーメディアで使用されています。</p> | ||||
| <p>FATタイプ(FAT12/FAT16/FAT32)は、その論理ドライブ上の<em>クラスタ数によってのみ決定</em>される決まり[FAT仕様書より]になっていて、それ以外の要因はありません。したがって、どのFATタイプになるかはドライブ・サイズとクラスタ・サイズに依存します。クラスタ・サイズは大きくするほど性能が上がり、ディスク利用効率は落ちます。</p> | ||||
| <p>クラスタ数がFATタイプの境界に近くなるときは、FR_MKFS_ABORTEDで関数が失敗する可能性があります。</p> | ||||
| </div> | ||||
| 
 | ||||
| @ -60,6 +63,11 @@ FRESULT f_mkfs ( | ||||
| </div> | ||||
| 
 | ||||
| 
 | ||||
| <p class="foot"><a href="../00index_e.html">Return</a></p> | ||||
| <div class="para ref"> | ||||
| <h4>参照</h4> | ||||
| <p><tt><a href="filename.html#vol">ボリューム管理</a>, <a href="fdisk.html">f_fdisk</a></tt></p> | ||||
| </div> | ||||
| 
 | ||||
| <p class="foot"><a href="../00index_j.html">戻る</a></p> | ||||
| </body> | ||||
| </html> | ||||
|  | ||||
| @ -73,7 +73,7 @@ FRESULT f_open ( | ||||
| <div class="para desc"> | ||||
| <h4>解説</h4> | ||||
| <p>既存のファイルを開いたり、新しいファイルを作成します。関数が成功するとファイル・オブジェクトが作成され、以降そのファイルに対するアクセスに使用します。ファイルを閉じるときは、<a href="close.html">f_close()</a>を使用します。何らかの変更が行われたファイルがその後正しく閉じられなかった場合、そのファイルが破損する場合があります。</p> | ||||
| <p>もしも既に開かれているファイルを開く必要がある場合は、<a href="appnote.html#dup">多重アクセス制御</a>を参照してください。</p> | ||||
| <p>既に開かれているファイルを開く必要がある場合は、<a href="appnote.html#dup">多重アクセス制御</a>を参照してください。しかし、一つのファイルに対する書き込みモードを含む重複オープンは常に禁止です。</p> | ||||
| <p>ファイル・アクセスを開始する前に、<a href="mount.html">f_mount()</a>を使ってそれぞれの論理ドライブにワーク・エリア(ファイル・システム・オブジェクト)を与える必要があります。この初期化の後、その論理ドライブに対して全てのファイル関数が使えるようになります。</p> | ||||
| </div> | ||||
| 
 | ||||
| @ -109,7 +109,7 @@ void main (void) | ||||
| 
 | ||||
|     <span class="c">/* ソースからデスティネーションにコピーする */</span> | ||||
|     for (;;) { | ||||
|         res = f_read(&fsrc, buffer, sizeof(buffer), &br); | ||||
|         res = f_read(&fsrc, buffer, sizeof buffer, &br); | ||||
|         if (res || br == 0) break;   <span class="c">/* エラーかファイル終端 */</span> | ||||
|         res = f_write(&fdst, buffer, br, &bw); | ||||
|         if (res || bw < br) break;   <span class="c">/* エラーかディスク満杯 */</span> | ||||
|  | ||||
| @ -35,7 +35,7 @@ int f_putc ( | ||||
| 
 | ||||
| <div class="para ret"> | ||||
| <h4>戻り値</h4> | ||||
| <p>文字が正常に書き込まれると書き込んだ文字が返されます。ディスクが満杯またはエラーにより書き込まれなかったときは<tt>EOF (-1)</tt>が返されます。</p> | ||||
| <p>文字が正常に書き込まれると書き込んだ文字数(1)が返されます。ディスクが満杯またはエラーにより書き込まれなかったときは<tt>EOF (-1)</tt>が返されます。</p> | ||||
| <p>APIにUnicodeが選択されている(<tt>_LFN_UNICODE</tt>が1)ときは、UTF-8エンコードでファイルに書き込みます。それ以外の時は無変換(1文字1バイト)で書き込みます。</p> | ||||
| </div> | ||||
| 
 | ||||
|  | ||||
| @ -16,7 +16,7 @@ | ||||
| <p>ファイルに文字列を書き込みます。</p> | ||||
| <pre> | ||||
| int f_puts ( | ||||
|   const TCHAR* <em>Str</em>,  <span class="c">/* 文字列 */</span> | ||||
|   const TCHAR* <em>Str</em>,  <span class="c">/* 書き込む文字列 */</span> | ||||
|   FIL* <em>FileObject</em>    <span class="c">/* ファイル・オブジェクト */</span> | ||||
| ); | ||||
| </pre> | ||||
| @ -35,7 +35,7 @@ int f_puts ( | ||||
| 
 | ||||
| <div class="para ret"> | ||||
| <h4>戻り値</h4> | ||||
| <p>文字列が正常に書き込まれると、書き込まれた文字数が返されます。ディスクが満杯またはエラーにより正常に書き込まれなかったときは<tt>EOF (-1)</tt>が返されます。</p> | ||||
| <p>文字列が正常に書き込まれると、書き込まれた文字数が返されます。ディスクが満杯またはエラーにより書き込みが中断されたときは<tt>EOF (-1)</tt>が返されます。</p> | ||||
| <p>APIにUnicodeが選択されている(<tt>_LFN_UNICODE</tt>が1)ときは、UTF-8エンコードでファイルに書き込みます。それ以外の時は無変換(1文字1バイト)で書き込みます。</p> | ||||
| </div> | ||||
| 
 | ||||
|  | ||||
| @ -23,6 +23,7 @@ | ||||
| <ul> | ||||
| <li>ボリューム上のFAT構造にエラーがある。</li> | ||||
| <li>スタック不足や他のタスク等によるワーク・エリア(ファイル・システム・オブジェクトやファイル・オブジェクト)の破壊。多くはこれが原因。</li> | ||||
| <li>そのファイルオブジェクトでは過去に<tt>FR_DISK_ERR</tt>が発生している。</li> | ||||
| </ul> | ||||
| </dd> | ||||
| <dt id="nr">FR_NOT_READY</dt> | ||||
| @ -77,6 +78,8 @@ | ||||
| </dd> | ||||
| <dt id="tf">FR_TOO_MANY_OPEN_FILES</dt> | ||||
| <dd>同時オープン可能なファイル数を越えてファイルを開こうとした。(関連オプション: _FS_SHARE)</dd> | ||||
| <dt id="ip">FR_INVALID_PARAMETER</dt> | ||||
| <dd>与えられたパラメータが無効または矛盾している。</dd> | ||||
| </dl> | ||||
| 
 | ||||
| </body> | ||||
|  | ||||
| @ -81,7 +81,7 @@ FRESULT scan_files ( | ||||
| <span class="k">#if</span> _USE_LFN | ||||
|     static char lfn[_MAX_LFN + 1]; | ||||
|     fno.lfname = lfn; | ||||
|     fno.lfsize = sizeof(lfn); | ||||
|     fno.lfsize = sizeof lfn; | ||||
| <span class="k">#endif</span> | ||||
| 
 | ||||
| 
 | ||||
|  | ||||
| @ -26,10 +26,10 @@ | ||||
|     WORD    id;           <span class="c">/* ファイル・システム・マウントID */</span> | ||||
|     WORD    n_rootdir;    <span class="c">/* ルート・ディレクトリのエントリ数 (FAT12/16) */</span> | ||||
| <span class="k">#if</span> _MAX_SS != 512 | ||||
|     WORD    ssize;        <span class="c">/* セクタ・サイズ (可変セクタ長のみ) */</span> | ||||
|     WORD    ssize;        <span class="c">/* セクタ・サイズ (512, 1024, 2048 or 4096) */</span> | ||||
| <span class="k">#endif</span> | ||||
| <span class="k">#if</span> _FS_REENTRANT | ||||
|     HANDLE  h_mutex;      <span class="c">/* 同期オブジェクトID */</span> | ||||
|     _SYNC_t sobj;         <span class="c">/* 同期オブジェクトID */</span> | ||||
| <span class="k">#endif</span> | ||||
| <span class="k">#if</span> !_FS_READONLY | ||||
|     DWORD   last_clust;   <span class="c">/* 最後に割り当てられたクラスタ番号 */</span> | ||||
| @ -39,7 +39,7 @@ | ||||
| <span class="k">#if</span> _FS_RPATH | ||||
|     DWORD   cdir;         <span class="c">/* カレント・ディレクトリのクラスタ (0:ルート) */</span> | ||||
| <span class="k">#endif</span> | ||||
|     DWORD   n_fatent;     <span class="c">/* FATのエントリ数 (= クラスタ数 + 2) */</span> | ||||
|     DWORD   n_fatent;     <span class="c">/* FATのエントリ数 (== クラスタ数 + 2) */</span> | ||||
|     DWORD   fsize;        <span class="c">/* FAT 1個当たりのセクタ数 */</span> | ||||
|     DWORD   fatbase;      <span class="c">/* FAT領域開始セクタ */</span> | ||||
|     DWORD   dirbase;      <span class="c">/* ルート・ディレクトリ開始セクタ (FAT32: クラスタ番号) */</span> | ||||
|  | ||||
| @ -53,7 +53,7 @@ FRESULT f_stat ( | ||||
| 
 | ||||
| <div class="para desc"> | ||||
| <h4>‰ð<EFBFBD>à</h4> | ||||
| <p>ファイルまたはディレクトリに関する情報を得ます。得られるファイル情報の詳細については <tt>FILINFO</tt>構造体を参照してください。</p> | ||||
| <p>指定されたファイルまたはディレクトリに関する情報(サイズ、タイムスタンプおよび属性)を得ます。ディレクトリのサイズ情報は常に0です。</p> | ||||
| </div> | ||||
| 
 | ||||
| 
 | ||||
|  | ||||
| @ -1,3 +1,7 @@ | ||||
| R0.09, Sep 6, 2011 | ||||
|   f_mkfs() supports multiple partition to finish the multiple partition feature. | ||||
|   Added f_fdisk(). (_MULTI_PARTITION = 2) | ||||
| 
 | ||||
| R0.08b, Jan 15, 2011 | ||||
|   Fast seek feature is also applied to f_read() and f_write(). | ||||
|   f_lseek() reports required table size on creating CLMP. | ||||
|  | ||||
| @ -1,4 +1,4 @@ | ||||
| FatFs Module Source Files R0.08b                       (C)ChaN, 2011 | ||||
| FatFs Module Source Files R0.09                        (C)ChaN, 2011 | ||||
| 
 | ||||
| 
 | ||||
| FILES | ||||
| @ -125,3 +125,6 @@ REVISION HISTORY | ||||
|                        f_lseek() reports required table size on creating CLMP. | ||||
|                        Extended format syntax of f_printf function. | ||||
|                        Ignores duplicated directory separators in given path names. | ||||
| 
 | ||||
|   Sep 06,'11 R0.09     f_mkfs() supports multiple partition to finish the multiple partition feature. | ||||
|                        Added f_fdisk(). (_MULTI_PARTITION = 2) | ||||
|  | ||||
							
								
								
									
										299
									
								
								src/ff.c
									
									
									
									
									
								
							
							
						
						
									
										299
									
								
								src/ff.c
									
									
									
									
									
								
							| @ -1,5 +1,5 @@ | ||||
| /*----------------------------------------------------------------------------/
 | ||||
| /  FatFs - FAT file system module  R0.08b                 (C)ChaN, 2011 | ||||
| /  FatFs - FAT file system module  R0.09                  (C)ChaN, 2011 | ||||
| /-----------------------------------------------------------------------------/ | ||||
| / FatFs module is a generic FAT file system module for small embedded systems. | ||||
| / This is a free software that opened for education, research and commercial | ||||
| @ -87,6 +87,9 @@ | ||||
| /                   f_lseek() reports required table size on creating CLMP. | ||||
| /                   Extended format syntax of f_printf function. | ||||
| /                   Ignores duplicated directory separators in given path names. | ||||
| / | ||||
| / Sep 06,'11 R0.09  f_mkfs() supports multiple partition to finish the multiple partition feature. | ||||
| /                   Added f_fdisk(). (_MULTI_PARTITION = 2) | ||||
| /---------------------------------------------------------------------------*/ | ||||
| 
 | ||||
| #include "ff.h"			/* FatFs configurations and declarations */ | ||||
| @ -99,7 +102,7 @@ | ||||
| 
 | ||||
| ---------------------------------------------------------------------------*/ | ||||
| 
 | ||||
| #if _FATFS != 8237 | ||||
| #if _FATFS != 6502	/* Revision ID */ | ||||
| #error Wrong include file (ff.h). | ||||
| #endif | ||||
| 
 | ||||
| @ -109,7 +112,7 @@ | ||||
| #error Wrong sector size. | ||||
| #endif | ||||
| #if _MAX_SS != 512 | ||||
| #define	SS(fs)	((fs)->ssize)	/* Multiple sector size */ | ||||
| #define	SS(fs)	((fs)->ssize)	/* Variable sector size */ | ||||
| #else | ||||
| #define	SS(fs)	512U			/* Fixed sector size */ | ||||
| #endif | ||||
| @ -453,13 +456,18 @@ typedef struct { | ||||
| 
 | ||||
| 
 | ||||
| /*------------------------------------------------------------*/ | ||||
| /* Work area                                                  */ | ||||
| /* Module private work area                                   */ | ||||
| /*------------------------------------------------------------*/ | ||||
| /* Note that uninitialized variables with static duration are
 | ||||
| /  zeroed/nulled at start-up. If not, the compiler or start-up | ||||
| /  routine is out of ANSI-C standard. | ||||
| */ | ||||
| 
 | ||||
| #if _VOLUMES | ||||
| static | ||||
| FATFS *FatFs[_VOLUMES];	/* Pointer to the file system objects (logical drives) */ | ||||
| #else | ||||
| #error Number of drives must not be 0. | ||||
| #error Number of volumes must not be 0. | ||||
| #endif | ||||
| 
 | ||||
| static | ||||
| @ -475,23 +483,23 @@ static | ||||
| FILESEM	Files[_FS_SHARE];	/* File lock semaphores */ | ||||
| #endif | ||||
| 
 | ||||
| #if _USE_LFN == 0			/* No LFN */ | ||||
| #if _USE_LFN == 0			/* No LFN feature */ | ||||
| #define	DEF_NAMEBUF			BYTE sfn[12] | ||||
| #define INIT_BUF(dobj)		(dobj).fn = sfn | ||||
| #define	FREE_BUF() | ||||
| 
 | ||||
| #elif _USE_LFN == 1			/* LFN with static LFN working buffer */ | ||||
| #elif _USE_LFN == 1			/* LFN feature with static working buffer */ | ||||
| static WCHAR LfnBuf[_MAX_LFN+1]; | ||||
| #define	DEF_NAMEBUF			BYTE sfn[12] | ||||
| #define INIT_BUF(dobj)		{ (dobj).fn = sfn; (dobj).lfn = LfnBuf; } | ||||
| #define	FREE_BUF() | ||||
| 
 | ||||
| #elif _USE_LFN == 2 		/* LFN with dynamic LFN working buffer on the stack */ | ||||
| #elif _USE_LFN == 2 		/* LFN feature with dynamic working buffer on the stack */ | ||||
| #define	DEF_NAMEBUF			BYTE sfn[12]; WCHAR lbuf[_MAX_LFN+1] | ||||
| #define INIT_BUF(dobj)		{ (dobj).fn = sfn; (dobj).lfn = lbuf; } | ||||
| #define	FREE_BUF() | ||||
| 
 | ||||
| #elif _USE_LFN == 3 		/* LFN with dynamic LFN working buffer on the heap */ | ||||
| #elif _USE_LFN == 3 		/* LFN feature with dynamic working buffer on the heap */ | ||||
| #define	DEF_NAMEBUF			BYTE sfn[12]; WCHAR *lfn | ||||
| #define INIT_BUF(dobj)		{ lfn = ff_memalloc((_MAX_LFN + 1) * 2); \ | ||||
| 							  if (!lfn) LEAVE_FF((dobj).fs, FR_NOT_ENOUGH_CORE); \ | ||||
| @ -624,9 +632,7 @@ FRESULT chk_lock (	/* Check if the file can be accessed */ | ||||
| 
 | ||||
| 
 | ||||
| static | ||||
| int enq_lock (	/* Check if an entry is available for a new file */ | ||||
| 	FATFS* fs	/* File system object */ | ||||
| ) | ||||
| int enq_lock (void)	/* Check if an entry is available for a new file */ | ||||
| { | ||||
| 	UINT i; | ||||
| 
 | ||||
| @ -776,7 +782,7 @@ FRESULT sync (	/* FR_OK: successful, FR_DISK_ERR: failed */ | ||||
| 			fs->fsi_flag = 0; | ||||
| 		} | ||||
| 		/* Make sure that no pending write process in the physical drive */ | ||||
| 		if (disk_ioctl(fs->drv, CTRL_SYNC, (void*)0) != RES_OK) | ||||
| 		if (disk_ioctl(fs->drv, CTRL_SYNC, 0) != RES_OK) | ||||
| 			res = FR_DISK_ERR; | ||||
| 	} | ||||
| 
 | ||||
| @ -1113,6 +1119,7 @@ FRESULT dir_next (	/* FR_OK:Succeeded, FR_NO_FILE:End of table, FR_DENIED:EOT an | ||||
| 	WORD i; | ||||
| 
 | ||||
| 
 | ||||
| 	stretch = stretch;		/* To suppress warning on read-only cfg. */ | ||||
| 	i = dj->index + 1; | ||||
| 	if (!i || !dj->sect)	/* Report EOT when index has reached 65535 */ | ||||
| 		return FR_NO_FILE; | ||||
| @ -1968,11 +1975,11 @@ FRESULT follow_path (	/* FR_OK(0): successful, !=0: error code */ | ||||
| 
 | ||||
| 
 | ||||
| /*-----------------------------------------------------------------------*/ | ||||
| /* Load boot record and check if it is an FAT boot record                */ | ||||
| /* Load a sector and check if it is an FAT Volume Boot Record            */ | ||||
| /*-----------------------------------------------------------------------*/ | ||||
| 
 | ||||
| static | ||||
| BYTE check_fs (	/* 0:The FAT BR, 1:Valid BR but not an FAT, 2:Not a BR, 3:Disk error */ | ||||
| BYTE check_fs (	/* 0:FAT-VBR, 1:Valid BR but not FAT, 2:Not a BR, 3:Disk error */ | ||||
| 	FATFS *fs,	/* File system object */ | ||||
| 	DWORD sect	/* Sector# (lba) to check if it is an FAT boot record or not */ | ||||
| ) | ||||
| @ -2004,7 +2011,7 @@ FRESULT chk_mounted (	/* FR_OK(0): successful, !=0: any error occurred */ | ||||
| 	BYTE chk_wp			/* !=0: Check media write protection for write access */ | ||||
| ) | ||||
| { | ||||
| 	BYTE fmt, b, *tbl; | ||||
| 	BYTE fmt, b, pi, *tbl; | ||||
| 	UINT vol; | ||||
| 	DSTATUS stat; | ||||
| 	DWORD bsect, fasize, tsect, sysect, nclst, szbfat; | ||||
| @ -2024,7 +2031,7 @@ FRESULT chk_mounted (	/* FR_OK(0): successful, !=0: any error occurred */ | ||||
| #endif | ||||
| 	} | ||||
| 
 | ||||
| 	/* Check if the logical drive is valid or not */ | ||||
| 	/* Check if the file system object is valid or not */ | ||||
| 	if (vol >= _VOLUMES) 				/* Is the drive number valid? */ | ||||
| 		return FR_INVALID_DRIVE; | ||||
| 	*rfs = fs = FatFs[vol];				/* Return pointer to the corresponding file system object */ | ||||
| @ -2035,44 +2042,43 @@ FRESULT chk_mounted (	/* FR_OK(0): successful, !=0: any error occurred */ | ||||
| 	if (fs->fs_type) {					/* If the logical drive has been mounted */ | ||||
| 		stat = disk_status(fs->drv); | ||||
| 		if (!(stat & STA_NOINIT)) {		/* and the physical drive is kept initialized (has not been changed), */ | ||||
| #if !_FS_READONLY | ||||
| 			if (chk_wp && (stat & STA_PROTECT))	/* Check write protection if needed */ | ||||
| 			if (!_FS_READONLY && chk_wp && (stat & STA_PROTECT))	/* Check write protection if needed */ | ||||
| 				return FR_WRITE_PROTECTED; | ||||
| #endif | ||||
| 			return FR_OK;				/* The file system object is valid */ | ||||
| 		} | ||||
| 	} | ||||
| 
 | ||||
| 	/* The logical drive must be mounted. */ | ||||
| 	/* Following code attempts to mount a volume. (analyze BPB and initialize the fs object) */ | ||||
| 	/* The file system object is not valid. */ | ||||
| 	/* Following code attempts to mount the volume. (analyze BPB and initialize the fs object) */ | ||||
| 
 | ||||
| 	fs->fs_type = 0;					/* Clear the file system object */ | ||||
| 	fs->drv = (BYTE)LD2PD(vol);			/* Bind the logical drive and a physical drive */ | ||||
| 	fs->drv = LD2PD(vol);				/* Bind the logical drive and a physical drive */ | ||||
| 	stat = disk_initialize(fs->drv);	/* Initialize low level disk I/O layer */ | ||||
| 	if (stat & STA_NOINIT)				/* Check if the initialization succeeded */ | ||||
| 		return FR_NOT_READY;			/* Failed to initialize due to no media or hard error */ | ||||
| 	if (!_FS_READONLY && chk_wp && (stat & STA_PROTECT))	/* Check disk write protection if needed */ | ||||
| 		return FR_WRITE_PROTECTED; | ||||
| #if _MAX_SS != 512						/* Get disk sector size (variable sector size cfg only) */ | ||||
| 	if (disk_ioctl(fs->drv, GET_SECTOR_SIZE, &fs->ssize) != RES_OK) | ||||
| 		return FR_DISK_ERR; | ||||
| #endif | ||||
| #if !_FS_READONLY | ||||
| 	if (chk_wp && (stat & STA_PROTECT))	/* Check disk write protection if needed */ | ||||
| 		return FR_WRITE_PROTECTED; | ||||
| #endif | ||||
| 	/* Search FAT partition on the drive. Supports only generic partitionings, FDISK and SFD. */ | ||||
| 	fmt = check_fs(fs, bsect = 0);		/* Check sector 0 if it is a VBR */ | ||||
| 	if (fmt == 1) {						/* Not an FAT-VBR, the disk may be partitioned */ | ||||
| 		/* Check the partition listed in top of the partition table */ | ||||
| 		tbl = &fs->win[MBR_Table + LD2PT(vol) * SZ_PTE];/* Partition table */ | ||||
| 		if (tbl[4]) {									/* Is the partition existing? */ | ||||
| 			bsect = LD_DWORD(&tbl[8]);					/* Partition offset in LBA */ | ||||
| 			fmt = check_fs(fs, bsect);					/* Check the partition */ | ||||
| 	fmt = check_fs(fs, bsect = 0);		/* Load sector 0 and check if it is an FAT-VBR (in SFD) */ | ||||
| 	if (LD2PT(vol) && !fmt) fmt = 1;	/* Force non-SFD if the volume is forced partition */ | ||||
| 	if (fmt == 1) {						/* Not an FAT-VBR, the physical drive can be partitioned */ | ||||
| 		/* Check the partition listed in the partition table */ | ||||
| 		pi = LD2PT(vol); | ||||
| 		if (pi) pi--; | ||||
| 		tbl = &fs->win[MBR_Table + pi * SZ_PTE];/* Partition table */ | ||||
| 		if (tbl[4]) {						/* Is the partition existing? */ | ||||
| 			bsect = LD_DWORD(&tbl[8]);		/* Partition offset in LBA */ | ||||
| 			fmt = check_fs(fs, bsect);		/* Check the partition */ | ||||
| 		} | ||||
| 	} | ||||
| 	if (fmt == 3) return FR_DISK_ERR; | ||||
| 	if (fmt) return FR_NO_FILESYSTEM;					/* No FAT volume is found */ | ||||
| 	if (fmt) return FR_NO_FILESYSTEM;		/* No FAT volume is found */ | ||||
| 
 | ||||
| 	/* Following code initializes the file system object */ | ||||
| 	/* An FAT volume is found. Following code initializes the file system object */ | ||||
| 
 | ||||
| 	if (LD_WORD(fs->win+BPB_BytsPerSec) != SS(fs))		/* (BPB_BytsPerSec must be equal to the physical sector size) */ | ||||
| 		return FR_NO_FILESYSTEM; | ||||
| @ -2202,27 +2208,27 @@ FRESULT f_mount ( | ||||
| 	FATFS *rfs; | ||||
| 
 | ||||
| 
 | ||||
| 	if (vol >= _VOLUMES)			/* Check if the drive number is valid */ | ||||
| 	if (vol >= _VOLUMES)		/* Check if the drive number is valid */ | ||||
| 		return FR_INVALID_DRIVE; | ||||
| 	rfs = FatFs[vol];				/* Get current fs object */ | ||||
| 	rfs = FatFs[vol];			/* Get current fs object */ | ||||
| 
 | ||||
| 	if (rfs) { | ||||
| #if _FS_SHARE | ||||
| 		clear_lock(rfs); | ||||
| #endif | ||||
| #if _FS_REENTRANT					/* Discard sync object of the current volume */ | ||||
| #if _FS_REENTRANT				/* Discard sync object of the current volume */ | ||||
| 		if (!ff_del_syncobj(rfs->sobj)) return FR_INT_ERR; | ||||
| #endif | ||||
| 		rfs->fs_type = 0;			/* Clear old fs object */ | ||||
| 		rfs->fs_type = 0;		/* Clear old fs object */ | ||||
| 	} | ||||
| 
 | ||||
| 	if (fs) { | ||||
| 		fs->fs_type = 0;			/* Clear new fs object */ | ||||
| #if _FS_REENTRANT					/* Create sync object for the new volume */ | ||||
| 		fs->fs_type = 0;		/* Clear new fs object */ | ||||
| #if _FS_REENTRANT				/* Create sync object for the new volume */ | ||||
| 		if (!ff_cre_syncobj(vol, &fs->sobj)) return FR_INT_ERR; | ||||
| #endif | ||||
| 	} | ||||
| 	FatFs[vol] = fs;				/* Register new fs object */ | ||||
| 	FatFs[vol] = fs;			/* Register new fs object */ | ||||
| 
 | ||||
| 	return FR_OK; | ||||
| } | ||||
| @ -2276,7 +2282,7 @@ FRESULT f_open ( | ||||
| 		if (res != FR_OK) {					/* No file, create new */ | ||||
| 			if (res == FR_NO_FILE)			/* There is no file to open, create a new entry */ | ||||
| #if _FS_SHARE | ||||
| 				res = enq_lock(dj.fs) ? dir_register(&dj) : FR_TOO_MANY_OPEN_FILES; | ||||
| 				res = enq_lock() ? dir_register(&dj) : FR_TOO_MANY_OPEN_FILES; | ||||
| #else | ||||
| 				res = dir_register(&dj); | ||||
| #endif | ||||
| @ -3555,10 +3561,10 @@ FRESULT f_mkfs ( | ||||
| { | ||||
| 	static const WORD vst[] = { 1024,   512,  256,  128,   64,    32,   16,    8,    4,    2,   0}; | ||||
| 	static const WORD cst[] = {32768, 16384, 8192, 4096, 2048, 16384, 8192, 4096, 2048, 1024, 512}; | ||||
| 	BYTE fmt, md, *tbl; | ||||
| 	BYTE fmt, md, sys, *tbl, pdrv, part; | ||||
| 	DWORD n_clst, vs, n, wsect; | ||||
| 	UINT i; | ||||
| 	DWORD b_vol, b_fat, b_dir, b_data;	/* Offset (LBA) */ | ||||
| 	DWORD b_vol, b_fat, b_dir, b_data;	/* LBA */ | ||||
| 	DWORD n_vol, n_rsv, n_fat, n_dir;	/* Size */ | ||||
| 	FATFS *fs; | ||||
| 	DSTATUS stat; | ||||
| @ -3566,25 +3572,39 @@ FRESULT f_mkfs ( | ||||
| 
 | ||||
| 	/* Check mounted drive and clear work area */ | ||||
| 	if (drv >= _VOLUMES) return FR_INVALID_DRIVE; | ||||
| 	if (sfd > 1) return FR_INVALID_PARAMETER; | ||||
| 	if (au & (au - 1)) return FR_INVALID_PARAMETER; | ||||
| 	fs = FatFs[drv]; | ||||
| 	if (!fs) return FR_NOT_ENABLED; | ||||
| 	fs->fs_type = 0; | ||||
| 	drv = LD2PD(drv); | ||||
| 	pdrv = LD2PD(drv);	/* Physical drive */ | ||||
| 	part = LD2PT(drv);	/* Partition (0:auto detect, 1-4:get from partition table)*/ | ||||
| 
 | ||||
| 	/* Get disk statics */ | ||||
| 	stat = disk_initialize(drv); | ||||
| 	stat = disk_initialize(pdrv); | ||||
| 	if (stat & STA_NOINIT) return FR_NOT_READY; | ||||
| 	if (stat & STA_PROTECT) return FR_WRITE_PROTECTED; | ||||
| #if _MAX_SS != 512					/* Get disk sector size */ | ||||
| 	if (disk_ioctl(drv, GET_SECTOR_SIZE, &SS(fs)) != RES_OK) | ||||
| 	if (disk_ioctl(pdrv, GET_SECTOR_SIZE, &SS(fs)) != RES_OK || SS(fs) > _MAX_SS) | ||||
| 		return FR_DISK_ERR; | ||||
| #endif | ||||
| 	if (disk_ioctl(drv, GET_SECTOR_COUNT, &n_vol) != RES_OK || n_vol < 128) | ||||
| 		return FR_DISK_ERR; | ||||
| 	b_vol = (sfd) ? 0 : 63;	/* Volume start sector */ | ||||
| 	n_vol -= b_vol; | ||||
| 	if (au & (au - 1)) au = 0;	/* Check validity of the AU size */ | ||||
| 	if (!au) {					/* AU auto selection */ | ||||
| 	if (_MULTI_PARTITION && part) { | ||||
| 		/* Get partition information from partition table in the MBR */ | ||||
| 		if (disk_read(pdrv, fs->win, 0, 1) != RES_OK) return FR_DISK_ERR; | ||||
| 		if (LD_WORD(fs->win+BS_55AA) != 0xAA55) return FR_MKFS_ABORTED; | ||||
| 		tbl = &fs->win[MBR_Table + (part - 1) * SZ_PTE]; | ||||
| 		if (!tbl[4]) return FR_MKFS_ABORTED;	/* No partition? */ | ||||
| 		b_vol = LD_DWORD(tbl+8);	/* Volume start sector */ | ||||
| 		n_vol = LD_DWORD(tbl+12);	/* Volume size */ | ||||
| 	} else { | ||||
| 		/* Create a partition in this function */ | ||||
| 		if (disk_ioctl(pdrv, GET_SECTOR_COUNT, &n_vol) != RES_OK || n_vol < 128) | ||||
| 			return FR_DISK_ERR; | ||||
| 		b_vol = (sfd) ? 0 : 63;		/* Volume start sector */ | ||||
| 		n_vol -= b_vol;				/* Volume size */ | ||||
| 	} | ||||
| 
 | ||||
| 	if (!au) {				/* AU auto selection */ | ||||
| 		vs = n_vol / (2000 / (SS(fs) / 512)); | ||||
| 		for (i = 0; vs < vst[i]; i++) ; | ||||
| 		au = cst[i]; | ||||
| @ -3613,10 +3633,10 @@ FRESULT f_mkfs ( | ||||
| 	b_fat = b_vol + n_rsv;				/* FAT area start sector */ | ||||
| 	b_dir = b_fat + n_fat * N_FATS;		/* Directory area start sector */ | ||||
| 	b_data = b_dir + n_dir;				/* Data area start sector */ | ||||
| 	if (n_vol < b_data + au) return FR_MKFS_ABORTED;	/* Too small volume */ | ||||
| 	if (n_vol < b_data + au - b_vol) return FR_MKFS_ABORTED;	/* Too small volume */ | ||||
| 
 | ||||
| 	/* Align data start sector to erase block boundary (for flash memory media) */ | ||||
| 	if (disk_ioctl(drv, GET_BLOCK_SIZE, &n) != RES_OK || !n || n > 32768) n = 1; | ||||
| 	if (disk_ioctl(pdrv, GET_BLOCK_SIZE, &n) != RES_OK || !n || n > 32768) n = 1; | ||||
| 	n = (b_data + n - 1) & ~(n - 1);	/* Next nearest erase block from current data start */ | ||||
| 	n = (n - b_data) / N_FATS; | ||||
| 	if (fmt == FS_FAT32) {		/* FAT32: Move FAT offset */ | ||||
| @ -3632,36 +3652,42 @@ FRESULT f_mkfs ( | ||||
| 		|| (fmt == FS_FAT32 && n_clst < MIN_FAT32)) | ||||
| 		return FR_MKFS_ABORTED; | ||||
| 
 | ||||
| 	/* Create partition table if required */ | ||||
| 	if (sfd) {	/* No patition table (SFD) */ | ||||
| 		md = 0xF0; | ||||
| 	} else {	/* With patition table (FDISK) */ | ||||
| 		DWORD n_disk = b_vol + n_vol; | ||||
| 
 | ||||
| 		mem_set(fs->win, 0, SS(fs)); | ||||
| 		tbl = fs->win+MBR_Table; | ||||
| 		ST_DWORD(tbl, 0x00010180);			/* Partition start in CHS */ | ||||
| 		if (n_disk < 63UL * 255 * 1024) {	/* Partition end in CHS */ | ||||
| 			n_disk = n_disk / 63 / 255; | ||||
| 			tbl[7] = (BYTE)n_disk; | ||||
| 			tbl[6] = (BYTE)((n_disk >> 2) | 63); | ||||
| 		} else { | ||||
| 			ST_WORD(&tbl[6], 0xFFFF);	/* CHS saturated */ | ||||
| 		} | ||||
| 		tbl[5] = 254; | ||||
| 		if (fmt != FS_FAT32)				/* System ID */ | ||||
| 			tbl[4] = (n_vol < 0x10000) ? 0x04 : 0x06; | ||||
| 		else | ||||
| 			tbl[4] = 0x0c; | ||||
| 		ST_DWORD(tbl+8, 63);				/* Partition start in LBA */ | ||||
| 		ST_DWORD(tbl+12, n_vol);			/* Partition size in LBA */ | ||||
| 		ST_WORD(fs->win+BS_55AA, 0xAA55);	/* MBR signature */ | ||||
| 		if (disk_write(drv, fs->win, 0, 1) != RES_OK)	/* Put the MBR into first physical sector */ | ||||
| 			return FR_DISK_ERR; | ||||
| 		md = 0xF8; | ||||
| 	switch (fmt) {	/* Determine system ID for partition table */ | ||||
| 	case FS_FAT12:	sys = 0x01; break; | ||||
| 	case FS_FAT16:	sys = (n_vol < 0x10000) ? 0x04 : 0x06; break; | ||||
| 	default: 		sys = 0x0C; | ||||
| 	} | ||||
| 
 | ||||
| 	/* Create volume boot record */ | ||||
| 	if (_MULTI_PARTITION && part) { | ||||
| 		/* Update system ID in the partition table */ | ||||
| 		tbl = &fs->win[MBR_Table + (part - 1) * SZ_PTE]; | ||||
| 		tbl[4] = sys; | ||||
| 		if (disk_write(pdrv, fs->win, 0, 1) != RES_OK) return FR_DISK_ERR; | ||||
| 		md = 0xF8; | ||||
| 	} else { | ||||
| 		if (sfd) {	/* No patition table (SFD) */ | ||||
| 			md = 0xF0; | ||||
| 		} else {	/* Create partition table (FDISK) */ | ||||
| 			mem_set(fs->win, 0, SS(fs)); | ||||
| 			tbl = fs->win+MBR_Table;	/* Create partiton table for single partition in the drive */ | ||||
| 			tbl[1] = 1;						/* Partition start head */ | ||||
| 			tbl[2] = 1;						/* Partition start sector */ | ||||
| 			tbl[3] = 0;						/* Partition start cylinder */ | ||||
| 			tbl[4] = sys;					/* System type */ | ||||
| 			tbl[5] = 254;					/* Partition end head */ | ||||
| 			n = (b_vol + n_vol) / 63 / 255; | ||||
| 			tbl[6] = (BYTE)((n >> 2) | 63);	/* Partiiton end sector */ | ||||
| 			tbl[7] = (BYTE)n;				/* End cylinder */ | ||||
| 			ST_DWORD(tbl+8, 63);			/* Partition start in LBA */ | ||||
| 			ST_DWORD(tbl+12, n_vol);		/* Partition size in LBA */ | ||||
| 			ST_WORD(fs->win+BS_55AA, 0xAA55);	/* MBR signature */ | ||||
| 			if (disk_write(pdrv, fs->win, 0, 1) != RES_OK)	/* Write it to the MBR sector */ | ||||
| 				return FR_DISK_ERR; | ||||
| 			md = 0xF8; | ||||
| 		} | ||||
| 	} | ||||
| 
 | ||||
| 	/* Create BPB in the VBR */ | ||||
| 	tbl = fs->win;							/* Clear sector */ | ||||
| 	mem_set(tbl, 0, SS(fs)); | ||||
| 	mem_cpy(tbl, "\xEB\xFE\x90" "MSDOS5.0", 11);/* Boot jump code, OEM name */ | ||||
| @ -3699,10 +3725,10 @@ FRESULT f_mkfs ( | ||||
| 		mem_cpy(tbl+BS_VolLab, "NO NAME    " "FAT     ", 19);	/* Volume label, FAT signature */ | ||||
| 	} | ||||
| 	ST_WORD(tbl+BS_55AA, 0xAA55);			/* Signature (Offset is fixed here regardless of sector size) */ | ||||
| 	if (disk_write(drv, tbl, b_vol, 1) != RES_OK)	/* Write VBR */ | ||||
| 	if (disk_write(pdrv, tbl, b_vol, 1) != RES_OK)	/* Write it to the VBR sector */ | ||||
| 		return FR_DISK_ERR; | ||||
| 	if (fmt == FS_FAT32)							/* Write backup VBR if needed (VBR+6) */ | ||||
| 		disk_write(drv, tbl, b_vol + 6, 1); | ||||
| 		disk_write(pdrv, tbl, b_vol + 6, 1); | ||||
| 
 | ||||
| 	/* Initialize FAT area */ | ||||
| 	wsect = b_fat; | ||||
| @ -3718,11 +3744,11 @@ FRESULT f_mkfs ( | ||||
| 			ST_DWORD(tbl+4, 0xFFFFFFFF); | ||||
| 			ST_DWORD(tbl+8, 0x0FFFFFFF);	/* Reserve cluster #2 for root dir */ | ||||
| 		} | ||||
| 		if (disk_write(drv, tbl, wsect++, 1) != RES_OK) | ||||
| 		if (disk_write(pdrv, tbl, wsect++, 1) != RES_OK) | ||||
| 			return FR_DISK_ERR; | ||||
| 		mem_set(tbl, 0, SS(fs));			/* Fill following FAT entries with zero */ | ||||
| 		for (n = 1; n < n_fat; n++) {		/* This loop may take a time on FAT32 volume due to many single sector writes */ | ||||
| 			if (disk_write(drv, tbl, wsect++, 1) != RES_OK) | ||||
| 			if (disk_write(pdrv, tbl, wsect++, 1) != RES_OK) | ||||
| 				return FR_DISK_ERR; | ||||
| 		} | ||||
| 	} | ||||
| @ -3730,7 +3756,7 @@ FRESULT f_mkfs ( | ||||
| 	/* Initialize root directory */ | ||||
| 	i = (fmt == FS_FAT32) ? au : n_dir; | ||||
| 	do { | ||||
| 		if (disk_write(drv, tbl, wsect++, 1) != RES_OK) | ||||
| 		if (disk_write(pdrv, tbl, wsect++, 1) != RES_OK) | ||||
| 			return FR_DISK_ERR; | ||||
| 	} while (--i); | ||||
| 
 | ||||
| @ -3739,7 +3765,7 @@ FRESULT f_mkfs ( | ||||
| 		DWORD eb[2]; | ||||
| 
 | ||||
| 		eb[0] = wsect; eb[1] = wsect + (n_clst - ((fmt == FS_FAT32) ? 1 : 0)) * au - 1; | ||||
| 		disk_ioctl(drv, CTRL_ERASE_SECTOR, eb); | ||||
| 		disk_ioctl(pdrv, CTRL_ERASE_SECTOR, eb); | ||||
| 	} | ||||
| #endif | ||||
| 
 | ||||
| @ -3750,13 +3776,82 @@ FRESULT f_mkfs ( | ||||
| 		ST_DWORD(tbl+FSI_Free_Count, n_clst - 1);	/* Number of free clusters */ | ||||
| 		ST_DWORD(tbl+FSI_Nxt_Free, 2);				/* Last allocated cluster# */ | ||||
| 		ST_WORD(tbl+BS_55AA, 0xAA55); | ||||
| 		disk_write(drv, tbl, b_vol + 1, 1);	/* Write original (VBR+1) */ | ||||
| 		disk_write(drv, tbl, b_vol + 7, 1);	/* Write backup (VBR+7) */ | ||||
| 		disk_write(pdrv, tbl, b_vol + 1, 1);	/* Write original (VBR+1) */ | ||||
| 		disk_write(pdrv, tbl, b_vol + 7, 1);	/* Write backup (VBR+7) */ | ||||
| 	} | ||||
| 
 | ||||
| 	return (disk_ioctl(drv, CTRL_SYNC, (void*)0) == RES_OK) ? FR_OK : FR_DISK_ERR; | ||||
| 	return (disk_ioctl(pdrv, CTRL_SYNC, 0) == RES_OK) ? FR_OK : FR_DISK_ERR; | ||||
| } | ||||
| 
 | ||||
| 
 | ||||
| #if _MULTI_PARTITION == 2 | ||||
| /*-----------------------------------------------------------------------*/ | ||||
| /* Divide Physical Drive                                                 */ | ||||
| /*-----------------------------------------------------------------------*/ | ||||
| 
 | ||||
| FRESULT f_fdisk ( | ||||
| 	BYTE pdrv,			/* Physical drive number */ | ||||
| 	const DWORD szt[],	/* Pointer to the size table for each partitions */ | ||||
| 	void* work			/* Pointer to the working buffer */ | ||||
| ) | ||||
| { | ||||
| 	UINT i, n, sz_cyl, tot_cyl, b_cyl, e_cyl, p_cyl; | ||||
| 	BYTE s_hd, e_hd, *p, *buf = (BYTE*)work; | ||||
| 	DSTATUS stat; | ||||
| 	DWORD sz_disk, sz_part, s_part; | ||||
| 
 | ||||
| 
 | ||||
| 	stat = disk_initialize(pdrv); | ||||
| 	if (stat & STA_NOINIT) return FR_NOT_READY; | ||||
| 	if (stat & STA_PROTECT) return FR_WRITE_PROTECTED; | ||||
| 	if (disk_ioctl(pdrv, GET_SECTOR_COUNT, &sz_disk)) return FR_DISK_ERR; | ||||
| 
 | ||||
| 	/* Determine CHS in the table regardless of the drive geometry */ | ||||
| 	for (n = 16; n < 256 && sz_disk / n / 63 > 1024; n *= 2) ; | ||||
| 	if (n == 256) n--; | ||||
| 	e_hd = n - 1; | ||||
| 	sz_cyl = 63 * n; | ||||
| 	tot_cyl = sz_disk / sz_cyl; | ||||
| 
 | ||||
| 	/* Create partition table */ | ||||
| 	mem_set(buf, 0, _MAX_SS); | ||||
| 	p = buf + MBR_Table; b_cyl = 0; | ||||
| 	for (i = 0; i < 4; i++, p += SZ_PTE) { | ||||
| 		p_cyl = (szt[i] <= 100) ? (DWORD)tot_cyl * szt[i] / 100 : szt[i] / sz_cyl; | ||||
| 		if (!p_cyl) continue; | ||||
| 		s_part = (DWORD)sz_cyl * b_cyl; | ||||
| 		sz_part = (DWORD)sz_cyl * p_cyl; | ||||
| 		if (i == 0) {	/* Exclude first track of cylinder 0 */ | ||||
| 			s_hd = 1; | ||||
| 			s_part += 63; sz_part -= 63; | ||||
| 		} else { | ||||
| 			s_hd = 0; | ||||
| 		} | ||||
| 		e_cyl = b_cyl + p_cyl - 1; | ||||
| 		if (e_cyl >= tot_cyl) return FR_INVALID_PARAMETER; | ||||
| 
 | ||||
| 		/* Set partition table */ | ||||
| 		p[1] = s_hd;						/* Start head */ | ||||
| 		p[2] = (BYTE)((b_cyl >> 2) + 1);	/* Start sector */ | ||||
| 		p[3] = (BYTE)b_cyl;					/* Start cylinder */ | ||||
| 		p[4] = 0x06;						/* System type (temporary setting) */ | ||||
| 		p[5] = e_hd;						/* End head */ | ||||
| 		p[6] = (BYTE)((e_cyl >> 2) + 63);	/* End sector */ | ||||
| 		p[7] = (BYTE)e_cyl;					/* End cylinder */ | ||||
| 		ST_DWORD(p + 8, s_part);			/* Start sector in LBA */ | ||||
| 		ST_DWORD(p + 12, sz_part);			/* Partition size */ | ||||
| 
 | ||||
| 		/* Next partition */ | ||||
| 		b_cyl += p_cyl; | ||||
| 	} | ||||
| 	ST_WORD(p, 0xAA55); | ||||
| 
 | ||||
| 	/* Write it to the MBR */ | ||||
| 	return (disk_write(pdrv, buf, 0, 1) || disk_ioctl(pdrv, CTRL_SYNC, 0)) ? FR_DISK_ERR : FR_OK; | ||||
| } | ||||
| 
 | ||||
| 
 | ||||
| #endif /* _MULTI_PARTITION == 2 */ | ||||
| #endif /* _USE_MKFS && !_FS_READONLY */ | ||||
| 
 | ||||
| 
 | ||||
| @ -3894,7 +3989,7 @@ int f_printf ( | ||||
| 	UINT i, j, w; | ||||
| 	ULONG v; | ||||
| 	TCHAR c, d, s[16], *p; | ||||
| 	int res, cc; | ||||
| 	int res, chc, cc; | ||||
| 
 | ||||
| 
 | ||||
| 	va_start(arp, str); | ||||
| @ -3930,11 +4025,13 @@ int f_printf ( | ||||
| 		case 'S' :					/* String */ | ||||
| 			p = va_arg(arp, TCHAR*); | ||||
| 			for (j = 0; p[j]; j++) ; | ||||
| 			res = 0; | ||||
| 			while (!(f & 2) && j++ < w) res += (cc = f_putc(' ', fil)); | ||||
| 			res += (cc = f_puts(p, fil)); | ||||
| 			while (j++ < w) res += (cc = f_putc(' ', fil)); | ||||
| 			if (cc != EOF) cc = res; | ||||
| 			chc = 0; | ||||
| 			if (!(f & 2)) { | ||||
| 				while (j++ < w) chc += (cc = f_putc(' ', fil)); | ||||
| 			} | ||||
| 			chc += (cc = f_puts(p, fil)); | ||||
| 			while (j++ < w) chc += (cc = f_putc(' ', fil)); | ||||
| 			if (cc != EOF) cc = chc; | ||||
| 			continue; | ||||
| 		case 'C' :					/* Character */ | ||||
| 			cc = f_putc((TCHAR)va_arg(arp, int), fil); continue; | ||||
| @ -3952,7 +4049,7 @@ int f_printf ( | ||||
| 		} | ||||
| 
 | ||||
| 		/* Get an argument and put it in numeral */ | ||||
| 		v = (f & 4) ? va_arg(arp, long) : ((d == 'D') ? (long)va_arg(arp, int) : va_arg(arp, unsigned int)); | ||||
| 		v = (f & 4) ? (ULONG)va_arg(arp, long) : ((d == 'D') ? (ULONG)(long)va_arg(arp, int) : (ULONG)va_arg(arp, unsigned int)); | ||||
| 		if (d == 'D' && (v & 0x80000000)) { | ||||
| 			v = 0 - v; | ||||
| 			f |= 8; | ||||
|  | ||||
							
								
								
									
										40
									
								
								src/ff.h
									
									
									
									
									
								
							
							
						
						
									
										40
									
								
								src/ff.h
									
									
									
									
									
								
							| @ -1,5 +1,5 @@ | ||||
| /*---------------------------------------------------------------------------/
 | ||||
| /  FatFs - FAT file system module include file  R0.08b    (C)ChaN, 2011 | ||||
| /  FatFs - FAT file system module include file  R0.09     (C)ChaN, 2011 | ||||
| /----------------------------------------------------------------------------/ | ||||
| / FatFs module is a generic FAT file system module for small embedded systems. | ||||
| / This is a free software that opened for education, research and commercial | ||||
| @ -15,7 +15,7 @@ | ||||
| /----------------------------------------------------------------------------*/ | ||||
| 
 | ||||
| #ifndef _FATFS | ||||
| #define _FATFS	8237	/* Revision ID */ | ||||
| #define _FATFS	6502	/* Revision ID */ | ||||
| 
 | ||||
| #ifdef __cplusplus | ||||
| extern "C" { | ||||
| @ -33,17 +33,17 @@ extern "C" { | ||||
| /* Definitions of volume management */ | ||||
| 
 | ||||
| #if _MULTI_PARTITION		/* Multiple partition configuration */ | ||||
| #define LD2PD(vol) (VolToPart[vol].pd)	/* Get physical drive# */ | ||||
| #define LD2PT(vol) (VolToPart[vol].pt)	/* Get partition# */ | ||||
| typedef struct { | ||||
| 	BYTE pd;	/* Physical drive# */ | ||||
| 	BYTE pt;	/* Partition # (0-3) */ | ||||
| 	BYTE pd;	/* Physical drive number */ | ||||
| 	BYTE pt;	/* Partition: 0:Auto detect, 1-4:Forced partition) */ | ||||
| } PARTITION; | ||||
| extern const PARTITION VolToPart[];	/* Volume - Physical location resolution table */ | ||||
| extern PARTITION VolToPart[];	/* Volume - Partition resolution table */ | ||||
| #define LD2PD(vol) (VolToPart[vol].pd)	/* Get physical drive number */ | ||||
| #define LD2PT(vol) (VolToPart[vol].pt)	/* Get partition index */ | ||||
| 
 | ||||
| #else						/* Single partition configuration */ | ||||
| #define LD2PD(vol) (vol)	/* Logical drive# is bound to the same physical drive# */ | ||||
| #define LD2PT(vol) 0		/* Always mounts the 1st partition */ | ||||
| #define LD2PD(vol) (vol)	/* Each logical drive is bound to the same physical drive number */ | ||||
| #define LD2PT(vol) 0		/* Always mounts the 1st partition or in SFD */ | ||||
| 
 | ||||
| #endif | ||||
| 
 | ||||
| @ -84,7 +84,7 @@ typedef struct { | ||||
| 	WORD	id;				/* File system mount ID */ | ||||
| 	WORD	n_rootdir;		/* Number of root directory entries (FAT12/16) */ | ||||
| #if _MAX_SS != 512 | ||||
| 	WORD	ssize;			/* Bytes per sector (512,1024,2048,4096) */ | ||||
| 	WORD	ssize;			/* Bytes per sector (512, 1024, 2048 or 4096) */ | ||||
| #endif | ||||
| #if _FS_REENTRANT | ||||
| 	_SYNC_t	sobj;			/* Identifier of sync object */ | ||||
| @ -188,12 +188,13 @@ typedef enum { | ||||
| 	FR_WRITE_PROTECTED,		/* (10) The physical drive is write protected */ | ||||
| 	FR_INVALID_DRIVE,		/* (11) The logical drive number is invalid */ | ||||
| 	FR_NOT_ENABLED,			/* (12) The volume has no work area */ | ||||
| 	FR_NO_FILESYSTEM,		/* (13) There is no valid FAT volume on the physical drive */ | ||||
| 	FR_NO_FILESYSTEM,		/* (13) There is no valid FAT volume */ | ||||
| 	FR_MKFS_ABORTED,		/* (14) The f_mkfs() aborted due to any parameter error */ | ||||
| 	FR_TIMEOUT,				/* (15) Could not get a grant to access the volume within defined period */ | ||||
| 	FR_LOCKED,				/* (16) The operation is rejected according to the file shareing policy */ | ||||
| 	FR_NOT_ENOUGH_CORE,		/* (17) LFN working buffer could not be allocated */ | ||||
| 	FR_TOO_MANY_OPEN_FILES	/* (18) Number of open files > _FS_SHARE */ | ||||
| 	FR_TOO_MANY_OPEN_FILES,	/* (18) Number of open files > _FS_SHARE */ | ||||
| 	FR_INVALID_PARAMETER	/* (19) Given parameter is invalid */ | ||||
| } FRESULT; | ||||
| 
 | ||||
| 
 | ||||
| @ -218,25 +219,26 @@ FRESULT	f_mkdir (const TCHAR*);						/* Create a new directory */ | ||||
| FRESULT f_chmod (const TCHAR*, BYTE, BYTE);			/* Change attriburte of the file/dir */ | ||||
| FRESULT f_utime (const TCHAR*, const FILINFO*);		/* Change timestamp of the file/dir */ | ||||
| FRESULT f_rename (const TCHAR*, const TCHAR*);		/* Rename/Move a file or directory */ | ||||
| FRESULT f_forward (FIL*, UINT(*)(const BYTE*,UINT), UINT, UINT*);	/* Forward data to the stream */ | ||||
| FRESULT f_mkfs (BYTE, BYTE, UINT);					/* Create a file system on the drive */ | ||||
| FRESULT f_chdrive (BYTE);							/* Change current drive */ | ||||
| FRESULT f_chdir (const TCHAR*);						/* Change current directory */ | ||||
| FRESULT f_getcwd (TCHAR*, UINT);					/* Get current directory */ | ||||
| FRESULT f_forward (FIL*, UINT(*)(const BYTE*,UINT), UINT, UINT*);	/* Forward data to the stream */ | ||||
| FRESULT f_mkfs (BYTE, BYTE, UINT);					/* Create a file system on the drive */ | ||||
| FRESULT	f_fdisk (BYTE, const DWORD[], void*);		/* Divide a physical drive into some partitions */ | ||||
| int f_putc (TCHAR, FIL*);							/* Put a character to the file */ | ||||
| int f_puts (const TCHAR*, FIL*);					/* Put a string to the file */ | ||||
| int f_printf (FIL*, const TCHAR*, ...);				/* Put a formatted string to the file */ | ||||
| TCHAR* f_gets (TCHAR*, int, FIL*);					/* Get a string from the file */ | ||||
| 
 | ||||
| #ifndef EOF | ||||
| #define EOF (-1) | ||||
| #endif | ||||
| 
 | ||||
| #define f_eof(fp) (((fp)->fptr == (fp)->fsize) ? 1 : 0) | ||||
| #define f_error(fp) (((fp)->flag & FA__ERROR) ? 1 : 0) | ||||
| #define f_tell(fp) ((fp)->fptr) | ||||
| #define f_size(fp) ((fp)->fsize) | ||||
| 
 | ||||
| #ifndef EOF | ||||
| #define EOF (-1) | ||||
| #endif | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| @ -308,7 +310,7 @@ int ff_del_syncobj (_SYNC_t);		/* Delete a sync object */ | ||||
| #define AM_MASK	0x3F	/* Mask of defined bits */ | ||||
| 
 | ||||
| 
 | ||||
| /* Fast seek function */ | ||||
| /* Fast seek feature */ | ||||
| #define CREATE_LINKMAP	0xFFFFFFFF | ||||
| 
 | ||||
| 
 | ||||
|  | ||||
							
								
								
									
										13
									
								
								src/ffconf.h
									
									
									
									
									
								
							
							
						
						
									
										13
									
								
								src/ffconf.h
									
									
									
									
									
								
							| @ -1,5 +1,5 @@ | ||||
| /*---------------------------------------------------------------------------/
 | ||||
| /  FatFs - FAT file system module configuration file  R0.08b (C)ChaN, 2011 | ||||
| /  FatFs - FAT file system module configuration file  R0.09  (C)ChaN, 2011 | ||||
| /----------------------------------------------------------------------------/ | ||||
| / | ||||
| / CAUTION! Do not forget to make clean the project after any changes to | ||||
| @ -7,11 +7,11 @@ | ||||
| / | ||||
| /----------------------------------------------------------------------------*/ | ||||
| #ifndef _FFCONF | ||||
| #define _FFCONF 8237	/* Revision ID */ | ||||
| #define _FFCONF 6502	/* Revision ID */ | ||||
| 
 | ||||
| 
 | ||||
| /*---------------------------------------------------------------------------/
 | ||||
| / Function and Buffer Configurations | ||||
| / Functions and Buffer Configurations | ||||
| /----------------------------------------------------------------------------*/ | ||||
| 
 | ||||
| #define	_FS_TINY		0	/* 0:Normal or 1:Tiny */ | ||||
| @ -36,7 +36,7 @@ | ||||
| /   3: f_lseek is removed in addition to 2. */ | ||||
| 
 | ||||
| 
 | ||||
| #define	_USE_STRFUNC	0	/* 0:Disable or 1/2:Enable */ | ||||
| #define	_USE_STRFUNC	0	/* 0:Disable or 1-2:Enable */ | ||||
| /* To enable string functions, set _USE_STRFUNC to 1 or 2. */ | ||||
| 
 | ||||
| 
 | ||||
| @ -137,7 +137,7 @@ | ||||
| /  and GET_SECTOR_SIZE command must be implememted to the disk_ioctl function. */ | ||||
| 
 | ||||
| 
 | ||||
| #define	_MULTI_PARTITION	0	/* 0:Single partition or 1:Multiple partition */ | ||||
| #define	_MULTI_PARTITION	0	/* 0:Single partition, 1/2:Enable multiple partition */ | ||||
| /* When set to 0, each volume is bound to the same physical drive number and
 | ||||
| / it can mount only first primaly partition. When it is set to 1, each volume | ||||
| / is tied to the partitions listed in VolToPart[]. */ | ||||
| @ -163,7 +163,8 @@ | ||||
| /  When the byte order on the memory is big-endian or address miss-aligned word | ||||
| /  access results incorrect behavior, the _WORD_ACCESS must be set to 0. | ||||
| /  If it is not the case, the value can also be set to 1 to improve the | ||||
| /  performance and code size. */ | ||||
| /  performance and code size. | ||||
| */ | ||||
| 
 | ||||
| 
 | ||||
| /* A header file that defines sync object types on the O/S, such as
 | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user