mirror of
https://github.com/eried/portapack-mayhem.git
synced 2024-10-01 01:26:06 -04:00
FatFs: Update to release R0.12b.
This commit is contained in:
parent
dd0048db8d
commit
85712a2c5f
@ -5,7 +5,7 @@
|
|||||||
/ FatFs - FAT file system module configuration file
|
/ FatFs - FAT file system module configuration file
|
||||||
/---------------------------------------------------------------------------*/
|
/---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
#define _FFCONF 80186 /* Revision ID */
|
#define _FFCONF 68020 /* Revision ID */
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------/
|
/*---------------------------------------------------------------------------/
|
||||||
/ Function Configurations
|
/ Function Configurations
|
||||||
@ -207,14 +207,14 @@
|
|||||||
|
|
||||||
#define _FS_TINY 0
|
#define _FS_TINY 0
|
||||||
/* This option switches tiny buffer configuration. (0:Normal or 1:Tiny)
|
/* This option switches tiny buffer configuration. (0:Normal or 1:Tiny)
|
||||||
/ At the tiny configuration, size of the file object (FIL) is reduced _MAX_SS bytes.
|
/ At the tiny configuration, size of file object (FIL) is reduced _MAX_SS bytes.
|
||||||
/ Instead of private sector buffer eliminated from the file object, common sector
|
/ Instead of private sector buffer eliminated from the file object, common sector
|
||||||
/ buffer in the file system object (FATFS) is used for the file data transfer. */
|
/ buffer in the file system object (FATFS) is used for the file data transfer. */
|
||||||
|
|
||||||
|
|
||||||
#define _FS_EXFAT 0
|
#define _FS_EXFAT 0
|
||||||
/* This option switches support of exFAT file system in addition to the traditional
|
/* This option switches support of exFAT file system. (0:Disable or 1:Enable)
|
||||||
/ FAT file system. (0:Disable or 1:Enable) To enable exFAT, also LFN must be enabled.
|
/ When enable exFAT, also LFN needs to be enabled. (_USE_LFN >= 1)
|
||||||
/ Note that enabling exFAT discards C89 compatibility. */
|
/ Note that enabling exFAT discards C89 compatibility. */
|
||||||
|
|
||||||
|
|
||||||
@ -262,7 +262,9 @@
|
|||||||
/ The _FS_TIMEOUT defines timeout period in unit of time tick.
|
/ The _FS_TIMEOUT defines timeout period in unit of time tick.
|
||||||
/ The _SYNC_t defines O/S dependent sync object type. e.g. HANDLE, ID, OS_EVENT*,
|
/ The _SYNC_t defines O/S dependent sync object type. e.g. HANDLE, ID, OS_EVENT*,
|
||||||
/ SemaphoreHandle_t and etc.. A header file for O/S definitions needs to be
|
/ SemaphoreHandle_t and etc.. A header file for O/S definitions needs to be
|
||||||
/ included somewhere in the scope of ff.c. */
|
/ included somewhere in the scope of ff.h. */
|
||||||
|
|
||||||
|
/* #include <windows.h> // O/S definitions */
|
||||||
|
|
||||||
|
|
||||||
/*--- End of configuration options ---*/
|
/*--- End of configuration options ---*/
|
||||||
|
@ -121,7 +121,7 @@
|
|||||||
<h3>Resources</h3>
|
<h3>Resources</h3>
|
||||||
<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>
|
<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>
|
<ul>
|
||||||
<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 10, 2016</span></li>
|
||||||
<li>Community: <a href="http://elm-chan.org/fsw/ff/bd/">FatFs User Forum</a></li>
|
<li>Community: <a href="http://elm-chan.org/fsw/ff/bd/">FatFs User Forum</a></li>
|
||||||
<li><a href="https://msdn.microsoft.com/en-us/windows/hardware/gg463080.aspx">FAT32 Specification by Microsoft</a>↗ (The authorized document on FAT file system)</li>
|
<li><a href="https://msdn.microsoft.com/en-us/windows/hardware/gg463080.aspx">FAT32 Specification by Microsoft</a>↗ (The authorized document on FAT file system)</li>
|
||||||
<li><a href="http://elm-chan.org/docs/fat.html">The basics of FAT file system [ja]</a></li>
|
<li><a href="http://elm-chan.org/docs/fat.html">The basics of FAT file system [ja]</a></li>
|
||||||
@ -136,6 +136,6 @@
|
|||||||
|
|
||||||
|
|
||||||
<hr>
|
<hr>
|
||||||
<p class="foot"><a href="http://elm-chan.org/fsw/ff/00index_e.html">Latest Information</a></p>
|
<p class="foot"><a href="http://elm-chan.org/fsw/ff/00index_e.html">FatFs home page</a></p>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
@ -120,7 +120,7 @@
|
|||||||
<h3>資料</h3>
|
<h3>資料</h3>
|
||||||
<p>FatFsモジュールはフリー ソフトウェアとして教育・研究・開発用に公開しています。どのような利用目的(個人利用から商用まで)でも使用・改変・配布について一切の制限はありませんが、全て利用者の責任の下での利用とします。詳しくはアプリケーション ノートを参照してください。</p>
|
<p>FatFsモジュールはフリー ソフトウェアとして教育・研究・開発用に公開しています。どのような利用目的(個人利用から商用まで)でも使用・改変・配布について一切の制限はありませんが、全て利用者の責任の下での利用とします。詳しくはアプリケーション ノートを参照してください。</p>
|
||||||
<ul>
|
<ul>
|
||||||
<li>最初に読め: <a href="ja/appnote.html">FatFsモジュール アプリケーション ノート</a></li>
|
<li>最初に読め: <a href="ja/appnote.html">FatFsモジュール アプリケーション ノート</a> <span class="mfd">2016. 9. 4</span></li>
|
||||||
<li>コミュニティ: <a href="http://elm-chan.org/fsw/ff/bd/">FatFsユーザ フォーラム</a></li>
|
<li>コミュニティ: <a href="http://elm-chan.org/fsw/ff/bd/">FatFsユーザ フォーラム</a></li>
|
||||||
<li><a href="https://msdn.microsoft.com/en-us/windows/hardware/gg463080.aspx">FATファイルシステム仕様 by Microsoft</a>↗ (The reference document on FAT file system)</li>
|
<li><a href="https://msdn.microsoft.com/en-us/windows/hardware/gg463080.aspx">FATファイルシステム仕様 by Microsoft</a>↗ (The reference document on FAT file system)</li>
|
||||||
<li><a href="http://elm-chan.org/docs/fat.html">FATファイルシステム概要</a> (↑を読むためのガイド)</li>
|
<li><a href="http://elm-chan.org/docs/fat.html">FATファイルシステム概要</a> (↑を読むためのガイド)</li>
|
||||||
@ -136,6 +136,6 @@
|
|||||||
|
|
||||||
|
|
||||||
<hr>
|
<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="http://elm-chan.org/fsw/ff/00index_j.html">FatFsホームページ</a></p>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
@ -37,17 +37,17 @@
|
|||||||
<li>ANSI C<br>
|
<li>ANSI C<br>
|
||||||
The FatFs module is a middleware written in ANSI C (C89). There is no platform dependence, so long as the compiler is in compliance with ANSI C.</li>
|
The FatFs module is a middleware written in ANSI C (C89). There is no platform dependence, so long as the compiler is in compliance with ANSI C.</li>
|
||||||
<li>Size of integer types<br>
|
<li>Size of integer types<br>
|
||||||
The FatFs module assumes that size of <tt>char</tt>/<tt>short</tt>/<tt>long</tt> are 8/16/32 bit and <tt>int</tt> is 16 or 32 bit. These correspondence are defined in <tt>integer.h</tt>. This will not be a problem on most compilers. When any conflict with existing definitions is occured, you must resolve it with care.</li>
|
The FatFs module assumes that size of <tt>char</tt>/<tt>short</tt>/<tt>long</tt> are 8/16/32 bit and <tt>int</tt> is 16 or 32 bit. These correspondence are defined in <tt>integer.h</tt>. This will not be a problem on most compilers. When a conflict with existing definitions is occured, you must resolve it with care.</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
<h4>System organizations</h4>
|
<h4>System organizations</h4>
|
||||||
<p>The dependency diagram shown below is a typical but not specific configuration of the embedded system with FatFs module.</p>
|
<p>The dependency diagram shown below is a typical but not specific configuration of the embedded system with FatFs module.</p>
|
||||||
<p><img src="../res/modules.png" width="580" height="280" alt="dependency diagram"></p>
|
<p><img src="../res/modules.png" width="580" height="280" alt="dependency diagram"></p>
|
||||||
<p>(a) If a working disk module with FatFs API is provided, no additional function is needed. (b) To attach existing disk drivers with different API, glue functions are needed to translate the APIs between FatFs and the drivers.</p>
|
<p>(a) If a working disk module with FatFs disk interface is provided, nothing else will be needed. (b) To attach existing disk drivers with different interface, glue functions are needed to translate the interfaces between FatFs and the drivers.</p>
|
||||||
<p><img src="../res/funcs.png" width="750" height="420" alt="functional diagram"></p>
|
<p><img src="../res/funcs.png" width="750" height="420" alt="functional diagram"></p>
|
||||||
|
|
||||||
<h4>Which function is required?</h4>
|
<h4>Required functions</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 system 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. Most of defined functions are not that always required. For example, disk write function is not required at read-only configuration. Following table shows which function is required depends on the configuration options.</p>
|
<p>You need to provide only low level disk I/O functions required by FatFs module and nothing else. If a working disk module for the target system is already existing, you need to write only glue functions to attach it to the FatFs module. If not, you need to port another disk module or write it from scratch. Most of defined functions are not that always required. For example, disk write function is not required at read-only configuration. Following table shows which function is required depends on the configuration options.</p>
|
||||||
<table class="lst2">
|
<table class="lst2">
|
||||||
<tr><th>Function</th><th>Required when</th><th>Note</th></tr>
|
<tr><th>Function</th><th>Required when</th><th>Note</th></tr>
|
||||||
<tr><td>disk_status<br>disk_initialize<br>disk_read</td><td>Always</td><td rowspan="5">Disk I/O functions.<br>Samples available in ffsample.zip.<br>There are many implementations on the web.</td></tr>
|
<tr><td>disk_status<br>disk_initialize<br>disk_read</td><td>Always</td><td rowspan="5">Disk I/O functions.<br>Samples available in ffsample.zip.<br>There are many implementations on the web.</td></tr>
|
||||||
@ -81,21 +81,21 @@ The FatFs module assumes that size of <tt>char</tt>/<tt>short</tt>/<tt>long</tt>
|
|||||||
<tr><th></th><th>ARM7<small><br>32bit</small></th><th>ARM7<small><br>Thumb</small></th><th>CM3<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><th></th><th>ARM7<small><br>32bit</small></th><th>ARM7<small><br>Thumb</small></th><th>CM3<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 class="cal"> <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>MSC</td></tr>
|
<tr class="cal"> <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>MSC</td></tr>
|
||||||
<!-- ARM Thumb CM3 AVR H8 PIC24 RL78 V850ES SH-2A RX600 IA-32 -->
|
<!-- ARM Thumb CM3 AVR H8 PIC24 RL78 V850ES SH-2A RX600 IA-32 -->
|
||||||
<tr class="ral"><td class="cal">text (Full, R/W)</td><td>10.1k</td><td>6.6k</td><td>6.2k</td><td>12.1k</td><td>10.5k</td><td>11.2k</td><td>12.6k</td><td>8.5k</td><td>8.7k</td><td>6.3k</td><td>8.4k</td></tr>
|
<tr class="ral"><td class="cal">text (Full, R/W)</td><td>10.4k</td><td>6.8k</td><td>6.3k</td><td>12.4k</td> <td>9.8k</td><td>11.1k</td><td>12.8k</td><td>8.6k</td><td>8.9k</td><td>6.4k</td><td>8.5k</td></tr>
|
||||||
<tr class="ral"><td class="cal">text (Min, R/W)</td> <td>6.6k</td><td>4.5k</td><td>4.2k</td> <td>7.9k</td> <td>7.0k</td> <td>7.6k</td> <td>8.8k</td><td>5.9k</td><td>5.8k</td><td>4.3k</td><td>5.8k</td></tr>
|
<tr class="ral"><td class="cal">text (Min, R/W)</td> <td>6.8k</td><td>4.6k</td><td>4.3k</td> <td>8.2k</td> <td>6.7k</td> <td>7.6k</td> <td>9.1k</td><td>6.0k</td><td>5.9k</td><td>4.5k</td><td>5.9k</td></tr>
|
||||||
<tr class="ral"><td class="cal">text (Full, R/O)</td> <td>4.8k</td><td>3.1k</td><td>2.9k</td> <td>5.8k</td> <td>5.1k</td> <td>5.5k</td> <td>6.4k</td><td>4.1k</td><td>4.0k</td><td>3.1k</td><td>4.0k</td></tr>
|
<tr class="ral"><td class="cal">text (Full, R/O)</td> <td>4.8k</td><td>3.1k</td><td>2.8k</td> <td>5.6k</td> <td>4.6k</td> <td>5.3k</td> <td>6.3k</td><td>4.0k</td><td>3.9k</td><td>3.0k</td><td>3.9k</td></tr>
|
||||||
<tr class="ral"><td class="cal">text (Min, R/O)</td> <td>3.5k</td><td>2.4k</td><td>2.3k</td> <td>4.4k</td> <td>3.9k</td> <td>4.2k</td> <td>5.0k</td><td>3.3k</td><td>3.1k</td><td>2.4k</td><td>3.1k</td></tr>
|
<tr class="ral"><td class="cal">text (Min, R/O)</td> <td>3.6k</td><td>2.4k</td><td>2.3k</td> <td>4.4k</td> <td>3.5k</td> <td>4.0k</td> <td>4.9k</td><td>3.3k</td><td>3.0k</td><td>2.4k</td><td>3.1k</td></tr>
|
||||||
<tr class="ral"><td class="cal">bss</td><td>V*4 + 2</td><td>V*4 + 2</td><td>V*4 + 2</td><td>V*2 + 2</td><td>V*4 + 2</td><td>V*2 + 2</td><td>V*2 + 2</td><td>V*4 + 2</td><td>V*4 + 2</td><td>V*4 + 2</td><td>V*4 + 2</td></tr>
|
<tr class="ral"><td class="cal">bss</td><td>V*4 + 2</td><td>V*4 + 2</td><td>V*4 + 2</td><td>V*2 + 2</td><td>V*4 + 2</td><td>V*2 + 2</td><td>V*2 + 2</td><td>V*4 + 2</td><td>V*4 + 2</td><td>V*4 + 2</td><td>V*4 + 2</td></tr>
|
||||||
<tr class="ral"><td class="cal">Work area<br><small>(_FS_TINY == 0)</small></td><td>V*564<br>+ F*552</td><td>V*564<br>+ F*552</td><td>V*564<br>+ F*552</td><td>V*560<br>+ F*546</td><td>V*560<br>+ F*546</td><td>V*560<br>+ F*546</td><td>V*560<br>+ F*546</td><td>V*564<br>+ F*552</td><td>V*564<br>+ F*552</td><td>V*564<br>+ F*552</td><td>V*564<br>+ F*552</td></tr>
|
<tr class="ral"><td class="cal">Work area<br><small>(_FS_TINY == 0)</small></td><td>V*564<br>+ F*552</td><td>V*564<br>+ F*552</td><td>V*564<br>+ F*552</td><td>V*560<br>+ F*546</td><td>V*560<br>+ F*546</td><td>V*560<br>+ F*546</td><td>V*560<br>+ F*546</td><td>V*564<br>+ F*552</td><td>V*564<br>+ F*552</td><td>V*564<br>+ F*552</td><td>V*564<br>+ F*552</td></tr>
|
||||||
<tr class="ral"><td class="cal">Work area<br><small>(_FS_TINY == 1)</small></td><td>V*564<br>+ F*40</td><td>V*564<br>+ F*40</td><td>V*564<br>+ F*40</td><td>V*560<br>+ F*34</td><td>V*560<br>+ F*34</td><td>V*560<br>+ F*34</td><td>V*560<br>+ F*34</td><td>V*564<br>+ F*40</td><td>V*564<br>+ F*40</td><td>V*564<br>+ F*40</td><td>V*564<br>+ F*40</td></tr>
|
<tr class="ral"><td class="cal">Work area<br><small>(_FS_TINY == 1)</small></td><td>V*564<br>+ F*40</td><td>V*564<br>+ F*40</td><td>V*564<br>+ F*40</td><td>V*560<br>+ F*34</td><td>V*560<br>+ F*34</td><td>V*560<br>+ F*34</td><td>V*560<br>+ F*34</td><td>V*564<br>+ F*40</td><td>V*564<br>+ F*40</td><td>V*564<br>+ F*40</td><td>V*564<br>+ F*40</td></tr>
|
||||||
</table>
|
</table>
|
||||||
<p>These are the memory usage on some target systems with following condition. The memory sizes are in unit of byte, <em>V</em> denotes option <tt>_VOLUMES</tt> and <em>F</em> denotes number of open files. All samples here are optimezed in code size.</p>
|
<p>These are the memory usage on some target systems with following condition. The memory sizes are in unit of byte, <em>V</em> denotes option <tt>_VOLUMES</tt> and <em>F</em> denotes number of open files. All samples here are optimezed in code size.</p>
|
||||||
<pre>
|
<pre>
|
||||||
FatFs R0.12 options:
|
FatFs R0.12b options:
|
||||||
_FS_READONLY 0 (R/W) or 1 (R/O)
|
_FS_READONLY 0 (R/W) or 1 (R/O)
|
||||||
_FS_MINIMIZE 0 (Full, with all basic functions) or 3 (Min, with fully minimized)
|
_FS_MINIMIZE 0 (Full, with all basic functions) or 3 (Min, with fully minimized)
|
||||||
_FS_TINY 0 (Default) or 1 (Tiny file object)
|
_FS_TINY 0 (Default) or 1 (Tiny file object)
|
||||||
And any other options are left unchanged from original setting.
|
And other options are left unchanged from original setting.
|
||||||
</pre>
|
</pre>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@ -160,22 +160,22 @@ And any other options are left unchanged from original setting.
|
|||||||
|
|
||||||
<div class="para doc" id="unicode">
|
<div class="para doc" id="unicode">
|
||||||
<h3>Unicode API</h3>
|
<h3>Unicode API</h3>
|
||||||
<p>By default, FatFs uses ANSI/OEM code set on the API even at LFN configuration. FatFs can also switch the character encoding on the API to Unicode by configuration option <tt><a href="config.html#lfn_unicode">_LFN_UNICODE</a></tt>. This means that FatFs supports the full featured LFN specification. The data type <tt>TCHAR</tt> specifies any string on the API is an alias of <tt>char</tt>(ANSI) or <tt>WCHAR</tt>(UTF-16). For more information, refer to the description in the <a href="filename.html#uni">file name</a>.</p>
|
<p>By default, FatFs uses ANSI/OEM code set on the API even at LFN configuration. FatFs can also switch the character encoding on the API to Unicode by configuration option <tt><a href="config.html#lfn_unicode">_LFN_UNICODE</a></tt>. This means that FatFs supports the full featured LFN specification. The data type <tt>TCHAR</tt> specifies strings on the API is an alias of <tt>char</tt>(ANSI/OEM) or <tt>WCHAR</tt>(UTF-16). For more information, refer to the description in the <a href="filename.html#uni">file name</a>.</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="para doc" id="exfat">
|
<div class="para doc" id="exfat">
|
||||||
<h3>exFAT File System</h3>
|
<h3>exFAT File System</h3>
|
||||||
<p>The exFAT (Microsoft's Extended File Allocation Table) file system is a replacement of the FAT file system which has been widely used in the embedded systems and consumer devices. It is adopted by SDA (SD Association) as a recommended file system for high capacity SD cards (>32GB) and they are being shipped with this format, so that the exFAT will soon become one of the standard file systems for removable media.</p>
|
<p>The exFAT (Microsoft's Extended File Allocation Table) file system is a replacement of the FAT file system which has been widely used in the embedded systems and consumer devices. It is adopted by SDA (SD Association) as a recommended file system for high capacity SD cards (>32GB) and they are being shipped with this format, so that the exFAT will soon become one of the standard file systems for removable media.</p>
|
||||||
<p>The exFAT file system allows the file size larger than 4 GiB limit what FAT file system allows upto and some file system overhead, especially file allocation delay, are reduced as well. This feature improves the write throughput to the file. However a problem on the current implementation of FatFs is that write throughput at writing to the growing edge of the fragmented file gets less than the throughput on the FAT volume. Pre-allocating a contiguous block with <tt>f_expand</tt> function may be a workaround of this problem.</p>
|
<p>The exFAT file system allows the file size larger than 4 GiB limit what FAT file system allows upto and some file system overhead, especially file allocation delay, are reduced as well. This feature improves the write throughput to the file. However a problem on the current implementation of FatFs is that write throughput at writing to the growing edge of the fragmented file gets less than the throughput on the FAT volume. Pre-allocating a contiguous block with <tt>f_expand</tt> function may be a workaround of this problem.</p>
|
||||||
<p>Note that the exFAT is a patent of Microsoft Corporation. The exFAT function of FatFs is an implementation based on US. Pat. App. Pub. No. 2009/0164440 A1. FatFs module can swich the exFAT on or off by configuration option. When enable the exFAT on the commercial products, you will need to be licensed by Microsoft depends on the final destination of the products.</p></div>
|
<p>Note that the exFAT is a patent of Microsoft Corporation. The exFAT function of FatFs is an implementation based on US. Pat. App. Pub. No. 2009/0164440 A1. FatFs module can swich the exFAT on/off by configuration option. When enable the exFAT on the commercial products, you will need to be licensed by Microsoft depends on the final destination of the products.</p></div>
|
||||||
<p><em>Remark: Enabling exFAT discards C89 compatibility because of need for 64-bit integer type.</em></p>
|
<p><em>Remark: Enabling exFAT discards C89 compatibility because of need for 64-bit integer type.</em></p>
|
||||||
|
|
||||||
<div class="para doc" id="reentrant">
|
<div class="para doc" id="reentrant">
|
||||||
<h3>Re-entrancy</h3>
|
<h3>Re-entrancy</h3>
|
||||||
<p>The file operations to the different volume is always re-entrant regardless of configurations except when LFN enabled with static working buffer. It can work simultaneously without any mutual exclusion.</p>
|
<p>The file operations to the different volume is always re-entrant regardless of configurations except when LFN enabled with static working buffer. It can work simultaneously without any mutual exclusion.</p>
|
||||||
<p>The file operations to the same volume is not re-entrant but it can also be configured thread-safe by option <tt><a href="config.html#fs_reentrant">_FS_REENTRANT</a></tt>. It enables to control exclusive use of each file system object. In this case, also the OS dependent synchronization object control functions, <tt>ff_cre_syncobj/ff_del_syncobj/ff_req_grant/ff_rel_grant</tt>, needed to be added to the project. There are some examples in the <tt>option/syscall.c</tt>.</p>
|
<p>The file operations to the same volume is not re-entrant but it can also be configured thread-safe by option <tt><a href="config.html#fs_reentrant">_FS_REENTRANT</a></tt>. It enables to control exclusive use of each file system object. In this case, also the OS dependent synchronization object control functions, <tt>ff_cre_syncobj/ff_del_syncobj/ff_req_grant/ff_rel_grant</tt>, needed to be added to the project. There are some examples in the <tt>option/syscall.c</tt>.</p>
|
||||||
<p>When a file function is called while the volume is being accessed by any other task, the file function to the volume will be suspended until that task leaves the file function. If the wait time exceeded a period defined by <tt>_TIMEOUT</tt>, the file function will abort with <tt>FR_TIMEOUT</tt>. The timeout function might not be supported on the some RTOSs.</p>
|
<p>When a file function is called while the volume is being accessed by other task, the file function to the volume will be suspended until that task leaves the file function. If the wait time exceeded a period defined by <tt>_TIMEOUT</tt>, the file function will abort with <tt>FR_TIMEOUT</tt>. The timeout function might not be supported on the some RTOSs.</p>
|
||||||
<p>There is an exception on the re-entrancy for <tt>f_mount/f_mkfs/f_fdisk</tt> function. These volume management functions are not re-entrant to the same volume and corresponding physical drive. When use these functions, any other tasks need to avoid to access the volume.</p>
|
<p>There is an exception on the re-entrancy for <tt>f_mount/f_mkfs/f_fdisk</tt> function. These volume management functions are not re-entrant to the same volume and corresponding physical drive. When use these functions, other tasks need to avoid to access the volume.</p>
|
||||||
<p>Note that this section describes on the re-entrancy of the FatFs module itself. The <tt>_FS_REENTRANT</tt> controls only exclusive use of each file system object and it does not that prevent to re-enter the low level disk functions. For example, only <tt>disk_status</tt> function can be re-entered at single volume system and any disk function can be re-entered at multiple volume system. Thus the low level disk I/O layer must be always thread-safe when any FatFs API is re-entered by two or more tasks.</p>
|
<p>Note that this section describes on the re-entrancy of the FatFs module itself. The <tt>_FS_REENTRANT</tt> controls only exclusive use of each file system object and it does not that prevent to re-enter the low level disk functions. For example, only <tt>disk_status</tt> function can be re-entered at single volume system and any disk function can be re-entered at multiple volume system. Thus the low level disk I/O layer must be always thread-safe when any FatFs API is re-entered by two or more tasks.</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@ -218,7 +218,7 @@ Figure 6. Comparison between Multiple/Single Sector Write<br>
|
|||||||
|
|
||||||
<div class="para doc" id="critical">
|
<div class="para doc" id="critical">
|
||||||
<h3>Critical Section</h3>
|
<h3>Critical Section</h3>
|
||||||
<p>If a write operation to the FAT volume is interrupted due to any accidental failure, such as sudden blackout, incorrect media removal and unrecoverable disk error, the FAT structure on the volume can be broken. Following images shows the critical section of the FatFs module.</p>
|
<p>If a write operation to the FAT volume is interrupted due to an accidental failure, such as sudden blackout, incorrect media removal and unrecoverable disk error, the FAT structure on the volume can be broken. Following images shows the critical section of the FatFs module.</p>
|
||||||
<div class="lset">
|
<div class="lset">
|
||||||
Figure 4. Long critical section<br>
|
Figure 4. Long critical section<br>
|
||||||
<img src="../res/f4.png" width="320" height="436" alt="fig.4">
|
<img src="../res/f4.png" width="320" height="436" alt="fig.4">
|
||||||
@ -236,17 +236,17 @@ Figure 5. Minimized critical section<br>
|
|||||||
<li>The file created as new or overwritten remains but no content.</li>
|
<li>The file created as new or overwritten remains but no content.</li>
|
||||||
<li>Efficiency of disk use gets worse due to lost clusters.</li>
|
<li>Efficiency of disk use gets worse due to lost clusters.</li>
|
||||||
</ul>
|
</ul>
|
||||||
<p>Each case does not affect the files that not opened in write mode. To minimize risk of data loss, the critical section can be minimized by minimizing the time that file is opened in write mode or using <tt>f_sync</tt> function as shown in Figure 5.</p>
|
<p>Each case does not affect any file not opened in write mode. To minimize risk of data loss, the critical section can be minimized by minimizing the time that file is opened in write mode or using <tt>f_sync</tt> function as shown in Figure 5.</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="para doc" id="fs3">
|
<div class="para doc" id="fs3">
|
||||||
<h3>Extended Use of FatFs API</h3>
|
<h3>Extended Use of FatFs API</h3>
|
||||||
<p>These are examples of extended use of FatFs APIs. New item will be added whenever a useful code is found.</p>
|
<p>These are examples of extended use of FatFs APIs. New item will be added whenever a useful code is found.</p>
|
||||||
<ol>
|
<ol>
|
||||||
<li><a href="../res/app1.c">Open or create a file for append</a> (for R0.12 and older)</li>
|
<li><a href="../res/app1.c">Open or create a file for append</a> (for only R0.12 and earlier)</li>
|
||||||
<li><a href="../res/app2.c">Empty a directory</a></li>
|
<li><a href="../res/app2.c">Empty a directory</a></li>
|
||||||
<li><a href="../res/app3.c">Allocate contiguous area to the file</a> (for R0.11a and older)</li>
|
<li><a href="../res/app3.c">Allocate contiguous area to the file</a> (for only R0.11a and earlier)</li>
|
||||||
<li><a href="../res/app4.c">Function/compatibility checker for low level disk I/O module</a></li>
|
<li><a href="../res/app4.c">Compatibility checker for low level disk I/O module</a></li>
|
||||||
<li><a href="../res/mkfatimg.zip">FAT image creator</a></li>
|
<li><a href="../res/mkfatimg.zip">FAT image creator</a></li>
|
||||||
</ol>
|
</ol>
|
||||||
</div>
|
</div>
|
||||||
@ -256,15 +256,15 @@ Figure 5. Minimized critical section<br>
|
|||||||
<p>FatFs has being developped as a personal project of the author, ChaN. It is free from the code anyone else wrote at current release. Following code block shows a copy of the FatFs license document that included in the source files.</p>
|
<p>FatFs has being developped as a personal project of the author, ChaN. It is free from the code anyone else wrote at current release. Following code block shows a copy of the FatFs license document that included in the source files.</p>
|
||||||
<pre>
|
<pre>
|
||||||
/*----------------------------------------------------------------------------/
|
/*----------------------------------------------------------------------------/
|
||||||
/ FatFs - Generic FAT file system module R0.12a /
|
/ FatFs - Generic FAT file system module Rx.xx /
|
||||||
/-----------------------------------------------------------------------------/
|
/-----------------------------------------------------------------------------/
|
||||||
/
|
/
|
||||||
/ Copyright (C) 2016, ChaN, all right reserved.
|
/ Copyright (C) 20xx, ChaN, all right reserved.
|
||||||
/
|
/
|
||||||
/ FatFs module is an open source software. Redistribution and use of FatFs in
|
/ FatFs module is an open source software. Redistribution and use of FatFs in
|
||||||
/ source and binary forms, with or without modification, are permitted provided
|
/ source and binary forms, with or without modification, are permitted provided
|
||||||
/ that the following condition is met:
|
/ that the following condition is met:
|
||||||
|
/
|
||||||
/ 1. Redistributions of source code must retain the above copyright notice,
|
/ 1. Redistributions of source code must retain the above copyright notice,
|
||||||
/ this condition and the following disclaimer.
|
/ this condition and the following disclaimer.
|
||||||
/
|
/
|
||||||
|
@ -25,7 +25,7 @@ FRESULT f_chdir (
|
|||||||
<h4>Parameters</h4>
|
<h4>Parameters</h4>
|
||||||
<dl class="par">
|
<dl class="par">
|
||||||
<dt>path</dt>
|
<dt>path</dt>
|
||||||
<dd>Pointer to the null-terminated string that specifies a <a href="filename.html">directory</a> to go.</dd>
|
<dd>Pointer to the null-terminated string that specifies the <a href="filename.html">directory</a> to go.</dd>
|
||||||
</dl>
|
</dl>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@ -50,7 +50,7 @@ FRESULT f_chdir (
|
|||||||
|
|
||||||
<div class="para desc">
|
<div class="para desc">
|
||||||
<h4>Description</h4>
|
<h4>Description</h4>
|
||||||
<p>The <tt>f_chdir</tt> function changes the current directory of the logical drive. The current directory of a drive is initialized to the root directory when the drive is auto-mounted. Note that the current directory is retained in the each file system object so that it also affects other tasks that using the volume.</p>
|
<p>The <tt>f_chdir</tt> function changes the current directory of the logical drive. The current directory of a drive is set to the root directory when the drive is mounted. Note that the current directory is retained in the each file system object, so that it also affects other tasks that use the volume.</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
@ -63,10 +63,10 @@ FRESULT f_chdir (
|
|||||||
<div class="para use">
|
<div class="para use">
|
||||||
<h4>Example</h4>
|
<h4>Example</h4>
|
||||||
<pre>
|
<pre>
|
||||||
<span class="c">/* Change current direcoty of the current drive (dir1 under root dir) */</span>
|
<span class="c">/* Change current direcoty of the current drive ('dir1' under root directory) */</span>
|
||||||
f_chdir("/dir1");
|
f_chdir("/dir1");
|
||||||
|
|
||||||
<span class="c">/* Change current direcoty of drive 2 (parent dir) */</span>
|
<span class="c">/* Change current direcoty of drive 2 (parent directory) */</span>
|
||||||
f_chdir("2:..");
|
f_chdir("2:..");
|
||||||
</pre>
|
</pre>
|
||||||
</div>
|
</div>
|
||||||
|
@ -45,16 +45,16 @@
|
|||||||
<p>Disable (0) or Enable (1) <tt>f_mkfs</tt> function.</p>
|
<p>Disable (0) or Enable (1) <tt>f_mkfs</tt> function.</p>
|
||||||
|
|
||||||
<h4 id="use_fastseek">_USE_FASTSEEK</h4>
|
<h4 id="use_fastseek">_USE_FASTSEEK</h4>
|
||||||
<p>Disable (0) or Enable (1) fast seek function to enable accelerated mode of <tt>f_lseek</tt>, <tt>f_read</tt> and <tt>f_write</tt> function. For more information, read <a href="lseek.html">here</a>.</p>
|
<p>Disable (0) or Enable (1) fast seek function to enable accelerated mode for <tt>f_lseek</tt>, <tt>f_read</tt> and <tt>f_write</tt> function. For more information, read <a href="lseek.html">here</a>.</p>
|
||||||
|
|
||||||
<h4 id="use_expand">_USE_EXPAND</h4>
|
<h4 id="use_expand">_USE_EXPAND</h4>
|
||||||
<p>Disable (0) or Enable (1) , <tt>f_enpand</tt> function. Also <tt>_FS_READONLY</tt> needs to be 0.</p>
|
<p>Disable (0) or Enable (1) , <tt>f_enpand</tt> function. Also <tt>_FS_READONLY</tt> needs to be 0.</p>
|
||||||
|
|
||||||
<h4 id="use_chmod">_USE_CHMOD</h4>
|
<h4 id="use_chmod">_USE_CHMOD</h4>
|
||||||
<p>Disable (0) or Enable (1) metadata manipulation functions, <tt>f_chmod</tt> and <tt>f_utime</tt>. Also <tt>_FS_READONLY</tt> needs to be 0.</p>
|
<p>Disable (0) or Enable (1) metadata control functions, <tt>f_chmod</tt> and <tt>f_utime</tt>. Also <tt>_FS_READONLY</tt> needs to be 0.</p>
|
||||||
|
|
||||||
<h4 id="use_label">_USE_LABEL</h4>
|
<h4 id="use_label">_USE_LABEL</h4>
|
||||||
<p>Disable (0) or Enable (1) volume label functions, <tt>f_getlabel</tt> and <tt>f_setlabel</tt>.</p>
|
<p>Disable (0) or Enable (1) API functions for volume label, <tt>f_getlabel</tt> and <tt>f_setlabel</tt>.</p>
|
||||||
|
|
||||||
<h4 id="use_forward">_USE_FORWARD</h4>
|
<h4 id="use_forward">_USE_FORWARD</h4>
|
||||||
<p>Disable (0) or Enable (1) <tt>f_forward</tt> function.</p>
|
<p>Disable (0) or Enable (1) <tt>f_forward</tt> function.</p>
|
||||||
@ -147,7 +147,7 @@
|
|||||||
<p>Disable (0) or Enable (1). This option switches multi-partition function. By default (0), each logical drive number is bound to the same physical drive number and only an FAT volume in the physical drive is mounted. When enabled, each logical drive is bound to the partition on the physical drive listed in the user defined partition resolution table <tt>VolToPart[]</tt>. Also <tt>f_fdisk</tt> funciton will be available. For more information, read <a href="filename.html#vol">here</a>.</p>
|
<p>Disable (0) or Enable (1). This option switches multi-partition function. By default (0), each logical drive number is bound to the same physical drive number and only an FAT volume in the physical drive is mounted. When enabled, each logical drive is bound to the partition on the physical drive listed in the user defined partition resolution table <tt>VolToPart[]</tt>. Also <tt>f_fdisk</tt> funciton will be available. For more information, read <a href="filename.html#vol">here</a>.</p>
|
||||||
|
|
||||||
<h4 id="max_ss">_MIN_SS, _MAX_SS</h4>
|
<h4 id="max_ss">_MIN_SS, _MAX_SS</h4>
|
||||||
<p>This set of options defines the size of sector on low level disk I/O interface, <tt>disk_read</tt> and <tt>disk_write</tt> function. Valid values are 512, 1024, 2048 and 4096. <tt>_MIN_SS</tt> defines minimum sector size and <tt>_MAX_SS</tt> defines the maximum sector size. Always set both 512 for any type of memory card and harddisk. But a larger value may be required for on-board flash memory and some type of optical media. When <tt>_MAX_SS > _MIN_SS</tt>, FatFs is configured to variable sector size and <tt>GET_SECTOR_SIZE</tt> command must be implemented to the <tt>disk_ioctl</tt> function.</p>
|
<p>This set of options defines the size of sector on low level disk I/O interface, <tt>disk_read</tt> and <tt>disk_write</tt> function. Valid values are 512, 1024, 2048 and 4096. <tt>_MIN_SS</tt> defines minimum sector size and <tt>_MAX_SS</tt> defines the maximum sector size. Always set both 512 for memory card and harddisk. But a larger value may be required for on-board flash memory and some type of optical media. When <tt>_MAX_SS > _MIN_SS</tt>, support of variable sector size is enabled and <tt>GET_SECTOR_SIZE</tt> command needs to be implemented to the <tt>disk_ioctl</tt> function.</p>
|
||||||
|
|
||||||
<h4 id="use_trim">_USE_TRIM</h4>
|
<h4 id="use_trim">_USE_TRIM</h4>
|
||||||
<p>Disable (0) or Enable (1). This option switches ATA-TRIM function. To enable Trim function, also <tt>CTRL_TRIM</tt> command should be implemented to the <tt>disk_ioctl</tt> function.</p>
|
<p>Disable (0) or Enable (1). This option switches ATA-TRIM function. To enable Trim function, also <tt>CTRL_TRIM</tt> command should be implemented to the <tt>disk_ioctl</tt> function.</p>
|
||||||
@ -175,7 +175,7 @@
|
|||||||
<p>This option switches support for the exFAT file system in addition to the FAT file system, Enabled(1) or Disabled(1). To enable this feature, also LFN must be enabled and configureing <tt>_LFN_UNICODE = 1</tt> and <tt>_MAX_LFN = 255</tt> is recommended for full-featured exFAT function. Note that enabling exFAT discards C89 compatibility because of need for 64-bit integer type.</p>
|
<p>This option switches support for the exFAT file system in addition to the FAT file system, Enabled(1) or Disabled(1). To enable this feature, also LFN must be enabled and configureing <tt>_LFN_UNICODE = 1</tt> and <tt>_MAX_LFN = 255</tt> is recommended for full-featured exFAT function. Note that enabling exFAT discards C89 compatibility because of need for 64-bit integer type.</p>
|
||||||
|
|
||||||
<h4 id="fs_nortc">_FS_NORTC</h4>
|
<h4 id="fs_nortc">_FS_NORTC</h4>
|
||||||
<p>Use RTC (0) or Do not use RTC (1). This option controls timestamp function. If the system does not have an RTC function or valid timestamp is not needed, set <tt>_FS_NORTC</tt> to 1 to disable the timestamp function. Any object modified by FatFs will have a fixed timestamp value defined by <tt>_NORTC_MON</tt>, <tt>_NORTC_MDAY</tt> and <tt>_NORTC_YEAR</tt>. To use the timestamp function, set <tt>_FS_NORTC = 0</tt> and add <tt>get_fattime</tt> function to the project to get the current time form real-time clock. This option has no effect at read-only configuration.</p>
|
<p>Use RTC (0) or Do not use RTC (1). This option controls timestamp function. If the system does not have an RTC function or valid timestamp is not needed, set <tt>_FS_NORTC</tt> to 1 to disable the timestamp function. Any object modified by FatFs will have a fixed timestamp defined by <tt>_NORTC_MON</tt>, <tt>_NORTC_MDAY</tt> and <tt>_NORTC_YEAR</tt>. To use the timestamp function, set <tt>_FS_NORTC = 0</tt> and add <tt>get_fattime</tt> function to the project to get the current time form real-time clock. This option has no effect at read-only configuration.</p>
|
||||||
|
|
||||||
<h4 id="nortc_time">_NORTC_MON, _NORTC_MDAY, _NORTC_YEAR</h4>
|
<h4 id="nortc_time">_NORTC_MON, _NORTC_MDAY, _NORTC_YEAR</h4>
|
||||||
<p>This set of options defines the time to be used at no RTC systems. This option has no effect at read-only configuration or <tt>_FS_NORTC = 0</tt>.</p>
|
<p>This set of options defines the time to be used at no RTC systems. This option has no effect at read-only configuration or <tt>_FS_NORTC = 0</tt>.</p>
|
||||||
@ -184,12 +184,12 @@
|
|||||||
<p>This option switches file lock function to control duplicated file open and illegal operations to open objects. Note that the file lock function is independent of re-entrancy. This option must be 0 at read-only configuration.</p>
|
<p>This option switches file lock function to control duplicated file open and illegal operations to open objects. Note that the file lock function is independent of re-entrancy. This option must be 0 at read-only configuration.</p>
|
||||||
<table class="lst1">
|
<table class="lst1">
|
||||||
<tr><th>Value</th><th>Description</th></tr>
|
<tr><th>Value</th><th>Description</th></tr>
|
||||||
<tr><td>0</td><td>Disable file lock function. To avoid volume corruption, application program should avoid illegal open, remove and rename to the open objects.</td></tr>
|
<tr><td>0</td><td>Disable file lock function. To avoid collapsing file by wrong file operation, application program needs to avoid illegal open, remove and rename to the open objects.</td></tr>
|
||||||
<tr><td>>0</td><td>Enable file lock function. The value defines how many files/sub-directories can be opened simultaneously under file lock control. Illigal operations to the open object will be rejected with <tt>FR_LOCKED</tt>.</td></tr>
|
<tr><td>>0</td><td>Enable file lock function. The value defines how many files/sub-directories can be opened simultaneously under the file lock control. Illigal operations to the open object will be rejected with <tt>FR_LOCKED</tt>.</td></tr>
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
<h4 id="fs_reentrant">_FS_REENTRANT</h4>
|
<h4 id="fs_reentrant">_FS_REENTRANT</h4>
|
||||||
<p>Disable (0) or Enable (1). This option switches the re-entrancy (thread safe) of the FatFs module itself. Note that file/directory access to the different volume is always re-entrant and it can work simultaneously regardless of this option but volume control functions, <tt>f_mount</tt>, <tt>f_mkfs</tt> and <tt>f_fdisk</tt>, are always not re-entrant. Only file/directory access to the same volume, in other words, exclusive use of each file system object, is under control of this function. To enable this feature, also user provided synchronization handlers, <tt>ff_req_grant</tt>, <tt>ff_rel_grant</tt>, <tt>ff_del_syncobj</tt> and <tt>ff_cre_syncobj</tt>, need to be added to the project. Sample code is available in <tt>option/syscall.c</tt>.</p>
|
<p>Disable (0) or Enable (1). This option switches the re-entrancy (thread safe) of the FatFs module itself. Note that file/directory access to the different volume is always re-entrant and it can work simultaneously regardless of this option but volume control functions. <tt>f_mount</tt>, <tt>f_mkfs</tt> and <tt>f_fdisk</tt>, are always not re-entrant. Only file/directory access to the same volume, in other words, exclusive use of each file system object, is under control of this function. To enable this feature, also user provided synchronization handlers, <tt>ff_req_grant</tt>, <tt>ff_rel_grant</tt>, <tt>ff_del_syncobj</tt> and <tt>ff_cre_syncobj</tt>, need to be added to the project. Sample code is available in <tt>option/syscall.c</tt>.</p>
|
||||||
|
|
||||||
<h4 id="fs_timeout">_FS_TIMEOUT</h4>
|
<h4 id="fs_timeout">_FS_TIMEOUT</h4>
|
||||||
<p>Number of time ticks to abort the file function with <tt>FR_TIMEOUT</tt> when wait time is too long. This option has no effect when <tt>_FS_REENTRANT = 0</tt>.</p>
|
<p>Number of time ticks to abort the file function with <tt>FR_TIMEOUT</tt> when wait time is too long. This option has no effect when <tt>_FS_REENTRANT = 0</tt>.</p>
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
|
|
||||||
<div class="para func">
|
<div class="para func">
|
||||||
<h2>disk_initialize</h2>
|
<h2>disk_initialize</h2>
|
||||||
<p>The disk_initialize function initializes the storage device.</p>
|
<p>The disk_initialize function is called to initializes the storage device.</p>
|
||||||
<pre>
|
<pre>
|
||||||
DSTATUS disk_initialize (
|
DSTATUS disk_initialize (
|
||||||
BYTE <span class="arg">pdrv</span> <span class="c">/* [IN] Physical drive number */</span>
|
BYTE <span class="arg">pdrv</span> <span class="c">/* [IN] Physical drive number */</span>
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
|
|
||||||
<div class="para func">
|
<div class="para func">
|
||||||
<h2>disk_ioctl</h2>
|
<h2>disk_ioctl</h2>
|
||||||
<p>The disk_ioctl function controls device specific features and miscellaneous functions other than generic read/write.</p>
|
<p>The disk_ioctl function is called to control device specific features and miscellaneous functions other than generic read/write.</p>
|
||||||
<pre>
|
<pre>
|
||||||
DRESULT disk_ioctl (
|
DRESULT disk_ioctl (
|
||||||
BYTE <span class="arg">pdrv</span>, <span class="c">/* [IN] Drive number */</span>
|
BYTE <span class="arg">pdrv</span>, <span class="c">/* [IN] Drive number */</span>
|
||||||
@ -59,9 +59,9 @@ DRESULT disk_ioctl (
|
|||||||
<tr><th>Command</th><th>Description</th></tr>
|
<tr><th>Command</th><th>Description</th></tr>
|
||||||
<tr><td>CTRL_SYNC</td><td>Make sure that the device has finished pending write process. If the disk I/O module has a write back cache, the dirty buffers must be written back to the media immediately. Nothing to do for this command if each write operation to the media is completed within the <tt>disk_write</tt> function.</td></tr>
|
<tr><td>CTRL_SYNC</td><td>Make sure that the device has finished pending write process. If the disk I/O module has a write back cache, the dirty buffers must be written back to the media immediately. Nothing to do for this command if each write operation to the media is completed within the <tt>disk_write</tt> function.</td></tr>
|
||||||
<tr><td>GET_SECTOR_COUNT</td><td>Returns number of available sectors on the drive into the <tt>DWORD</tt> variable pointed by <tt class="arg">buff</tt>. This command is used by only <tt>f_mkfs</tt> and <tt>f_fdisk</tt> function to determine the volume/partition size to be created. Required at <tt>_USE_MKFS == 1</tt> or <tt>_MULTI_PARTITION == 1</tt>.</td></tr>
|
<tr><td>GET_SECTOR_COUNT</td><td>Returns number of available sectors on the drive into the <tt>DWORD</tt> variable pointed by <tt class="arg">buff</tt>. This command is used by only <tt>f_mkfs</tt> and <tt>f_fdisk</tt> function to determine the volume/partition size to be created. Required at <tt>_USE_MKFS == 1</tt> or <tt>_MULTI_PARTITION == 1</tt>.</td></tr>
|
||||||
<tr><td>GET_SECTOR_SIZE</td><td>Returns sector size of the media into the <tt>WORD</tt> variable pointed by <tt class="arg">buff</tt>. Valid return values of this command are 512, 1024, 2048 and 4096. This command is required only at variable sector size configuration, <tt>_MAX_SS > _MIN_SS</tt>. At fixed sector size configuration, <tt>_MAX_SS == _MIN_SS</tt>, this command is not used and the device must work at that sector size.</td></tr>
|
<tr><td>GET_SECTOR_SIZE</td><td>Returns sector size of the device into the <tt>WORD</tt> variable pointed by <tt class="arg">buff</tt>. Valid return values of this command are 512, 1024, 2048 and 4096. This command is required only at variable sector size configuration, <tt>_MAX_SS > _MIN_SS</tt>. At the fixed sector size configuration, <tt>_MAX_SS == _MIN_SS</tt>, this command is not used and the device must work at that sector size.</td></tr>
|
||||||
<tr><td>GET_BLOCK_SIZE</td><td>Returns erase block size of the flash memory media in unit of sector into the <tt>DWORD</tt> variable pointed by <tt class="arg">buff</tt>. The allowable value is from 1 to 32768 in power of 2. Return 1 if the erase block size is unknown or non flash memory media. This command is used by only <tt>f_mkfs</tt> function and it attempts to align data area to the erase block boundary. Required at <tt>_USE_MKFS == 1</tt>.</td></tr>
|
<tr><td>GET_BLOCK_SIZE</td><td>Returns erase block size of the flash memory media in unit of sector into the <tt>DWORD</tt> variable pointed by <tt class="arg">buff</tt>. The allowable value is from 1 to 32768 in power of 2. Return 1 if the erase block size is unknown or non flash memory media. This command is used by only <tt>f_mkfs</tt> function and it attempts to align data area on the erase block boundary. Required at <tt>_USE_MKFS == 1</tt>.</td></tr>
|
||||||
<tr><td>CTRL_TRIM</td><td>Informs the device the data on the block of sectors that specified by <tt>DWORD</tt> array {<start sector>, <end sector>} pointed by <tt class="arg">buff</tt> is no longer needed and it may be erased. This is an identical command to Trim of ATA device. Nothing to do for this command if this funcion is not supported or not a flash memory device. The FatFs does not check the result code and the file function is not affected even if the sector block was not erased well. This command is called on remove a cluster chain and in the <tt>f_mkfs</tt> function. Required at <tt>_USE_TRIM == 1</tt>.</td></tr>
|
<tr><td>CTRL_TRIM</td><td>Informs the device the data on the block of sectors is no longer needed and it can be erased. The sector block is specified by <tt>DWORD</tt> array {<start sector>, <end sector>} pointed by <tt class="arg">buff</tt>. This is an identical command to Trim of ATA device. Nothing to do for this command if this funcion is not supported or not a flash memory device. The FatFs does not check the result code and the file function is not affected even if the sector block was not erased well. This command is called on remove a cluster chain and in the <tt>f_mkfs</tt> function. Required at <tt>_USE_TRIM == 1</tt>.</td></tr>
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
<p>FatFs never uses any device dependent command nor user defined command. Following table shows an example of non-standard commands usable for some applications.</p>
|
<p>FatFs never uses any device dependent command nor user defined command. Following table shows an example of non-standard commands usable for some applications.</p>
|
||||||
@ -69,8 +69,8 @@ DRESULT disk_ioctl (
|
|||||||
<caption>Example of optional ioctl command</caption>
|
<caption>Example of optional ioctl command</caption>
|
||||||
<tr><th>Command</th><th>Description</th></tr>
|
<tr><th>Command</th><th>Description</th></tr>
|
||||||
<tr><td>CTRL_FORMAT</td><td>Create a physical format on the media. If <tt class="arg">buff</tt> is not null, it is pointer to the call-back function for progress notification.</td></tr>
|
<tr><td>CTRL_FORMAT</td><td>Create a physical format on the media. If <tt class="arg">buff</tt> is not null, it is pointer to the call-back function for progress notification.</td></tr>
|
||||||
<tr><td>CTRL_POWER_IDLE</td><td>Put the device idle state. <tt>STA_NOINIT</tt> in status flag may not be set if the device goes active state by generic read/write function.</td></tr>
|
<tr><td>CTRL_POWER_IDLE</td><td>Put the device idle state. <tt>STA_NOINIT</tt> in the current status flags may not be set if the device goes active state by generic read/write function.</td></tr>
|
||||||
<tr><td>CTRL_POWER_OFF</td><td>Put the device off state. Shut-down the power to the device and deinitialize the device interface if needed. <tt>STA_NOINIT</tt> in status flag must be set. The device goes active state by <tt>disk_initialize</tt> function.</td></tr>
|
<tr><td>CTRL_POWER_OFF</td><td>Put the device off state. Shut-down the power to the device and deinitialize the device interface if needed. <tt>STA_NOINIT</tt> in the current status flags must be set. The device goes active state by <tt>disk_initialize</tt> function.</td></tr>
|
||||||
<tr><td>CTRL_LOCK</td><td>Lock media eject mechanism.</td></tr>
|
<tr><td>CTRL_LOCK</td><td>Lock media eject mechanism.</td></tr>
|
||||||
<tr><td>CTRL_UNLOCK</td><td>Unlock media eject mechanism.</td></tr>
|
<tr><td>CTRL_UNLOCK</td><td>Unlock media eject mechanism.</td></tr>
|
||||||
<tr><td>CTRL_EJECT</td><td>Eject media cartridge. <tt>STA_NOINIT</tt> and <tt>STA_NODISK</tt> in status flag are set after the function succeeded.</td></tr>
|
<tr><td>CTRL_EJECT</td><td>Eject media cartridge. <tt>STA_NOINIT</tt> and <tt>STA_NODISK</tt> in status flag are set after the function succeeded.</td></tr>
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
|
|
||||||
<div class="para func">
|
<div class="para func">
|
||||||
<h2>disk_read</h2>
|
<h2>disk_read</h2>
|
||||||
<p>The disk_read function reads sector(s) from the storage device.</p>
|
<p>The disk_read function is called to read data from the sector(s) of storage device.</p>
|
||||||
<pre>
|
<pre>
|
||||||
DRESULT disk_read (
|
DRESULT disk_read (
|
||||||
BYTE <span class="arg">pdrv</span>, <span class="c">/* [IN] Physical drive number */</span>
|
BYTE <span class="arg">pdrv</span>, <span class="c">/* [IN] Physical drive number */</span>
|
||||||
@ -30,7 +30,7 @@ DRESULT disk_read (
|
|||||||
<dt>pdrv</dt>
|
<dt>pdrv</dt>
|
||||||
<dd>Physical drive number to identify the target device.</dd>
|
<dd>Physical drive number to identify the target device.</dd>
|
||||||
<dt>buff</dt>
|
<dt>buff</dt>
|
||||||
<dd>Pointer to the <em>byte array</em> to store the read data.</dd>
|
<dd>Pointer to the first item of the <em>byte array</em> to store read data.</dd>
|
||||||
<dt>sector</dt>
|
<dt>sector</dt>
|
||||||
<dd>Start sector number in 32-bit LBA.</dd>
|
<dd>Start sector number in 32-bit LBA.</dd>
|
||||||
<dt>count</dt>
|
<dt>count</dt>
|
||||||
@ -45,7 +45,7 @@ DRESULT disk_read (
|
|||||||
<dt>RES_OK (0)</dt>
|
<dt>RES_OK (0)</dt>
|
||||||
<dd>The function succeeded.</dd>
|
<dd>The function succeeded.</dd>
|
||||||
<dt>RES_ERROR</dt>
|
<dt>RES_ERROR</dt>
|
||||||
<dd>Any hard error occured during the read operation and could not recover it.</dd>
|
<dd>A hard error occured during the read operation and could not recover it.</dd>
|
||||||
<dt>RES_PARERR</dt>
|
<dt>RES_PARERR</dt>
|
||||||
<dd>Invalid parameter.</dd>
|
<dd>Invalid parameter.</dd>
|
||||||
<dt>RES_NOTRDY</dt>
|
<dt>RES_NOTRDY</dt>
|
||||||
@ -61,7 +61,7 @@ DRESULT disk_read (
|
|||||||
<ul>
|
<ul>
|
||||||
<li>Convert word transfer to byte transfer in this function if needed. - Recommended.</li>
|
<li>Convert word transfer to byte transfer in this function if needed. - Recommended.</li>
|
||||||
<li>On the <tt>f_read</tt> calls, avoid long read request that includes a whole of sector. - Any direct transfer never occures.</li>
|
<li>On the <tt>f_read</tt> calls, avoid long read request that includes a whole of sector. - Any direct transfer never occures.</li>
|
||||||
<li>On the <tt>f_read</tt> calls, make sure that <tt>(((UINT)data & 3) == (f_tell(fp) & 3))</tt> is true. - Word alignment of <tt>buff</tt> is guaranteed.</li>
|
<li>On the <tt>f_read</tt> calls, make sure that <tt>(((UINT)data & 3) == (f_tell(fp) & 3))</tt> is true. - Word alignment of <tt class="arg">buff</tt> is guaranteed.</li>
|
||||||
</ul>
|
</ul>
|
||||||
<p>Generally, a multiple sector transfer request must not be split into single sector transactions to the storage device, or you will not get good read throughput.</p>
|
<p>Generally, a multiple sector transfer request must not be split into single sector transactions to the storage device, or you will not get good read throughput.</p>
|
||||||
</div>
|
</div>
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
|
|
||||||
<div class="para func">
|
<div class="para func">
|
||||||
<h2>disk_status</h2>
|
<h2>disk_status</h2>
|
||||||
<p>The disk_status function returns the current drive status.</p>
|
<p>The disk_status function is called to inquire the current drive status.</p>
|
||||||
<pre>
|
<pre>
|
||||||
DSTATUS disk_status (
|
DSTATUS disk_status (
|
||||||
BYTE <span class="arg">pdrv</span> <span class="c">/* [IN] Physical drive number */</span>
|
BYTE <span class="arg">pdrv</span> <span class="c">/* [IN] Physical drive number */</span>
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
|
|
||||||
<div class="para func">
|
<div class="para func">
|
||||||
<h2>disk_write</h2>
|
<h2>disk_write</h2>
|
||||||
<p>The disk_write writes sector(s) to the storage device.</p>
|
<p>The disk_write function is called to write data to the sector(s) of storage device.</p>
|
||||||
<pre>
|
<pre>
|
||||||
DRESULT disk_write (
|
DRESULT disk_write (
|
||||||
BYTE <span class="arg">drv</span>, <span class="c">/* [IN] Physical drive number */</span>
|
BYTE <span class="arg">drv</span>, <span class="c">/* [IN] Physical drive number */</span>
|
||||||
@ -30,7 +30,7 @@ DRESULT disk_write (
|
|||||||
<dt>pdrv</dt>
|
<dt>pdrv</dt>
|
||||||
<dd>Physical drive number to identify the target device.</dd>
|
<dd>Physical drive number to identify the target device.</dd>
|
||||||
<dt>buff</dt>
|
<dt>buff</dt>
|
||||||
<dd>Pointer to the <em>byte array</em> to be written. The size of data to be written is sector size * <tt class="arg">count</tt> bytes.</dd>
|
<dd>Pointer to the first item of the <em>byte array</em> to be written. The size of data to be written is sector size * <tt class="arg">count</tt> bytes.</dd>
|
||||||
<dt>sector</dt>
|
<dt>sector</dt>
|
||||||
<dd>Start sector number in 32-bit LBA.</dd>
|
<dd>Start sector number in 32-bit LBA.</dd>
|
||||||
<dt>count</dt>
|
<dt>count</dt>
|
||||||
@ -45,7 +45,7 @@ DRESULT disk_write (
|
|||||||
<dt>RES_OK (0)</dt>
|
<dt>RES_OK (0)</dt>
|
||||||
<dd>The function succeeded.</dd>
|
<dd>The function succeeded.</dd>
|
||||||
<dt>RES_ERROR</dt>
|
<dt>RES_ERROR</dt>
|
||||||
<dd>Any hard error occured during the write operation and could not recover it.</dd>
|
<dd>A hard error occured during the write operation and could not recover it.</dd>
|
||||||
<dt>RES_WRPRT</dt>
|
<dt>RES_WRPRT</dt>
|
||||||
<dd>The medium is write protected.</dd>
|
<dd>The medium is write protected.</dd>
|
||||||
<dt>RES_PARERR</dt>
|
<dt>RES_PARERR</dt>
|
||||||
|
@ -59,9 +59,9 @@ FRESULT f_expand (
|
|||||||
<li>The file has been opened in read-only mode.</li>
|
<li>The file has been opened in read-only mode.</li>
|
||||||
<li>Not allowable file size. (>= 4GiB on FAT volume)</li>
|
<li>Not allowable file size. (>= 4GiB on FAT volume)</li>
|
||||||
</ul>
|
</ul>
|
||||||
<p>When <tt class="arg">opt</tt> is 0, the function finds a contiguous data area and set it as suggested point for next allocation instead of allocating it to the file. The next cluster allocation is started at top of the contiguous area found by this function. Thus the write file is guaranteed be contiguous and no allocation delay until the size reaches that size at least unless any other operation to the volume with changes of FAT is performed.</p>
|
<p>When <tt class="arg">opt</tt> is 0, the function finds a contiguous data area and set it as suggested point for next allocation instead of allocating it to the file. The next cluster allocation is started at top of the contiguous area found by this function. Thus the write file is guaranteed be contiguous and no allocation delay until the size reaches that size at least unless any other changes to the volume is performed.</p>
|
||||||
<p>The contiguous file would have an advantage at time-critical read/write operations. It reduces some overheads in the file system and the storage media caused by random access due to fragmented file data. Especially, at the exFAT volume, any FAT access for the contiguous file is completely eliminated and storage media will be accessed sequentially.</p>
|
<p>The contiguous file would have an advantage at time-critical read/write operations. It reduces some overheads in the file system and the storage media caused by random access due to fragmented file data. Especially FAT access for the contiguous file on the exFAT volume is completely eliminated and storage media will be accessed sequentially.</p>
|
||||||
<p>Also the contiguous file data can be easily accessed directly via low-level disk functions but it is not recommended in consideration for future compatibility.</p>
|
<p>Also the contiguous file data can be easily accessed directly via low-level disk functions. But this is not recommended in consideration for future compatibility.</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="para comp">
|
<div class="para comp">
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
|
|
||||||
<div class="para func">
|
<div class="para func">
|
||||||
<h2>get_fattime</h2>
|
<h2>get_fattime</h2>
|
||||||
<p>The get_fattime function gets current time.</p>
|
<p>The get_fattime function is called to get the current time.</p>
|
||||||
<pre>
|
<pre>
|
||||||
DWORD get_fattime (void);
|
DWORD get_fattime (void);
|
||||||
</pre>
|
</pre>
|
||||||
@ -22,7 +22,7 @@ DWORD get_fattime (void);
|
|||||||
|
|
||||||
<div class="para ret">
|
<div class="para ret">
|
||||||
<h4>Return Value</h4>
|
<h4>Return Value</h4>
|
||||||
<p>Currnet local time is returned with packed into a <tt>DWORD</tt> value. The bit field is as follows:</p>
|
<p>Currnet local time shall be returned as bit-fields packed into a <tt>DWORD</tt> value. The bit fields are as follows:</p>
|
||||||
<dl class="ret">
|
<dl class="ret">
|
||||||
<dt>bit31:25</dt>
|
<dt>bit31:25</dt>
|
||||||
<dd>Year origin from the 1980 (0..127)</dd>
|
<dd>Year origin from the 1980 (0..127)</dd>
|
||||||
|
@ -74,10 +74,10 @@ FRESULT f_fdisk (
|
|||||||
DWORD plist[] = {50, 50, 0, 0}; <span class="c">/* Divide drive into two partitions */</span>
|
DWORD plist[] = {50, 50, 0, 0}; <span class="c">/* Divide drive into two partitions */</span>
|
||||||
BYTE work[_MAX_SS];
|
BYTE work[_MAX_SS];
|
||||||
|
|
||||||
f_fdisk(0, plist, work); <span class="c">/* Divide physical drive 0 */</span>
|
f_fdisk(0, plist, work); <span class="c">/* Divide physical drive 0 */</span>
|
||||||
|
|
||||||
f_mkfs("0:", FMT_ANY, work, sizeof work); <span class="c">/* Create FAT volume on the logical drive 0 */</span>
|
f_mkfs("0:", FM_ANY, work, sizeof work); <span class="c">/* Create FAT volume on the logical drive 0 */</span>
|
||||||
f_mkfs("1:", FMT_ANY, work, sizeof work); <span class="c">/* Create FAT volume on the logical drive 1 */</span>
|
f_mkfs("1:", FM_ANY, work, sizeof work); <span class="c">/* Create FAT volume on the logical drive 1 */</span>
|
||||||
|
|
||||||
</pre>
|
</pre>
|
||||||
</div>
|
</div>
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
<h1>Path Names</h1>
|
<h1>Path Names on the FatFs</h1>
|
||||||
|
|
||||||
<div class="para doc" id="nam">
|
<div class="para doc" id="nam">
|
||||||
<h3>Format of the path names</h3>
|
<h3>Format of the path names</h3>
|
||||||
@ -19,7 +19,7 @@
|
|||||||
<p>The FatFs module supports long file name (LFN) and 8.3 format file name (SFN). The LFN can be used when (<tt><a href="config.html#use_lfn">_USE_LFN</a> != 0</tt>). The sub directories are separated with a \ or / in the same way as DOS/Windows API. Duplicated separators are skipped and ignored. Only a difference is that the logical drive is specified in a numeral with a colon. When drive number is omitted, the drive number is assumed as <em>default drive</em> (drive 0 or current drive).</p>
|
<p>The FatFs module supports long file name (LFN) and 8.3 format file name (SFN). The LFN can be used when (<tt><a href="config.html#use_lfn">_USE_LFN</a> != 0</tt>). The sub directories are separated with a \ or / in the same way as DOS/Windows API. Duplicated separators are skipped and ignored. Only a difference is that the logical drive is specified in a numeral with a colon. When drive number is omitted, the drive number is assumed as <em>default drive</em> (drive 0 or current drive).</p>
|
||||||
<p>Control characters (<tt>'\0'</tt> to <tt>'\x1F'</tt>) are recognized as end of the path name. Leading/embedded spaces in the path name are valid as a part of the name at LFN configuration but the space is recognized as end of the path name at non-LFN configuration. Trailing spaces and dots are ignored at both configurations.</p>
|
<p>Control characters (<tt>'\0'</tt> to <tt>'\x1F'</tt>) are recognized as end of the path name. Leading/embedded spaces in the path name are valid as a part of the name at LFN configuration but the space is recognized as end of the path name at non-LFN configuration. Trailing spaces and dots are ignored at both configurations.</p>
|
||||||
<p>In default configuration (<tt><a href="config.html#fs_rpath">_FS_RPATH</a> == 0</tt>), it does not have a concept of current directory like OS oriented file system. All objects on the volume are always specified in full path name that follows from the root directory. Dot directory names (<tt>".", ".."</tt>) are not allowed. Heading separator is ignored and it can be exist or omitted. The default drive is fixed to drive 0.</p>
|
<p>In default configuration (<tt><a href="config.html#fs_rpath">_FS_RPATH</a> == 0</tt>), it does not have a concept of current directory like OS oriented file system. All objects on the volume are always specified in full path name that follows from the root directory. Dot directory names (<tt>".", ".."</tt>) are not allowed. Heading separator is ignored and it can be exist or omitted. The default drive is fixed to drive 0.</p>
|
||||||
<p>When relative path is enabled (<tt>_FS_RPATH >= 1</tt>), specified path is followed from the root directory if a heading separator is exist. If not, it is followed from the current directory of the drive set by <a href="chdir.html">f_chdir</a> function. Dot names are also allowed for the path names. The default drive is the current drive set by <a href="chdrive.html">f_chdrive</a> function.</p>
|
<p>When relative path is enabled (<tt>_FS_RPATH >= 1</tt>), specified path is followed from the root directory if a heading separator is exist. If not, it is followed from the current directory of the drive set by <a href="chdir.html"><tt>f_chdir</tt></a> function. Dot names are also allowed for the path names. The default drive is the current drive set by <a href="chdrive.html"><tt>f_chdrive</tt></a> function.</p>
|
||||||
<table class="lst2">
|
<table class="lst2">
|
||||||
<tr><td>Path name</td><td>_FS_RPATH == 0</td><td>_FS_RPATH >= 1</td></tr>
|
<tr><td>Path name</td><td>_FS_RPATH == 0</td><td>_FS_RPATH >= 1</td></tr>
|
||||||
<tr class="lst3"><td>file.txt</td><td>A file in the root directory of the drive 0</td><td>A file in the current directory of the current drive</td></tr>
|
<tr class="lst3"><td>file.txt</td><td>A file in the root directory of the drive 0</td><td>A file in the current directory of the current drive</td></tr>
|
||||||
@ -36,12 +36,12 @@
|
|||||||
<tr><td>/..</td><td>Invalid name</td><td>The root directory (sticks the top level)</td></tr>
|
<tr><td>/..</td><td>Invalid name</td><td>The root directory (sticks the top level)</td></tr>
|
||||||
</table>
|
</table>
|
||||||
<p>When option <tt><a href="config.html#str_volume_id">_STR_VOLUME_ID</a></tt> is specified, also pre-defined strings can be used as drive identifier in the path name instead of a numeral. e.g. <tt>"sd:file1.txt"</tt>, <tt>"ram:swapfile.dat"</tt> and DOS/Windows style drive letter, of course.</p>
|
<p>When option <tt><a href="config.html#str_volume_id">_STR_VOLUME_ID</a></tt> is specified, also pre-defined strings can be used as drive identifier in the path name instead of a numeral. e.g. <tt>"sd:file1.txt"</tt>, <tt>"ram:swapfile.dat"</tt> and DOS/Windows style drive letter, of course.</p>
|
||||||
<p><em>Remark: In this revision, R0.12, double dot name <tt>".."</tt> cannot follow the parent directory on the exFAT volume. It will work as <tt>"."</tt> and stay there.</em></p>
|
<p><em>Remark: In this revision, double dot name <tt>".."</tt> cannot follow the parent directory on the exFAT volume. It will work as <tt>"."</tt> and stay there.</em></p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="para doc" id="case">
|
<div class="para doc" id="case">
|
||||||
<h3>Legal Characters and Case Sensitivity</h3>
|
<h3>Legal Characters and Case Sensitivity</h3>
|
||||||
<p>On the FAT file system, legal characters for file name are, <tt>0-9 A-Z ! # $ % & ' ( ) - @ ^ _ ` { } ~</tt> and extended characters (<tt>\x80</tt>-<tt>\xFF</tt>). Under LFN supported system, also white space and <tt>+ , ; = [ ]</tt> are legal for the file name and the white spaces and periods can be placed anywhere in the name except for end of the name string.</p>
|
<p>On the FAT file system, legal characters for object name (file/directory name) are, <tt>0-9 A-Z ! # $ % & ' ( ) - @ ^ _ ` { } ~</tt> and extended characters (<tt>\x80</tt>-<tt>\xFF</tt>). Under LFN supported system, also <tt>+ , ; = [ ]</tt> and space are legal for the object name and the white spaces and periods can be placed anywhere in the path name except for end of the object name.</p>
|
||||||
<p>FAT file system is case-insensitive to the object names on the volume. All object names are compared in case-insensitive. For example, these three names, <tt>file.txt</tt>, <tt>File.Txt</tt> and <tt>FILE.TXT</tt>, are identical. This is applied to also extended charactres. When an object is created on the FAT volume, upper converted name is recorded to the SFN entry, and the raw name is recorded to the LFN entry.</p>
|
<p>FAT file system is case-insensitive to the object names on the volume. All object names are compared in case-insensitive. For example, these three names, <tt>file.txt</tt>, <tt>File.Txt</tt> and <tt>FILE.TXT</tt>, are identical. This is applied to also extended charactres. When an object is created on the FAT volume, upper converted name is recorded to the SFN entry, and the raw name is recorded to the LFN entry.</p>
|
||||||
<p>As for the DBCS language MS-DOS, it was case-sensitive to the extended characters. To follow this specification, FatFs works with case-sensitive to the extended characters at only non-LFN with DBCS configuration (DOS/DBCS specs). But at LFN configuration, FatFs works with case-insensitive to all characters (WindowsNT specs). This can cause a problem on compatibility with Windows system when an object with extended characters is created on the volume at non-LFN and DBCS configuration; therfore the object names with DBCS extended characters should not be used on the FAT volume shared by those systems.</p>
|
<p>As for the DBCS language MS-DOS, it was case-sensitive to the extended characters. To follow this specification, FatFs works with case-sensitive to the extended characters at only non-LFN with DBCS configuration (DOS/DBCS specs). But at LFN configuration, FatFs works with case-insensitive to all characters (WindowsNT specs). This can cause a problem on compatibility with Windows system when an object with extended characters is created on the volume at non-LFN and DBCS configuration; therfore the object names with DBCS extended characters should not be used on the FAT volume shared by those systems.</p>
|
||||||
</div>
|
</div>
|
||||||
|
@ -61,11 +61,11 @@ FRESULT f_findfirst (
|
|||||||
|
|
||||||
<div class="para desc">
|
<div class="para desc">
|
||||||
<h4>Description</h4>
|
<h4>Description</h4>
|
||||||
<p>After the directory specified by <tt class="arg">path</tt> could be opened, it starts to search the directory for the items with a name specified by <tt class="arg">pattern</tt>. If found, the information about the object is stored into the file information structure. For more information about file information structure, refer to <a href="readdir.html"><tt>f_readdir</tt></a> function.</p>
|
<p>After the directory specified by <tt class="arg">path</tt> could be opened, it starts to search the directory for items with the name specified by <tt class="arg">pattern</tt>. If the first item is found, the information about the object is stored into the file information structure. For more information about file information structure, refer to <a href="readdir.html"><tt>f_readdir</tt></a> function.</p>
|
||||||
<p>The matching pattern can contain wildcard characters (<tt>?</tt> and <tt>*</tt>). A <tt>?</tt> matches an any character and an <tt>*</tt> matches an any string in length of zero or longer. When support of long file name is enabled, only <tt>fname[]</tt> is tested at <tt>_USE_FIND == 1</tt> and also <tt>altname[]</tt> is tested at <tt>_USE_FIND == 2</tt>. In this revision, there are some differences listed below between FatFs and standard systems in matching condition.</p>
|
<p>The matching pattern can contain wildcard characters (<tt>?</tt> and <tt>*</tt>). A <tt>?</tt> matches an any character and an <tt>*</tt> matches an any string in length of zero or longer. When support of long file name is enabled, only <tt>fname[]</tt> is tested at <tt>_USE_FIND == 1</tt> and also <tt>altname[]</tt> is tested at <tt>_USE_FIND == 2</tt>. In this revision, there are some differences listed below between FatFs and standard systems in matching condition.</p>
|
||||||
<ul>
|
<ul>
|
||||||
<li><tt>"*.*"</tt> never matches any name without extension while it matches any names at the standard systems.</li>
|
<li><tt>"*.*"</tt> never matches any name without extension while it matches any name with or without extension at the standard systems.</li>
|
||||||
<li>Any patterns terminated with a period never matches any name while it matches any names without extensiton at the standard systems.</li>
|
<li>Any pattern terminated with a period never matches any name while it matches any name without extensiton at the standard systems.</li>
|
||||||
<li><a href="filename.html#case">DBCS extended characters</a> are compared in case-sensitive at LFN with non-Unicode configuration.</li>
|
<li><a href="filename.html#case">DBCS extended characters</a> are compared in case-sensitive at LFN with non-Unicode configuration.</li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
@ -82,7 +82,7 @@ FRESULT f_findfirst (
|
|||||||
<pre>
|
<pre>
|
||||||
<span class="c">/* Search a directory for objects and display it */</span>
|
<span class="c">/* Search a directory for objects and display it */</span>
|
||||||
|
|
||||||
void find_image (void)
|
void find_image_file (void)
|
||||||
{
|
{
|
||||||
FRESULT fr; <span class="c">/* Return value */</span>
|
FRESULT fr; <span class="c">/* Return value */</span>
|
||||||
DIR dj; <span class="c">/* Directory search object */</span>
|
DIR dj; <span class="c">/* Directory search object */</span>
|
||||||
@ -94,6 +94,7 @@ void find_image (void)
|
|||||||
printf("%s\n", fno.fname); <span class="c">/* Display the object name */</span>
|
printf("%s\n", fno.fname); <span class="c">/* Display the object name */</span>
|
||||||
fr = f_findnext(&dj, &fno); <span class="c">/* Search for next item */</span>
|
fr = f_findnext(&dj, &fno); <span class="c">/* Search for next item */</span>
|
||||||
}
|
}
|
||||||
|
|
||||||
f_closedir(&dj);
|
f_closedir(&dj);
|
||||||
}
|
}
|
||||||
</pre>
|
</pre>
|
||||||
|
@ -46,6 +46,7 @@ FRESULT f_forward (
|
|||||||
<a href="rc.html#de">FR_DISK_ERR</a>,
|
<a href="rc.html#de">FR_DISK_ERR</a>,
|
||||||
<a href="rc.html#ie">FR_INT_ERR</a>,
|
<a href="rc.html#ie">FR_INT_ERR</a>,
|
||||||
<a href="rc.html#io">FR_INVALID_OBJECT</a>,
|
<a href="rc.html#io">FR_INVALID_OBJECT</a>,
|
||||||
|
<a href="rc.html#dn">FR_DENIED</a>,
|
||||||
<a href="rc.html#tm">FR_TIMEOUT</a>
|
<a href="rc.html#tm">FR_TIMEOUT</a>
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
@ -114,7 +115,7 @@ FRESULT play_file (
|
|||||||
<span class="c">/* Repeat until the file pointer reaches end of the file */</span>
|
<span class="c">/* Repeat until the file pointer reaches end of the file */</span>
|
||||||
while (rc == FR_OK && !f_eof(&fil)) {
|
while (rc == FR_OK && !f_eof(&fil)) {
|
||||||
|
|
||||||
<span class="c">/* any other processes... */</span>
|
<span class="c">/* some processes... */</span>
|
||||||
|
|
||||||
<span class="c">/* Fill output stream periodicaly or on-demand */</span>
|
<span class="c">/* Fill output stream periodicaly or on-demand */</span>
|
||||||
rc = f_forward(&fil, out_stream, 1000, &dmy);
|
rc = f_forward(&fil, out_stream, 1000, &dmy);
|
||||||
|
@ -51,7 +51,7 @@ FRESULT f_getcwd (
|
|||||||
<div class="para desc">
|
<div class="para desc">
|
||||||
<h4>Description</h4>
|
<h4>Description</h4>
|
||||||
<p>The <tt>f_getcwd</tt> function retrieves full path name of the current directory of the current drive. When <tt>_VOLUMES</tt> is larger than 1, a logical drive number is added to top of the path name.</p>
|
<p>The <tt>f_getcwd</tt> function retrieves full path name of the current directory of the current drive. When <tt>_VOLUMES</tt> is larger than 1, a logical drive number is added to top of the path name.</p>
|
||||||
<p><em>Note: In this revision, R0.12, this function cannot retrieve the current directory path on the exFAT volume. It always returns the root directory path.</em></p>
|
<p><em>Note: In this revision, this function cannot retrieve the current directory path on the exFAT volume. It always returns the root directory path.</em></p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
@ -39,7 +39,7 @@ FRESULT f_mkdir (
|
|||||||
<a href="rc.html#nr">FR_NOT_READY</a>,
|
<a href="rc.html#nr">FR_NOT_READY</a>,
|
||||||
<a href="rc.html#np">FR_NO_PATH</a>,
|
<a href="rc.html#np">FR_NO_PATH</a>,
|
||||||
<a href="rc.html#in">FR_INVALID_NAME</a>,
|
<a href="rc.html#in">FR_INVALID_NAME</a>,
|
||||||
<a href="rc.html#de">FR_DENIED</a>,
|
<a href="rc.html#dn">FR_DENIED</a>,
|
||||||
<a href="rc.html#ex">FR_EXIST</a>,
|
<a href="rc.html#ex">FR_EXIST</a>,
|
||||||
<a href="rc.html#wp">FR_WRITE_PROTECTED</a>,
|
<a href="rc.html#wp">FR_WRITE_PROTECTED</a>,
|
||||||
<a href="rc.html#id">FR_INVALID_DRIVE</a>,
|
<a href="rc.html#id">FR_INVALID_DRIVE</a>,
|
||||||
|
@ -29,13 +29,13 @@ FRESULT f_mkfs (
|
|||||||
<h4>Parameters</h4>
|
<h4>Parameters</h4>
|
||||||
<dl class="par">
|
<dl class="par">
|
||||||
<dt>path</dt>
|
<dt>path</dt>
|
||||||
<dd>Pointer to the null-terminated string specifies the <a href="filename.html">logical drive</a> to be formatted. If there is no drive number in it, it means the default drive. The logical drive does not need to be mounted.</dd>
|
<dd>Pointer to the null-terminated string specifies the <a href="filename.html">logical drive</a> to be formatted. If there is no drive number in it, it means the default drive. The logical drive may or may not be mounted for the format process.</dd>
|
||||||
<dt>opt</dt>
|
<dt>opt</dt>
|
||||||
<dd>Specifies the format option in combination of <tt>FM_FAT</tt>, <tt>FM_FAT32</tt>, <tt>FM_EXFAT</tt> and bitwise-or of these three, <tt>FM_ANY</tt>. <tt>FM_EXFAT</tt> is ignored when exFAT is not enabled. These flags specify which FAT type to be created on the volume. If two or more types are specified, one out of them will be selected depends on the volume size. The flag <tt>FM_SFD</tt> specifies to place the volume on the drive in SFD format.</dd>
|
<dd>Specifies the format option in combination of <tt>FM_FAT</tt>, <tt>FM_FAT32</tt>, <tt>FM_EXFAT</tt> and bitwise-or of these three, <tt>FM_ANY</tt>. <tt>FM_EXFAT</tt> is ignored when exFAT is not enabled. These flags specify which FAT type to be created on the volume. If two or more types are specified, one out of them will be selected depends on the volume size. The flag <tt>FM_SFD</tt> specifies to place the volume on the drive in SFD format.</dd>
|
||||||
<dt>au</dt>
|
<dt>au</dt>
|
||||||
<dd>Specifies size of the allocation unit (cluter) in unit of byte. The valid value is N times the sector size. N is power of 2 from 1 to 128 for FAT volume and upto 16MiB for exFAT volume. If zero is given, the default allocation unit size is selected depends on the volume size.</dd>
|
<dd>Specifies size of the allocation unit (cluter) in unit of byte. The valid value is <tt>n</tt> times the sector size. The <tt>n</tt> is power of 2 from 1 to 128 for FAT volume and upto 16MiB for exFAT volume. If zero is given, the default allocation unit size is selected depends on the volume size.</dd>
|
||||||
<dt>work</dt>
|
<dt>work</dt>
|
||||||
<dd>Pointer to the working buffer for the format process.</dd>
|
<dd>Pointer to the working buffer used for the format process.</dd>
|
||||||
<dt>len</dt>
|
<dt>len</dt>
|
||||||
<dd>Size of the working buffer in unit of byte. It needs to be the sector size at least. Plenty of working buffer reduces number of write transaction to the device and the format process will be finished quickly.</dd>
|
<dd>Size of the working buffer in unit of byte. It needs to be the sector size at least. Plenty of working buffer reduces number of write transaction to the device and the format process will be finished quickly.</dd>
|
||||||
</dl>
|
</dl>
|
||||||
@ -78,7 +78,7 @@ int main (void)
|
|||||||
FIL fil; <span class="c">/* File object */</span>
|
FIL fil; <span class="c">/* File object */</span>
|
||||||
FRESULT res; <span class="c">/* API result code */</span>
|
FRESULT res; <span class="c">/* API result code */</span>
|
||||||
UINT bw; <span class="c">/* Bytes written */</span>
|
UINT bw; <span class="c">/* Bytes written */</span>
|
||||||
BYTE work[_MAX_SS]; <span class="c">/* Work area (larger is better for process time) */</span>
|
BYTE work[_MAX_SS]; <span class="c">/* Work area (larger is better for processing time) */</span>
|
||||||
|
|
||||||
|
|
||||||
<span class="c">/* Create FAT volume */</span>
|
<span class="c">/* Create FAT volume */</span>
|
||||||
|
@ -31,7 +31,7 @@ FRESULT f_mount (
|
|||||||
<dt>path</dt>
|
<dt>path</dt>
|
||||||
<dd>Pointer to the null-terminated string that specifies the <a href="filename.html">logical drive</a>. The string without drive number means the default drive.</dd>
|
<dd>Pointer to the null-terminated string that specifies the <a href="filename.html">logical drive</a>. The string without drive number means the default drive.</dd>
|
||||||
<dt>opt</dt>
|
<dt>opt</dt>
|
||||||
<dd>Initialization option. 0: Do not mount now (to be mounted later), 1: Force mounted the volume to check if the volume is ready to work.</dd>
|
<dd>Mounting option. 0: Do not mount now (to be mounted on the first access to the volume), 1: Force mounted the volume to check if it is ready to work.</dd>
|
||||||
</dl>
|
</dl>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@ -54,15 +54,15 @@ FRESULT f_mount (
|
|||||||
<li>Determines the logical drive which specified by <tt class="arg">path</tt>.</li>
|
<li>Determines the logical drive which specified by <tt class="arg">path</tt>.</li>
|
||||||
<li>Clears and unregisters the regsitered work area of the drive if exist.</li>
|
<li>Clears and unregisters the regsitered work area of the drive if exist.</li>
|
||||||
<li>Clears and registers the new work area to the drive if <tt class="arg">fs</tt> is not NULL.</li>
|
<li>Clears and registers the new work area to the drive if <tt class="arg">fs</tt> is not NULL.</li>
|
||||||
<li>Performs volume mount process to the drive if forced mount is specified.</li>
|
<li>Performs volume mount process to the drive if forced mounting is specified.</li>
|
||||||
</ol>
|
</ol>
|
||||||
<p>The file system object is the work area needed for each logical drive. It must be given to the logical drive with this function prior to use any other file functions except for <tt>f_fdisk</tt> function to the logical drive. To unregister the work area, specify a NULL to the <tt class="arg">fs</tt>, and then the work area can be discarded.</p>
|
<p>The file system object is the work area needed for each logical drive. It must be given to the logical drive with this function prior to use any API functions except for <tt>f_mkfs/f_fdisk</tt> function to the logical drive.</p>
|
||||||
<p>If forced mounting is not specified, this function always succeeds regardless of the physical drive status due to delayed mount feature. It only clears (de-initializes) the given work area and registers its address to the internal table. There is no activity of the physical drive in this function. It can also be used to force de-initialized the registered work area of a logical drive. The volume mount processes, initialize the corresponding physical drive, find the FAT volume in it and initialize the work area, is performed in the subsequent file access functions when either or both of following condition is true.</p>
|
<p>If forced mounting is not specified (<tt>opt = 0</tt>), this function always succeeds regardless of the physical drive status. It only clears (de-initializes) the given work area and registers its address to the internal table and no activity of the physical drive in this function. To unregister the work area, specify a NULL to the <tt class="arg">fs</tt>, and then the work area can be discarded. The volume mount processes, initialize the corresponding physical drive, find the FAT volume in it and initialize the work area, is performed in the subsequent file access functions when either or both of following condition is true.</p>
|
||||||
<ul>
|
<ul>
|
||||||
<li>File system object is not initialized. It is de-initialized by <tt>f_mount</tt> function.</li>
|
<li>File system object has not been initialized. It is de-initialized by <tt>f_mount</tt> function.</li>
|
||||||
<li>Physical drive is not initialized. It is de-initialized by system reset or media removal.</li>
|
<li>Physical drive is not initialized. It is de-initialized by system reset or media removal.</li>
|
||||||
</ul>
|
</ul>
|
||||||
<p>If the function with forced mounting failed, it means that the file system object has been registered successfully but the volume is currently not ready to work. The volume mount process will also be attempted at subsequent file access functions.</p>
|
<p>If the function with forced mounting (<tt>opt = 1</tt>) failed, it means that the file system object has been registered successfully but the volume is currently not ready to work. The volume mount process will be attempted at subsequent file access functions if the file system object is not initialized. (delayed mounting)</p>
|
||||||
<p>If implementation of the disk I/O layer lacks media change detection, application program needs to perform a <tt>f_mount</tt> function after each media change to force cleared the file system object.</p>
|
<p>If implementation of the disk I/O layer lacks media change detection, application program needs to perform a <tt>f_mount</tt> function after each media change to force cleared the file system object.</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
@ -40,7 +40,7 @@ FRESULT f_open (
|
|||||||
<tr><td>FA_CREATE_NEW</td><td>Creates a new file. The function fails with <tt>FR_EXIST</tt> if the file is existing.</td></tr>
|
<tr><td>FA_CREATE_NEW</td><td>Creates a new file. The function fails with <tt>FR_EXIST</tt> if the file is existing.</td></tr>
|
||||||
<tr><td>FA_CREATE_ALWAYS</td><td>Creates a new file. If the file is existing, it will be truncated and overwritten.</td></tr>
|
<tr><td>FA_CREATE_ALWAYS</td><td>Creates a new file. If the file is existing, it will be truncated and overwritten.</td></tr>
|
||||||
<tr><td>FA_OPEN_ALWAYS</td><td>Opens the file if it is existing. If not, a new file will be created.</td></tr>
|
<tr><td>FA_OPEN_ALWAYS</td><td>Opens the file if it is existing. If not, a new file will be created.</td></tr>
|
||||||
<tr><td>FA_OPEN_APPEND</td><td>Same as <tt>FA_OPEN_ALWAYS</tt> except read/write pointer is set end of the file.</td></tr>
|
<tr><td>FA_OPEN_APPEND</td><td>Same as <tt>FA_OPEN_ALWAYS</tt> except the read/write pointer is set end of the file.</td></tr>
|
||||||
</table>
|
</table>
|
||||||
</dd>
|
</dd>
|
||||||
</dl>
|
</dl>
|
||||||
@ -57,7 +57,7 @@ FRESULT f_open (
|
|||||||
<a href="rc.html#ok">FR_NO_FILE</a>,
|
<a href="rc.html#ok">FR_NO_FILE</a>,
|
||||||
<a href="rc.html#np">FR_NO_PATH</a>,
|
<a href="rc.html#np">FR_NO_PATH</a>,
|
||||||
<a href="rc.html#in">FR_INVALID_NAME</a>,
|
<a href="rc.html#in">FR_INVALID_NAME</a>,
|
||||||
<a href="rc.html#de">FR_DENIED</a>,
|
<a href="rc.html#dn">FR_DENIED</a>,
|
||||||
<a href="rc.html#ex">FR_EXIST</a>,
|
<a href="rc.html#ex">FR_EXIST</a>,
|
||||||
<a href="rc.html#io">FR_INVALID_OBJECT</a>,
|
<a href="rc.html#io">FR_INVALID_OBJECT</a>,
|
||||||
<a href="rc.html#wp">FR_WRITE_PROTECTED</a>,
|
<a href="rc.html#wp">FR_WRITE_PROTECTED</a>,
|
||||||
@ -74,7 +74,7 @@ FRESULT f_open (
|
|||||||
|
|
||||||
<div class="para desc">
|
<div class="para desc">
|
||||||
<h4>Description</h4>
|
<h4>Description</h4>
|
||||||
<p>Before using any file function, a work area (file system object) must be registered to the logical drive with <a href="mount.html"><tt>f_mount</tt></a> function. All API functions except for <tt>f_mkfs</tt> and <tt>f_fdisk</tt> function can work after this procedure.</p>
|
<p>Before using any file function, a work area (file system object) needs to be registered to the logical drive with <a href="mount.html"><tt>f_mount</tt></a> function. All API functions except for <tt>f_mkfs/f_fdisk</tt> function get ready to work after this procedure.</p>
|
||||||
<p>After <tt>f_open</tt> function succeeded, the file object is valid. The file object is used for subsequent operations to the file to identify the file. Open file must be closed prior to power down, media removal or re-mount, or the file can be collapsed. To close an open file, use <a href="close.html"><tt>f_close</tt></a> function.</p>
|
<p>After <tt>f_open</tt> function succeeded, the file object is valid. The file object is used for subsequent operations to the file to identify the file. Open file must be closed prior to power down, media removal or re-mount, or the file can be collapsed. To close an open file, use <a href="close.html"><tt>f_close</tt></a> function.</p>
|
||||||
<p>If duplicated file open is needed, read <a href="appnote.html#dup">here</a> carefully. However duplicated open of a file with any write mode flag is always prohibited.</p>
|
<p>If duplicated file open is needed, read <a href="appnote.html#dup">here</a> carefully. However duplicated open of a file with any write mode flag is always prohibited.</p>
|
||||||
</div>
|
</div>
|
||||||
|
@ -39,7 +39,7 @@ int f_printf (
|
|||||||
|
|
||||||
<div class="para ret">
|
<div class="para ret">
|
||||||
<h4>Return Values</h4>
|
<h4>Return Values</h4>
|
||||||
<p>When the function succeeded, it returns number of characters written. When the function failed due to disk full or any error, an <tt>EOF (-1)</tt> will be returned.</p>
|
<p>When the function succeeded, it returns number of characters written. If the function could not write the generated string to the file due to disk full or an error, <tt>EOF (-1)</tt> will be returned.</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
@ -6,12 +6,12 @@
|
|||||||
<link rel="up" title="FatFs" href="../00index_e.html">
|
<link rel="up" title="FatFs" href="../00index_e.html">
|
||||||
<link rel="alternate" hreflang="ja" title="Japanese" href="../ja/rc.html">
|
<link rel="alternate" hreflang="ja" title="Japanese" href="../ja/rc.html">
|
||||||
<link rel="stylesheet" href="../css_e.css" type="text/css" media="screen" title="ELM Default">
|
<link rel="stylesheet" href="../css_e.css" type="text/css" media="screen" title="ELM Default">
|
||||||
<title>FatFs - Return Codes</title>
|
<title>FatFs - API Return Code</title>
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
<h1>Return Code of the File Functions</h1>
|
<h1>Return Code of API Functions</h1>
|
||||||
<p>On the FatFs API, most of file functions return common result code as enum type <tt>FRESULT</tt>. When a function succeeded, it returns zero, otherwise returns non-zero value that indicates type of error.</p>
|
<p>Most of API functions return common result code as enum type <tt>FRESULT</tt>. When an API function succeeded, it returns zero (<tt>FR_OK</tt>), otherwise it returns non-zero value indicates type of error.</p>
|
||||||
|
|
||||||
<dl class="ret">
|
<dl class="ret">
|
||||||
|
|
||||||
@ -25,7 +25,8 @@
|
|||||||
<dd>Assertion failed. An insanity is detected in the internal process. One of the following possibilities is suspected.
|
<dd>Assertion failed. An insanity is detected in the internal process. One of the following possibilities is suspected.
|
||||||
<ul>
|
<ul>
|
||||||
<li>Work area (file system object, file object or etc...) has been broken by stack overflow or any other tasks. This is the reason in most case.</li>
|
<li>Work area (file system object, file object or etc...) has been broken by stack overflow or any other tasks. This is the reason in most case.</li>
|
||||||
<li>There is any error of the FAT structure on the volume.</li>
|
<li>There is an error of the FAT structure on the volume.</li>
|
||||||
|
<li>There is a bug in the FatFs module itself.</li>
|
||||||
</ul>
|
</ul>
|
||||||
Note that if once this error occured at any operation to an open file, the file object is aborted and all operations to the file except for close will be rejected.
|
Note that if once this error occured at any operation to an open file, the file object is aborted and all operations to the file except for close will be rejected.
|
||||||
</dd>
|
</dd>
|
||||||
@ -50,25 +51,25 @@ Note that if once this error occured at any operation to an open file, the file
|
|||||||
<li>Deleting the non-empty directory or current directory.</li>
|
<li>Deleting the non-empty directory or current directory.</li>
|
||||||
<li>Reading the file opened without <tt>FA_READ</tt> flag.</li>
|
<li>Reading the file opened without <tt>FA_READ</tt> flag.</li>
|
||||||
<li>Any modification to the file opened without <tt>FA_WRITE</tt> flag.</li>
|
<li>Any modification to the file opened without <tt>FA_WRITE</tt> flag.</li>
|
||||||
<li>Could not create the file or directory due to the directory table is full.</li>
|
<li>Could not create the object due to root directory full or disk full.</li>
|
||||||
<li>Could not allocate a contiguous area to the file.</li>
|
<li>Could not allocate a contiguous area to the file.</li>
|
||||||
</ul>
|
</ul>
|
||||||
</dd>
|
</dd>
|
||||||
|
|
||||||
<dt id="ex">FR_EXIST</dt>
|
<dt id="ex">FR_EXIST</dt>
|
||||||
<dd>Name collision. Any object that has the same name is already existing.</dd>
|
<dd>Name collision. An object with the same name is already existing.</dd>
|
||||||
|
|
||||||
<dt id="io">FR_INVALID_OBJECT</dt>
|
<dt id="io">FR_INVALID_OBJECT</dt>
|
||||||
<dd>The file/directory object is invalid or a null pointer is given. There are some reasons as follows:
|
<dd>The file/directory object is invalid or a null pointer is given. There are some reasons as follows:
|
||||||
<ul>
|
<ul>
|
||||||
<li>It has been closed, it is not opened or it can be collapsed.</li>
|
<li>It has been closed, it has not been opened or it has been collapsed.</li>
|
||||||
<li>It has been invalidated by a voulme mount process. All open objects of the volume are invalidated as well.</li>
|
<li>It has been invalidated by a voulme mount process. Open objects on the volume are invalidated by voulme mount process.</li>
|
||||||
<li>The corresponding physical drive is not ready due to a media removal.</li>
|
<li>Physical drive is not ready to work due to a media removal.</li>
|
||||||
</ul>
|
</ul>
|
||||||
</dd>
|
</dd>
|
||||||
|
|
||||||
<dt id="wp">FR_WRITE_PROTECTED</dt>
|
<dt id="wp">FR_WRITE_PROTECTED</dt>
|
||||||
<dd>Any write mode operation against the write-protected media.</dd>
|
<dd>A write mode operation against the write-protected media.</dd>
|
||||||
|
|
||||||
<dt id="id">FR_INVALID_DRIVE</dt>
|
<dt id="id">FR_INVALID_DRIVE</dt>
|
||||||
<dd>Invalid drive number is specified in the path name. A null pointer is given as the path name. (Related option: <tt><a href="config.html#volumes">_VOLUMES</a></tt>)</dd>
|
<dd>Invalid drive number is specified in the path name. A null pointer is given as the path name. (Related option: <tt><a href="config.html#volumes">_VOLUMES</a></tt>)</dd>
|
||||||
@ -107,7 +108,7 @@ Note that if once this error occured at any operation to an open file, the file
|
|||||||
<dd>Number of open objects has been reached maximum value and no more object can be opened. (Related option: <tt><a href="config.html#fs_lock">_FS_LOCK</a></tt>)</dd>
|
<dd>Number of open objects has been reached maximum value and no more object can be opened. (Related option: <tt><a href="config.html#fs_lock">_FS_LOCK</a></tt>)</dd>
|
||||||
|
|
||||||
<dt id="ip">FR_INVALID_PARAMETER</dt>
|
<dt id="ip">FR_INVALID_PARAMETER</dt>
|
||||||
<dd>The given parameter is invalid or there is any inconsistent.</dd>
|
<dd>The given parameter is invalid or there is an inconsistent for the volume.</dd>
|
||||||
</dl>
|
</dl>
|
||||||
|
|
||||||
<p class="foot"><a href="../00index_e.html">Return</a></p>
|
<p class="foot"><a href="../00index_e.html">Return</a></p>
|
||||||
|
@ -45,6 +45,7 @@ FRESULT f_read (
|
|||||||
<a href="rc.html#ok">FR_OK</a>,
|
<a href="rc.html#ok">FR_OK</a>,
|
||||||
<a href="rc.html#de">FR_DISK_ERR</a>,
|
<a href="rc.html#de">FR_DISK_ERR</a>,
|
||||||
<a href="rc.html#ie">FR_INT_ERR</a>,
|
<a href="rc.html#ie">FR_INT_ERR</a>,
|
||||||
|
<a href="rc.html#dn">FR_DENIED</a>,
|
||||||
<a href="rc.html#io">FR_INVALID_OBJECT</a>,
|
<a href="rc.html#io">FR_INVALID_OBJECT</a>,
|
||||||
<a href="rc.html#tm">FR_TIMEOUT</a>
|
<a href="rc.html#tm">FR_TIMEOUT</a>
|
||||||
</p>
|
</p>
|
||||||
@ -53,7 +54,7 @@ FRESULT f_read (
|
|||||||
|
|
||||||
<div class="para desc">
|
<div class="para desc">
|
||||||
<h4>Description</h4>
|
<h4>Description</h4>
|
||||||
<p>The function starts to read data from the file at the position pointed by the read/write pointer. The read/write pointer advances as number of bytes read. After the function succeeded, <tt class="arg">*br</tt> should be checked to detect end of the file. In case of <tt class="arg">*br</tt> is less than <tt class="arg">btr</tt>, it means the read/write pointer reached end of the file during read operation.</p>
|
<p>The function starts to read data from the file at the position pointed by the read/write pointer. The read/write pointer advances as number of bytes read. After the function succeeded, <tt class="arg">*br</tt> should be checked to detect end of the file. In case of <tt class="arg">*br</tt> < <tt class="arg">btr</tt>, it means the read/write pointer reached end of the file during read operation.</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
|
|
||||||
<div class="para func">
|
<div class="para func">
|
||||||
<h2>f_rename</h2>
|
<h2>f_rename</h2>
|
||||||
<p>Renames a file or sub-directory.</p>
|
<p>The f_rename function renames and/or moves a file or sub-directory.</p>
|
||||||
<pre>
|
<pre>
|
||||||
FRESULT f_rename (
|
FRESULT f_rename (
|
||||||
const TCHAR* <span class="arg">old_name</span>, <span class="c">/* [IN] Old object name */</span>
|
const TCHAR* <span class="arg">old_name</span>, <span class="c">/* [IN] Old object name */</span>
|
||||||
@ -28,7 +28,7 @@ FRESULT f_rename (
|
|||||||
<dt>old_name</dt>
|
<dt>old_name</dt>
|
||||||
<dd>Pointer to a null-terminated string that specifies the existing <a href="filename.html">file or sub-directory</a> to be renamed.</dd>
|
<dd>Pointer to a null-terminated string that specifies the existing <a href="filename.html">file or sub-directory</a> to be renamed.</dd>
|
||||||
<dt>new_name</dt>
|
<dt>new_name</dt>
|
||||||
<dd>Pointer to a null-terminated string that specifies the new object name. Any drive number may be specified in this string but it is ignored and assumed as the same drive of the <tt class="arg">old_name</tt>.</dd>
|
<dd>Pointer to a null-terminated string that specifies the new object name. A drive number may be specified in this string but it is ignored and assumed as the same drive of the <tt class="arg">old_name</tt>. Any object with this path name except <tt class="arg">old_name</tt> must not be exist, or the function fails with <tt>FR_EXIST</tt>.</dd>
|
||||||
</dl>
|
</dl>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@ -43,7 +43,6 @@ FRESULT f_rename (
|
|||||||
<a href="rc.html#ok">FR_NO_FILE</a>,
|
<a href="rc.html#ok">FR_NO_FILE</a>,
|
||||||
<a href="rc.html#np">FR_NO_PATH</a>,
|
<a href="rc.html#np">FR_NO_PATH</a>,
|
||||||
<a href="rc.html#in">FR_INVALID_NAME</a>,
|
<a href="rc.html#in">FR_INVALID_NAME</a>,
|
||||||
<a href="rc.html#de">FR_DENIED</a>,
|
|
||||||
<a href="rc.html#ex">FR_EXIST</a>,
|
<a href="rc.html#ex">FR_EXIST</a>,
|
||||||
<a href="rc.html#wp">FR_WRITE_PROTECTED</a>,
|
<a href="rc.html#wp">FR_WRITE_PROTECTED</a>,
|
||||||
<a href="rc.html#id">FR_INVALID_DRIVE</a>,
|
<a href="rc.html#id">FR_INVALID_DRIVE</a>,
|
||||||
@ -58,7 +57,7 @@ FRESULT f_rename (
|
|||||||
|
|
||||||
<div class="para desc">
|
<div class="para desc">
|
||||||
<h4>Description</h4>
|
<h4>Description</h4>
|
||||||
<p>Renames a file or sub-directory and can also move it to other directory in the same logical drive. The object to be renamed must not be an open object, or <em>the FAT volume can be collapsed</em>. Such the wrong operation can be rejected safely when <a href="appnote.html#dup">file lock feature</a> is enabled.</p>
|
<p>Renames a file or sub-directory and can also move it to other directory in the same volume. The object to be renamed must not be an open object, or <em>the FAT volume can be collapsed</em>. Such the wrong operation is rejected safely when <a href="appnote.html#dup">file lock function</a> is enabled.</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
@ -77,7 +76,7 @@ FRESULT f_rename (
|
|||||||
<span class="c">/* Rename an object in the drive 2 */</span>
|
<span class="c">/* Rename an object in the drive 2 */</span>
|
||||||
f_rename("2:oldname.txt", "newname.txt");
|
f_rename("2:oldname.txt", "newname.txt");
|
||||||
|
|
||||||
<span class="c">/* Rename an object and move it to other directory */</span>
|
<span class="c">/* Rename an object and move it to other directory in the volume */</span>
|
||||||
f_rename("log.txt", "old/log0001.txt");
|
f_rename("log.txt", "old/log0001.txt");
|
||||||
</pre>
|
</pre>
|
||||||
</div>
|
</div>
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
|
|
||||||
<div class="para">
|
<div class="para">
|
||||||
<h2>FATFS</h2>
|
<h2>FATFS</h2>
|
||||||
<p>The <tt>FATFS</tt> structure (file system object) holds dynamic work area of individual logical drives. It is given by application program and registerd/unregisterd to the FatFs module with <tt>f_mount</tt> function. Initialization is done on first API call after <tt>f_mount</tt> function or media change. Application program must not modify any member in this structure, or any data on the FAT volume can be collapsed.</p>
|
<p>The <tt>FATFS</tt> structure (file system object) holds dynamic work area of individual logical drives. It is given by application program and registerd/unregisterd to the FatFs module with <tt>f_mount</tt> function. Initialization of the structure is done by volume mount process whenever necessary. Application program must not modify any member in this structure, or the FAT volume can be collapsed.</p>
|
||||||
<pre>
|
<pre>
|
||||||
<span class="k">typedef</span> <span class="k">struct</span> {
|
<span class="k">typedef</span> <span class="k">struct</span> {
|
||||||
BYTE fs_type; <span class="c">/* File system type (0, FS_FAT12, FS_FAT16, FS_FAT32 or FS_EXFAT) */</span>
|
BYTE fs_type; <span class="c">/* File system type (0, FS_FAT12, FS_FAT16, FS_FAT32 or FS_EXFAT) */</span>
|
||||||
|
@ -33,7 +33,7 @@
|
|||||||
<h4>Members</h4>
|
<h4>Members</h4>
|
||||||
<dl>
|
<dl>
|
||||||
<dt>fsize</dt>
|
<dt>fsize</dt>
|
||||||
<dd>Indicates size of the file in unit of byte. Always zero for directories. <tt>FSIZE_t</tt> is an alias of integer type either <tt>DWORD</tt>(32-bit) or <tt>QWORD</tt>(64-bit) depends on the configuration option <tt>_FS_EXFAT</tt>.</dd>
|
<dd>Indicates size of the file in unit of byte. <tt>FSIZE_t</tt> is an alias of integer type either <tt>DWORD</tt>(32-bit) or <tt>QWORD</tt>(64-bit) depends on the configuration option <tt>_FS_EXFAT</tt>. Do not care when the item is a directory.</dd>
|
||||||
<dt>fdate</dt>
|
<dt>fdate</dt>
|
||||||
<dd>Indicates the date when the file was modified or the directory was created.<br>
|
<dd>Indicates the date when the file was modified or the directory was created.<br>
|
||||||
<dl>
|
<dl>
|
||||||
|
@ -40,7 +40,7 @@ FRESULT f_unlink (
|
|||||||
<a href="rc.html#ok">FR_NO_FILE</a>,
|
<a href="rc.html#ok">FR_NO_FILE</a>,
|
||||||
<a href="rc.html#np">FR_NO_PATH</a>,
|
<a href="rc.html#np">FR_NO_PATH</a>,
|
||||||
<a href="rc.html#in">FR_INVALID_NAME</a>,
|
<a href="rc.html#in">FR_INVALID_NAME</a>,
|
||||||
<a href="rc.html#de">FR_DENIED</a>,
|
<a href="rc.html#dn">FR_DENIED</a>,
|
||||||
<a href="rc.html#ex">FR_EXIST</a>,
|
<a href="rc.html#ex">FR_EXIST</a>,
|
||||||
<a href="rc.html#wp">FR_WRITE_PROTECTED</a>,
|
<a href="rc.html#wp">FR_WRITE_PROTECTED</a>,
|
||||||
<a href="rc.html#id">FR_INVALID_DRIVE</a>,
|
<a href="rc.html#id">FR_INVALID_DRIVE</a>,
|
||||||
|
@ -45,6 +45,7 @@ FRESULT f_write (
|
|||||||
<a href="rc.html#ok">FR_OK</a>,
|
<a href="rc.html#ok">FR_OK</a>,
|
||||||
<a href="rc.html#de">FR_DISK_ERR</a>,
|
<a href="rc.html#de">FR_DISK_ERR</a>,
|
||||||
<a href="rc.html#ie">FR_INT_ERR</a>,
|
<a href="rc.html#ie">FR_INT_ERR</a>,
|
||||||
|
<a href="rc.html#dn">FR_DENIED</a>,
|
||||||
<a href="rc.html#io">FR_INVALID_OBJECT</a>,
|
<a href="rc.html#io">FR_INVALID_OBJECT</a>,
|
||||||
<a href="rc.html#tm">FR_TIMEOUT</a>
|
<a href="rc.html#tm">FR_TIMEOUT</a>
|
||||||
</p>
|
</p>
|
||||||
@ -53,7 +54,7 @@ FRESULT f_write (
|
|||||||
|
|
||||||
<div class="para desc">
|
<div class="para desc">
|
||||||
<h4>Description</h4>
|
<h4>Description</h4>
|
||||||
<p>The function starts to write data to the file at the position pointed by the read/write pointer. The read/write pointer advances as number of bytes written. After the function succeeded, <tt class="arg">*bw</tt> should be checked to detect the disk full. In case of <tt class="arg">*bw</tt> is less than <tt class="arg">btw</tt>, it means the volume got full during the write operation. The function can take a time when the volume is full or close to full.</p>
|
<p>The function starts to write data to the file at the position pointed by the read/write pointer. The read/write pointer advances as number of bytes written. After the function succeeded, <tt class="arg">*bw</tt> should be checked to detect the disk full. In case of <tt class="arg">*bw</tt> < <tt class="arg">btw</tt>, it means the volume got full during the write operation. The function can take a time when the volume is full or close to full.</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
@ -47,7 +47,7 @@ FatFsモジュールはANSI C(C89)準拠で記述されているので、普通
|
|||||||
<p><img src="../res/funcs.png" width="750" height="420" alt="functional diagram"></p>
|
<p><img src="../res/funcs.png" width="750" height="420" alt="functional diagram"></p>
|
||||||
|
|
||||||
<h4>ユーザの作成する関数</h4>
|
<h4>ユーザの作成する関数</h4>
|
||||||
<p>ポーティング作業は、要求されるデバイス制御関数を用意することが全てで、それ以外にすることは何もありません。既に動作しているデバイス制御モジュールがあるなら、そのAPIをFatFsに合わせるかグルー関数を介してつなぐだけで済みますが、無い場合はほかから移植するか最初から書くかする必要があります。定義されている全ての関数が常に必要なわけではありません。例えば、リード オンリ構成では書き込み系関数は必要ありません。次の表に構成オプションと要求される関数の対応を示します。</p>
|
<p>ポーティング作業は、要求されるデバイス制御関数を用意することが全てで、それ以外にすることは何もありません。既に動作しているデバイス制御モジュールがあるなら、そのインターフェースをFatFsに合わせるかグルー関数を介してつなぐだけで済みますが、無い場合はほかから移植するか最初から書くかする必要があります。定義されている全ての関数が常に必要なわけではありません。例えば、リード オンリ構成では書き込み系関数は必要ありません。次の表に構成オプションと要求される関数の対応を示します。</p>
|
||||||
<table class="lst2">
|
<table class="lst2">
|
||||||
<tr><th>必要な関数</th><th>必要となる条件</th><th>備考</th></tr>
|
<tr><th>必要な関数</th><th>必要となる条件</th><th>備考</th></tr>
|
||||||
<tr><td>disk_status<br>disk_initialize<br>disk_read</td><td>常時</td><td rowspan="5">ffsample.zip (サンプル)<br>その他web上に多数</td></tr>
|
<tr><td>disk_status<br>disk_initialize<br>disk_read</td><td>常時</td><td rowspan="5">ffsample.zip (サンプル)<br>その他web上に多数</td></tr>
|
||||||
@ -81,16 +81,16 @@ FatFsモジュールはANSI C(C89)準拠で記述されているので、普通
|
|||||||
<tr><th></th><th>ARM7<small><br>32bit</small></th><th>ARM7<small><br>Thumb</small></th><th>CM3<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><th></th><th>ARM7<small><br>32bit</small></th><th>ARM7<small><br>Thumb</small></th><th>CM3<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 class="cal"> <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>MSC</td></tr>
|
<tr class="cal"> <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>MSC</td></tr>
|
||||||
<!-- ARM Thumb CM3 AVR H8 PIC24 RL78 V850ES SH-2A RX600 IA-32 -->
|
<!-- ARM Thumb CM3 AVR H8 PIC24 RL78 V850ES SH-2A RX600 IA-32 -->
|
||||||
<tr class="ral"><td class="cal">text (Full, R/W)</td><td>10.1k</td><td>6.6k</td><td>6.2k</td><td>12.1k</td><td>10.5k</td><td>11.2k</td><td>12.6k</td><td>8.5k</td><td>8.7k</td><td>6.3k</td><td>8.4k</td></tr>
|
<tr class="ral"><td class="cal">text (Full, R/W)</td><td>10.4k</td><td>6.8k</td><td>6.3k</td><td>12.4k</td> <td>9.8k</td><td>11.1k</td><td>12.8k</td><td>8.6k</td><td>8.9k</td><td>6.4k</td><td>8.5k</td></tr>
|
||||||
<tr class="ral"><td class="cal">text (Min, R/W)</td> <td>6.6k</td><td>4.5k</td><td>4.2k</td> <td>7.9k</td> <td>7.0k</td> <td>7.6k</td> <td>8.8k</td><td>5.9k</td><td>5.8k</td><td>4.3k</td><td>5.8k</td></tr>
|
<tr class="ral"><td class="cal">text (Min, R/W)</td> <td>6.8k</td><td>4.6k</td><td>4.3k</td> <td>8.2k</td> <td>6.7k</td> <td>7.6k</td> <td>9.1k</td><td>6.0k</td><td>5.9k</td><td>4.5k</td><td>5.9k</td></tr>
|
||||||
<tr class="ral"><td class="cal">text (Full, R/O)</td> <td>4.8k</td><td>3.1k</td><td>2.9k</td> <td>5.8k</td> <td>5.1k</td> <td>5.5k</td> <td>6.4k</td><td>4.1k</td><td>4.0k</td><td>3.1k</td><td>4.0k</td></tr>
|
<tr class="ral"><td class="cal">text (Full, R/O)</td> <td>4.8k</td><td>3.1k</td><td>2.8k</td> <td>5.6k</td> <td>4.6k</td> <td>5.3k</td> <td>6.3k</td><td>4.0k</td><td>3.9k</td><td>3.0k</td><td>3.9k</td></tr>
|
||||||
<tr class="ral"><td class="cal">text (Min, R/O)</td> <td>3.5k</td><td>2.4k</td><td>2.3k</td> <td>4.4k</td> <td>3.9k</td> <td>4.2k</td> <td>5.0k</td><td>3.3k</td><td>3.1k</td><td>2.4k</td><td>3.1k</td></tr>
|
<tr class="ral"><td class="cal">text (Min, R/O)</td> <td>3.6k</td><td>2.4k</td><td>2.3k</td> <td>4.4k</td> <td>3.5k</td> <td>4.0k</td> <td>4.9k</td><td>3.3k</td><td>3.0k</td><td>2.4k</td><td>3.1k</td></tr>
|
||||||
<tr class="ral"><td class="cal">bss</td><td>V*4 + 2</td><td>V*4 + 2</td><td>V*4 + 2</td><td>V*2 + 2</td><td>V*4 + 2</td><td>V*2 + 2</td><td>V*2 + 2</td><td>V*4 + 2</td><td>V*4 + 2</td><td>V*4 + 2</td><td>V*4 + 2</td></tr>
|
<tr class="ral"><td class="cal">bss</td><td>V*4 + 2</td><td>V*4 + 2</td><td>V*4 + 2</td><td>V*2 + 2</td><td>V*4 + 2</td><td>V*2 + 2</td><td>V*2 + 2</td><td>V*4 + 2</td><td>V*4 + 2</td><td>V*4 + 2</td><td>V*4 + 2</td></tr>
|
||||||
<tr class="ral"><td class="cal">Work area<br><small>(_FS_TINY == 0)</small></td><td>V*564<br>+ F*552</td><td>V*564<br>+ F*552</td><td>V*564<br>+ F*552</td><td>V*560<br>+ F*546</td><td>V*560<br>+ F*546</td><td>V*560<br>+ F*546</td><td>V*560<br>+ F*546</td><td>V*564<br>+ F*552</td><td>V*564<br>+ F*552</td><td>V*564<br>+ F*552</td><td>V*564<br>+ F*552</td></tr>
|
<tr class="ral"><td class="cal">Work area<br><small>(_FS_TINY == 0)</small></td><td>V*564<br>+ F*552</td><td>V*564<br>+ F*552</td><td>V*564<br>+ F*552</td><td>V*560<br>+ F*546</td><td>V*560<br>+ F*546</td><td>V*560<br>+ F*546</td><td>V*560<br>+ F*546</td><td>V*564<br>+ F*552</td><td>V*564<br>+ F*552</td><td>V*564<br>+ F*552</td><td>V*564<br>+ F*552</td></tr>
|
||||||
<tr class="ral"><td class="cal">Work area<br><small>(_FS_TINY == 1)</small></td><td>V*564<br>+ F*40</td><td>V*564<br>+ F*40</td><td>V*564<br>+ F*40</td><td>V*560<br>+ F*34</td><td>V*560<br>+ F*34</td><td>V*560<br>+ F*34</td><td>V*560<br>+ F*34</td><td>V*564<br>+ F*40</td><td>V*564<br>+ F*40</td><td>V*564<br>+ F*40</td><td>V*564<br>+ F*40</td></tr>
|
<tr class="ral"><td class="cal">Work area<br><small>(_FS_TINY == 1)</small></td><td>V*564<br>+ F*40</td><td>V*564<br>+ F*40</td><td>V*564<br>+ F*40</td><td>V*560<br>+ F*34</td><td>V*560<br>+ F*34</td><td>V*560<br>+ F*34</td><td>V*560<br>+ F*34</td><td>V*564<br>+ F*40</td><td>V*564<br>+ F*40</td><td>V*564<br>+ F*40</td><td>V*564<br>+ F*40</td></tr>
|
||||||
</table>
|
</table>
|
||||||
<pre>
|
<pre>
|
||||||
FatFs R0.12 options:
|
FatFs R0.12b options:
|
||||||
_FS_READONLY 0 (R/W) or 1 (R/O)
|
_FS_READONLY 0 (R/W) or 1 (R/O)
|
||||||
_FS_MINIMIZE 0 (Full, with all basic functions) or 3 (Min, with fully minimized)
|
_FS_MINIMIZE 0 (Full, with all basic functions) or 3 (Min, with fully minimized)
|
||||||
_FS_TINY 0 (Default) or 1 (Tiny file object)
|
_FS_TINY 0 (Default) or 1 (Tiny file object)
|
||||||
@ -254,13 +254,13 @@ And any other options are left not changed from default setting.
|
|||||||
|
|
||||||
<div class="para doc" id="license">
|
<div class="para doc" id="license">
|
||||||
<h3>FatFsのライセンスについて</h3>
|
<h3>FatFsのライセンスについて</h3>
|
||||||
<p>FatFsは、作者(ChaN)の個人プロジェクトとして開発されています。現在のリビジョンにおいてコントリビューターはいないため、作者の書いたソース コード以外は含まれません。ソース ファイルにライセンス条件が記述されているので、利用の際はそれに従うこと。原文は英語ですが、参考までに以下に日本語訳を示しておきます。</p>
|
<p>FatFsは、作者(ChaN)の個人プロジェクトとして開発されています。現在までのリビジョンにおいてコントリビューターはいないため、作者以外の書いたソース コードは含まれません。ソース ファイルにライセンス条件が記述されているので、利用の際はそれに従うこと。原文は英語ですが、参考までに以下に日本語訳を示しておきます。</p>
|
||||||
<pre>
|
<pre>
|
||||||
/*----------------------------------------------------------------------------/
|
/*----------------------------------------------------------------------------/
|
||||||
/ FatFs - Generic FAT file system module R0.12a /
|
/ FatFs - Generic FAT file system module Rx.xx /
|
||||||
/-----------------------------------------------------------------------------/
|
/-----------------------------------------------------------------------------/
|
||||||
/
|
/
|
||||||
/ Copyright (C) 2016, ChaN, all right reserved.
|
/ Copyright (C) 20xx, ChaN, all right reserved.
|
||||||
/
|
/
|
||||||
/ FatFsモジュールはオープンソースソフトウェアです。FatFsの再配布および使用は、
|
/ FatFsモジュールはオープンソースソフトウェアです。FatFsの再配布および使用は、
|
||||||
/ ソースコードかバイナリ形式か、また変更の有無にかかわらず、次の条件が満たされ
|
/ ソースコードかバイナリ形式か、また変更の有無にかかわらず、次の条件が満たされ
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
|
|
||||||
<div class="para func">
|
<div class="para func">
|
||||||
<h2>disk_initialize</h2>
|
<h2>disk_initialize</h2>
|
||||||
<p>ストレージ デバイスを初期化します。</p>
|
<p>ストレージ デバイスの初期化の際に呼ばれます。</p>
|
||||||
<pre>
|
<pre>
|
||||||
DSTATUS disk_initialize (
|
DSTATUS disk_initialize (
|
||||||
BYTE <span class="arg">pdrv</span> <span class="c">/* [IN] 物理ドライブ番号 */</span>
|
BYTE <span class="arg">pdrv</span> <span class="c">/* [IN] 物理ドライブ番号 */</span>
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
|
|
||||||
<div class="para func">
|
<div class="para func">
|
||||||
<h2>disk_ioctl</h2>
|
<h2>disk_ioctl</h2>
|
||||||
<p>一般的なデータ読み書き以外のストレージ デバイス自体に対する様々な制御を行います。</p>
|
<p>一般的なデータ読み書き以外のストレージ デバイス自体に対する様々な制御を行うときに呼ばれます。</p>
|
||||||
<pre>
|
<pre>
|
||||||
DRESULT disk_ioctl (
|
DRESULT disk_ioctl (
|
||||||
BYTE <span class="arg">pdrv</span>, <span class="c">/* [IN] 物理ドライブ番号 */</span>
|
BYTE <span class="arg">pdrv</span>, <span class="c">/* [IN] 物理ドライブ番号 */</span>
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
|
|
||||||
<div class="para func">
|
<div class="para func">
|
||||||
<h2>disk_read</h2>
|
<h2>disk_read</h2>
|
||||||
<p>ストレージ デバイスからデータを読み出します。</p>
|
<p>ストレージ デバイスからデータを読み出すときに呼ばれます。</p>
|
||||||
<pre>
|
<pre>
|
||||||
DRESULT disk_read (
|
DRESULT disk_read (
|
||||||
BYTE <span class="arg">pdrv</span>, <span class="c">/* [IN] 物理ドライブ番号 */</span>
|
BYTE <span class="arg">pdrv</span>, <span class="c">/* [IN] 物理ドライブ番号 */</span>
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
|
|
||||||
<div class="para func">
|
<div class="para func">
|
||||||
<h2>disk_status</h2>
|
<h2>disk_status</h2>
|
||||||
<p>ストレージ デバイスの状態を取得します。</p>
|
<p>ストレージ デバイスの状態を取得するために呼ばれます。</p>
|
||||||
<pre>
|
<pre>
|
||||||
DSTATUS disk_status (
|
DSTATUS disk_status (
|
||||||
BYTE <span class="arg">pdrv</span> <span class="c">/* [IN] 物理ドライブ番号 */</span>
|
BYTE <span class="arg">pdrv</span> <span class="c">/* [IN] 物理ドライブ番号 */</span>
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
|
|
||||||
<div class="para func">
|
<div class="para func">
|
||||||
<h2>disk_write</h2>
|
<h2>disk_write</h2>
|
||||||
<p>ストレージ デバイスにデータを書き込みます。</p>
|
<p>ストレージ デバイスにデータを書き込むときに呼ばれます。</p>
|
||||||
<pre>
|
<pre>
|
||||||
DRESULT disk_write (
|
DRESULT disk_write (
|
||||||
BYTE <span class="arg">pdrv</span>, <span class="c">/* [IN] 物理ドライブ番号 */</span>
|
BYTE <span class="arg">pdrv</span>, <span class="c">/* [IN] 物理ドライブ番号 */</span>
|
||||||
|
@ -43,8 +43,8 @@ FRESULT f_expand (
|
|||||||
<a href="rc.html#ok">FR_OK</a>,
|
<a href="rc.html#ok">FR_OK</a>,
|
||||||
<a href="rc.html#de">FR_DISK_ERR</a>,
|
<a href="rc.html#de">FR_DISK_ERR</a>,
|
||||||
<a href="rc.html#ie">FR_INT_ERR</a>,
|
<a href="rc.html#ie">FR_INT_ERR</a>,
|
||||||
<a href="rc.html#io">FR_INVALID_OBJECT</a>,
|
|
||||||
<a href="rc.html#dn">FR_DENIED</a>,
|
<a href="rc.html#dn">FR_DENIED</a>,
|
||||||
|
<a href="rc.html#io">FR_INVALID_OBJECT</a>,
|
||||||
<a href="rc.html#tm">FR_TIMEOUT</a>
|
<a href="rc.html#tm">FR_TIMEOUT</a>
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
|
|
||||||
<div class="para func">
|
<div class="para func">
|
||||||
<h2>get_fattime</h2>
|
<h2>get_fattime</h2>
|
||||||
<p>現在時刻を取得します。</p>
|
<p>現在時刻を取得する際に呼ばれます。</p>
|
||||||
<pre>
|
<pre>
|
||||||
DWORD get_fattime (void);
|
DWORD get_fattime (void);
|
||||||
</pre>
|
</pre>
|
||||||
|
@ -74,10 +74,10 @@ FRESULT f_fdisk (
|
|||||||
DWORD plist[] = {50, 50, 0, 0}; <span class="c">/* 第1区画,第2区画それぞれに50%ずつ割り当て */</span>
|
DWORD plist[] = {50, 50, 0, 0}; <span class="c">/* 第1区画,第2区画それぞれに50%ずつ割り当て */</span>
|
||||||
BYTE work[_MAX_SS];
|
BYTE work[_MAX_SS];
|
||||||
|
|
||||||
f_fdisk(0, plist, work); <span class="c">/* 物理ドライブ 0 の分割 */</span>
|
f_fdisk(0, plist, work); <span class="c">/* 物理ドライブ 0 の分割 */</span>
|
||||||
|
|
||||||
f_mkfs("0:", FMT_ANY, work, sizeof work); <span class="c">/* 論理ドライブ 0: のフォーマット */</span>
|
f_mkfs("0:", FM_ANY, work, sizeof work); <span class="c">/* 論理ドライブ 0: のフォーマット */</span>
|
||||||
f_mkfs("1:", FMT_ANY, work, sizeof work); <span class="c">/* 論理ドライブ 1: のフォーマット */</span>
|
f_mkfs("1:", FM_ANY, work, sizeof work); <span class="c">/* 論理ドライブ 1: のフォーマット */</span>
|
||||||
|
|
||||||
</pre>
|
</pre>
|
||||||
</div>
|
</div>
|
||||||
|
@ -80,9 +80,9 @@ FRESULT f_findfirst (
|
|||||||
<div class="para use">
|
<div class="para use">
|
||||||
<h4>使用例</h4>
|
<h4>使用例</h4>
|
||||||
<pre>
|
<pre>
|
||||||
<span class="c">/* ディレクトリ内のオブジェクトの検索と表示 */</span>
|
<span class="c">/* ディレクトリ内のjpegファイルの検索 */</span>
|
||||||
|
|
||||||
void find_image (void)
|
void find_image_file (void)
|
||||||
{
|
{
|
||||||
FRESULT fr; <span class="c">/* API戻り値 */</span>
|
FRESULT fr; <span class="c">/* API戻り値 */</span>
|
||||||
DIR dj; <span class="c">/* ディレクトリ オブジェクト */</span>
|
DIR dj; <span class="c">/* ディレクトリ オブジェクト */</span>
|
||||||
@ -94,6 +94,7 @@ void find_image (void)
|
|||||||
printf("%s\n", fno.fname); <span class="c">/* 見つけた項目の名前を表示 */</span>
|
printf("%s\n", fno.fname); <span class="c">/* 見つけた項目の名前を表示 */</span>
|
||||||
fr = f_findnext(&dj, &fno); <span class="c">/* 次を検索 */</span>
|
fr = f_findnext(&dj, &fno); <span class="c">/* 次を検索 */</span>
|
||||||
}
|
}
|
||||||
|
|
||||||
f_closedir(&dj);
|
f_closedir(&dj);
|
||||||
}
|
}
|
||||||
</pre>
|
</pre>
|
||||||
|
@ -45,7 +45,7 @@ FRESULT f_forward (
|
|||||||
<a href="rc.html#ok">FR_OK</a>,
|
<a href="rc.html#ok">FR_OK</a>,
|
||||||
<a href="rc.html#de">FR_DISK_ERR</a>,
|
<a href="rc.html#de">FR_DISK_ERR</a>,
|
||||||
<a href="rc.html#ie">FR_INT_ERR</a>,
|
<a href="rc.html#ie">FR_INT_ERR</a>,
|
||||||
<a href="rc.html#de">FR_DENIED</a>,
|
<a href="rc.html#dn">FR_DENIED</a>,
|
||||||
<a href="rc.html#io">FR_INVALID_OBJECT</a>,
|
<a href="rc.html#io">FR_INVALID_OBJECT</a>,
|
||||||
<a href="rc.html#tm">FR_TIMEOUT</a>
|
<a href="rc.html#tm">FR_TIMEOUT</a>
|
||||||
</p>
|
</p>
|
||||||
|
@ -39,7 +39,7 @@ FRESULT f_mkdir (
|
|||||||
<a href="rc.html#nr">FR_NOT_READY</a>,
|
<a href="rc.html#nr">FR_NOT_READY</a>,
|
||||||
<a href="rc.html#np">FR_NO_PATH</a>,
|
<a href="rc.html#np">FR_NO_PATH</a>,
|
||||||
<a href="rc.html#in">FR_INVALID_NAME</a>,
|
<a href="rc.html#in">FR_INVALID_NAME</a>,
|
||||||
<a href="rc.html#de">FR_DENIED</a>,
|
<a href="rc.html#dn">FR_DENIED</a>,
|
||||||
<a href="rc.html#ex">FR_EXIST</a>,
|
<a href="rc.html#ex">FR_EXIST</a>,
|
||||||
<a href="rc.html#wp">FR_WRITE_PROTECTED</a>,
|
<a href="rc.html#wp">FR_WRITE_PROTECTED</a>,
|
||||||
<a href="rc.html#id">FR_INVALID_DRIVE</a>,
|
<a href="rc.html#id">FR_INVALID_DRIVE</a>,
|
||||||
|
@ -52,8 +52,8 @@ FRESULT f_mount (
|
|||||||
<p>FatFsモジュールでは、それぞれの論理ドライブに<em>ファイル システム オブジェクト</em>というワーク エリアが必要です。この関数は論理ドライブにファイル システム オブジェクトを登録したり抹消したりします。何らかのファイル関数を使用する前に、この関数でその論理ドライブのファイル システム オブジェクトを与えておかなければなりません。<tt class="arg">fs</tt>にヌル ポインタを指定すると、その論理ドライブのファイル システム オブジェクトの登録は抹消されるだけです。登録抹消されたファイル システム オブジェクトのメモリは解放できます。操作の対象の論理ドライブ上に開かれたままのファイルやディレクトリがあった場合、それらに対して作成された構造体は全て無効になります。この関数の内部処理は次のような順に行われます。</p>
|
<p>FatFsモジュールでは、それぞれの論理ドライブに<em>ファイル システム オブジェクト</em>というワーク エリアが必要です。この関数は論理ドライブにファイル システム オブジェクトを登録したり抹消したりします。何らかのファイル関数を使用する前に、この関数でその論理ドライブのファイル システム オブジェクトを与えておかなければなりません。<tt class="arg">fs</tt>にヌル ポインタを指定すると、その論理ドライブのファイル システム オブジェクトの登録は抹消されるだけです。登録抹消されたファイル システム オブジェクトのメモリは解放できます。操作の対象の論理ドライブ上に開かれたままのファイルやディレクトリがあった場合、それらに対して作成された構造体は全て無効になります。この関数の内部処理は次のような順に行われます。</p>
|
||||||
<ol>
|
<ol>
|
||||||
<li>対象の論理ドライブを<tt class="arg">path</tt>から得る。</li>
|
<li>対象の論理ドライブを<tt class="arg">path</tt>から得る。</li>
|
||||||
<li>既に登録されているファイル システム オブジェクトはクリア(無効化)し、登録を解除する。</li>
|
<li>登録されているファイル システム オブジェクトがあるときは、それをクリア(無効化)し、登録を解除する。</li>
|
||||||
<li><tt class="arg">fs</tt>が有効なポインタのときは、そのファイル システム オブジェクトをクリアし登録する。</li>
|
<li><tt class="arg">fs</tt>が有効なポインタのときは、そのファイル システム オブジェクトをクリアし、登録する。</li>
|
||||||
<li>マウント動作が指定されているときは、それを実行する。</li>
|
<li>マウント動作が指定されているときは、それを実行する。</li>
|
||||||
</ol>
|
</ol>
|
||||||
<p><tt class="arg">opt</tt>に0を指定すると、マウント動作(物理ドライブの初期化、FATボリュームの検索、BPBを解析しファイル システム オブジェクトを初期化)は行われず、関数は物理ドライブの状態に関わらず常に成功します。関数内では下位レイヤへのアクセスは発生せず、指定されたファイル システム オブジェクトをクリア(無効化)し、そのアドレスを内部配列に登録するだけです。単に登録済みのファイル システム オブジェクトをクリアする目的にも使えます。実際のマウント動作は、ボリュームへのアクセス(パス名を渡すもの全て)が行われたときに、次のうちいずれかの条件が真の場合に行われます。</p>
|
<p><tt class="arg">opt</tt>に0を指定すると、マウント動作(物理ドライブの初期化、FATボリュームの検索、BPBを解析しファイル システム オブジェクトを初期化)は行われず、関数は物理ドライブの状態に関わらず常に成功します。関数内では下位レイヤへのアクセスは発生せず、指定されたファイル システム オブジェクトをクリア(無効化)し、そのアドレスを内部配列に登録するだけです。単に登録済みのファイル システム オブジェクトをクリアする目的にも使えます。実際のマウント動作は、ボリュームへのアクセス(パス名を渡すもの全て)が行われたときに、次のうちいずれかの条件が真の場合に行われます。</p>
|
||||||
|
@ -57,7 +57,7 @@ FRESULT f_open (
|
|||||||
<a href="rc.html#ok">FR_NO_FILE</a>,
|
<a href="rc.html#ok">FR_NO_FILE</a>,
|
||||||
<a href="rc.html#np">FR_NO_PATH</a>,
|
<a href="rc.html#np">FR_NO_PATH</a>,
|
||||||
<a href="rc.html#in">FR_INVALID_NAME</a>,
|
<a href="rc.html#in">FR_INVALID_NAME</a>,
|
||||||
<a href="rc.html#de">FR_DENIED</a>,
|
<a href="rc.html#dn">FR_DENIED</a>,
|
||||||
<a href="rc.html#ex">FR_EXIST</a>,
|
<a href="rc.html#ex">FR_EXIST</a>,
|
||||||
<a href="rc.html#io">FR_INVALID_OBJECT</a>,
|
<a href="rc.html#io">FR_INVALID_OBJECT</a>,
|
||||||
<a href="rc.html#wp">FR_WRITE_PROTECTED</a>,
|
<a href="rc.html#wp">FR_WRITE_PROTECTED</a>,
|
||||||
|
@ -11,22 +11,23 @@
|
|||||||
|
|
||||||
<body>
|
<body>
|
||||||
<h1>ファイル関数の戻り値</h1>
|
<h1>ファイル関数の戻り値</h1>
|
||||||
<p>FatFsのAPIでは、一部の関数を除き結果に応じた共通のリザルト コード(FRESULT型(enum))を返します。関数が成功した場合は0を返します。失敗した場合は0以外の値を返し、値はエラーの種類を示します。</p>
|
<p>FatFsのAPIでは、一部の関数を除き結果に応じた共通のリザルト コード(FRESULT型(enum))を返します。関数が成功した場合は0 (<tt>FR_OK</tt>)を返します。失敗した場合は0以外の値を返し、値はエラーの種類を示します。</p>
|
||||||
|
|
||||||
<dl class="ret">
|
<dl class="ret">
|
||||||
<dt id="ok">FR_OK (0)</dt>
|
<dt id="ok">FR_OK (0)</dt>
|
||||||
<dd>関数は成功した。</dd>
|
<dd>関数は成功した。</dd>
|
||||||
<dt id="de">FR_DISK_ERR</dt>
|
<dt id="de">FR_DISK_ERR</dt>
|
||||||
<dd>下位レイヤ(<tt>disk_read/disk_write/disk_ioctl</tt>関数)で回復不能なエラーが発生した。<br>※開かれたファイルの操作においてこのエラーが発生すると、そのファイル オブジェクトはアボート状態となり、クローズ以外のの操作ができなくなります。</dd>
|
<dd>下位レイヤ(<tt>disk_read/disk_write/disk_ioctl</tt>関数)で回復不能なエラーが発生した。<br>※開かれたファイルの操作においてこのエラーが発生すると、そのファイル オブジェクトはアボート状態となり、クローズ以外の操作ができなくなります。</dd>
|
||||||
<dt id="ie">FR_INT_ERR</dt>
|
<dt id="ie">FR_INT_ERR</dt>
|
||||||
<dd>内部処理の健全性に異常が検出された。原因としては次のようなことが考えられます。
|
<dd>内部処理の健全性チェックで何らかの異常が検出された。原因としては次のようなことが考えられます。
|
||||||
<ul>
|
<ul>
|
||||||
<li>ボリューム上のFAT構造にエラーがある。</li>
|
|
||||||
<li>スタック不足や不正なメモリ操作等によるワーク エリアの破壊。多くはこれが原因。</li>
|
<li>スタック不足や不正なメモリ操作等によるワーク エリアの破壊。多くはこれが原因。</li>
|
||||||
|
<li>ボリューム上のFAT構造にエラーがある。</li>
|
||||||
|
<li>FatFsモジュール自体のバグ。</li>
|
||||||
</ul>
|
</ul>
|
||||||
※開かれたファイルの操作においてこのエラーが発生すると、そのファイル オブジェクトはアボート状態となり、クローズ以外の操作ができなくなります。</dd>
|
※開かれたファイルの操作においてこのエラーが発生すると、そのファイル オブジェクトはアボート状態となり、クローズ以外の操作ができなくなります。</dd>
|
||||||
<dt id="nr">FR_NOT_READY</dt>
|
<dt id="nr">FR_NOT_READY</dt>
|
||||||
<dd><a href="dinit.html"><tt>disk_initialize</tt>関数</a>の失敗。物理ドライブが動作可能な状態にない。</dd>
|
<dd>下位レイヤ(<tt>disk_initialize</tt>関数)の失敗。つまり、物理ドライブが動作可能な状態にない。</dd>
|
||||||
<dt id="nf">FR_NO_FILE</dt>
|
<dt id="nf">FR_NO_FILE</dt>
|
||||||
<dd>指定されたファイルが見つからなかった。</dd>
|
<dd>指定されたファイルが見つからなかった。</dd>
|
||||||
<dt id="np">FR_NO_PATH</dt>
|
<dt id="np">FR_NO_PATH</dt>
|
||||||
@ -41,7 +42,8 @@
|
|||||||
<li>空でないディレクトリまたはカレント ディレクトリを削除しようとした。</li>
|
<li>空でないディレクトリまたはカレント ディレクトリを削除しようとした。</li>
|
||||||
<li><tt>FA_READ</tt>フラグを付けずに開いたファイルに対して読み出しを行った。</li>
|
<li><tt>FA_READ</tt>フラグを付けずに開いたファイルに対して読み出しを行った。</li>
|
||||||
<li><tt>FA_WRITE</tt>フラグを付けずに開いたファイルに対して変更を加えようとした。</li>
|
<li><tt>FA_WRITE</tt>フラグを付けずに開いたファイルに対して変更を加えようとした。</li>
|
||||||
<li>ボリュームまたは静的ディレクトリが満杯でオブジェクトの新規作成ができなかった。</li>
|
<li>ボリュームまたは静的ディレクトリ(FAT12/16のルート)が満杯でディレクトリ エントリの新規作成ができなかった。</li>
|
||||||
|
<li>ファイルに割り当てる連続領域が見つからなかった。</li>
|
||||||
</ul>
|
</ul>
|
||||||
</dd>
|
</dd>
|
||||||
<dt id="ex">FR_EXIST</dt>
|
<dt id="ex">FR_EXIST</dt>
|
||||||
@ -50,8 +52,8 @@
|
|||||||
<dd>指定されたファイル オブジェクトやディレクトリ オブジェクトが無効、またはヌル ポインタが渡された。無効になる理由は次のことが考えられます。
|
<dd>指定されたファイル オブジェクトやディレクトリ オブジェクトが無効、またはヌル ポインタが渡された。無効になる理由は次のことが考えられます。
|
||||||
<ul>
|
<ul>
|
||||||
<li>オープンされていない、既に閉じられた、破損しているなど。</li>
|
<li>オープンされていない、既に閉じられた、破損しているなど。</li>
|
||||||
<li>それの属するボリュームのマウント動作があった。ボリューム上で開かれたオブジェクトは全て無効化される。</li>
|
<li>そのボリュームでマウント動作があり、ボリューム上の開かれたオブジェクトが全て無効化された。</li>
|
||||||
<li>関連する物理ドライブがメディアの取り外しで動作不可能になっている。</li>
|
<li>物理ドライブがメディアの取り外しで動作不可能になっている。</li>
|
||||||
</ul>
|
</ul>
|
||||||
</dd>
|
</dd>
|
||||||
<dt id="wp">FR_WRITE_PROTECTED</dt>
|
<dt id="wp">FR_WRITE_PROTECTED</dt>
|
||||||
|
@ -45,7 +45,7 @@ FRESULT f_read (
|
|||||||
<a href="rc.html#ok">FR_OK</a>,
|
<a href="rc.html#ok">FR_OK</a>,
|
||||||
<a href="rc.html#de">FR_DISK_ERR</a>,
|
<a href="rc.html#de">FR_DISK_ERR</a>,
|
||||||
<a href="rc.html#ie">FR_INT_ERR</a>,
|
<a href="rc.html#ie">FR_INT_ERR</a>,
|
||||||
<a href="rc.html#de">FR_DENIED</a>,
|
<a href="rc.html#dn">FR_DENIED</a>,
|
||||||
<a href="rc.html#io">FR_INVALID_OBJECT</a>,
|
<a href="rc.html#io">FR_INVALID_OBJECT</a>,
|
||||||
<a href="rc.html#tm">FR_TIMEOUT</a>
|
<a href="rc.html#tm">FR_TIMEOUT</a>
|
||||||
</p>
|
</p>
|
||||||
|
@ -28,7 +28,7 @@ FRESULT f_rename (
|
|||||||
<dt>old_name</dt>
|
<dt>old_name</dt>
|
||||||
<dd>変更対象のファイルまたはサブ ディレクトリの<a href="filename.html">パス名</a>を示すヌル文字<tt>'\0'</tt>終端の文字列へのポインタを指定します。</dd>
|
<dd>変更対象のファイルまたはサブ ディレクトリの<a href="filename.html">パス名</a>を示すヌル文字<tt>'\0'</tt>終端の文字列へのポインタを指定します。</dd>
|
||||||
<dt>new_name</dt>
|
<dt>new_name</dt>
|
||||||
<dd>新しいパス名を示すヌル文字<tt>'\0'</tt>終端の文字列へのポインタを指定します。既に存在するオブジェクトと同じ名前は使えません。また、ドライブ番号は指定しても無視され、<tt class="arg">old_name</tt>で決められた論理ドライブ上のオブジェクトとして扱われます。</dd>
|
<dd>新しいパス名を示すヌル文字<tt>'\0'</tt>終端の文字列へのポインタを指定します。また、ドライブ番号は指定しても無視され、<tt class="arg">old_name</tt>で決められたボリューム上のオブジェクトとして扱われます。これと同じパス名(<tt class="arg">old_name</tt>は除く)のオブジェクトが存在すると、関数は<tt>FR_EXIST</tt>で失敗します。</dd>
|
||||||
</dl>
|
</dl>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
|
|
||||||
<div class="para">
|
<div class="para">
|
||||||
<h2>FATFS</h2>
|
<h2>FATFS</h2>
|
||||||
<p><tt>FATFS</tt>構造体(ファイル システム オブジェクト)は、個々の論理ドライブのダイナミック ワーク エリアを保持し、<tt>f_mount</tt>関数でFatFsモジュールに登録されます。初期化が行われるタイミングは、<tt>f_mount</tt>関数(強制マウント指定)の実行またはメディア交換の後の最初のファイル アクセスの時です。アプリケーションは、この構造体のメンバを書き換えてはなりません。</p>
|
<p><tt>FATFS</tt>構造体(ファイル システム オブジェクト)は、個々の論理ドライブのダイナミック ワーク エリアを保持し、<tt>f_mount</tt>関数でFatFsモジュールに登録されます。構造体の作成は、随時ボリューム マウント プロセスにより行われます。アプリケーションは、この構造体のメンバを書き換えてはなりません。</p>
|
||||||
|
|
||||||
<pre>
|
<pre>
|
||||||
<span class="k">typedef</span> <span class="k">struct</span> {
|
<span class="k">typedef</span> <span class="k">struct</span> {
|
||||||
|
@ -36,7 +36,7 @@ FRESULT f_truncate (
|
|||||||
<a href="rc.html#ok">FR_OK</a>,
|
<a href="rc.html#ok">FR_OK</a>,
|
||||||
<a href="rc.html#de">FR_DISK_ERR</a>,
|
<a href="rc.html#de">FR_DISK_ERR</a>,
|
||||||
<a href="rc.html#ie">FR_INT_ERR</a>,
|
<a href="rc.html#ie">FR_INT_ERR</a>,
|
||||||
<a href="rc.html#de">FR_DENIED</a>,
|
<a href="rc.html#dn">FR_DENIED</a>,
|
||||||
<a href="rc.html#io">FR_INVALID_OBJECT</a>,
|
<a href="rc.html#io">FR_INVALID_OBJECT</a>,
|
||||||
<a href="rc.html#tm">FR_TIMEOUT</a>
|
<a href="rc.html#tm">FR_TIMEOUT</a>
|
||||||
</p>
|
</p>
|
||||||
|
@ -40,7 +40,7 @@ FRESULT f_unlink (
|
|||||||
<a href="rc.html#ok">FR_NO_FILE</a>,
|
<a href="rc.html#ok">FR_NO_FILE</a>,
|
||||||
<a href="rc.html#np">FR_NO_PATH</a>,
|
<a href="rc.html#np">FR_NO_PATH</a>,
|
||||||
<a href="rc.html#in">FR_INVALID_NAME</a>,
|
<a href="rc.html#in">FR_INVALID_NAME</a>,
|
||||||
<a href="rc.html#de">FR_DENIED</a>,
|
<a href="rc.html#dn">FR_DENIED</a>,
|
||||||
<a href="rc.html#wp">FR_WRITE_PROTECTED</a>,
|
<a href="rc.html#wp">FR_WRITE_PROTECTED</a>,
|
||||||
<a href="rc.html#id">FR_INVALID_DRIVE</a>,
|
<a href="rc.html#id">FR_INVALID_DRIVE</a>,
|
||||||
<a href="rc.html#ne">FR_NOT_ENABLED</a>,
|
<a href="rc.html#ne">FR_NOT_ENABLED</a>,
|
||||||
|
@ -45,7 +45,7 @@ FRESULT f_write (
|
|||||||
<a href="rc.html#ok">FR_OK</a>,
|
<a href="rc.html#ok">FR_OK</a>,
|
||||||
<a href="rc.html#de">FR_DISK_ERR</a>,
|
<a href="rc.html#de">FR_DISK_ERR</a>,
|
||||||
<a href="rc.html#ie">FR_INT_ERR</a>,
|
<a href="rc.html#ie">FR_INT_ERR</a>,
|
||||||
<a href="rc.html#de">FR_DENIED</a>,
|
<a href="rc.html#dn">FR_DENIED</a>,
|
||||||
<a href="rc.html#io">FR_INVALID_OBJECT</a>,
|
<a href="rc.html#io">FR_INVALID_OBJECT</a>,
|
||||||
<a href="rc.html#tm">FR_TIMEOUT</a>
|
<a href="rc.html#tm">FR_TIMEOUT</a>
|
||||||
</p>
|
</p>
|
||||||
|
Binary file not shown.
Before Width: | Height: | Size: 27 KiB After Width: | Height: | Size: 68 KiB |
189
firmware/chibios-portapack/ext/fatfs/doc/updates.txt
Normal file
189
firmware/chibios-portapack/ext/fatfs/doc/updates.txt
Normal file
@ -0,0 +1,189 @@
|
|||||||
|
R0.12b (September 4, 2016)
|
||||||
|
Improved f_rename() to be able to rename objects with the same name but case.
|
||||||
|
Fixed an error in the case conversion teble of code page 866. (ff.c)
|
||||||
|
Fixed writing data is truncated at the file offset 4GiB on the exFAT volume. (appeared at R0.12)
|
||||||
|
Fixed creating a file in the root directory of exFAT volume can fail. (appeared at R0.12)
|
||||||
|
Fixed f_mkfs() creating exFAT volume with too small cluster size can collapse unallocated memory. (appeared at R0.12)
|
||||||
|
Fixed wrong object name can be returned when read directory at Unicode cfg. (appeared at R0.12)
|
||||||
|
Fixed large file allocation/removing on the exFAT volume collapses allocation bitmap. (appeared at R0.12)
|
||||||
|
Fixed some internal errors in f_expand() and f_lseek(). (appeared at R0.12)
|
||||||
|
|
||||||
|
R0.12a (July 10, 2016)
|
||||||
|
Added support for creating exFAT volume with some changes of f_mkfs().
|
||||||
|
Added a file open method FA_OPEN_APPEND. An f_lseek() following f_open() is no longer needed.
|
||||||
|
f_forward() is available regardless of _FS_TINY.
|
||||||
|
Fixed f_mkfs() creates wrong volume. (appeared at R0.12)
|
||||||
|
Fixed wrong memory read in create_name(). (appeared at R0.12)
|
||||||
|
Fixed compilation fails at some configurations, _USE_FASTSEEK and _USE_FORWARD.
|
||||||
|
|
||||||
|
R0.12 (April 12, 2016)
|
||||||
|
Added support for exFAT file system. (_FS_EXFAT)
|
||||||
|
Added f_expand(). (_USE_EXPAND)
|
||||||
|
Changed some members in FINFO structure and behavior of f_readdir().
|
||||||
|
Added an option _USE_CHMOD and removed an option _WORD_ACCESS.
|
||||||
|
Fixed errors in the case conversion teble of Unicode (cc*.c).
|
||||||
|
|
||||||
|
R0.11a (September 5, 2015)
|
||||||
|
Fixed wrong media change can lead a deadlock at thread-safe configuration.
|
||||||
|
Added code page 771, 860, 861, 863, 864, 865 and 869. (_CODE_PAGE)
|
||||||
|
Removed some code pages actually not exist on the standard systems. (_CODE_PAGE)
|
||||||
|
Fixed errors in the case conversion teble of code page 437 and 850 (ff.c).
|
||||||
|
Fixed errors in the case conversion teble of Unicode (cc*.c).
|
||||||
|
|
||||||
|
R0.11 (February 9, 2015)
|
||||||
|
Added f_findfirst() and f_findnext(). (_USE_FIND)
|
||||||
|
Fixed f_unlink() does not remove cluster chain of the file. (appeared at R0.10c)
|
||||||
|
Fixed _FS_NORTC option does not work properly. (appeared at R0.10c)
|
||||||
|
|
||||||
|
R0.10c (November 9, 2014)
|
||||||
|
Added a configuration option for the platforms without RTC. (_FS_NORTC)
|
||||||
|
Fixed volume label created by Mac OS X cannot be retrieved with f_getlabel(). (appeared at R0.09b)
|
||||||
|
Fixed a potential problem of FAT access that can appear on disk error.
|
||||||
|
Fixed null pointer dereference on attempting to delete the root direcotry. (appeared at R0.08)
|
||||||
|
|
||||||
|
R0.10b (May 19, 2014)
|
||||||
|
Fixed a hard error in the disk I/O layer can collapse the directory entry.
|
||||||
|
Fixed LFN entry is not deleted on delete/rename an object with its lossy converted SFN. (appeared at R0.07)
|
||||||
|
|
||||||
|
R0.10a (January 15, 2014)
|
||||||
|
Added arbitrary strings as drive number in the path name. (_STR_VOLUME_ID)
|
||||||
|
Added an option for minimum sector size. (_MIN_SS)
|
||||||
|
2nd argument of f_rename() can have a drive number and it will be ignored.
|
||||||
|
Fixed f_mount() with forced mount fails when drive number is larger than 0. (appeared at R0.10)
|
||||||
|
Fixed f_close() invalidates the file object without volume lock.
|
||||||
|
Fixed volume lock is left acquired after return from f_closedir(). (appeared at R0.10)
|
||||||
|
Fixed creation of a directory entry with LFN fails on too many SFN collisions. (appeared at R0.07)
|
||||||
|
|
||||||
|
R0.10 (October 2, 2013)
|
||||||
|
Added an option for character encoding on the file. (_STRF_ENCODE)
|
||||||
|
Added f_closedir().
|
||||||
|
Added forced full FAT scan option for f_getfree(). (_FS_NOFSINFO)
|
||||||
|
Added forced mount option with changes of f_mount().
|
||||||
|
Improved behavior of volume auto detection.
|
||||||
|
Improved write throughput of f_puts() and f_printf().
|
||||||
|
Changed argument of f_chdrive(), f_mkfs(), disk_read() and disk_write().
|
||||||
|
Fixed f_write() can be truncated when the file size is close to 4GB.
|
||||||
|
Fixed f_open(), f_mkdir() and f_setlabel() can return incorrect result code on error.
|
||||||
|
|
||||||
|
R0.09b (January 24, 2013)
|
||||||
|
Added f_getlabel() and f_setlabel(). (_USE_LABEL = 1)
|
||||||
|
|
||||||
|
R0.09a (August 27, 2012)
|
||||||
|
Fixed assertion failure due to OS/2 EA on FAT12/16 volume.
|
||||||
|
Changed file functions reject null object pointer to avoid crash.
|
||||||
|
Changed option name _FS_SHARE to _FS_LOCK.
|
||||||
|
|
||||||
|
R0.09 (September 6, 2011)
|
||||||
|
f_mkfs() supports multiple partition on a physical drive.
|
||||||
|
Added f_fdisk(). (_MULTI_PARTITION = 2)
|
||||||
|
|
||||||
|
R0.08b (January 15, 2011)
|
||||||
|
Fast seek function is also applied to f_read() and f_write().
|
||||||
|
f_lseek() reports required table size on creating CLMP.
|
||||||
|
Extended format syntax of f_printf().
|
||||||
|
Ignores duplicated directory separators in given path names.
|
||||||
|
|
||||||
|
R0.08a (August 16, 2010)
|
||||||
|
Added f_getcwd(). (_FS_RPATH = 2)
|
||||||
|
Added sector erase function. (_USE_ERASE)
|
||||||
|
Moved file lock semaphore table from fs object to the bss.
|
||||||
|
Fixed a wrong directory entry is created on non-LFN cfg when the given name contains ';'.
|
||||||
|
Fixed f_mkfs() creates wrong FAT32 volume.
|
||||||
|
|
||||||
|
R0.08 (May 15, 2010)
|
||||||
|
Added a memory configuration option. (_USE_LFN)
|
||||||
|
Added support of file lock. (_FS_SHARE)
|
||||||
|
Added fast seek function. (_USE_FASTSEEK)
|
||||||
|
Changed some types on the API, XCHAR->TCHAR.
|
||||||
|
Changed fname member in the FILINFO structure on Unicode cfg.
|
||||||
|
String functions support UTF-8 encoding files on Unicode cfg.
|
||||||
|
|
||||||
|
R0.07e (November 3, 2009)
|
||||||
|
Separated out configuration options from ff.h to ffconf.h.
|
||||||
|
Added a configuration option, _LFN_UNICODE.
|
||||||
|
Fixed f_unlink() fails to remove a sub-dir on _FS_RPATH.
|
||||||
|
Fixed name matching error on the 13 char boundary.
|
||||||
|
Changed f_readdir() to return the SFN with always upper case on non-LFN cfg.
|
||||||
|
|
||||||
|
R0.07c (Junuary 21, 2009)
|
||||||
|
Fixed f_unlink() may return FR_OK on error.
|
||||||
|
Fixed wrong cache control in f_lseek().
|
||||||
|
Added support of relative path.
|
||||||
|
Added f_chdir().
|
||||||
|
Added f_chdrive().
|
||||||
|
Added proper case conversion to extended characters.
|
||||||
|
|
||||||
|
R0.07a (April 14, 2009)
|
||||||
|
Separated out OS dependent code on re-entrant configuration.
|
||||||
|
Added multiple sector size support.
|
||||||
|
|
||||||
|
R0.07 (April 1, 2009)
|
||||||
|
Merged Tiny-FatFs into FatFs as a buffer configuration option.
|
||||||
|
Added long file name support.
|
||||||
|
Added multiple code page support.
|
||||||
|
Added re-entrancy for multitask operation.
|
||||||
|
Added auto cluster size selection to f_mkfs().
|
||||||
|
Added rewind option to f_readdir().
|
||||||
|
Changed result code of critical errors.
|
||||||
|
Renamed string functions to avoid name collision.
|
||||||
|
|
||||||
|
R0.06 (April 1, 2008)
|
||||||
|
Added f_forward. (Tiny-FatFs)
|
||||||
|
Added string functions: fgets, fputc, fputs and fprintf.
|
||||||
|
Improved performance of f_lseek on moving to the same or following cluster.
|
||||||
|
|
||||||
|
R0.05a (February 3, 2008)
|
||||||
|
Added f_truncate.
|
||||||
|
Added f_utime.
|
||||||
|
Fixed off by one error at FAT sub-type determination.
|
||||||
|
Fixed btr in f_read can be mistruncated.
|
||||||
|
Fixed cached sector is left not flushed when create and close without write.
|
||||||
|
|
||||||
|
R0.05 (August 26, 2007)
|
||||||
|
Changed arguments of f_read, f_write.
|
||||||
|
Changed arguments of f_mkfs. (FatFs)
|
||||||
|
Fixed f_mkfs on FAT32 creates incorrect FSInfo. (FatFs)
|
||||||
|
Fixed f_mkdir on FAT32 creates incorrect directory. (FatFs)
|
||||||
|
|
||||||
|
R0.04b (May 5, 2007)
|
||||||
|
Added _USE_NTFLAG option.
|
||||||
|
Added FSInfo support.
|
||||||
|
Fixed some problems corresponds to FAT32. (Tiny-FatFs)
|
||||||
|
Fixed DBCS name can result FR_INVALID_NAME.
|
||||||
|
Fixed short seek (<= csize) collapses the file object.
|
||||||
|
|
||||||
|
R0.04a (April 1, 2007)
|
||||||
|
Supported multiple partitions on a plysical drive. (FatFs)
|
||||||
|
Added minimization level 3.
|
||||||
|
Added a capability of extending file size to f_lseek.
|
||||||
|
Fixed an endian sensitive code in f_mkfs. (FatFs)
|
||||||
|
Fixed a problem corresponds to FAT32 support. (Tiny-FatFs)
|
||||||
|
|
||||||
|
R0.04 (February 4, 2007)
|
||||||
|
Supported multiple drive system. (FatFs)
|
||||||
|
Changed some APIs for multiple drive system.
|
||||||
|
Added f_mkfs. (FatFs)
|
||||||
|
Added _USE_FAT32 option. (Tiny-FatFs)
|
||||||
|
|
||||||
|
R0.03a (December 11, 2006)
|
||||||
|
Improved cluster scan algolithm to write files fast.
|
||||||
|
Fixed f_mkdir creates incorrect directory on FAT32.
|
||||||
|
|
||||||
|
R0.03 (September 22, 2006)
|
||||||
|
Added f_rename.
|
||||||
|
Changed option _FS_MINIMUM to _FS_MINIMIZE.
|
||||||
|
|
||||||
|
R0.02a (June 10, 2006)
|
||||||
|
Added a configuration option _FS_MINIMUM.
|
||||||
|
|
||||||
|
R0.02 (Jun 01, 2006)
|
||||||
|
Added FAT12.
|
||||||
|
Removed unbuffered mode.
|
||||||
|
Fixed a problem on small (<32M) patition.
|
||||||
|
|
||||||
|
R0.01 (April 29, 2006)
|
||||||
|
First release
|
||||||
|
|
||||||
|
R0.00 (February 26, 2006)
|
||||||
|
Prototype (not released)
|
||||||
|
|
@ -260,8 +260,20 @@ R0.12a (July 10, 2016)
|
|||||||
Added support for creating exFAT volume with some changes of f_mkfs().
|
Added support for creating exFAT volume with some changes of f_mkfs().
|
||||||
Added a file open method FA_OPEN_APPEND. An f_lseek() following f_open() is no longer needed.
|
Added a file open method FA_OPEN_APPEND. An f_lseek() following f_open() is no longer needed.
|
||||||
f_forward() is available regardless of _FS_TINY.
|
f_forward() is available regardless of _FS_TINY.
|
||||||
Fixed f_mkfs() creates wrong volume.
|
Fixed f_mkfs() creates wrong volume. (appeared at R0.12)
|
||||||
|
Fixed wrong memory read in create_name(). (appeared at R0.12)
|
||||||
Fixed compilation fails at some configurations, _USE_FASTSEEK and _USE_FORWARD.
|
Fixed compilation fails at some configurations, _USE_FASTSEEK and _USE_FORWARD.
|
||||||
Fixed wrong memory read in create_name().
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
R0.12b (September 04, 2016)
|
||||||
|
|
||||||
|
Improved f_rename() to be able to rename objects with the same name but case.
|
||||||
|
Fixed an error in the case conversion teble of code page 866. (ff.c)
|
||||||
|
Fixed writing data is truncated at the file offset 4GiB on the exFAT volume. (appeared at R0.12)
|
||||||
|
Fixed creating a file in the root directory of exFAT volume can fail. (appeared at R0.12)
|
||||||
|
Fixed f_mkfs() creating exFAT volume with too small cluster size can collapse unallocated memory. (appeared at R0.12)
|
||||||
|
Fixed wrong object name can be returned when read directory at Unicode cfg. (appeared at R0.12)
|
||||||
|
Fixed large file allocation/removing on the exFAT volume collapses allocation bitmap. (appeared at R0.12)
|
||||||
|
Fixed some internal errors in f_expand() and f_lseek(). (appeared at R0.12)
|
||||||
|
|
||||||
|
@ -41,7 +41,7 @@ DSTATUS disk_status (
|
|||||||
|
|
||||||
return stat;
|
return stat;
|
||||||
|
|
||||||
case DEB_USB :
|
case DEV_USB :
|
||||||
result = USB_disk_status();
|
result = USB_disk_status();
|
||||||
|
|
||||||
// translate the reslut code here
|
// translate the reslut code here
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*----------------------------------------------------------------------------/
|
/*----------------------------------------------------------------------------/
|
||||||
/ FatFs - Generic FAT file system module R0.12a /
|
/ FatFs - Generic FAT file system module R0.12b /
|
||||||
/-----------------------------------------------------------------------------/
|
/-----------------------------------------------------------------------------/
|
||||||
/
|
/
|
||||||
/ Copyright (C) 2016, ChaN, all right reserved.
|
/ Copyright (C) 2016, ChaN, all right reserved.
|
||||||
@ -28,7 +28,7 @@
|
|||||||
|
|
||||||
---------------------------------------------------------------------------*/
|
---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
#if _FATFS != 80186 /* Revision ID */
|
#if _FATFS != 68020 /* Revision ID */
|
||||||
#error Wrong include file (ff.h).
|
#error Wrong include file (ff.h).
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -396,7 +396,7 @@ typedef struct {
|
|||||||
#define BPB_NumFATs 16 /* Number of FATs (BYTE) */
|
#define BPB_NumFATs 16 /* Number of FATs (BYTE) */
|
||||||
#define BPB_RootEntCnt 17 /* Size of root directory area for FAT12/16 [entry] (WORD) */
|
#define BPB_RootEntCnt 17 /* Size of root directory area for FAT12/16 [entry] (WORD) */
|
||||||
#define BPB_TotSec16 19 /* Volume size (16-bit) [sector] (WORD) */
|
#define BPB_TotSec16 19 /* Volume size (16-bit) [sector] (WORD) */
|
||||||
#define BPB_Media 21 /* Media descriptor (BYTE) */
|
#define BPB_Media 21 /* Media descriptor byte (BYTE) */
|
||||||
#define BPB_FATSz16 22 /* FAT size (16-bit) [sector] (WORD) */
|
#define BPB_FATSz16 22 /* FAT size (16-bit) [sector] (WORD) */
|
||||||
#define BPB_SecPerTrk 24 /* Track size for int13h [sector] (WORD) */
|
#define BPB_SecPerTrk 24 /* Track size for int13h [sector] (WORD) */
|
||||||
#define BPB_NumHeads 26 /* Number of heads for int13h (WORD) */
|
#define BPB_NumHeads 26 /* Number of heads for int13h (WORD) */
|
||||||
@ -409,6 +409,7 @@ typedef struct {
|
|||||||
#define BS_VolLab 43 /* Volume label string (8-byte) */
|
#define BS_VolLab 43 /* Volume label string (8-byte) */
|
||||||
#define BS_FilSysType 54 /* File system type string (8-byte) */
|
#define BS_FilSysType 54 /* File system type string (8-byte) */
|
||||||
#define BS_BootCode 62 /* Boot code (448-byte) */
|
#define BS_BootCode 62 /* Boot code (448-byte) */
|
||||||
|
#define BS_55AA 510 /* Signature word (WORD) */
|
||||||
|
|
||||||
#define BPB_FATSz32 36 /* FAT32: FAT size [sector] (DWORD) */
|
#define BPB_FATSz32 36 /* FAT32: FAT size [sector] (DWORD) */
|
||||||
#define BPB_ExtFlags32 40 /* FAT32: Extended flags (WORD) */
|
#define BPB_ExtFlags32 40 /* FAT32: Extended flags (WORD) */
|
||||||
@ -462,8 +463,6 @@ typedef struct {
|
|||||||
#define PTE_StLba 8 /* MBR PTE: Start in LBA */
|
#define PTE_StLba 8 /* MBR PTE: Start in LBA */
|
||||||
#define PTE_SizLba 12 /* MBR PTE: Size in LBA */
|
#define PTE_SizLba 12 /* MBR PTE: Size in LBA */
|
||||||
|
|
||||||
#define BS_55AA 510 /* Signature word (WORD) */
|
|
||||||
|
|
||||||
#define DIR_Name 0 /* Short file name (11-byte) */
|
#define DIR_Name 0 /* Short file name (11-byte) */
|
||||||
#define DIR_Attr 11 /* Attribute (BYTE) */
|
#define DIR_Attr 11 /* Attribute (BYTE) */
|
||||||
#define DIR_NTres 12 /* Lower case flag (BYTE) */
|
#define DIR_NTres 12 /* Lower case flag (BYTE) */
|
||||||
@ -1141,7 +1140,7 @@ DWORD find_bitmap ( /* 0:No free cluster, 2..:Free cluster found, 0xFFFFFFFF:Dis
|
|||||||
if (clst >= fs->n_fatent - 2) clst = 0;
|
if (clst >= fs->n_fatent - 2) clst = 0;
|
||||||
scl = val = clst; ctr = 0;
|
scl = val = clst; ctr = 0;
|
||||||
for (;;) {
|
for (;;) {
|
||||||
if (move_window(fs, fs->database + val / 8 / SS(fs)) != FR_OK) return 0xFFFFFFFF;
|
if (move_window(fs, fs->database + val / 8 / SS(fs)) != FR_OK) return 0xFFFFFFFF; /* (assuming bitmap is located top of the cluster heap) */
|
||||||
i = val / 8 % SS(fs); bm = 1 << (val % 8);
|
i = val / 8 % SS(fs); bm = 1 << (val % 8);
|
||||||
do {
|
do {
|
||||||
do {
|
do {
|
||||||
@ -1180,7 +1179,7 @@ FRESULT change_bitmap (
|
|||||||
|
|
||||||
|
|
||||||
clst -= 2; /* The first bit corresponds to cluster #2 */
|
clst -= 2; /* The first bit corresponds to cluster #2 */
|
||||||
sect = fs->database + clst / 8 / SS(fs); /* Sector address */
|
sect = fs->database + clst / 8 / SS(fs); /* Sector address (assuming bitmap is located top of the cluster heap) */
|
||||||
i = clst / 8 % SS(fs); /* Byte offset in the sector */
|
i = clst / 8 % SS(fs); /* Byte offset in the sector */
|
||||||
bm = 1 << (clst % 8); /* Bit mask in the byte */
|
bm = 1 << (clst % 8); /* Bit mask in the byte */
|
||||||
for (;;) {
|
for (;;) {
|
||||||
@ -1321,7 +1320,7 @@ DWORD create_chain ( /* 0:No free cluster, 1:Internal error, 0xFFFFFFFF:Disk err
|
|||||||
|
|
||||||
|
|
||||||
if (clst == 0) { /* Create a new chain */
|
if (clst == 0) { /* Create a new chain */
|
||||||
scl = fs->last_clst; /* Get suggested cluster to start at */
|
scl = fs->last_clst; /* Get suggested cluster to start from */
|
||||||
if (scl == 0 || scl >= fs->n_fatent) scl = 1;
|
if (scl == 0 || scl >= fs->n_fatent) scl = 1;
|
||||||
}
|
}
|
||||||
else { /* Stretch current chain */
|
else { /* Stretch current chain */
|
||||||
@ -1333,7 +1332,7 @@ DWORD create_chain ( /* 0:No free cluster, 1:Internal error, 0xFFFFFFFF:Disk err
|
|||||||
}
|
}
|
||||||
|
|
||||||
#if _FS_EXFAT
|
#if _FS_EXFAT
|
||||||
if (fs->fs_type == FS_EXFAT) { /* At the exFAT */
|
if (fs->fs_type == FS_EXFAT) { /* On the exFAT volume */
|
||||||
ncl = find_bitmap(fs, scl, 1); /* Find a free cluster */
|
ncl = find_bitmap(fs, scl, 1); /* Find a free cluster */
|
||||||
if (ncl == 0 || ncl == 0xFFFFFFFF) return ncl; /* No free cluster or hard error? */
|
if (ncl == 0 || ncl == 0xFFFFFFFF) return ncl; /* No free cluster or hard error? */
|
||||||
res = change_bitmap(fs, ncl, 1, 1); /* Mark the cluster 'in use' */
|
res = change_bitmap(fs, ncl, 1, 1); /* Mark the cluster 'in use' */
|
||||||
@ -1349,7 +1348,7 @@ DWORD create_chain ( /* 0:No free cluster, 1:Internal error, 0xFFFFFFFF:Disk err
|
|||||||
}
|
}
|
||||||
} else
|
} else
|
||||||
#endif
|
#endif
|
||||||
{ /* At the FAT12/16/32 */
|
{ /* On the FAT12/16/32 volume */
|
||||||
ncl = scl; /* Start cluster */
|
ncl = scl; /* Start cluster */
|
||||||
for (;;) {
|
for (;;) {
|
||||||
ncl++; /* Next cluster */
|
ncl++; /* Next cluster */
|
||||||
@ -1775,7 +1774,7 @@ void gen_numname (
|
|||||||
/* itoa (hexdecimal) */
|
/* itoa (hexdecimal) */
|
||||||
i = 7;
|
i = 7;
|
||||||
do {
|
do {
|
||||||
c = (seq % 16) + '0';
|
c = (BYTE)((seq % 16) + '0');
|
||||||
if (c > '9') c += 7;
|
if (c > '9') c += 7;
|
||||||
ns[i--] = c;
|
ns[i--] = c;
|
||||||
seq /= 16;
|
seq /= 16;
|
||||||
@ -2105,7 +2104,7 @@ FRESULT dir_read (
|
|||||||
c = dp->dir[DIR_Name]; /* Test for the entry type */
|
c = dp->dir[DIR_Name]; /* Test for the entry type */
|
||||||
if (c == 0) { res = FR_NO_FILE; break; } /* Reached to end of the directory */
|
if (c == 0) { res = FR_NO_FILE; break; } /* Reached to end of the directory */
|
||||||
#if _FS_EXFAT
|
#if _FS_EXFAT
|
||||||
if (fs->fs_type == FS_EXFAT) { /* At the exFAT */
|
if (fs->fs_type == FS_EXFAT) { /* On the exFAT volume */
|
||||||
if (_USE_LABEL && vol) {
|
if (_USE_LABEL && vol) {
|
||||||
if (c == 0x83) break; /* Volume label entry? */
|
if (c == 0x83) break; /* Volume label entry? */
|
||||||
} else {
|
} else {
|
||||||
@ -2120,7 +2119,7 @@ FRESULT dir_read (
|
|||||||
}
|
}
|
||||||
} else
|
} else
|
||||||
#endif
|
#endif
|
||||||
{ /* At the FAT12/16/32 */
|
{ /* On the FAT12/16/32 volume */
|
||||||
dp->obj.attr = a = dp->dir[DIR_Attr] & AM_MASK; /* Get attribute */
|
dp->obj.attr = a = dp->dir[DIR_Attr] & AM_MASK; /* Get attribute */
|
||||||
#if _USE_LFN != 0 /* LFN configuration */
|
#if _USE_LFN != 0 /* LFN configuration */
|
||||||
if (c == DDEM || c == '.' || (int)((a & ~AM_ARC) == AM_VOL) != vol) { /* An entry without valid data */
|
if (c == DDEM || c == '.' || (int)((a & ~AM_ARC) == AM_VOL) != vol) { /* An entry without valid data */
|
||||||
@ -2129,7 +2128,7 @@ FRESULT dir_read (
|
|||||||
if (a == AM_LFN) { /* An LFN entry is found */
|
if (a == AM_LFN) { /* An LFN entry is found */
|
||||||
if (c & LLEF) { /* Is it start of an LFN sequence? */
|
if (c & LLEF) { /* Is it start of an LFN sequence? */
|
||||||
sum = dp->dir[LDIR_Chksum];
|
sum = dp->dir[LDIR_Chksum];
|
||||||
c &= ~LLEF; ord = c;
|
c &= (BYTE)~LLEF; ord = c;
|
||||||
dp->blk_ofs = dp->dptr;
|
dp->blk_ofs = dp->dptr;
|
||||||
}
|
}
|
||||||
/* Check LFN validity and capture it */
|
/* Check LFN validity and capture it */
|
||||||
@ -2178,7 +2177,7 @@ FRESULT dir_find ( /* FR_OK(0):succeeded, !=0:error */
|
|||||||
res = dir_sdi(dp, 0); /* Rewind directory object */
|
res = dir_sdi(dp, 0); /* Rewind directory object */
|
||||||
if (res != FR_OK) return res;
|
if (res != FR_OK) return res;
|
||||||
#if _FS_EXFAT
|
#if _FS_EXFAT
|
||||||
if (fs->fs_type == FS_EXFAT) { /* At the exFAT */
|
if (fs->fs_type == FS_EXFAT) { /* On the exFAT volume */
|
||||||
BYTE nc;
|
BYTE nc;
|
||||||
UINT di, ni;
|
UINT di, ni;
|
||||||
WORD hash = xname_sum(fs->lfnbuf); /* Hash value of the name to find */
|
WORD hash = xname_sum(fs->lfnbuf); /* Hash value of the name to find */
|
||||||
@ -2194,7 +2193,7 @@ FRESULT dir_find ( /* FR_OK(0):succeeded, !=0:error */
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
/* At the FAT12/16/32 */
|
/* On the FAT12/16/32 volume */
|
||||||
#if _USE_LFN != 0
|
#if _USE_LFN != 0
|
||||||
ord = sum = 0xFF; dp->blk_ofs = 0xFFFFFFFF; /* Reset LFN sequence */
|
ord = sum = 0xFF; dp->blk_ofs = 0xFFFFFFFF; /* Reset LFN sequence */
|
||||||
#endif
|
#endif
|
||||||
@ -2212,7 +2211,7 @@ FRESULT dir_find ( /* FR_OK(0):succeeded, !=0:error */
|
|||||||
if (!(dp->fn[NSFLAG] & NS_NOLFN)) {
|
if (!(dp->fn[NSFLAG] & NS_NOLFN)) {
|
||||||
if (c & LLEF) { /* Is it start of LFN sequence? */
|
if (c & LLEF) { /* Is it start of LFN sequence? */
|
||||||
sum = dp->dir[LDIR_Chksum];
|
sum = dp->dir[LDIR_Chksum];
|
||||||
c &= ~LLEF; ord = c; /* LFN start order */
|
c &= (BYTE)~LLEF; ord = c; /* LFN start order */
|
||||||
dp->blk_ofs = dp->dptr; /* Start offset of LFN */
|
dp->blk_ofs = dp->dptr; /* Start offset of LFN */
|
||||||
}
|
}
|
||||||
/* Check validity of the LFN entry and compare it with given name */
|
/* Check validity of the LFN entry and compare it with given name */
|
||||||
@ -2258,7 +2257,7 @@ FRESULT dir_register ( /* FR_OK:succeeded, FR_DENIED:no free entry or too many S
|
|||||||
for (nlen = 0; fs->lfnbuf[nlen]; nlen++) ; /* Get lfn length */
|
for (nlen = 0; fs->lfnbuf[nlen]; nlen++) ; /* Get lfn length */
|
||||||
|
|
||||||
#if _FS_EXFAT
|
#if _FS_EXFAT
|
||||||
if (fs->fs_type == FS_EXFAT) { /* At the exFAT */
|
if (fs->fs_type == FS_EXFAT) { /* On the exFAT volume */
|
||||||
DIR dj;
|
DIR dj;
|
||||||
|
|
||||||
nent = (nlen + 14) / 15 + 2; /* Number of entries to allocate (85+C0+C1s) */
|
nent = (nlen + 14) / 15 + 2; /* Number of entries to allocate (85+C0+C1s) */
|
||||||
@ -2284,7 +2283,7 @@ FRESULT dir_register ( /* FR_OK:succeeded, FR_DENIED:no free entry or too many S
|
|||||||
return FR_OK;
|
return FR_OK;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
/* At the FAT12/16/32 */
|
/* On the FAT12/16/32 volume */
|
||||||
mem_cpy(sn, dp->fn, 12);
|
mem_cpy(sn, dp->fn, 12);
|
||||||
if (sn[NSFLAG] & NS_LOSS) { /* When LFN is out of 8.3 format, generate a numbered name */
|
if (sn[NSFLAG] & NS_LOSS) { /* When LFN is out of 8.3 format, generate a numbered name */
|
||||||
dp->fn[NSFLAG] = NS_NOLFN; /* Find only SFN */
|
dp->fn[NSFLAG] = NS_NOLFN; /* Find only SFN */
|
||||||
@ -2361,9 +2360,9 @@ FRESULT dir_remove ( /* FR_OK:Succeeded, FR_DISK_ERR:A disk error */
|
|||||||
res = move_window(fs, dp->sect);
|
res = move_window(fs, dp->sect);
|
||||||
if (res != FR_OK) break;
|
if (res != FR_OK) break;
|
||||||
/* Mark an entry 'deleted' */
|
/* Mark an entry 'deleted' */
|
||||||
if (_FS_EXFAT && fs->fs_type == FS_EXFAT) { /* At the exFAT */
|
if (_FS_EXFAT && fs->fs_type == FS_EXFAT) { /* On the exFAT volume */
|
||||||
dp->dir[XDIR_Type] &= 0x7F;
|
dp->dir[XDIR_Type] &= 0x7F;
|
||||||
} else { /* At the FAT12/16/32 */
|
} else { /* On the FAT12/16/32 volume */
|
||||||
dp->dir[DIR_Name] = DDEM;
|
dp->dir[DIR_Name] = DDEM;
|
||||||
}
|
}
|
||||||
fs->wflag = 1;
|
fs->wflag = 1;
|
||||||
@ -2413,12 +2412,12 @@ void get_fileinfo ( /* No return code */
|
|||||||
|
|
||||||
#if _USE_LFN != 0 /* LFN configuration */
|
#if _USE_LFN != 0 /* LFN configuration */
|
||||||
#if _FS_EXFAT
|
#if _FS_EXFAT
|
||||||
if (fs->fs_type == FS_EXFAT) { /* At the exFAT */
|
if (fs->fs_type == FS_EXFAT) { /* On the exFAT volume */
|
||||||
get_xdir_info(fs->dirbuf, fno);
|
get_xdir_info(fs->dirbuf, fno);
|
||||||
return;
|
return;
|
||||||
} else
|
} else
|
||||||
#endif
|
#endif
|
||||||
{ /* At the FAT12/16/32 */
|
{ /* On the FAT12/16/32 volume */
|
||||||
if (dp->blk_ofs != 0xFFFFFFFF) { /* Get LFN if available */
|
if (dp->blk_ofs != 0xFFFFFFFF) { /* Get LFN if available */
|
||||||
i = j = 0;
|
i = j = 0;
|
||||||
while ((w = fs->lfnbuf[j++]) != 0) { /* Get an LFN character */
|
while ((w = fs->lfnbuf[j++]) != 0) { /* Get an LFN character */
|
||||||
@ -2628,7 +2627,7 @@ FRESULT create_name ( /* FR_OK: successful, FR_INVALID_NAME: could not create */
|
|||||||
if (si) cf |= NS_LOSS | NS_LFN;
|
if (si) cf |= NS_LOSS | NS_LFN;
|
||||||
while (di && lfn[di - 1] != '.') di--; /* Find extension (di<=si: no extension) */
|
while (di && lfn[di - 1] != '.') di--; /* Find extension (di<=si: no extension) */
|
||||||
|
|
||||||
b = i = 0; ni = 8;
|
i = b = 0; ni = 8;
|
||||||
for (;;) {
|
for (;;) {
|
||||||
w = lfn[si++]; /* Get an LFN character */
|
w = lfn[si++]; /* Get an LFN character */
|
||||||
if (!w) break; /* Break on end of the LFN */
|
if (!w) break; /* Break on end of the LFN */
|
||||||
@ -2955,7 +2954,7 @@ FRESULT find_volume ( /* FR_OK(0): successful, !=0: any error occurred */
|
|||||||
UINT i;
|
UINT i;
|
||||||
|
|
||||||
|
|
||||||
/* Get logical drive number from the path name */
|
/* Get logical drive number */
|
||||||
*rfs = 0;
|
*rfs = 0;
|
||||||
vol = get_ldnumber(path);
|
vol = get_ldnumber(path);
|
||||||
if (vol < 0) return FR_INVALID_DRIVE;
|
if (vol < 0) return FR_INVALID_DRIVE;
|
||||||
@ -2967,7 +2966,7 @@ FRESULT find_volume ( /* FR_OK(0): successful, !=0: any error occurred */
|
|||||||
ENTER_FF(fs); /* Lock the volume */
|
ENTER_FF(fs); /* Lock the volume */
|
||||||
*rfs = fs; /* Return pointer to the file system object */
|
*rfs = fs; /* Return pointer to the file system object */
|
||||||
|
|
||||||
mode &= ~FA_READ; /* Desired access mode, write access or not */
|
mode &= (BYTE)~FA_READ; /* Desired access mode, write access or not */
|
||||||
if (fs->fs_type) { /* If the volume has been mounted */
|
if (fs->fs_type) { /* If the volume has been mounted */
|
||||||
stat = disk_status(fs->drv);
|
stat = disk_status(fs->drv);
|
||||||
if (!(stat & STA_NOINIT)) { /* and the physical drive is kept initialized */
|
if (!(stat & STA_NOINIT)) { /* and the physical drive is kept initialized */
|
||||||
@ -3045,7 +3044,7 @@ FRESULT find_volume ( /* FR_OK(0): successful, !=0: any error occurred */
|
|||||||
fs->volbase = bsect;
|
fs->volbase = bsect;
|
||||||
fs->database = bsect + ld_dword(fs->win + BPB_DataOfsEx);
|
fs->database = bsect + ld_dword(fs->win + BPB_DataOfsEx);
|
||||||
fs->fatbase = bsect + ld_dword(fs->win + BPB_FatOfsEx);
|
fs->fatbase = bsect + ld_dword(fs->win + BPB_FatOfsEx);
|
||||||
if (maxlba < fs->database + nclst * fs->csize) return FR_NO_FILESYSTEM; /* (Volume size must not be smaller than the size requiered) */
|
if (maxlba < (QWORD)fs->database + nclst * fs->csize) return FR_NO_FILESYSTEM; /* (Volume size must not be smaller than the size requiered) */
|
||||||
fs->dirbase = ld_dword(fs->win + BPB_RootClusEx);
|
fs->dirbase = ld_dword(fs->win + BPB_RootClusEx);
|
||||||
|
|
||||||
/* Check if bitmap location is in assumption (at the first cluster) */
|
/* Check if bitmap location is in assumption (at the first cluster) */
|
||||||
@ -3162,15 +3161,14 @@ FRESULT find_volume ( /* FR_OK(0): successful, !=0: any error occurred */
|
|||||||
|
|
||||||
static
|
static
|
||||||
FRESULT validate ( /* Returns FR_OK or FR_INVALID_OBJECT */
|
FRESULT validate ( /* Returns FR_OK or FR_INVALID_OBJECT */
|
||||||
void* dfp, /* Pointer to the FIL/DIR object to check validity */
|
_FDID* obj, /* Pointer to the _OBJ, the 1st member in the FIL/DIR object, to check validity */
|
||||||
FATFS** fs /* Pointer to pointer to the owner file system object to return */
|
FATFS** fs /* Pointer to pointer to the owner file system object to return */
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
_FDID *obj = (_FDID*)dfp; /* Assuming .obj in the FIL/DIR is the first member */
|
|
||||||
FRESULT res;
|
FRESULT res;
|
||||||
|
|
||||||
|
|
||||||
if (!dfp || !obj->fs || !obj->fs->fs_type || obj->fs->id != obj->id || (disk_status(obj->fs->drv) & STA_NOINIT)) {
|
if (!obj || !obj->fs || !obj->fs->fs_type || obj->fs->id != obj->id || (disk_status(obj->fs->drv) & STA_NOINIT)) {
|
||||||
*fs = 0; /* The object is invalid */
|
*fs = 0; /* The object is invalid */
|
||||||
res = FR_INVALID_OBJECT;
|
res = FR_INVALID_OBJECT;
|
||||||
} else {
|
} else {
|
||||||
@ -3208,6 +3206,7 @@ FRESULT f_mount (
|
|||||||
const TCHAR *rp = path;
|
const TCHAR *rp = path;
|
||||||
|
|
||||||
|
|
||||||
|
/* Get logical drive number */
|
||||||
vol = get_ldnumber(&rp);
|
vol = get_ldnumber(&rp);
|
||||||
if (vol < 0) return FR_INVALID_DRIVE;
|
if (vol < 0) return FR_INVALID_DRIVE;
|
||||||
cfs = FatFs[vol]; /* Pointer to fs object */
|
cfs = FatFs[vol]; /* Pointer to fs object */
|
||||||
@ -3261,7 +3260,7 @@ FRESULT f_open (
|
|||||||
|
|
||||||
if (!fp) return FR_INVALID_OBJECT;
|
if (!fp) return FR_INVALID_OBJECT;
|
||||||
|
|
||||||
/* Get logical drive number */
|
/* Get logical drive */
|
||||||
mode &= _FS_READONLY ? FA_READ : FA_READ | FA_WRITE | FA_CREATE_ALWAYS | FA_CREATE_NEW | FA_OPEN_ALWAYS | FA_OPEN_APPEND | FA_SEEKEND;
|
mode &= _FS_READONLY ? FA_READ : FA_READ | FA_WRITE | FA_CREATE_ALWAYS | FA_CREATE_NEW | FA_OPEN_ALWAYS | FA_OPEN_APPEND | FA_SEEKEND;
|
||||||
res = find_volume(&path, &fs, mode);
|
res = find_volume(&path, &fs, mode);
|
||||||
if (res == FR_OK) {
|
if (res == FR_OK) {
|
||||||
@ -3460,7 +3459,7 @@ FRESULT f_read (
|
|||||||
|
|
||||||
|
|
||||||
*br = 0; /* Clear read byte counter */
|
*br = 0; /* Clear read byte counter */
|
||||||
res = validate(fp, &fs);
|
res = validate(&fp->obj, &fs); /* Check validity of the file object */
|
||||||
if (res != FR_OK || (res = (FRESULT)fp->err) != FR_OK) LEAVE_FF(fs, res); /* Check validity */
|
if (res != FR_OK || (res = (FRESULT)fp->err) != FR_OK) LEAVE_FF(fs, res); /* Check validity */
|
||||||
if (!(fp->flag & FA_READ)) LEAVE_FF(fs, FR_DENIED); /* Check access mode */
|
if (!(fp->flag & FA_READ)) LEAVE_FF(fs, FR_DENIED); /* Check access mode */
|
||||||
remain = fp->obj.objsize - fp->fptr;
|
remain = fp->obj.objsize - fp->fptr;
|
||||||
@ -3495,9 +3494,7 @@ FRESULT f_read (
|
|||||||
if (csect + cc > fs->csize) { /* Clip at cluster boundary */
|
if (csect + cc > fs->csize) { /* Clip at cluster boundary */
|
||||||
cc = fs->csize - csect;
|
cc = fs->csize - csect;
|
||||||
}
|
}
|
||||||
if (disk_read(fs->drv, rbuff, sect, cc) != RES_OK) {
|
if (disk_read(fs->drv, rbuff, sect, cc) != RES_OK) ABORT(fs, FR_DISK_ERR);
|
||||||
ABORT(fs, FR_DISK_ERR);
|
|
||||||
}
|
|
||||||
#if !_FS_READONLY && _FS_MINIMIZE <= 2 /* Replace one of the read sectors with cached data if it contains a dirty sector */
|
#if !_FS_READONLY && _FS_MINIMIZE <= 2 /* Replace one of the read sectors with cached data if it contains a dirty sector */
|
||||||
#if _FS_TINY
|
#if _FS_TINY
|
||||||
if (fs->wflag && fs->winsect - sect < cc) {
|
if (fs->wflag && fs->winsect - sect < cc) {
|
||||||
@ -3517,12 +3514,10 @@ FRESULT f_read (
|
|||||||
#if !_FS_READONLY
|
#if !_FS_READONLY
|
||||||
if (fp->flag & FA_DIRTY) { /* Write-back dirty sector cache */
|
if (fp->flag & FA_DIRTY) { /* Write-back dirty sector cache */
|
||||||
if (disk_write(fs->drv, fp->buf, fp->sect, 1) != RES_OK) ABORT(fs, FR_DISK_ERR);
|
if (disk_write(fs->drv, fp->buf, fp->sect, 1) != RES_OK) ABORT(fs, FR_DISK_ERR);
|
||||||
fp->flag &= ~FA_DIRTY;
|
fp->flag &= (BYTE)~FA_DIRTY;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
if (disk_read(fs->drv, fp->buf, sect, 1) != RES_OK) { /* Fill sector cache */
|
if (disk_read(fs->drv, fp->buf, sect, 1) != RES_OK) ABORT(fs, FR_DISK_ERR); /* Fill sector cache */
|
||||||
ABORT(fs, FR_DISK_ERR);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
fp->sect = sect;
|
fp->sect = sect;
|
||||||
@ -3563,7 +3558,7 @@ FRESULT f_write (
|
|||||||
|
|
||||||
|
|
||||||
*bw = 0; /* Clear write byte counter */
|
*bw = 0; /* Clear write byte counter */
|
||||||
res = validate(fp, &fs);
|
res = validate(&fp->obj, &fs); /* Check validity of the file object */
|
||||||
if (res != FR_OK || (res = (FRESULT)fp->err) != FR_OK) LEAVE_FF(fs, res); /* Check validity */
|
if (res != FR_OK || (res = (FRESULT)fp->err) != FR_OK) LEAVE_FF(fs, res); /* Check validity */
|
||||||
if (!(fp->flag & FA_WRITE)) LEAVE_FF(fs, FR_DENIED); /* Check access mode */
|
if (!(fp->flag & FA_WRITE)) LEAVE_FF(fs, FR_DENIED); /* Check access mode */
|
||||||
|
|
||||||
@ -3603,7 +3598,7 @@ FRESULT f_write (
|
|||||||
#else
|
#else
|
||||||
if (fp->flag & FA_DIRTY) { /* Write-back sector cache */
|
if (fp->flag & FA_DIRTY) { /* Write-back sector cache */
|
||||||
if (disk_write(fs->drv, fp->buf, fp->sect, 1) != RES_OK) ABORT(fs, FR_DISK_ERR);
|
if (disk_write(fs->drv, fp->buf, fp->sect, 1) != RES_OK) ABORT(fs, FR_DISK_ERR);
|
||||||
fp->flag &= ~FA_DIRTY;
|
fp->flag &= (BYTE)~FA_DIRTY;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
sect = clust2sect(fs, fp->clust); /* Get current sector */
|
sect = clust2sect(fs, fp->clust); /* Get current sector */
|
||||||
@ -3614,9 +3609,7 @@ FRESULT f_write (
|
|||||||
if (csect + cc > fs->csize) { /* Clip at cluster boundary */
|
if (csect + cc > fs->csize) { /* Clip at cluster boundary */
|
||||||
cc = fs->csize - csect;
|
cc = fs->csize - csect;
|
||||||
}
|
}
|
||||||
if (disk_write(fs->drv, wbuff, sect, cc) != RES_OK) {
|
if (disk_write(fs->drv, wbuff, sect, cc) != RES_OK) ABORT(fs, FR_DISK_ERR);
|
||||||
ABORT(fs, FR_DISK_ERR);
|
|
||||||
}
|
|
||||||
#if _FS_MINIMIZE <= 2
|
#if _FS_MINIMIZE <= 2
|
||||||
#if _FS_TINY
|
#if _FS_TINY
|
||||||
if (fs->winsect - sect < cc) { /* Refill sector cache if it gets invalidated by the direct write */
|
if (fs->winsect - sect < cc) { /* Refill sector cache if it gets invalidated by the direct write */
|
||||||
@ -3626,7 +3619,7 @@ FRESULT f_write (
|
|||||||
#else
|
#else
|
||||||
if (fp->sect - sect < cc) { /* Refill sector cache if it gets invalidated by the direct write */
|
if (fp->sect - sect < cc) { /* Refill sector cache if it gets invalidated by the direct write */
|
||||||
mem_cpy(fp->buf, wbuff + ((fp->sect - sect) * SS(fs)), SS(fs));
|
mem_cpy(fp->buf, wbuff + ((fp->sect - sect) * SS(fs)), SS(fs));
|
||||||
fp->flag &= ~FA_DIRTY;
|
fp->flag &= (BYTE)~FA_DIRTY;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
@ -3634,16 +3627,15 @@ FRESULT f_write (
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
#if _FS_TINY
|
#if _FS_TINY
|
||||||
if (fp->fptr >= fp->obj.objsize) { /* Avoid silly cache filling at growing edge */
|
if (fp->fptr >= fp->obj.objsize) { /* Avoid silly cache filling on the growing edge */
|
||||||
if (sync_window(fs) != FR_OK) ABORT(fs, FR_DISK_ERR);
|
if (sync_window(fs) != FR_OK) ABORT(fs, FR_DISK_ERR);
|
||||||
fs->winsect = sect;
|
fs->winsect = sect;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
if (fp->sect != sect) { /* Fill sector cache with file data */
|
if (fp->sect != sect && /* Fill sector cache with file data */
|
||||||
if (fp->fptr < fp->obj.objsize &&
|
fp->fptr < fp->obj.objsize &&
|
||||||
disk_read(fs->drv, fp->buf, sect, 1) != RES_OK) {
|
disk_read(fs->drv, fp->buf, sect, 1) != RES_OK) {
|
||||||
ABORT(fs, FR_DISK_ERR);
|
ABORT(fs, FR_DISK_ERR);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
fp->sect = sect;
|
fp->sect = sect;
|
||||||
@ -3660,7 +3652,7 @@ FRESULT f_write (
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
fp->flag |= FA_MODIFIED; /* Set file change flag */
|
fp->flag |= FA_MODIFIED; /* Set file change flag */
|
||||||
|
|
||||||
LEAVE_FF(fs, FR_OK);
|
LEAVE_FF(fs, FR_OK);
|
||||||
}
|
}
|
||||||
@ -3680,17 +3672,16 @@ FRESULT f_sync (
|
|||||||
FATFS *fs;
|
FATFS *fs;
|
||||||
DWORD tm;
|
DWORD tm;
|
||||||
BYTE *dir;
|
BYTE *dir;
|
||||||
#if _FS_EXFAT
|
|
||||||
DEF_NAMBUF
|
DEF_NAMBUF
|
||||||
#endif
|
|
||||||
|
|
||||||
res = validate(fp, &fs); /* Check validity of the object */
|
|
||||||
|
res = validate(&fp->obj, &fs); /* Check validity of the file object */
|
||||||
if (res == FR_OK) {
|
if (res == FR_OK) {
|
||||||
if (fp->flag & FA_MODIFIED) { /* Is there any change to the file? */
|
if (fp->flag & FA_MODIFIED) { /* Is there any change to the file? */
|
||||||
#if !_FS_TINY
|
#if !_FS_TINY
|
||||||
if (fp->flag & FA_DIRTY) { /* Write-back cached data if needed */
|
if (fp->flag & FA_DIRTY) { /* Write-back cached data if needed */
|
||||||
if (disk_write(fs->drv, fp->buf, fp->sect, 1) != RES_OK) LEAVE_FF(fs, FR_DISK_ERR);
|
if (disk_write(fs->drv, fp->buf, fp->sect, 1) != RES_OK) LEAVE_FF(fs, FR_DISK_ERR);
|
||||||
fp->flag &= ~FA_DIRTY;
|
fp->flag &= (BYTE)~FA_DIRTY;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
/* Update the directory entry */
|
/* Update the directory entry */
|
||||||
@ -3715,7 +3706,7 @@ FRESULT f_sync (
|
|||||||
res = store_xdir(&dj); /* Restore it to the directory */
|
res = store_xdir(&dj); /* Restore it to the directory */
|
||||||
if (res == FR_OK) {
|
if (res == FR_OK) {
|
||||||
res = sync_fs(fs);
|
res = sync_fs(fs);
|
||||||
fp->flag &= ~FA_MODIFIED;
|
fp->flag &= (BYTE)~FA_MODIFIED;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
FREE_NAMBUF();
|
FREE_NAMBUF();
|
||||||
@ -3733,7 +3724,7 @@ FRESULT f_sync (
|
|||||||
st_word(dir + DIR_LstAccDate, 0);
|
st_word(dir + DIR_LstAccDate, 0);
|
||||||
fs->wflag = 1;
|
fs->wflag = 1;
|
||||||
res = sync_fs(fs); /* Restore it to the directory */
|
res = sync_fs(fs); /* Restore it to the directory */
|
||||||
fp->flag &= ~FA_MODIFIED;
|
fp->flag &= (BYTE)~FA_MODIFIED;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -3763,7 +3754,7 @@ FRESULT f_close (
|
|||||||
if (res == FR_OK)
|
if (res == FR_OK)
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
res = validate(fp, &fs); /* Lock volume */
|
res = validate(&fp->obj, &fs); /* Lock volume */
|
||||||
if (res == FR_OK) {
|
if (res == FR_OK) {
|
||||||
#if _FS_LOCK != 0
|
#if _FS_LOCK != 0
|
||||||
res = dec_lock(fp->obj.lockid); /* Decrement file open counter */
|
res = dec_lock(fp->obj.lockid); /* Decrement file open counter */
|
||||||
@ -3796,10 +3787,11 @@ FRESULT f_chdrive (
|
|||||||
int vol;
|
int vol;
|
||||||
|
|
||||||
|
|
||||||
|
/* Get logical drive number */
|
||||||
vol = get_ldnumber(&path);
|
vol = get_ldnumber(&path);
|
||||||
if (vol < 0) return FR_INVALID_DRIVE;
|
if (vol < 0) return FR_INVALID_DRIVE;
|
||||||
|
|
||||||
CurrVol = (BYTE)vol;
|
CurrVol = (BYTE)vol; /* Set it as current volume */
|
||||||
|
|
||||||
return FR_OK;
|
return FR_OK;
|
||||||
}
|
}
|
||||||
@ -3815,7 +3807,7 @@ FRESULT f_chdir (
|
|||||||
FATFS *fs;
|
FATFS *fs;
|
||||||
DEF_NAMBUF
|
DEF_NAMBUF
|
||||||
|
|
||||||
/* Get logical drive number */
|
/* Get logical drive */
|
||||||
res = find_volume(&path, &fs, 0);
|
res = find_volume(&path, &fs, 0);
|
||||||
if (res == FR_OK) {
|
if (res == FR_OK) {
|
||||||
dj.obj.fs = fs;
|
dj.obj.fs = fs;
|
||||||
@ -3874,7 +3866,7 @@ FRESULT f_getcwd (
|
|||||||
|
|
||||||
|
|
||||||
*buff = 0;
|
*buff = 0;
|
||||||
/* Get logical drive number */
|
/* Get logical drive */
|
||||||
res = find_volume((const TCHAR**)&buff, &fs, 0); /* Get current volume */
|
res = find_volume((const TCHAR**)&buff, &fs, 0); /* Get current volume */
|
||||||
if (res == FR_OK) {
|
if (res == FR_OK) {
|
||||||
dj.obj.fs = fs;
|
dj.obj.fs = fs;
|
||||||
@ -3951,7 +3943,7 @@ FRESULT f_lseek (
|
|||||||
DWORD cl, pcl, ncl, tcl, dsc, tlen, ulen, *tbl;
|
DWORD cl, pcl, ncl, tcl, dsc, tlen, ulen, *tbl;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
res = validate(fp, &fs); /* Check validity of the object */
|
res = validate(&fp->obj, &fs); /* Check validity of the file object */
|
||||||
if (res != FR_OK || (res = (FRESULT)fp->err) != FR_OK) LEAVE_FF(fs, res); /* Check validity */
|
if (res != FR_OK || (res = (FRESULT)fp->err) != FR_OK) LEAVE_FF(fs, res); /* Check validity */
|
||||||
#if _USE_FASTSEEK
|
#if _USE_FASTSEEK
|
||||||
if (fp->cltbl) { /* Fast seek */
|
if (fp->cltbl) { /* Fast seek */
|
||||||
@ -3993,12 +3985,10 @@ FRESULT f_lseek (
|
|||||||
#if !_FS_READONLY
|
#if !_FS_READONLY
|
||||||
if (fp->flag & FA_DIRTY) { /* Write-back dirty sector cache */
|
if (fp->flag & FA_DIRTY) { /* Write-back dirty sector cache */
|
||||||
if (disk_write(fs->drv, fp->buf, fp->sect, 1) != RES_OK) ABORT(fs, FR_DISK_ERR);
|
if (disk_write(fs->drv, fp->buf, fp->sect, 1) != RES_OK) ABORT(fs, FR_DISK_ERR);
|
||||||
fp->flag &= ~FA_DIRTY;
|
fp->flag &= (BYTE)~FA_DIRTY;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
if (disk_read(fs->drv, fp->buf, dsc, 1) != RES_OK) { /* Load current sector */
|
if (disk_read(fs->drv, fp->buf, dsc, 1) != RES_OK) ABORT(fs, FR_DISK_ERR); /* Load current sector */
|
||||||
ABORT(fs, FR_DISK_ERR);
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
fp->sect = dsc;
|
fp->sect = dsc;
|
||||||
}
|
}
|
||||||
@ -4021,7 +4011,7 @@ FRESULT f_lseek (
|
|||||||
bcs = (DWORD)fs->csize * SS(fs); /* Cluster size (byte) */
|
bcs = (DWORD)fs->csize * SS(fs); /* Cluster size (byte) */
|
||||||
if (ifptr > 0 &&
|
if (ifptr > 0 &&
|
||||||
(ofs - 1) / bcs >= (ifptr - 1) / bcs) { /* When seek to same or following cluster, */
|
(ofs - 1) / bcs >= (ifptr - 1) / bcs) { /* When seek to same or following cluster, */
|
||||||
fp->fptr = (ifptr - 1) & ~(bcs - 1); /* start from the current cluster */
|
fp->fptr = (ifptr - 1) & ~(FSIZE_t)(bcs - 1); /* start from the current cluster */
|
||||||
ofs -= fp->fptr;
|
ofs -= fp->fptr;
|
||||||
clst = fp->clust;
|
clst = fp->clust;
|
||||||
} else { /* When seek to back cluster, */
|
} else { /* When seek to back cluster, */
|
||||||
@ -4045,13 +4035,15 @@ FRESULT f_lseek (
|
|||||||
fp->obj.objsize = fp->fptr;
|
fp->obj.objsize = fp->fptr;
|
||||||
fp->flag |= FA_MODIFIED;
|
fp->flag |= FA_MODIFIED;
|
||||||
}
|
}
|
||||||
clst = create_chain(&fp->obj, clst); /* Force stretch if in write mode */
|
clst = create_chain(&fp->obj, clst); /* Follow chain with forceed stretch */
|
||||||
if (clst == 0) { /* When disk gets full, clip file size */
|
if (clst == 0) { /* Clip file size in case of disk full */
|
||||||
ofs = 0; break;
|
ofs = 0; break;
|
||||||
}
|
}
|
||||||
} else
|
} else
|
||||||
#endif
|
#endif
|
||||||
|
{
|
||||||
clst = get_fat(&fp->obj, clst); /* Follow cluster chain if not in write mode */
|
clst = get_fat(&fp->obj, clst); /* Follow cluster chain if not in write mode */
|
||||||
|
}
|
||||||
if (clst == 0xFFFFFFFF) ABORT(fs, FR_DISK_ERR);
|
if (clst == 0xFFFFFFFF) ABORT(fs, FR_DISK_ERR);
|
||||||
if (clst <= 1 || clst >= fs->n_fatent) ABORT(fs, FR_INT_ERR);
|
if (clst <= 1 || clst >= fs->n_fatent) ABORT(fs, FR_INT_ERR);
|
||||||
fp->clust = clst;
|
fp->clust = clst;
|
||||||
@ -4064,26 +4056,22 @@ FRESULT f_lseek (
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (!_FS_READONLY && fp->fptr > fp->obj.objsize) { /* Set file change flag if the file size is extended */
|
||||||
|
fp->obj.objsize = fp->fptr;
|
||||||
|
fp->flag |= FA_MODIFIED;
|
||||||
|
}
|
||||||
if (fp->fptr % SS(fs) && nsect != fp->sect) { /* Fill sector cache if needed */
|
if (fp->fptr % SS(fs) && nsect != fp->sect) { /* Fill sector cache if needed */
|
||||||
#if !_FS_TINY
|
#if !_FS_TINY
|
||||||
#if !_FS_READONLY
|
#if !_FS_READONLY
|
||||||
if (fp->flag & FA_DIRTY) { /* Write-back dirty sector cache */
|
if (fp->flag & FA_DIRTY) { /* Write-back dirty sector cache */
|
||||||
if (disk_write(fs->drv, fp->buf, fp->sect, 1) != RES_OK) ABORT(fs, FR_DISK_ERR);
|
if (disk_write(fs->drv, fp->buf, fp->sect, 1) != RES_OK) ABORT(fs, FR_DISK_ERR);
|
||||||
fp->flag &= ~FA_DIRTY;
|
fp->flag &= (BYTE)~FA_DIRTY;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
if (disk_read(fs->drv, fp->buf, nsect, 1) != RES_OK) { /* Fill sector cache */
|
if (disk_read(fs->drv, fp->buf, nsect, 1) != RES_OK) ABORT(fs, FR_DISK_ERR); /* Fill sector cache */
|
||||||
ABORT(fs, FR_DISK_ERR);
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
fp->sect = nsect;
|
fp->sect = nsect;
|
||||||
}
|
}
|
||||||
#if !_FS_READONLY
|
|
||||||
if (fp->fptr > fp->obj.objsize) { /* Set file change flag if the file size is extended */
|
|
||||||
fp->obj.objsize = fp->fptr;
|
|
||||||
fp->flag |= FA_MODIFIED;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
LEAVE_FF(fs, res);
|
LEAVE_FF(fs, res);
|
||||||
@ -4109,7 +4097,7 @@ FRESULT f_opendir (
|
|||||||
|
|
||||||
if (!dp) return FR_INVALID_OBJECT;
|
if (!dp) return FR_INVALID_OBJECT;
|
||||||
|
|
||||||
/* Get logical drive number */
|
/* Get logical drive */
|
||||||
obj = &dp->obj;
|
obj = &dp->obj;
|
||||||
res = find_volume(&path, &fs, 0);
|
res = find_volume(&path, &fs, 0);
|
||||||
if (res == FR_OK) {
|
if (res == FR_OK) {
|
||||||
@ -4174,7 +4162,7 @@ FRESULT f_closedir (
|
|||||||
FATFS *fs;
|
FATFS *fs;
|
||||||
|
|
||||||
|
|
||||||
res = validate(dp, &fs);
|
res = validate(&dp->obj, &fs); /* Check validity of the file object */
|
||||||
if (res == FR_OK) {
|
if (res == FR_OK) {
|
||||||
#if _FS_LOCK != 0
|
#if _FS_LOCK != 0
|
||||||
if (dp->obj.lockid) { /* Decrement sub-directory open counter */
|
if (dp->obj.lockid) { /* Decrement sub-directory open counter */
|
||||||
@ -4209,7 +4197,7 @@ FRESULT f_readdir (
|
|||||||
DEF_NAMBUF
|
DEF_NAMBUF
|
||||||
|
|
||||||
|
|
||||||
res = validate(dp, &fs); /* Check validity of the object */
|
res = validate(&dp->obj, &fs); /* Check validity of the directory object */
|
||||||
if (res == FR_OK) {
|
if (res == FR_OK) {
|
||||||
if (!fno) {
|
if (!fno) {
|
||||||
res = dir_sdi(dp, 0); /* Rewind the directory object */
|
res = dir_sdi(dp, 0); /* Rewind the directory object */
|
||||||
@ -4297,7 +4285,7 @@ FRESULT f_stat (
|
|||||||
DEF_NAMBUF
|
DEF_NAMBUF
|
||||||
|
|
||||||
|
|
||||||
/* Get logical drive number */
|
/* Get logical drive */
|
||||||
res = find_volume(&path, &dj.obj.fs, 0);
|
res = find_volume(&path, &dj.obj.fs, 0);
|
||||||
if (res == FR_OK) {
|
if (res == FR_OK) {
|
||||||
INIT_NAMBUF(dj.obj.fs);
|
INIT_NAMBUF(dj.obj.fs);
|
||||||
@ -4336,7 +4324,7 @@ FRESULT f_getfree (
|
|||||||
_FDID obj;
|
_FDID obj;
|
||||||
|
|
||||||
|
|
||||||
/* Get logical drive number */
|
/* Get logical drive */
|
||||||
res = find_volume(&path, &fs, 0);
|
res = find_volume(&path, &fs, 0);
|
||||||
if (res == FR_OK) {
|
if (res == FR_OK) {
|
||||||
*fatfs = fs; /* Return ptr to the fs object */
|
*fatfs = fs; /* Return ptr to the fs object */
|
||||||
@ -4418,8 +4406,8 @@ FRESULT f_truncate (
|
|||||||
DWORD ncl;
|
DWORD ncl;
|
||||||
|
|
||||||
|
|
||||||
res = validate(fp, &fs); /* Check validity of the object */
|
res = validate(&fp->obj, &fs); /* Check validity of the file object */
|
||||||
if (res != FR_OK || (res = (FRESULT)fp->err) != FR_OK) LEAVE_FF(fs, res); /* Check validity */
|
if (res != FR_OK || (res = (FRESULT)fp->err) != FR_OK) LEAVE_FF(fs, res);
|
||||||
if (!(fp->flag & FA_WRITE)) LEAVE_FF(fs, FR_DENIED); /* Check access mode */
|
if (!(fp->flag & FA_WRITE)) LEAVE_FF(fs, FR_DENIED); /* Check access mode */
|
||||||
|
|
||||||
if (fp->obj.objsize > fp->fptr) {
|
if (fp->obj.objsize > fp->fptr) {
|
||||||
@ -4442,7 +4430,7 @@ FRESULT f_truncate (
|
|||||||
if (disk_write(fs->drv, fp->buf, fp->sect, 1) != RES_OK) {
|
if (disk_write(fs->drv, fp->buf, fp->sect, 1) != RES_OK) {
|
||||||
res = FR_DISK_ERR;
|
res = FR_DISK_ERR;
|
||||||
} else {
|
} else {
|
||||||
fp->flag &= ~FA_DIRTY;
|
fp->flag &= (BYTE)~FA_DIRTY;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@ -4473,7 +4461,7 @@ FRESULT f_unlink (
|
|||||||
DEF_NAMBUF
|
DEF_NAMBUF
|
||||||
|
|
||||||
|
|
||||||
/* Get logical drive number */
|
/* Get logical drive */
|
||||||
res = find_volume(&path, &fs, FA_WRITE);
|
res = find_volume(&path, &fs, FA_WRITE);
|
||||||
dj.obj.fs = fs;
|
dj.obj.fs = fs;
|
||||||
if (res == FR_OK) {
|
if (res == FR_OK) {
|
||||||
@ -4567,7 +4555,7 @@ FRESULT f_mkdir (
|
|||||||
DEF_NAMBUF
|
DEF_NAMBUF
|
||||||
|
|
||||||
|
|
||||||
/* Get logical drive number */
|
/* Get logical drive */
|
||||||
res = find_volume(&path, &fs, FA_WRITE);
|
res = find_volume(&path, &fs, FA_WRITE);
|
||||||
dj.obj.fs = fs;
|
dj.obj.fs = fs;
|
||||||
if (res == FR_OK) {
|
if (res == FR_OK) {
|
||||||
@ -4661,7 +4649,7 @@ FRESULT f_rename (
|
|||||||
|
|
||||||
|
|
||||||
get_ldnumber(&path_new); /* Ignore drive number of new name */
|
get_ldnumber(&path_new); /* Ignore drive number of new name */
|
||||||
res = find_volume(&path_old, &fs, FA_WRITE); /* Get logical drive number of the old object */
|
res = find_volume(&path_old, &fs, FA_WRITE); /* Get logical drive of the old object */
|
||||||
if (res == FR_OK) {
|
if (res == FR_OK) {
|
||||||
djo.obj.fs = fs;
|
djo.obj.fs = fs;
|
||||||
INIT_NAMBUF(fs);
|
INIT_NAMBUF(fs);
|
||||||
@ -4678,10 +4666,12 @@ FRESULT f_rename (
|
|||||||
|
|
||||||
mem_cpy(buf, fs->dirbuf, SZDIRE * 2); /* Save 85+C0 entry of old object */
|
mem_cpy(buf, fs->dirbuf, SZDIRE * 2); /* Save 85+C0 entry of old object */
|
||||||
mem_cpy(&djn, &djo, sizeof djo);
|
mem_cpy(&djn, &djo, sizeof djo);
|
||||||
res = follow_path(&djn, path_new); /* Make sure if new object name is not in use */
|
res = follow_path(&djn, path_new); /* Make sure if new object name is not in use */
|
||||||
if (res == FR_OK) res = FR_EXIST; /* Is new name already in use? */
|
if (res == FR_OK) { /* Is new name already in use by any other object? */
|
||||||
if (res == FR_NO_FILE) { /* It is a valid path and no name collision */
|
res = (djn.obj.sclust == djo.obj.sclust && djn.dptr == djo.dptr) ? FR_NO_FILE : FR_EXIST;
|
||||||
res = dir_register(&djn); /* Register the new entry */
|
}
|
||||||
|
if (res == FR_NO_FILE) { /* It is a valid path and no name collision */
|
||||||
|
res = dir_register(&djn); /* Register the new entry */
|
||||||
if (res == FR_OK) {
|
if (res == FR_OK) {
|
||||||
nf = fs->dirbuf[XDIR_NumSec]; nn = fs->dirbuf[XDIR_NumName];
|
nf = fs->dirbuf[XDIR_NumSec]; nn = fs->dirbuf[XDIR_NumName];
|
||||||
nh = ld_word(fs->dirbuf + XDIR_NameHash);
|
nh = ld_word(fs->dirbuf + XDIR_NameHash);
|
||||||
@ -4698,7 +4688,9 @@ FRESULT f_rename (
|
|||||||
mem_cpy(buf, djo.dir + DIR_Attr, 21); /* Save information about the object except name */
|
mem_cpy(buf, djo.dir + DIR_Attr, 21); /* Save information about the object except name */
|
||||||
mem_cpy(&djn, &djo, sizeof (DIR)); /* Duplicate the directory object */
|
mem_cpy(&djn, &djo, sizeof (DIR)); /* Duplicate the directory object */
|
||||||
res = follow_path(&djn, path_new); /* Make sure if new object name is not in use */
|
res = follow_path(&djn, path_new); /* Make sure if new object name is not in use */
|
||||||
if (res == FR_OK) res = FR_EXIST; /* Is new name already in use? */
|
if (res == FR_OK) { /* Is new name already in use by any other object? */
|
||||||
|
res = (djn.obj.sclust == djo.obj.sclust && djn.dptr == djo.dptr) ? FR_NO_FILE : FR_EXIST;
|
||||||
|
}
|
||||||
if (res == FR_NO_FILE) { /* It is a valid path and no name collision */
|
if (res == FR_NO_FILE) { /* It is a valid path and no name collision */
|
||||||
res = dir_register(&djn); /* Register the new entry */
|
res = dir_register(&djn); /* Register the new entry */
|
||||||
if (res == FR_OK) {
|
if (res == FR_OK) {
|
||||||
@ -4761,7 +4753,7 @@ FRESULT f_chmod (
|
|||||||
DEF_NAMBUF
|
DEF_NAMBUF
|
||||||
|
|
||||||
|
|
||||||
res = find_volume(&path, &fs, FA_WRITE); /* Get logical drive number */
|
res = find_volume(&path, &fs, FA_WRITE); /* Get logical drive */
|
||||||
dj.obj.fs = fs;
|
dj.obj.fs = fs;
|
||||||
if (res == FR_OK) {
|
if (res == FR_OK) {
|
||||||
INIT_NAMBUF(fs);
|
INIT_NAMBUF(fs);
|
||||||
@ -4805,7 +4797,7 @@ FRESULT f_utime (
|
|||||||
DEF_NAMBUF
|
DEF_NAMBUF
|
||||||
|
|
||||||
|
|
||||||
res = find_volume(&path, &fs, FA_WRITE); /* Get logical drive number */
|
res = find_volume(&path, &fs, FA_WRITE); /* Get logical drive */
|
||||||
dj.obj.fs = fs;
|
dj.obj.fs = fs;
|
||||||
if (res == FR_OK) {
|
if (res == FR_OK) {
|
||||||
INIT_NAMBUF(fs);
|
INIT_NAMBUF(fs);
|
||||||
@ -4853,7 +4845,7 @@ FRESULT f_getlabel (
|
|||||||
WCHAR w;
|
WCHAR w;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Get logical drive number */
|
/* Get logical drive */
|
||||||
res = find_volume(&path, &fs, 0);
|
res = find_volume(&path, &fs, 0);
|
||||||
|
|
||||||
/* Get volume label */
|
/* Get volume label */
|
||||||
@ -4941,7 +4933,7 @@ FRESULT f_setlabel (
|
|||||||
static const char badchr[] = "\"*+,.:;<=>\?[]|\x7F";
|
static const char badchr[] = "\"*+,.:;<=>\?[]|\x7F";
|
||||||
|
|
||||||
|
|
||||||
/* Get logical drive number */
|
/* Get logical drive */
|
||||||
res = find_volume(&label, &fs, FA_WRITE);
|
res = find_volume(&label, &fs, FA_WRITE);
|
||||||
if (res != FR_OK) LEAVE_FF(fs, res);
|
if (res != FR_OK) LEAVE_FF(fs, res);
|
||||||
dj.obj.fs = fs;
|
dj.obj.fs = fs;
|
||||||
@ -4950,7 +4942,7 @@ FRESULT f_setlabel (
|
|||||||
for (slen = 0; (UINT)label[slen] >= ' '; slen++) ; /* Get name length */
|
for (slen = 0; (UINT)label[slen] >= ' '; slen++) ; /* Get name length */
|
||||||
|
|
||||||
#if _FS_EXFAT
|
#if _FS_EXFAT
|
||||||
if (fs->fs_type == FS_EXFAT) { /* At the exFAT */
|
if (fs->fs_type == FS_EXFAT) { /* On the exFAT volume */
|
||||||
for (i = j = 0; i < slen; ) { /* Create volume label in directory form */
|
for (i = j = 0; i < slen; ) { /* Create volume label in directory form */
|
||||||
w = label[i++];
|
w = label[i++];
|
||||||
#if !_LFN_UNICODE
|
#if !_LFN_UNICODE
|
||||||
@ -4967,7 +4959,7 @@ FRESULT f_setlabel (
|
|||||||
slen = j;
|
slen = j;
|
||||||
} else
|
} else
|
||||||
#endif
|
#endif
|
||||||
{ /* At the FAT12/16/32 */
|
{ /* On the FAT12/16/32 volume */
|
||||||
for ( ; slen && label[slen - 1] == ' '; slen--) ; /* Remove trailing spaces */
|
for ( ; slen && label[slen - 1] == ' '; slen--) ; /* Remove trailing spaces */
|
||||||
if (slen) { /* Is there a volume label to be set? */
|
if (slen) { /* Is there a volume label to be set? */
|
||||||
dirvn[0] = 0; i = j = 0; /* Create volume label in directory form */
|
dirvn[0] = 0; i = j = 0; /* Create volume label in directory form */
|
||||||
@ -5008,7 +5000,7 @@ FRESULT f_setlabel (
|
|||||||
res = dir_read(&dj, 1); /* Get volume label entry */
|
res = dir_read(&dj, 1); /* Get volume label entry */
|
||||||
if (res == FR_OK) {
|
if (res == FR_OK) {
|
||||||
if (_FS_EXFAT && fs->fs_type == FS_EXFAT) {
|
if (_FS_EXFAT && fs->fs_type == FS_EXFAT) {
|
||||||
dj.dir[XDIR_NumLabel] = slen / 2; /* Change the volume label */
|
dj.dir[XDIR_NumLabel] = (BYTE)(slen / 2); /* Change the volume label */
|
||||||
mem_cpy(dj.dir + XDIR_Label, dirvn, slen);
|
mem_cpy(dj.dir + XDIR_Label, dirvn, slen);
|
||||||
} else {
|
} else {
|
||||||
if (slen) {
|
if (slen) {
|
||||||
@ -5028,7 +5020,7 @@ FRESULT f_setlabel (
|
|||||||
mem_set(dj.dir, 0, SZDIRE); /* Clear the entry */
|
mem_set(dj.dir, 0, SZDIRE); /* Clear the entry */
|
||||||
if (_FS_EXFAT && fs->fs_type == FS_EXFAT) {
|
if (_FS_EXFAT && fs->fs_type == FS_EXFAT) {
|
||||||
dj.dir[XDIR_Type] = 0x83; /* Create 83 entry */
|
dj.dir[XDIR_Type] = 0x83; /* Create 83 entry */
|
||||||
dj.dir[XDIR_NumLabel] = slen / 2;
|
dj.dir[XDIR_NumLabel] = (BYTE)(slen / 2);
|
||||||
mem_cpy(dj.dir + XDIR_Label, dirvn, slen);
|
mem_cpy(dj.dir + XDIR_Label, dirvn, slen);
|
||||||
} else {
|
} else {
|
||||||
dj.dir[DIR_Attr] = AM_VOL; /* Create volume label entry */
|
dj.dir[DIR_Attr] = AM_VOL; /* Create volume label entry */
|
||||||
@ -5066,8 +5058,8 @@ FRESULT f_expand (
|
|||||||
DWORD n, clst, stcl, scl, ncl, tcl, lclst;
|
DWORD n, clst, stcl, scl, ncl, tcl, lclst;
|
||||||
|
|
||||||
|
|
||||||
res = validate(fp, &fs); /* Check validity of the object */
|
res = validate(&fp->obj, &fs); /* Check validity of the file object */
|
||||||
if (res != FR_OK || (res = (FRESULT)fp->err) != FR_OK) LEAVE_FF(fs, res); /* Check validity */
|
if (res != FR_OK || (res = (FRESULT)fp->err) != FR_OK) LEAVE_FF(fs, res);
|
||||||
if (fsz == 0 || fp->obj.objsize != 0 || !(fp->flag & FA_WRITE)) LEAVE_FF(fs, FR_DENIED);
|
if (fsz == 0 || fp->obj.objsize != 0 || !(fp->flag & FA_WRITE)) LEAVE_FF(fs, FR_DENIED);
|
||||||
#if _FS_EXFAT
|
#if _FS_EXFAT
|
||||||
if (fs->fs_type != FS_EXFAT && fsz >= 0x100000000) LEAVE_FF(fs, FR_DENIED); /* Check if in size limit */
|
if (fs->fs_type != FS_EXFAT && fsz >= 0x100000000) LEAVE_FF(fs, FR_DENIED); /* Check if in size limit */
|
||||||
@ -5161,8 +5153,8 @@ FRESULT f_forward (
|
|||||||
|
|
||||||
|
|
||||||
*bf = 0; /* Clear transfer byte counter */
|
*bf = 0; /* Clear transfer byte counter */
|
||||||
res = validate(fp, &fs); /* Check validity of the object */
|
res = validate(&fp->obj, &fs); /* Check validity of the file object */
|
||||||
if (res != FR_OK || (res = (FRESULT)fp->err) != FR_OK) LEAVE_FF(fs, res); /* Check validity */
|
if (res != FR_OK || (res = (FRESULT)fp->err) != FR_OK) LEAVE_FF(fs, res);
|
||||||
if (!(fp->flag & FA_READ)) LEAVE_FF(fs, FR_DENIED); /* Check access mode */
|
if (!(fp->flag & FA_READ)) LEAVE_FF(fs, FR_DENIED); /* Check access mode */
|
||||||
|
|
||||||
remain = fp->obj.objsize - fp->fptr;
|
remain = fp->obj.objsize - fp->fptr;
|
||||||
@ -5191,7 +5183,7 @@ FRESULT f_forward (
|
|||||||
#if !_FS_READONLY
|
#if !_FS_READONLY
|
||||||
if (fp->flag & FA_DIRTY) { /* Write-back dirty sector cache */
|
if (fp->flag & FA_DIRTY) { /* Write-back dirty sector cache */
|
||||||
if (disk_write(fs->drv, fp->buf, fp->sect, 1) != RES_OK) ABORT(fs, FR_DISK_ERR);
|
if (disk_write(fs->drv, fp->buf, fp->sect, 1) != RES_OK) ABORT(fs, FR_DISK_ERR);
|
||||||
fp->flag &= ~FA_DIRTY;
|
fp->flag &= (BYTE)~FA_DIRTY;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
if (disk_read(fs->drv, fp->buf, sect, 1) != RES_OK) ABORT(fs, FR_DISK_ERR);
|
if (disk_read(fs->drv, fp->buf, sect, 1) != RES_OK) ABORT(fs, FR_DISK_ERR);
|
||||||
@ -5226,14 +5218,14 @@ FRESULT f_mkfs (
|
|||||||
{
|
{
|
||||||
const UINT n_fats = 1; /* Number of FATs for FAT12/16/32 volume (1 or 2) */
|
const UINT n_fats = 1; /* Number of FATs for FAT12/16/32 volume (1 or 2) */
|
||||||
const UINT n_rootdir = 512; /* Number of root directory entries for FAT12/16 volume */
|
const UINT n_rootdir = 512; /* Number of root directory entries for FAT12/16 volume */
|
||||||
static const WORD cst[] = {1, 4, 16, 64, 256, 512, 0}; /* Cluster size boundary for FAT12/16 volume (4KS unit) */
|
static const WORD cst[] = {1, 4, 16, 64, 256, 512, 0}; /* Cluster size boundary for FAT12/16 volume (4Ks unit) */
|
||||||
static const WORD cst32[] = {1, 2, 4, 8, 16, 32, 0}; /* Cluster size boundary for FAT32 volume (128KS unit) */
|
static const WORD cst32[] = {1, 2, 4, 8, 16, 32, 0}; /* Cluster size boundary for FAT32 volume (128Ks unit) */
|
||||||
BYTE fmt, sys, *buf, *pte, pdrv, part;
|
BYTE fmt, sys, *buf, *pte, pdrv, part;
|
||||||
WORD ss;
|
WORD ss;
|
||||||
DWORD n, pau, n_clst, sz_blk, sect, szb_buf, sz_buf;
|
DWORD szb_buf, sz_buf, sz_blk, n_clst, pau, sect, nsect, n;
|
||||||
DWORD b_vol, b_fat, b_data; /* Base LBA for volume, fat, data */
|
DWORD b_vol, b_fat, b_data; /* Base LBA for volume, fat, data */
|
||||||
DWORD sz_vol, sz_rsv, sz_fat, sz_dir; /* Size for volume, fat, dir, data */
|
DWORD sz_vol, sz_rsv, sz_fat, sz_dir; /* Size for volume, fat, dir, data */
|
||||||
UINT i, ns;
|
UINT i;
|
||||||
int vol;
|
int vol;
|
||||||
DSTATUS stat;
|
DSTATUS stat;
|
||||||
#if _USE_TRIM || _FS_EXFAT
|
#if _USE_TRIM || _FS_EXFAT
|
||||||
@ -5246,34 +5238,33 @@ FRESULT f_mkfs (
|
|||||||
if (vol < 0) return FR_INVALID_DRIVE;
|
if (vol < 0) return FR_INVALID_DRIVE;
|
||||||
if (FatFs[vol]) FatFs[vol]->fs_type = 0; /* Clear mounted volume */
|
if (FatFs[vol]) FatFs[vol]->fs_type = 0; /* Clear mounted volume */
|
||||||
pdrv = LD2PD(vol); /* Physical drive */
|
pdrv = LD2PD(vol); /* Physical drive */
|
||||||
part = LD2PT(vol); /* Partition (0:create as new, 1-4:get by partition table) */
|
part = LD2PT(vol); /* Partition (0:create as new, 1-4:get from partition table) */
|
||||||
|
|
||||||
/* Check physical drive status */
|
/* Check physical drive status */
|
||||||
stat = disk_initialize(pdrv);
|
stat = disk_initialize(pdrv);
|
||||||
if (stat & STA_NOINIT) return FR_NOT_READY;
|
if (stat & STA_NOINIT) return FR_NOT_READY;
|
||||||
if (stat & STA_PROTECT) return FR_WRITE_PROTECTED;
|
if (stat & STA_PROTECT) return FR_WRITE_PROTECTED;
|
||||||
if (disk_ioctl(pdrv, GET_BLOCK_SIZE, &sz_blk) != RES_OK || !sz_blk || sz_blk > 32768 || (sz_blk & (sz_blk - 1))) sz_blk = 1;
|
if (disk_ioctl(pdrv, GET_BLOCK_SIZE, &sz_blk) != RES_OK || !sz_blk || sz_blk > 32768 || (sz_blk & (sz_blk - 1))) sz_blk = 1; /* Erase block to align data area */
|
||||||
#if _MAX_SS != _MIN_SS /* Get sector size of the medium */
|
#if _MAX_SS != _MIN_SS /* Get sector size of the medium */
|
||||||
if (disk_ioctl(pdrv, GET_SECTOR_SIZE, &ss) != RES_OK) return FR_DISK_ERR;
|
if (disk_ioctl(pdrv, GET_SECTOR_SIZE, &ss) != RES_OK) return FR_DISK_ERR;
|
||||||
if (ss > _MAX_SS || ss < _MIN_SS || (ss & (ss - 1))) return FR_DISK_ERR;
|
if (ss > _MAX_SS || ss < _MIN_SS || (ss & (ss - 1))) return FR_DISK_ERR;
|
||||||
#else
|
#else
|
||||||
ss = _MAX_SS;
|
ss = _MAX_SS;
|
||||||
#endif
|
#endif
|
||||||
if ((au != 0 && au < ss) || (au & (au - 1))) return FR_INVALID_PARAMETER; /* Check if au is valid */
|
if ((au != 0 && au < ss) || au > 0x1000000 || (au & (au - 1))) return FR_INVALID_PARAMETER; /* Check if au is valid */
|
||||||
au /= ss; /* Cluster size in byte to in sector */
|
au /= ss; /* Cluster size in unit of sector */
|
||||||
if (au > 32768) return FR_INVALID_PARAMETER;
|
|
||||||
|
|
||||||
/* Set size and pointer of the working buffer */
|
/* Get working buffer */
|
||||||
buf = (BYTE*)work; /* Use given working buffer */
|
buf = (BYTE*)work; /* Working buffer */
|
||||||
if (len < ss) return FR_MKFS_ABORTED;
|
sz_buf = len / ss; /* Size of working buffer (sector) */
|
||||||
szb_buf = len & ~(ss - 1); /* Round-down by sector size [byte] */
|
szb_buf = sz_buf * ss; /* Size of working buffer (byte) */
|
||||||
sz_buf = szb_buf / ss; /* Size of sector buffer [sector] */
|
if (!szb_buf) return FR_MKFS_ABORTED;
|
||||||
|
|
||||||
/* Determine where the volume to be located (b_vol, sz_vol) */
|
/* Determine where the volume to be located (b_vol, sz_vol) */
|
||||||
if (_MULTI_PARTITION && part != 0) {
|
if (_MULTI_PARTITION && part != 0) {
|
||||||
/* Get partition information from partition table in the MBR */
|
/* Get partition information from partition table in the MBR */
|
||||||
if (disk_read(pdrv, buf, 0, 1) != RES_OK) return FR_DISK_ERR; /* Load MBR */
|
if (disk_read(pdrv, buf, 0, 1) != RES_OK) return FR_DISK_ERR; /* Load MBR */
|
||||||
if (ld_word(buf + BS_55AA) != 0xAA55) return FR_MKFS_ABORTED; /* Check MBR is valid */
|
if (ld_word(buf + BS_55AA) != 0xAA55) return FR_MKFS_ABORTED; /* Check if MBR is valid */
|
||||||
pte = buf + (MBR_Table + (part - 1) * SZ_PTE);
|
pte = buf + (MBR_Table + (part - 1) * SZ_PTE);
|
||||||
if (!pte[PTE_System]) return FR_MKFS_ABORTED; /* No partition? */
|
if (!pte[PTE_System]) return FR_MKFS_ABORTED; /* No partition? */
|
||||||
b_vol = ld_dword(pte + PTE_StLba); /* Get volume start sector */
|
b_vol = ld_dword(pte + PTE_StLba); /* Get volume start sector */
|
||||||
@ -5285,16 +5276,16 @@ FRESULT f_mkfs (
|
|||||||
if (sz_vol < b_vol) return FR_MKFS_ABORTED;
|
if (sz_vol < b_vol) return FR_MKFS_ABORTED;
|
||||||
sz_vol -= b_vol; /* Volume size */
|
sz_vol -= b_vol; /* Volume size */
|
||||||
}
|
}
|
||||||
if (sz_vol < 128) return FR_MKFS_ABORTED; /* Check volume size (>=128s) */
|
if (sz_vol < 128) return FR_MKFS_ABORTED; /* Check if volume size is >=128s */
|
||||||
|
|
||||||
/* Pre-determine the FAT type by argument */
|
/* Pre-determine the FAT type */
|
||||||
do {
|
do {
|
||||||
if (_FS_EXFAT && (opt & FM_EXFAT)) { /* exFAT possible? */
|
if (_FS_EXFAT && (opt & FM_EXFAT)) { /* exFAT possible? */
|
||||||
if ((opt & FM_ANY) == FM_EXFAT || sz_vol >= 0x4000000 || au >= 256) { /* exFAT only, vol >= 64Ms or au >= 256s ? */
|
if ((opt & FM_ANY) == FM_EXFAT || sz_vol >= 0x4000000 || au > 128) { /* exFAT only, vol >= 64Ms or au > 128s ? */
|
||||||
fmt = FS_EXFAT; break;
|
fmt = FS_EXFAT; break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (au >= 256) return FR_INVALID_PARAMETER; /* Too large au for FAT/FAT32 */
|
if (au > 128) return FR_INVALID_PARAMETER; /* Too large au for FAT/FAT32 */
|
||||||
if (opt & FM_FAT32) { /* FAT32 possible? */
|
if (opt & FM_FAT32) { /* FAT32 possible? */
|
||||||
if ((opt & FM_ANY) == FM_FAT32 || !(opt & FM_FAT)) { /* FAT32 only or no-FAT? */
|
if ((opt & FM_ANY) == FM_FAT32 || !(opt & FM_FAT)) { /* FAT32 only or no-FAT? */
|
||||||
fmt = FS_FAT32; break;
|
fmt = FS_FAT32; break;
|
||||||
@ -5319,20 +5310,19 @@ FRESULT f_mkfs (
|
|||||||
/* Determine FAT location, data location and number of clusters */
|
/* Determine FAT location, data location and number of clusters */
|
||||||
if (!au) { /* au auto-selection */
|
if (!au) { /* au auto-selection */
|
||||||
au = 8;
|
au = 8;
|
||||||
if (sz_vol >= 0x80000) au = 64; /* >= 512KS */
|
if (sz_vol >= 0x80000) au = 64; /* >= 512Ks */
|
||||||
if (sz_vol >= 0x4000000) au = 256; /* >= 64MS */
|
if (sz_vol >= 0x4000000) au = 256; /* >= 64Ms */
|
||||||
}
|
}
|
||||||
b_fat = b_vol + 32; /* FAT start at offset 32 */
|
b_fat = b_vol + 32; /* FAT start at offset 32 */
|
||||||
sz_fat = ((sz_vol / au + 2) * 4 + ss - 1) / ss; /* Numbef of FAT sectors */
|
sz_fat = ((sz_vol / au + 2) * 4 + ss - 1) / ss; /* Number of FAT sectors */
|
||||||
b_data = (b_fat + sz_fat + sz_blk - 1) & ~(sz_blk - 1); /* Align data area to the erase block boundary */
|
b_data = (b_fat + sz_fat + sz_blk - 1) & ~(sz_blk - 1); /* Align data area to the erase block boundary */
|
||||||
if (b_data >= sz_vol / 2) return FR_MKFS_ABORTED; /* Too small volume? */
|
if (b_data >= sz_vol / 2) return FR_MKFS_ABORTED; /* Too small volume? */
|
||||||
n_clst = (sz_vol - (b_data - b_vol)) / au; /* Nunber of clusters */
|
n_clst = (sz_vol - (b_data - b_vol)) / au; /* Number of clusters */
|
||||||
if (n_clst <16) return FR_MKFS_ABORTED; /* Too few clusters? */
|
if (n_clst <16) return FR_MKFS_ABORTED; /* Too few clusters? */
|
||||||
if (n_clst > MAX_EXFAT) return FR_MKFS_ABORTED; /* Too many clusters? */
|
if (n_clst > MAX_EXFAT) return FR_MKFS_ABORTED; /* Too many clusters? */
|
||||||
|
|
||||||
szb_bit = (n_clst + 7) / 8; /* Size of allocation bitmap */
|
szb_bit = (n_clst + 7) / 8; /* Size of allocation bitmap */
|
||||||
tbl[0] = (szb_bit + au * ss - 1) / (au * ss); /* Number of bitmap clusters */
|
tbl[0] = (szb_bit + au * ss - 1) / (au * ss); /* Number of allocation bitmap clusters */
|
||||||
tbl[2] = 1; /* Number of rootdir clusters */
|
|
||||||
|
|
||||||
/* Create a compressed up-case table */
|
/* Create a compressed up-case table */
|
||||||
sect = b_data + au * tbl[0]; /* Table start sector */
|
sect = b_data + au * tbl[0]; /* Table start sector */
|
||||||
@ -5363,30 +5353,31 @@ FRESULT f_mkfs (
|
|||||||
sum = xsum32(buf[i + 1] = (BYTE)(ch >> 8), sum);
|
sum = xsum32(buf[i + 1] = (BYTE)(ch >> 8), sum);
|
||||||
i += 2; szb_case += 2;
|
i += 2; szb_case += 2;
|
||||||
if (!si || i == szb_buf) { /* Write buffered data when buffer full or end of process */
|
if (!si || i == szb_buf) { /* Write buffered data when buffer full or end of process */
|
||||||
ns = (i + ss - 1) / ss;
|
n = (i + ss - 1) / ss;
|
||||||
if (disk_write(pdrv, buf, sect, ns) != RES_OK) return FR_DISK_ERR;
|
if (disk_write(pdrv, buf, sect, n) != RES_OK) return FR_DISK_ERR;
|
||||||
sect += ns; i = 0;
|
sect += n; i = 0;
|
||||||
}
|
}
|
||||||
} while (si);
|
} while (si);
|
||||||
tbl[1] = (szb_case + au * ss - 1) / (au * ss); /* Number of up-case clusters */
|
tbl[1] = (szb_case + au * ss - 1) / (au * ss); /* Number of up-case table clusters */
|
||||||
|
tbl[2] = 1; /* Number of root dir clusters */
|
||||||
|
|
||||||
/* Initialize the allocation bitmap */
|
/* Initialize the allocation bitmap */
|
||||||
sect = b_data; n = (szb_bit + ss - 1) / ss; /* Start of bitmap and number of the sectors */
|
sect = b_data; nsect = (szb_bit + ss - 1) / ss; /* Start of bitmap and number of sectors */
|
||||||
nb = tbl[0] + tbl[1] + tbl[2]; /* Number of clusters in-use by system */
|
nb = tbl[0] + tbl[1] + tbl[2]; /* Number of clusters in-use by system */
|
||||||
do {
|
do {
|
||||||
mem_set(buf, 0, szb_buf);
|
mem_set(buf, 0, szb_buf);
|
||||||
for (i = 0; nb >= 8 && i < szb_buf; buf[i++] = 0xFF, nb -= 8) ;
|
for (i = 0; nb >= 8 && i < szb_buf; buf[i++] = 0xFF, nb -= 8) ;
|
||||||
for (b = 1; nb && i < szb_buf; buf[i] |= b, b <<= 1, nb--) ;
|
for (b = 1; nb && i < szb_buf; buf[i] |= b, b <<= 1, nb--) ;
|
||||||
ns = (n > sz_buf) ? sz_buf : n; /* Write the buffered data */
|
n = (nsect > sz_buf) ? sz_buf : nsect; /* Write the buffered data */
|
||||||
if (disk_write(pdrv, buf, sect, ns) != RES_OK) return FR_DISK_ERR;
|
if (disk_write(pdrv, buf, sect, n) != RES_OK) return FR_DISK_ERR;
|
||||||
sect += ns; n -= ns;
|
sect += n; nsect -= n;
|
||||||
} while (n);
|
} while (nsect);
|
||||||
|
|
||||||
/* Initialize the FAT */
|
/* Initialize the FAT */
|
||||||
sect = b_fat; n = sz_fat; /* Start of FAT and number of the sectors */
|
sect = b_fat; nsect = sz_fat; /* Start of FAT and number of FAT sectors */
|
||||||
j = nb = cl = 0;
|
j = nb = cl = 0;
|
||||||
do {
|
do {
|
||||||
mem_set(buf, 0, szb_buf); i = 0;
|
mem_set(buf, 0, szb_buf); i = 0; /* Clear work area and reset write index */
|
||||||
if (cl == 0) { /* Set entry 0 and 1 */
|
if (cl == 0) { /* Set entry 0 and 1 */
|
||||||
st_dword(buf + i, 0xFFFFFFF8); i += 4; cl++;
|
st_dword(buf + i, 0xFFFFFFF8); i += 4; cl++;
|
||||||
st_dword(buf + i, 0xFFFFFFFF); i += 4; cl++;
|
st_dword(buf + i, 0xFFFFFFFF); i += 4; cl++;
|
||||||
@ -5398,13 +5389,13 @@ FRESULT f_mkfs (
|
|||||||
}
|
}
|
||||||
if (!nb && j < 3) nb = tbl[j++]; /* Next chain */
|
if (!nb && j < 3) nb = tbl[j++]; /* Next chain */
|
||||||
} while (nb && i < szb_buf);
|
} while (nb && i < szb_buf);
|
||||||
ns = (n > sz_buf) ? sz_buf : n; /* Write the buffered data */
|
n = (nsect > sz_buf) ? sz_buf : nsect; /* Write the buffered data */
|
||||||
if (disk_write(pdrv, buf, sect, ns) != RES_OK) return FR_DISK_ERR;
|
if (disk_write(pdrv, buf, sect, n) != RES_OK) return FR_DISK_ERR;
|
||||||
sect += ns; n -= ns;
|
sect += n; nsect -= n;
|
||||||
} while (n);
|
} while (nsect);
|
||||||
|
|
||||||
/* Initialize the root directory */
|
/* Initialize the root directory */
|
||||||
mem_set(buf, 0, ss);
|
mem_set(buf, 0, szb_buf);
|
||||||
buf[SZDIRE * 0 + 0] = 0x83; /* 83 entry (volume label) */
|
buf[SZDIRE * 0 + 0] = 0x83; /* 83 entry (volume label) */
|
||||||
buf[SZDIRE * 1 + 0] = 0x81; /* 81 entry (allocation bitmap) */
|
buf[SZDIRE * 1 + 0] = 0x81; /* 81 entry (allocation bitmap) */
|
||||||
st_dword(buf + SZDIRE * 1 + 20, 2);
|
st_dword(buf + SZDIRE * 1 + 20, 2);
|
||||||
@ -5413,13 +5404,13 @@ FRESULT f_mkfs (
|
|||||||
st_dword(buf + SZDIRE * 2 + 4, sum);
|
st_dword(buf + SZDIRE * 2 + 4, sum);
|
||||||
st_dword(buf + SZDIRE * 2 + 20, 2 + tbl[0]);
|
st_dword(buf + SZDIRE * 2 + 20, 2 + tbl[0]);
|
||||||
st_dword(buf + SZDIRE * 2 + 24, szb_case);
|
st_dword(buf + SZDIRE * 2 + 24, szb_case);
|
||||||
sect = b_data + au * (tbl[0] + tbl[1]); n = au; /* Start of directory and number of the sectors */
|
sect = b_data + au * (tbl[0] + tbl[1]); nsect = au; /* Start of the root directory and number of sectors */
|
||||||
do { /* Fill root direcotry sectors */
|
do { /* Fill root directory sectors */
|
||||||
ns = (n > sz_buf) ? sz_buf : n;
|
n = (nsect > sz_buf) ? sz_buf : nsect;
|
||||||
if (disk_write(pdrv, buf, sect, ns) != RES_OK) return FR_DISK_ERR;
|
if (disk_write(pdrv, buf, sect, n) != RES_OK) return FR_DISK_ERR;
|
||||||
sect += ns;
|
|
||||||
mem_set(buf, 0, ss);
|
mem_set(buf, 0, ss);
|
||||||
} while (n -= ns);
|
sect += n; nsect -= n;
|
||||||
|
} while (nsect);
|
||||||
|
|
||||||
/* Create two set of the exFAT VBR blocks */
|
/* Create two set of the exFAT VBR blocks */
|
||||||
sect = b_vol;
|
sect = b_vol;
|
||||||
@ -5465,7 +5456,7 @@ FRESULT f_mkfs (
|
|||||||
}
|
}
|
||||||
|
|
||||||
} else
|
} else
|
||||||
#endif
|
#endif /* _FS_EXFAT */
|
||||||
{ /* Create an FAT12/16/32 volume */
|
{ /* Create an FAT12/16/32 volume */
|
||||||
do {
|
do {
|
||||||
pau = au;
|
pau = au;
|
||||||
@ -5548,14 +5539,14 @@ FRESULT f_mkfs (
|
|||||||
st_word(buf + BPB_BytsPerSec, ss); /* Sector size [byte] */
|
st_word(buf + BPB_BytsPerSec, ss); /* Sector size [byte] */
|
||||||
buf[BPB_SecPerClus] = (BYTE)pau; /* Cluster size [sector] */
|
buf[BPB_SecPerClus] = (BYTE)pau; /* Cluster size [sector] */
|
||||||
st_word(buf + BPB_RsvdSecCnt, (WORD)sz_rsv); /* Size of reserved area */
|
st_word(buf + BPB_RsvdSecCnt, (WORD)sz_rsv); /* Size of reserved area */
|
||||||
buf[BPB_NumFATs] = n_fats; /* Number of FATs */
|
buf[BPB_NumFATs] = (BYTE)n_fats; /* Number of FATs */
|
||||||
st_word(buf + BPB_RootEntCnt, (WORD)((fmt == FS_FAT32) ? 0 : n_rootdir)); /* Number of root directory entries */
|
st_word(buf + BPB_RootEntCnt, (WORD)((fmt == FS_FAT32) ? 0 : n_rootdir)); /* Number of root directory entries */
|
||||||
if (sz_vol < 0x10000) {
|
if (sz_vol < 0x10000) {
|
||||||
st_word(buf + BPB_TotSec16, (WORD)sz_vol); /* Volume size in 16-bit LBA */
|
st_word(buf + BPB_TotSec16, (WORD)sz_vol); /* Volume size in 16-bit LBA */
|
||||||
} else {
|
} else {
|
||||||
st_dword(buf + BPB_TotSec32, sz_vol); /* Volume size in 12-bit LBA */
|
st_dword(buf + BPB_TotSec32, sz_vol); /* Volume size in 32-bit LBA */
|
||||||
}
|
}
|
||||||
buf[BPB_Media] = 0xF8; /* Media descriptor */
|
buf[BPB_Media] = 0xF8; /* Media descriptor byte */
|
||||||
st_word(buf + BPB_SecPerTrk, 63); /* Number of sectors per track (for int13) */
|
st_word(buf + BPB_SecPerTrk, 63); /* Number of sectors per track (for int13) */
|
||||||
st_word(buf + BPB_NumHeads, 255); /* Number of heads (for int13) */
|
st_word(buf + BPB_NumHeads, 255); /* Number of heads (for int13) */
|
||||||
st_dword(buf + BPB_HiddSec, b_vol); /* Volume offset in the physical drive [sector] */
|
st_dword(buf + BPB_HiddSec, b_vol); /* Volume offset in the physical drive [sector] */
|
||||||
@ -5592,8 +5583,8 @@ FRESULT f_mkfs (
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Initialize FAT area */
|
/* Initialize FAT area */
|
||||||
mem_set(buf, 0, szb_buf);
|
mem_set(buf, 0, (UINT)szb_buf);
|
||||||
sect = b_fat; /* Start sector */
|
sect = b_fat; /* FAT start sector */
|
||||||
for (i = 0; i < n_fats; i++) { /* Initialize FATs each */
|
for (i = 0; i < n_fats; i++) { /* Initialize FATs each */
|
||||||
if (fmt == FS_FAT32) {
|
if (fmt == FS_FAT32) {
|
||||||
st_dword(buf + 0, 0xFFFFFFF8); /* Entry 0 */
|
st_dword(buf + 0, 0xFFFFFFF8); /* Entry 0 */
|
||||||
@ -5602,22 +5593,22 @@ FRESULT f_mkfs (
|
|||||||
} else {
|
} else {
|
||||||
st_dword(buf + 0, (fmt == FS_FAT12) ? 0xFFFFF8 : 0xFFFFFFF8); /* Entry 0 and 1 */
|
st_dword(buf + 0, (fmt == FS_FAT12) ? 0xFFFFF8 : 0xFFFFFFF8); /* Entry 0 and 1 */
|
||||||
}
|
}
|
||||||
n = sz_fat; /* Sector count of a FAT */
|
nsect = sz_fat; /* Number of FAT sectors */
|
||||||
do { /* Fill FAT sectors */
|
do { /* Fill FAT sectors */
|
||||||
ns = (n > sz_buf) ? sz_buf : n;
|
n = (nsect > sz_buf) ? sz_buf : nsect;
|
||||||
if (disk_write(pdrv, buf, sect, ns) != RES_OK) return FR_DISK_ERR;
|
if (disk_write(pdrv, buf, sect, (UINT)n) != RES_OK) return FR_DISK_ERR;
|
||||||
sect += ns;
|
|
||||||
mem_set(buf, 0, ss);
|
mem_set(buf, 0, ss);
|
||||||
} while (n -= ns);
|
sect += n; nsect -= n;
|
||||||
|
} while (nsect);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Initialize root directory (fill with zero) */
|
/* Initialize root directory (fill with zero) */
|
||||||
n = (fmt == FS_FAT32) ? pau : sz_dir; /* Sector count of root directory */
|
nsect = (fmt == FS_FAT32) ? pau : sz_dir; /* Number of root directory sectors */
|
||||||
do {
|
do {
|
||||||
ns = (n > sz_buf) ? sz_buf : n;
|
n = (nsect > sz_buf) ? sz_buf : nsect;
|
||||||
if (disk_write(pdrv, buf, sect, ns) != RES_OK) return FR_DISK_ERR;
|
if (disk_write(pdrv, buf, sect, (UINT)n) != RES_OK) return FR_DISK_ERR;
|
||||||
sect += ns;
|
sect += n; nsect -= n;
|
||||||
} while (n -= ns);
|
} while (nsect);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Determine system ID in the partition table */
|
/* Determine system ID in the partition table */
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*----------------------------------------------------------------------------/
|
/*----------------------------------------------------------------------------/
|
||||||
/ FatFs - Generic FAT file system module R0.12a /
|
/ FatFs - Generic FAT file system module R0.12b /
|
||||||
/-----------------------------------------------------------------------------/
|
/-----------------------------------------------------------------------------/
|
||||||
/
|
/
|
||||||
/ Copyright (C) 2016, ChaN, all right reserved.
|
/ Copyright (C) 2016, ChaN, all right reserved.
|
||||||
@ -19,7 +19,7 @@
|
|||||||
|
|
||||||
|
|
||||||
#ifndef _FATFS
|
#ifndef _FATFS
|
||||||
#define _FATFS 80186 /* Revision ID */
|
#define _FATFS 68020 /* Revision ID */
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
@ -159,7 +159,7 @@ typedef struct {
|
|||||||
/* File object structure (FIL) */
|
/* File object structure (FIL) */
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
_FDID obj; /* Object identifier */
|
_FDID obj; /* Object identifier (must be the 1st member to detect invalid object pointer) */
|
||||||
BYTE flag; /* File status flags */
|
BYTE flag; /* File status flags */
|
||||||
BYTE err; /* Abort flag (error code) */
|
BYTE err; /* Abort flag (error code) */
|
||||||
FSIZE_t fptr; /* File read/write pointer (Zeroed on file open) */
|
FSIZE_t fptr; /* File read/write pointer (Zeroed on file open) */
|
||||||
|
Loading…
Reference in New Issue
Block a user