FatFs: Update to R0.12a.
@ -18,22 +18,23 @@
|
||||
<hr>
|
||||
|
||||
<div class="abst">
|
||||
<img src="img/layers.png" class="rset" width="245" height="255" alt="layer">
|
||||
<p>FatFs is a generic FAT file system module for small embedded systems. The FatFs module is written in compliance with ANSI C (C89) and completely separated from the disk I/O layer. Therefore it is independent of the platform. It can be incorporated into small microcontrollers with limited resource, such as 8051, PIC, AVR, ARM, Z80, 78K and etc. Also Petit FatFs module for tiny microcontrollers is available <a href="http://elm-chan.org/fsw/ff/00index_p.html">here</a>.</p>
|
||||
<img src="res/layers.png" class="rset" width="245" height="255" alt="layer">
|
||||
<p>FatFs is a generic FAT/exFAT file system module for small embedded systems. The FatFs module is written in compliance with ANSI C (C89) and completely separated from the disk I/O layer. Therefore it is independent of the platform. It can be incorporated into small microcontrollers with limited resource, such as 8051, PIC, AVR, ARM, Z80, 78K and etc. Also Petit FatFs module for tiny microcontrollers is available <a href="http://elm-chan.org/fsw/ff/00index_p.html">here</a>.</p>
|
||||
|
||||
<h4>Features</h4>
|
||||
<ul>
|
||||
<li>Windows compatible FAT file system.</li>
|
||||
<li>Windows compatible FAT/exFAT file system.</li>
|
||||
<li>Platform independent. Easy to port.</li>
|
||||
<li>Very small footprint for code and work area.</li>
|
||||
<li>Various <a href="en/config.html">configuration options</a>:
|
||||
<li>Very small footprint for program code and work area.</li>
|
||||
<li>Various <a href="en/config.html">configuration options</a> to support for:
|
||||
<ul>
|
||||
<li>Multiple volumes (physical drives and partitions).</li>
|
||||
<li>Multiple ANSI/OEM code pages including DBCS.</li>
|
||||
<li>Long file name support in ANSI/OEM or Unicode.</li>
|
||||
<li>RTOS support for multi-task operation.</li>
|
||||
<li>Multiple sector size support upto 4KB.</li>
|
||||
<li>Read-only, minimized API, I/O buffer and etc...</li>
|
||||
<li>Long file name in ANSI/OEM or Unicode.</li>
|
||||
<li>exFAT file system.</li>
|
||||
<li>RTOS envilonment.</li>
|
||||
<li>Fixed or variable sector size.</li>
|
||||
<li>Read-only, optional API, I/O buffer and etc...</li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
@ -42,7 +43,7 @@
|
||||
|
||||
<div class="para">
|
||||
<h3>Application Interface</h3>
|
||||
<img src="img/layers1.png" class="rset" width="245" height="220" alt="layer">
|
||||
<img src="res/layers1.png" class="rset" width="245" height="220" alt="layer">
|
||||
<ul>
|
||||
<li>File Access
|
||||
<ul>
|
||||
@ -54,6 +55,7 @@
|
||||
<li><a href="en/truncate.html">f_truncate</a> - Truncate size</li>
|
||||
<li><a href="en/sync.html">f_sync</a> - Flush cached data</li>
|
||||
<li><a href="en/forward.html">f_forward</a> - Forward data to the stream</li>
|
||||
<li><a href="en/expand.html">f_expand</a> - Allocate a contiguous block to the file</li>
|
||||
<li><a href="en/gets.html">f_gets</a> - Read a string</li>
|
||||
<li><a href="en/putc.html">f_putc</a> - Write a character</li>
|
||||
<li><a href="en/puts.html">f_puts</a> - Write a string</li>
|
||||
@ -68,9 +70,9 @@
|
||||
<ul>
|
||||
<li><a href="en/opendir.html">f_opendir</a> - Open a directory</li>
|
||||
<li><a href="en/closedir.html">f_closedir</a> - Close an open directory</li>
|
||||
<li><a href="en/readdir.html">f_readdir</a> - Read an item</li>
|
||||
<li><a href="en/findfirst.html">f_findfirst</a> - Open a directory and read first item found</li>
|
||||
<li><a href="en/findnext.html">f_findnext</a> - Read a next item found</li>
|
||||
<li><a href="en/readdir.html">f_readdir</a> - Read an directory item</li>
|
||||
<li><a href="en/findfirst.html">f_findfirst</a> - Open a directory and read first item matched</li>
|
||||
<li><a href="en/findnext.html">f_findnext</a> - Read a next item matched</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li>File/Directory Management
|
||||
@ -102,14 +104,14 @@
|
||||
|
||||
<div class="para">
|
||||
<h3>Device Control Interface</h3>
|
||||
<img src="img/layers2.png" class="rset" width="245" height="220" alt="layer">
|
||||
<p>Since the FatFs module is a file system layer, it is completely separated from the physical devices, such as memory card, harddisk and any type of storage devices. FatFs accesses the storage devices via a simple interface shown below. The low level device control module is not a part of FatFs module. It is provided by implementer. Also sample implementations for some platforms are available in the downloads.</p>
|
||||
<img src="res/layers2.png" class="rset" width="245" height="220" alt="layer">
|
||||
<p>Since the FatFs module is a file system layer, it is completely separated from the physical devices, such as memory card, harddisk and any type of storage device. FatFs accesses the storage devices via a simple interface shown below. The low level device control module is <em>not a part of FatFs module</em>. It is provided by implementer. Also sample implementations for some platforms are available in the downloads.</p>
|
||||
<ul>
|
||||
<li><a href="en/dstat.html">disk_status</a> - Get device status</li>
|
||||
<li><a href="en/dinit.html">disk_initialize</a> - Initialize device</li>
|
||||
<li><a href="en/dread.html">disk_read</a> - Read sector(s)</li>
|
||||
<li><a href="en/dwrite.html">disk_write</a> - Write sector(s)</li>
|
||||
<li><a href="en/dioctl.html">disk_ioctl</a> - Control device dependent features</li>
|
||||
<li><a href="en/dioctl.html">disk_ioctl</a> - Control device dependent functions</li>
|
||||
<li><a href="en/fattime.html">get_fattime</a> - Get current time</li>
|
||||
</ul>
|
||||
</div>
|
||||
@ -119,25 +121,21 @@
|
||||
<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>
|
||||
<ul>
|
||||
<li>Read first: <a href="en/appnote.html">FatFs module application note</a> <span class="mfd">March 18, 2015</span></li>
|
||||
<li>Download: <a href="ff11.zip">FatFs R0.11</a> | <a href="updates.txt">Updates</a> | <a href="patches.html">Patches</a> <span class="mfd">March 9, 2015</span></li>
|
||||
<li>Download: <a href="ffsample.zip">FatFs sample projects for various platforms</a> <span class="mfd">February 9, 2015</span></li>
|
||||
<li>Download: <a href="archives.html">Old Releases</a></li>
|
||||
<li>Read first: <a href="en/appnote.html">FatFs module application note</a></li>
|
||||
<li>Community: <a href="http://elm-chan.org/fsw/ff/bd/">FatFs User Forum</a></li>
|
||||
<li><a href="http://stm32f4-discovery.com/2014/07/library-21-read-sd-card-fatfs-stm32f4xx-devices/">Read SD card with FatFs on STM32F4xx devices by Tilen Majerle</a>↗ (Quick and easy implementation for STM32F4-Discovery)</li>
|
||||
<li><a href="http://nemuisan.blog.bai.ne.jp/">Nemuisan's Blog</a>↗ (Well written implementations for STM32F/SDIO and LPC2300/MCI)</li>
|
||||
<li><a href="http://www.siwawi.arubi.uni-kl.de/avr_projects/arm_projects/arm_memcards/index.html">ARM-Projects by Martin THOMAS</a>↗ (Examples for LPC2000, AT91SAM and STM32)</li>
|
||||
<li><a href="http://www.microsoft.com/whdc/system/platform/firmware/fatgen.mspx">FAT32 Specification by Microsoft</a>↗ (The 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/mmc/mmc_e.html">How to Use MMC/SDC</a></li>
|
||||
<li><a href="img/rwtest.png">Benchmark 1</a> (ATmega64/9.2MHz with MMC via SPI, HDD/CFC via GPIO)</li>
|
||||
<li><a href="img/rwtest2.png">Benchmark 2</a> (LPC2368/72MHz with MMC via MCI)</li>
|
||||
<li><a href="http://members.jcom.home.ne.jp/felm/fd.mp4">Demo movie of an application</a> (this project is in ffsample.zip/lpc23xx)</li>
|
||||
</ul>
|
||||
<li><a href="http://elm-chan.org/junk/fa/faff.html">Playing with FlashAir and FatFs</a></li>
|
||||
<li><a href="http://stm32f4-discovery.com/2014/07/library-21-read-sd-card-fatfs-stm32f4xx-devices/">Read SD card with FatFs on STM32F4xx devices by Tilen Majerle</a>↗ (Quick and easy implementation for STM32F4-Discovery)</li>
|
||||
<li><a href="http://nemuisan.blog.bai.ne.jp/">Nemuisan's Blog</a>↗ (Well written implementations for STM32F/SPI & SDIO and LPC4088/SDMMC)</li>
|
||||
<li><a href="http://www.siwawi.arubi.uni-kl.de/avr_projects/arm_projects/arm_memcards/index.html">ARM-Projects by Martin THOMAS</a>↗ (Examples for LPC2000, AT91SAM and STM32)</li>
|
||||
<li><a href="res/rwtest1.png">Benchmark 1</a> (ATmega1284/20MHz with MMC via USART in SPI, CFC via GPIO)</li>
|
||||
<li><a href="res/rwtest2.png">Benchmark 2</a> (LPC2368/72MHz with MMC via MCI)</li>
|
||||
</div>
|
||||
|
||||
|
||||
<hr>
|
||||
<p class="foot"><a href="../../fsw_e.html">Return</a></p>
|
||||
<p class="foot"><a href="http://elm-chan.org/fsw/ff/00index_e.html">Latest Information</a></p>
|
||||
</body>
|
||||
</html>
|
||||
|
@ -18,20 +18,21 @@
|
||||
<hr>
|
||||
|
||||
<div class="abst">
|
||||
<img src="img/layers.png" class="rset" width="245" height="255" alt="layer">
|
||||
<p>FatFsは小規模な組み込みシステム向けの汎用FATファイルシステム モジュールです。ANSI C(C89)準拠でハードウェア アーキテクチャには依存しないので、必要なワーク エリアが確保できれば、8051, PIC, AVR, SH, Z80, 68k, H8, ARMなど安価なマイコンでも使用可能です。このほか、FatFsを極小マイコン向けにシュリンクした<a href="http://elm-chan.org/fsw/ff/00index_p.html">ぷちFatFs</a>もあります。</p>
|
||||
<img src="res/layers.png" class="rset" width="245" height="255" alt="layer">
|
||||
<p>FatFsは小規模な組み込みシステム向けの汎用FAT/exFATファイルシステム モジュールです。ANSI C(C89)準拠でハードウェア アーキテクチャには依存しないので、必要なワーク エリアが確保できれば、8051, PIC, AVR, SH, Z80, 68k, H8, ARMなど安価なマイコンでも使用可能です。このほか、FatFsを極小マイコン向けにシュリンクした<a href="http://elm-chan.org/fsw/ff/00index_p.html">ぷちFatFs</a>もあります。</p>
|
||||
<h4>FatFsモジュールの特徴</h4>
|
||||
<ul>
|
||||
<li>Windows互換 FATファイル システム</li>
|
||||
<li>Windows互換 FAT/exFATファイルシステム</li>
|
||||
<li>プラットフォーム非依存</li>
|
||||
<li>コンパクトなコードとRAM使用量</li>
|
||||
<li>多くの<a href="ja/config.html">構成オプション</a>:
|
||||
<ul>
|
||||
<li>複数のボリューム(物理ドライブ・区画)</li>
|
||||
<li>ボリューム構成(物理ドライブ数・区画)</li>
|
||||
<li>DBCSを含む複数のANSI/OEMコード ページの選択</li>
|
||||
<li>長いファイル名(LFN)への対応</li>
|
||||
<li>マルチタスク関連</li>
|
||||
<li>マルチ セクタ サイズ</li>
|
||||
<li>exFATファイルシステムへの対応</li>
|
||||
<li>RTOS環境への対応</li>
|
||||
<li>セクタ サイズ(固定/可変)</li>
|
||||
<li>リード オンリー構成、一部APIの削除、バッファ構成、その他…</li>
|
||||
</ul>
|
||||
</li>
|
||||
@ -41,7 +42,7 @@
|
||||
|
||||
<div class="para">
|
||||
<h3>上位レイヤ インターフェース</h3>
|
||||
<img src="img/layers1.png" class="rset" width="245" height="220" alt="layer">
|
||||
<img src="res/layers1.png" class="rset" width="245" height="220" alt="layer">
|
||||
<ul>
|
||||
<li>ファイル アクセス
|
||||
<ul>
|
||||
@ -53,6 +54,7 @@
|
||||
<li><a href="ja/truncate.html">f_truncate</a> - サイズの切り詰め</li>
|
||||
<li><a href="ja/sync.html">f_sync</a> - キャッシュされたデータのフラッシュ</li>
|
||||
<li><a href="ja/forward.html">f_forward</a> - データをストリーム関数に転送</li>
|
||||
<li><a href="ja/expand.html">f_expand</a> - 連続領域の割り当て</li>
|
||||
<li><a href="ja/gets.html">f_gets</a> - 文字列の読み出し</li>
|
||||
<li><a href="ja/putc.html">f_putc</a> - 文字の書き込み</li>
|
||||
<li><a href="ja/puts.html">f_puts</a> - 文字列の書き込み</li>
|
||||
@ -101,8 +103,8 @@
|
||||
|
||||
<div class="para">
|
||||
<h3>下位レイヤ インターフェース</h3>
|
||||
<img src="img/layers2.png" class="rset" width="245" height="220" alt="layer">
|
||||
<p>FatFsモジュールは、単なるファイル システム レイヤなので、ストレージ デバイス制御レイヤは含まれません。使用するプラットフォームやストレージ デバイスに対応した制御関数は、インプリメンタによって提供される必要があります。FatFsモジュールは、下位レイヤに対し標準的には次のインターフェースを要求します。一部の拡張機能、たとえばOS関連機能を有効にしたときは、加えてプロセス/メモリ操作関数なども必要になります。サンプル プロジェクトに下位レイヤの実装例を示します。</p>
|
||||
<img src="res/layers2.png" class="rset" width="245" height="220" alt="layer">
|
||||
<p>FatFsモジュールは、単なるファイルシステム レイヤなので、その下位のストレージ デバイス制御レイヤはそれに含まれません。それぞれのプラットフォームやストレージ デバイスに対応した制御レイヤは、インプリメンタによって提供される必要があります。FatFsモジュールは、下位レイヤに対し標準的には次のインターフェースを要求します。一部の拡張機能、たとえばOS関連機能を有効にしたときは、加えてプロセス/メモリ操作関数なども必要になります。サンプル プロジェクトに下位レイヤの実装例を示します。</p>
|
||||
<ul>
|
||||
<li><a href="ja/dstat.html">disk_status</a> - デバイスの状態取得</li>
|
||||
<li><a href="ja/dinit.html">disk_initialize</a> - デバイスの初期化</li>
|
||||
@ -118,24 +120,22 @@
|
||||
<h3>資料</h3>
|
||||
<p>FatFsモジュールはフリー ソフトウェアとして教育・研究・開発用に公開しています。どのような利用目的(個人利用から商用まで)でも使用・改変・配布について一切の制限はありませんが、全て利用者の責任の下での利用とします。詳しくはアプリケーション ノートを参照してください。</p>
|
||||
<ul>
|
||||
<li>最初に読め: <a href="ja/appnote.html">FatFsモジュール アプリケーション ノート</a> <span class="mfd">2015. 3. 18</span></li>
|
||||
<li>ダウンロード: <a href="ff11.zip">FatFs R0.11</a> | <a href="updates.txt">変更点</a> | <a href="patches.html">パッチ</a> <span class="mfd">2015. 3. 9</span></li>
|
||||
<li>ダウンロード: <a href="ffsample.zip">サンプル プロジェクト</a> <span class="mfd">2015. 2. 9</span></li>
|
||||
<li>ダウンロード: <a href="archives.html">旧バージョン</a></li>
|
||||
<li>最初に読め: <a href="ja/appnote.html">FatFsモジュール アプリケーション ノート</a></li>
|
||||
<li>コミュニティ: <a href="http://elm-chan.org/fsw/ff/bd/">FatFsユーザ フォーラム</a></li>
|
||||
<li><a href="http://stm32f4-discovery.com/2014/07/library-21-read-sd-card-fatfs-stm32f4xx-devices/">Read SD card with FatFs on STM32F4xx devices by Tilen Majerle</a>↗ (Quick and easy implementation for STM32F4-Discovery)</li>
|
||||
<li><a href="http://nemuisan.blog.bai.ne.jp/">ねむいさんのぶろぐ</a>↗ (Well written implementations for STM32F/SDIO and LPC2300/MCI)</li>
|
||||
<li><a href="http://www.siwawi.arubi.uni-kl.de/avr_projects/arm_projects/arm_memcards/index.html">ARM-Projects by Martin THOMAS</a>↗ (Examples for LPC2000, AT91SAM and STM32)</li>
|
||||
<li><a href="http://www.microsoft.com/whdc/system/platform/firmware/fatgen.mspx">FATファイルシステム仕様 by Microsoft</a>↗ (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/mmc/mmc.html">MMCの使いかた</a></li>
|
||||
<li><a href="img/rwtest.png">パフォーマンス テスト1</a> (ATmega64/9.2MHz with MMC via SPI, HDD/CFC via GPIO)</li>
|
||||
<li><a href="img/rwtest2.png">パフォーマンス テスト2</a> (LPC2368/72MHz with MMC via MCI)</li>
|
||||
<li><a href="http://elm-chan.org/junk/fa/faff.html">FlashAirとFatFs [en]</a></li>
|
||||
<li><a href="http://stm32f4-discovery.com/2014/07/library-21-read-sd-card-fatfs-stm32f4xx-devices/">Read SD card with FatFs on STM32F4xx devices by Tilen Majerle</a>↗ (Quick and easy implementation for STM32F4-Discovery)</li>
|
||||
<li><a href="http://nemuisan.blog.bai.ne.jp/">ねむいさんのぶろぐ</a>↗ (Well written implementations for STM32F/SPI & SDIO and LPC4088/SDMMC)</li>
|
||||
<li><a href="http://www.siwawi.arubi.uni-kl.de/avr_projects/arm_projects/arm_memcards/index.html">ARM-Projects by Martin THOMAS</a>↗ (Examples for LPC2000, AT91SAM and STM32)</li>
|
||||
<li><a href="res/rwtest1.png">パフォーマンス テスト1</a> (ATmega1284/20MHz with MMC via USART in SPI, CFC via GPIO)</li>
|
||||
<li><a href="res/rwtest2.png">パフォーマンス テスト2</a> (LPC2368/72MHz with MMC via MCI)</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
|
||||
<hr>
|
||||
<p class="foot"><a href="../../fsw.html">戻る</a></p>
|
||||
<p class="foot"><a href="http://elm-chan.org/fsw/ff/00index_j.html">FatFs Home Page</a></p>
|
||||
</body>
|
||||
</html>
|
||||
|
@ -15,9 +15,10 @@
|
||||
<li><a href="#port">How to Port</a></li>
|
||||
<li><a href="#limits">Limits</a></li>
|
||||
<li><a href="#memory">Memory Usage</a></li>
|
||||
<li><a href="#reduce">Module Size Reduction</a></li>
|
||||
<li><a href="#reduce">Reducing Module Size</a></li>
|
||||
<li><a href="#lfn">Long File Name</a></li>
|
||||
<li><a href="#unicode">Unicode API</a></li>
|
||||
<li><a href="#exfat">exFAT File System</a></li>
|
||||
<li><a href="#reentrant">Re-entrancy</a></li>
|
||||
<li><a href="#dup">Duplicated File Access</a></li>
|
||||
<li><a href="#fs1">Performance Effective File Access</a></li>
|
||||
@ -36,14 +37,14 @@
|
||||
<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>
|
||||
<li>Size of integer types<br>
|
||||
The FatFs module assumes that size of char/short/long are 8/16/32 bit and int is 16 or 32 bit. These correspondence are defined in <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 any conflict with existing definitions is occured, you must resolve it with care.</li>
|
||||
</ul>
|
||||
|
||||
<h4>System organizations</h4>
|
||||
<p>The dependency diagram shown below is a typical configuration of the embedded system with FatFs module.</p>
|
||||
<p><img src="../img/modules.png" width="580" height="280" alt="dependency diagram"></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>(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><img src="../img/funcs.png" width="680" 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>
|
||||
<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>
|
||||
@ -63,13 +64,13 @@ The FatFs module assumes that size of char/short/long are 8/16/32 bit and int is
|
||||
<div class="para doc" id="limits">
|
||||
<h3>Limits</h3>
|
||||
<ul>
|
||||
<li>FAT sub-types: FAT12, FAT16 and FAT32.</li>
|
||||
<li>File system type: FAT12, FAT16, FAT32(r0.0) and exFAT(r1.0).</li>
|
||||
<li>Number of open files: Unlimited. (depends on available memory)</li>
|
||||
<li>Number of volumes: Upto 10.</li>
|
||||
<li>File size: Upto 4G-1 bytes. (by FAT specs.)</li>
|
||||
<li>Volume size: Upto 2T bytes at 512 bytes/sector. (by FAT specs.)</li>
|
||||
<li>Cluster size: Upto 64K bytes at 512 bytes/sector. (by FAT specs.)</li>
|
||||
<li>Sector size: 512, 1024, 2048 and 4096 bytes. (by FAT specs.)</li>
|
||||
<li>Volume size: Upto 2 TiB at 512 bytes/sector.</li>
|
||||
<li>File size: Upto 4 GiB - 1 on FAT volume and virtually unlimited on exFAT volume.</li>
|
||||
<li>Cluster size: Upto 128 sectors on FAT volume and upto 16 MiB on exFAT volume.</li>
|
||||
<li>Sector size: 512, 1024, 2048 and 4096 bytes.</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
@ -78,73 +79,74 @@ The FatFs module assumes that size of char/short/long are 8/16/32 bit and int is
|
||||
<p>The memory usage varies depends on the <a href="config.html">configuration options</a>.</p>
|
||||
<table class="lst2">
|
||||
<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>VC6</td></tr>
|
||||
<!-- 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.6k</td><td>7.1k</td><td>6.5k</td><td>13.3k</td><td>10.9k</td><td>11.7k</td><td>13.3k</td><td>8.1k</td><td>9.0k</td><td>6.0k</td><td>7.9k</td></tr>
|
||||
<tr class="ral"> <td class="cal">text (Min, R/W)</td> <td>6.7k</td><td>4.6k</td><td>4.2k</td> <td>8.6k</td> <td>7.3k</td> <td>7.7k</td> <td>9.1k</td><td>5.3k</td><td>5.8k</td><td>3.9k</td><td>5.2k</td></tr>
|
||||
<tr class="ral"> <td class="cal">text (Full, R/O)</td> <td>4.8k</td><td>3.2k</td><td>2.9k</td> <td>6.2k</td> <td>5.2k</td> <td>5.5k</td> <td>6.5k</td><td>3.8k</td><td>4.0k</td><td>2.9k</td><td>3.7k</td></tr>
|
||||
<tr class="ral"> <td class="cal">text (Min, R/O)</td> <td>3.6k</td><td>2.5k</td><td>2.3k</td> <td>4.6k</td> <td>4.1k</td> <td>4.3k</td> <td>5.0k</td><td>3.0k</td><td>3.1k</td><td>2.2k</td><td>2.9k</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>(_FS_TINY == 0)</td><td>V*560<br>+ F*550</td><td>V*560<br>+ F*550</td><td>V*560<br>+ F*550</td><td>V*560<br>+ F*544</td><td>V*560<br>+ F*550</td><td>V*560<br>+ F*544</td><td>V*560<br>+ F*544</td><td>V*560<br>+ F*544</td><td>V*560<br>+ F*550</td><td>V*560<br>+ F*550</td><td>V*560<br>+ F*550</td></tr>
|
||||
<tr class="ral"> <td class="cal">Work area<br>(_FS_TINY == 1)</td><td>V*560<br>+ F*36</td><td>V*560<br>+ F*36</td><td>V*560<br>+ F*36</td><td>V*560<br>+ F*32</td><td>V*560<br>+ F*36</td><td>V*560<br>+ F*32</td><td>V*560<br>+ F*32</td><td>V*560<br>+ F*36</td><td>V*560<br>+ F*36</td><td>V*560<br>+ F*36</td><td>V*560<br>+ F*36</td></tr>
|
||||
<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 -->
|
||||
<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 (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 (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 (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">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 == 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>
|
||||
<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 number of volumes and <em>F</em> denotes number of open files. All samples 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>
|
||||
FatFs R0.11 options:
|
||||
FatFs R0.12 options:
|
||||
_FS_READONLY 0 (R/W) or 1 (R/O)
|
||||
_FS_MINIMIZE 0 (Full basic function) or 3 (Minimized function)
|
||||
_VOLUMES V (Number of logical drives to be used)
|
||||
_WORD_ACCESS 0 or 1 (Set for 1 if possible)
|
||||
(Any other options are left not changed from default setting)
|
||||
_FS_MINIMIZE 0 (Full, with all basic functions) or 3 (Min, with fully minimized)
|
||||
_FS_TINY 0 (Default) or 1 (Tiny file object)
|
||||
And any other options are left unchanged from original setting.
|
||||
</pre>
|
||||
</div>
|
||||
|
||||
<div class="para doc" id="reduce">
|
||||
<h3>Module Size Reduction</h3>
|
||||
<h3>Reducing Modle Size</h3>
|
||||
<p>Follwing table shows which API function is removed by configuration options for the module size reduction. To use any API function, the row of the function must be clear.</p>
|
||||
<table class="lst2">
|
||||
<tr><td rowspan="2">Function</td><td colspan="4">_FS_MINIMIZE</td><td colspan="2">_FS_READONLY</td><td colspan="2">_USE_STRFUNC</td><td colspan="3">_FS_RPATH</td><td colspan="2">_USE_FIND</td><td colspan="2">_USE_LABEL</td><td colspan="2">_USE_MKFS</td><td colspan="2">_USE_FORWARD</td><td colspan="2">_MULTI_PARTITION</td></tr>
|
||||
<tr><td>0</td><td>1</td><td>2</td><td>3</td><td>0</td><td>1</td><td>0 </td><td>1/2</td><td>0</td><td>1</td><td>2</td><td>0</td><td>1</td><td>0</td><td>1</td><td>0</td><td>1</td><td>0</td><td>1</td><td>0</td><td>1</td></tr>
|
||||
<tr class="lst3"><td>f_mount</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr>
|
||||
<tr><td>f_open</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr>
|
||||
<tr><td>f_close</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr>
|
||||
<tr><td>f_read</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr>
|
||||
<tr><td>f_write</td><td></td><td></td><td></td><td></td><td></td><td>x</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr>
|
||||
<tr><td>f_sync</td><td></td><td></td><td></td><td></td><td></td><td>x</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr>
|
||||
<tr><td>f_lseek</td><td></td><td></td><td></td><td>x</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr>
|
||||
<tr><td>f_opendir</td><td></td><td></td><td>x</td><td>x</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr>
|
||||
<tr><td>f_closedir</td><td></td><td></td><td>x</td><td>x</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr>
|
||||
<tr><td>f_readdir</td><td></td><td></td><td>x</td><td>x</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr>
|
||||
<tr><td>f_findfirst</td><td></td><td></td><td>x</td><td>x</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td>x</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr>
|
||||
<tr><td>f_findnext</td><td></td><td></td><td>x</td><td>x</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td>x</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr>
|
||||
<tr><td>f_stat</td><td></td><td>x</td><td>x</td><td>x</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr>
|
||||
<tr><td>f_getfree</td><td></td><td>x</td><td>x</td><td>x</td><td></td><td>x</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr>
|
||||
<tr><td>f_truncate</td><td></td><td>x</td><td>x</td><td>x</td><td></td><td>x</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr>
|
||||
<tr><td>f_unlink</td><td></td><td>x</td><td>x</td><td>x</td><td></td><td>x</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr>
|
||||
<tr><td>f_mkdir</td><td></td><td>x</td><td>x</td><td>x</td><td></td><td>x</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr>
|
||||
<tr><td>f_chmod</td><td></td><td>x</td><td>x</td><td>x</td><td></td><td>x</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr>
|
||||
<tr><td>f_utime</td><td></td><td>x</td><td>x</td><td>x</td><td></td><td>x</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr>
|
||||
<tr><td>f_rename</td><td></td><td>x</td><td>x</td><td>x</td><td></td><td>x</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr>
|
||||
<tr><td>f_chdir</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td>x</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr>
|
||||
<tr><td>f_chdrive</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td>x</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr>
|
||||
<tr><td>f_getcwd</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td>x</td><td>x</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr>
|
||||
<tr><td>f_getlabel</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td>x</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr>
|
||||
<tr><td>f_setlabel</td><td></td><td></td><td></td><td></td><td></td><td>x</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td>x</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr>
|
||||
<tr><td>f_forward</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td>x</td><td></td><td></td><td></td></tr>
|
||||
<tr><td>f_mkfs</td><td></td><td></td><td></td><td></td><td></td><td>x</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td>x</td><td></td><td></td><td></td><td></td><td></td></tr>
|
||||
<tr><td>f_fdisk</td><td></td><td></td><td></td><td></td><td></td><td>x</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td>x</td><td></td><td></td><td></td><td>x</td><td></td></tr>
|
||||
<tr><td>f_putc</td><td></td><td></td><td></td><td></td><td></td><td>x</td><td>x</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr>
|
||||
<tr><td>f_puts</td><td></td><td></td><td></td><td></td><td></td><td>x</td><td>x</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr>
|
||||
<tr><td>f_printf</td><td></td><td></td><td></td><td></td><td></td><td>x</td><td>x</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr>
|
||||
<tr><td>f_gets</td><td></td><td></td><td></td><td></td><td></td><td></td><td>x</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr>
|
||||
<tr><td rowspan="2">Function</td><td colspan="4">_FS_<br>MINIMIZE</td><td colspan="2">_FS_<br>READONLY</td><td colspan="2">_USE_<br>STRFUNC</td><td colspan="3">_FS_<br>RPATH</td><td colspan="2">_USE_<br>FIND</td><td colspan="2">_USE_<br>CHMOD</td><td colspan="2">_USE_<br>EXPAND</td><td colspan="2">_USE_<br>LABEL</td><td colspan="2">_USE_<br>MKFS</td><td colspan="2">_USE_<br>FORWARD</td><td colspan="2">_MULTI_<br>PARTITION</td></tr>
|
||||
<tr> <td>0</td><td>1</td><td>2</td><td>3</td><td>0</td><td>1</td><td>0</td><td>1</td><td>0</td><td>1</td><td>2</td><td>0</td><td>1</td><td>0</td><td>1</td><td>0</td><td>1</td><td>0</td><td>1</td><td>0</td><td>1</td><td>0</td><td>1</td><td>0</td><td>1</td></tr>
|
||||
<tr class="lst3">
|
||||
<td>f_mount</td> <td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td></tr>
|
||||
<tr><td>f_open</td> <td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td></tr>
|
||||
<tr><td>f_close</td> <td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td></tr>
|
||||
<tr><td>f_read</td> <td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td></tr>
|
||||
<tr><td>f_write</td> <td> </td><td> </td><td> </td><td> </td><td> </td><td>x</td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td></tr>
|
||||
<tr><td>f_sync</td> <td> </td><td> </td><td> </td><td> </td><td> </td><td>x</td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td></tr>
|
||||
<tr><td>f_lseek</td> <td> </td><td> </td><td> </td><td>x</td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td></tr>
|
||||
<tr><td>f_opendir</td> <td> </td><td> </td><td>x</td><td>x</td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td></tr>
|
||||
<tr><td>f_closedir</td> <td> </td><td> </td><td>x</td><td>x</td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td></tr>
|
||||
<tr><td>f_readdir</td> <td> </td><td> </td><td>x</td><td>x</td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td></tr>
|
||||
<tr><td>f_findfirst</td><td> </td><td> </td><td>x</td><td>x</td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td>x</td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td></tr>
|
||||
<tr><td>f_findnext</td> <td> </td><td> </td><td>x</td><td>x</td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td>x</td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td></tr>
|
||||
<tr><td>f_stat</td> <td> </td><td>x</td><td>x</td><td>x</td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td></tr>
|
||||
<tr><td>f_getfree</td> <td> </td><td>x</td><td>x</td><td>x</td><td> </td><td>x</td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td></tr>
|
||||
<tr><td>f_truncate</td> <td> </td><td>x</td><td>x</td><td>x</td><td> </td><td>x</td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td></tr>
|
||||
<tr><td>f_unlink</td> <td> </td><td>x</td><td>x</td><td>x</td><td> </td><td>x</td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td></tr>
|
||||
<tr><td>f_mkdir</td> <td> </td><td>x</td><td>x</td><td>x</td><td> </td><td>x</td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td></tr>
|
||||
<tr><td>f_rename</td> <td> </td><td>x</td><td>x</td><td>x</td><td> </td><td>x</td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td></tr>
|
||||
<tr><td>f_chdir</td> <td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td>x</td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td></tr>
|
||||
<tr><td>f_chdrive</td> <td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td>x</td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td></tr>
|
||||
<tr><td>f_getcwd</td> <td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td>x</td><td>x</td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td></tr>
|
||||
<tr><td>f_chmod</td> <td> </td><td> </td><td> </td><td> </td><td> </td><td>x</td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td>x</td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td></tr>
|
||||
<tr><td>f_utime</td> <td> </td><td> </td><td> </td><td> </td><td> </td><td>x</td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td>x</td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td></tr>
|
||||
<tr><td>f_getlabel</td> <td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td>x</td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td></tr>
|
||||
<tr><td>f_setlabel</td> <td> </td><td> </td><td> </td><td> </td><td> </td><td>x</td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td>x</td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td></tr>
|
||||
<tr><td>f_expand</td> <td> </td><td> </td><td> </td><td> </td><td> </td><td>x</td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td>x</td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td></tr>
|
||||
<tr><td>f_forward</td> <td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td>x</td><td> </td><td> </td><td> </td></tr>
|
||||
<tr><td>f_mkfs</td> <td> </td><td> </td><td> </td><td> </td><td> </td><td>x</td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td>x</td><td> </td><td> </td><td> </td><td> </td><td> </td></tr>
|
||||
<tr><td>f_fdisk</td> <td> </td><td> </td><td> </td><td> </td><td> </td><td>x</td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td>x</td><td> </td><td> </td><td> </td><td>x</td><td> </td></tr>
|
||||
<tr><td>f_putc</td> <td> </td><td> </td><td> </td><td> </td><td> </td><td>x</td><td>x</td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td></tr>
|
||||
<tr><td>f_puts</td> <td> </td><td> </td><td> </td><td> </td><td> </td><td>x</td><td>x</td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td></tr>
|
||||
<tr><td>f_printf</td> <td> </td><td> </td><td> </td><td> </td><td> </td><td>x</td><td>x</td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td></tr>
|
||||
<tr><td>f_gets</td> <td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td>x</td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td></tr>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<div class="para doc" id="lfn">
|
||||
<h3>Long File Name</h3>
|
||||
<p>FatFs module supports LFN (long file name). The two different file names, SFN (short file name) and LFN, of a file is transparent on the API except for <tt>f_readdir</tt> function. The LFN feature is disabled by default. To enable it, set <tt><a href="config.html#use_lfn">_USE_LFN</a></tt> to 1, 2 or 3, and add <tt>option/unicode.c</tt> to the project. The LFN feature requiers a certain working buffer in addition. The buffer size can be configured by <tt><a href="config.html#max_lfn">_MAX_LFN</a></tt> according to the available memory. The length of an LFN will reach up to 255 characters, so that the <tt>_MAX_LFN</tt> should be set to 255 for full featured LFN operation. If the size of working buffer is insufficient for the input file name, the file function fails with <tt>FR_INVALID_NAME</tt>. When use any re-entry to the API with the LFN feature, <tt>_USE_LFN</tt> must be set to 2 or 3. In this case, the file function allocates the working buffer on the stack or heap. The working buffer occupies <tt>(_MAX_LFN + 1) * 2</tt> bytes.</p>
|
||||
<p>FatFs module supports long file name (LFN). The two different file names, short file name (SFN) and LFN, of a file is transparent on the API except for <tt>f_readdir</tt> function. The support for LFN is disabled by default. To enable the LFN, set <tt><a href="config.html#use_lfn">_USE_LFN</a></tt> to 1, 2 or 3, and add <tt>option/unicode.c</tt> to the project. The LFN requiers a certain working buffer in addition. The buffer size can be configured by <tt><a href="config.html#max_lfn">_MAX_LFN</a></tt> according to the available memory. The length of an LFN will be up to 255 characters, so that the <tt>_MAX_LFN</tt> should be set to 255 for all file names. If the size of working buffer is insufficient for the input file name, the file function fails with <tt>FR_INVALID_NAME</tt>. When use any re-entry to the API with LFN is enabled, <tt>_USE_LFN</tt> must be set to 2 or 3. In this case, the file function allocates the working buffer on the stack or heap. The working buffer occupies <tt>(_MAX_LFN + 1) * 2</tt> bytes and additional 608 bytes when exFAT enabled.</p>
|
||||
<table class="lst2 rset">
|
||||
<caption>LFN cfg. at CM3/gcc</caption>
|
||||
<caption>With LFN at CM3+gcc</caption>
|
||||
<tr><th><tt>_CODE_PAGE</tt></th><th>Code size</th></tr>
|
||||
<tr><td>SBCS</td><td>+2.8K</td></tr>
|
||||
<tr><td>932(Japanese)</td><td>+62.6k</td></tr>
|
||||
@ -152,20 +154,27 @@ _WORD_ACCESS 0 or 1 (Set for 1 if possible)
|
||||
<tr><td>949(Korean)</td><td>+139k</td></tr>
|
||||
<tr><td>950(Traditional Chinese)</td><td>+111k</td></tr>
|
||||
</table>
|
||||
<p>When the LFN feature is enabled, the module size will be increased depends on the configured code page. Right table shows how much code size increased when LFN feature is enabled with some code pages. Especially, in the CJK region, tens of thousands of characters are being used. Unfortunately, it requires a huge OEM-Unicode bidirectional conversion table and the module size will be drastically increased as shown in the table. As the result, the FatFs with LFN feature with those code pages will not able to be implemented to most 8-bit microcontrollers.</p>
|
||||
<p>Note that the LFN feature on the FAT file system is a patent of Microsoft Corporation. This is not the case on FAT32 but most FAT32 drivers come with the LFN feature. FatFs can swich the LFN feature on/off by configuration option. When enable LFN feature on the commercial products, a license from Microsoft may be required depends on the final destination.</p>
|
||||
<p>When the LFN is enabled, the module size will be increased depends on the configured code page. Right table shows how much code size increased when LFN is enabled with some code pages. Especially, in the CJK region, tens of thousands of characters are being used. Unfortunately, it requires a huge OEM-Unicode bidirectional conversion table and the module size will be drastically increased as shown in the table. As the result, the FatFs with LFN enebled with those code pages will not able to be ported on the most 8-bit MCU systems.</p>
|
||||
<p>Note that the support for LFN on the FAT volume is a patent of Microsoft Corporation. This is not the case on FAT32 but most FAT32 drivers come with the support for LFN. FatFs can switch the LFN on/off by configuration option. When enable LFN on the commercial products, you will need to be licensed by Microsoft depends on the final destination of the products.</p>
|
||||
</div>
|
||||
|
||||
<div class="para doc" id="unicode">
|
||||
<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 <tt><a href="config.html#lfn_unicode">_LFN_UNICODE</a></tt> option. This means that the FatFs supports the True-LFN feature. 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 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>
|
||||
</div>
|
||||
|
||||
<div class="para doc" id="exfat">
|
||||
<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 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><em>Remark: Enabling exFAT discards C89 compatibility because of need for 64-bit integer type.</em></p>
|
||||
|
||||
<div class="para doc" id="reentrant">
|
||||
<h3>Re-entrancy</h3>
|
||||
<p>The file operations to the different volume is always re-entrant regardless of configurations and 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 to thread-safe by <tt><a href="config.html#fs_reentrant">_FS_REENTRANT</a></tt> option. 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 feature might not be supported on the some RTOSs.</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>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>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>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>
|
||||
@ -180,15 +189,15 @@ _WORD_ACCESS 0 or 1 (Set for 1 if possible)
|
||||
<h3>Performance Effective File Access</h3>
|
||||
<p>For good read/write throughput on the small embedded systems with limited size of memory, application programmer should consider what process is done in the FatFs module. The file data on the volume is transferred in following sequence by <tt>f_read</tt> function.</p>
|
||||
<p>Figure 1. Sector misaligned read (short)<br>
|
||||
<img src="../img/f1.png" width="490" height="110" alt="">
|
||||
<img src="../res/f1.png" width="490" height="110" alt="">
|
||||
</p>
|
||||
<p>Figure 2. Sector misaligned read (long)<br>
|
||||
<img src="../img/f2.png" width="490" height="140" alt="">
|
||||
<img src="../res/f2.png" width="490" height="140" alt="">
|
||||
</p>
|
||||
<p>Figure 3. Fully sector aligned read<br>
|
||||
<img src="../img/f3.png" width="490" height="119" alt="">
|
||||
<img src="../res/f3.png" width="490" height="119" alt="">
|
||||
</p>
|
||||
<p>The file I/O buffer is a sector buffer to read/write a partial data on the sector. The sector buffer is either file private sector buffer on each file object or shared sector buffer in the file system object. The buffer configuration option <tt><a href="config.html#fs_tiny">_FS_TINY</a></tt> determins which sector buffer is used for the file data transfer. When tiny buffer configuration (1) is selected, data memory consumption is reduced <tt>_MAX_SS</tt> bytes each file object. In this case, FatFs module uses only a sector buffer in the file system object for file data transfer and FAT/directory access. The disadvantage of the tiny buffer configuration is: the FAT data cached in the sector buffer will be lost by file data transfer and it must be reloaded at every cluster boundary. However it will be suitable for most application from view point of the decent performance and low memory comsumption.</p>
|
||||
<p>The file I/O buffer is a sector buffer to read/write a part of data on the sector. The sector buffer is either file private sector buffer on each file object or shared sector buffer in the file system object. The buffer configuration option <tt><a href="config.html#fs_tiny">_FS_TINY</a></tt> determins which sector buffer is used for the file data transfer. When tiny buffer configuration (1) is selected, data memory consumption is reduced <tt>_MAX_SS</tt> bytes each file object. In this case, FatFs module uses only a sector buffer in the file system object for file data transfer and FAT/directory access. The disadvantage of the tiny buffer configuration is: the FAT data cached in the sector buffer will be lost by file data transfer and it must be reloaded at every cluster boundary. However it will be suitable for most application from view point of the decent performance and low memory comsumption.</p>
|
||||
<p>Figure 1 shows that a partial sector, sector misaligned part of the file, is transferred via the file I/O buffer. At long data transfer shown in Figure 2, middle of transfer data that covers one or more sector is transferred to the application buffer directly. Figure 3 shows that the case of entier transfer data is aligned to the sector boundary. In this case, file I/O buffer is not used. On the direct transfer, the maximum extent of sectors are read with <tt>disk_read</tt> function at a time but the multiple sector transfer is divided at cluster boundary even if it is contiguous.</p>
|
||||
<p>Therefore taking effort to sector aligned read/write accesss eliminates buffered data transfer and the read/write performance will be improved. Besides the effect, cached FAT data will not be flushed by file data transfer at the tiny configuration, so that it can achieve same performance as non-tiny configuration with small memory footprint.</p>
|
||||
</div>
|
||||
@ -199,12 +208,12 @@ _WORD_ACCESS 0 or 1 (Set for 1 if possible)
|
||||
<h4>Using Mutiple-Sector Write</h4>
|
||||
<div class="rset">
|
||||
Figure 6. Comparison between Multiple/Single Sector Write<br>
|
||||
<img src="../img/f6.png" width="630" height="148" alt="fig.6">
|
||||
<img src="../res/f6.png" width="630" height="148" alt="fig.6">
|
||||
</div>
|
||||
<p>The write throughput of the flash memory media becomes the worst at single sector write transaction. The write throughput increases as the number of sectors per a write transaction as shown in Figure 6. This effect more appers at faster interface speed and the performance ratio often becomes grater than ten. <a href="../img/rwtest2.png">This graph</a> is clearly explaining how fast is multiple block write (W:16K, 32 sectors) than single block write (W:100, 1 sector), and also larger card tends to be slow at single block write. Number of write transactions also affects life time of the flash memory media. When compared at same amount of write data, the single sector write in Figure 6 above wears flash memory media 16 times more than multiple sector write in Figure 6 below. Single sector write is pretty pain for the flash memory media.</p>
|
||||
<p>Therefore the application program should write the data in large block as possible. The ideal write chunk size and alighment is size of sector, and size of cluster is the best. Of course all layers between the application and the storage device must have consideration on multiple sector write, however most of open-source memory card drivers lack it. Do not split a multiple sector write request into single sector write transactions or the write throughput gets poor. Note that FatFs module and its sample disk drivers supprt multiple sector read/write feature. </p>
|
||||
<p>The write throughput of the flash memory media becomes the worst at single sector write transaction. The write throughput increases as the number of sectors per a write transaction as shown in Figure 6. This effect more appers at faster interface speed and the performance ratio often becomes grater than ten. <a href="../res/rwtest2.png">This graph</a> is clearly explaining how fast is multiple block write (W:16K, 32 sectors) than single block write (W:100, 1 sector), and also larger card tends to be slow at single block write. Number of write transactions also affects life time of the flash memory media. When compared at same amount of write data, the single sector write in Figure 6 above wears flash memory media 16 times more than multiple sector write in Figure 6 below. Single sector write is pretty pain for the flash memory media.</p>
|
||||
<p>Therefore the application program should write the data in large block as possible. The ideal write chunk size and alighment is size of sector, and size of cluster is the best. Of course all layers between the application and the storage device must have consideration on multiple sector write, however most of open-source memory card drivers lack it. Do not split a multiple sector write request into single sector write transactions or the write throughput gets poor. Note that FatFs module and its sample disk drivers supprt multiple sector read/write operation. </p>
|
||||
<h4>Forcing Memory Erase</h4>
|
||||
<p>When remove a file with <tt>f_remove</tt> function, the data clusters occupied by the file are marked 'free' on the FAT. But the data sectors containing the file data are not that applied any process, so that the file data left occupies a part of the flash memory array as 'live block'. If the file data is forced erased on removing the file, those data blocks will be turned in to the free block pool. This may skip internal block erase operation to the data block on next write operation. As the result the write performance might be improved. FatFs can manage this feature by setting <tt><a href="config.html#use_trim">_USE_TRIM</a></tt> to 1. Note that this is an expectation of internal process of the flash memory storage and not that always effective. Also <tt>f_remove</tt> function will take a time when remove a large file. Most applications will not need this feature.</p>
|
||||
<p>When remove a file with <tt>f_unlink</tt> function, the data clusters occupied by the file are marked 'free' on the FAT. But the data sectors containing the file data are not that applied any process, so that the file data left occupies a part of the flash memory array as 'live block'. If the file data can be erased on removing the file, those data blocks will be turned into the free block pool. This may skip internal block erase operation to the data block on next write operation. As the result the write performance might be improved. FatFs can manage this function by setting <tt><a href="config.html#use_trim">_USE_TRIM</a></tt> to 1. Note that this is an expectation of internal process of the storage device and not that always effective. Most applications will not need this function. Also <tt>f_unlink</tt> function can take a time when remove a large file.</p>
|
||||
</div>
|
||||
|
||||
<div class="para doc" id="critical">
|
||||
@ -212,11 +221,11 @@ Figure 6. Comparison between Multiple/Single Sector Write<br>
|
||||
<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>
|
||||
<div class="lset">
|
||||
Figure 4. Long critical section<br>
|
||||
<img src="../img/f4.png" width="320" height="436" alt="fig.4">
|
||||
<img src="../res/f4.png" width="320" height="436" alt="fig.4">
|
||||
</div>
|
||||
<div class="lset">
|
||||
Figure 5. Minimized critical section<br>
|
||||
<img src="../img/f5.png" width="320" height="436" alt="fig.5">
|
||||
<img src="../res/f5.png" width="320" height="436" alt="fig.5">
|
||||
</div>
|
||||
<br class="clr">
|
||||
<p>An interruption in the red section can cause a cross link; as a result, the object being changed can be lost. If an interruption in the yellow section is occured, there is one or more possibility listed below.</p>
|
||||
@ -234,26 +243,28 @@ Figure 5. Minimized critical section<br>
|
||||
<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>
|
||||
<ol>
|
||||
<li><a href="../img/app1.c">Open or create a file for append</a></li>
|
||||
<li><a href="../img/app2.c">Empty a directory</a></li>
|
||||
<li><a href="../img/app3.c">Allocate contiguous area to the file</a></li>
|
||||
<li><a href="../img/app4.c">Function/Compatible checker for low level disk I/O module</a></li>
|
||||
<li><a href="../img/mkfatimg.zip">FAT image creator</a></li>
|
||||
<li><a href="../res/app1.c">Open or create a file for append</a> (for R0.12 and older)</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/app4.c">Function/compatibility checker for low level disk I/O module</a></li>
|
||||
<li><a href="../res/mkfatimg.zip">FAT image creator</a></li>
|
||||
</ol>
|
||||
</div>
|
||||
|
||||
<div class="para doc" id="license">
|
||||
<h3>About FatFs License</h3>
|
||||
<p>FatFs has being developped as a personal project of author, ChaN. It is free from the code anyone else wrote. 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>
|
||||
/*----------------------------------------------------------------------------/
|
||||
/ FatFs - FAT file system module R0.11 (C)ChaN, 2015
|
||||
/ FatFs - Generic FAT file system module R0.12a /
|
||||
/-----------------------------------------------------------------------------/
|
||||
/ FatFs module is a free software that opened under license policy of
|
||||
/ following conditions.
|
||||
/
|
||||
/ Copyright (C) 2015, ChaN, all right reserved.
|
||||
/ Copyright (C) 2016, ChaN, all right reserved.
|
||||
/
|
||||
/ FatFs module is an open source software. Redistribution and use of FatFs in
|
||||
/ source and binary forms, with or without modification, are permitted provided
|
||||
/ that the following condition is met:
|
||||
|
||||
/ 1. Redistributions of source code must retain the above copyright notice,
|
||||
/ this condition and the following disclaimer.
|
||||
/
|
||||
@ -263,7 +274,7 @@ Figure 5. Minimized critical section<br>
|
||||
/ by use of this software.
|
||||
/----------------------------------------------------------------------------*/
|
||||
</pre>
|
||||
<p>Therefore FatFs license is one of the BSD-style licenses but there is a significant feature. FatFs is mainly intended for embedded systems. In order to extend the usability for commercial products, the redistributions of FatFs in binary form, such as embedded code or any forms without source code, does not need to explain about use of FatFs in the documentations. This is equivalent to the 1-clause BSD license. Of course FatFs is compatible with the most open source software licenses including GNU GPL. When you redistribute the FatFs source code with any modification or create a fork, the license can also be changed to GNU GPL, BSD-style license or any open source software licenses that not conflict with FatFs license.</p>
|
||||
<p>Therefore FatFs license is one of the BSD-style licenses but there is a significant feature. FatFs is mainly intended for embedded systems. In order to extend the usability for commercial products, the redistributions of FatFs in binary form, such as embedded code, binary library and any forms without source code, does not need to include about FatFs in the documentations. This is equivalent to the 1-clause BSD license. Of course FatFs is compatible with the most open source software licenses including GNU GPL. When you redistribute the FatFs source code with any changes or create a fork, the license can also be changed to GNU GPL, BSD-style license or any open source software licenses that not conflict with FatFs license.</p>
|
||||
</div>
|
||||
|
||||
<p class="foot"><a href="../00index_e.html">Return Home</a></p>
|
||||
|
@ -72,7 +72,7 @@ FRESULT f_chmod (
|
||||
|
||||
<div class="para comp">
|
||||
<h4>QuickInfo</h4>
|
||||
<p>Available when <tt>_FS_READONLY == 0</tt> and <tt>_FS_MINIMIZE == 0</tt>.</p>
|
||||
<p>Available when <tt>_FS_READONLY == 0</tt> and <tt>_USE_CHMOD == 1</tt>.</p>
|
||||
</div>
|
||||
|
||||
|
||||
|
@ -45,7 +45,7 @@ FRESULT f_close (
|
||||
<div class="para desc">
|
||||
<h4>Description</h4>
|
||||
<p>The <tt>f_close</tt> function closes an open file object. If any data has been written to the file, the cached information of the file is written back to the volume. After the function succeeded, the file object is no longer valid and it can be discarded.</p>
|
||||
<p>Note that if the file object is in read-only mode and <tt>_FS_LOCK</tt> option is not enabled, the file object can also be discarded without this process. However this is not recommended for future compatibility.</p>
|
||||
<p>Note that if the file object is in read-only mode and <tt>_FS_LOCK</tt> is not enabled, the file object can also be discarded without this process. However this is not recommended for future compatibility.</p>
|
||||
</div>
|
||||
|
||||
|
||||
|
@ -44,7 +44,7 @@ FRESULT f_closedir (
|
||||
<div class="para desc">
|
||||
<h4>Description</h4>
|
||||
<p>The <tt>f_closedir</tt> function closes an open directory object. After the function succeeded, the directory object is no longer valid and it can be discarded.</p>
|
||||
<p>Note that the directory object can also be discarded without this process if <tt>_FS_LOCK</tt> option is not enabled. However this is not recommended for future compatibility.</p>
|
||||
<p>Note that the directory object can also be discarded without this process when option <tt>_FS_LOCK</tt> is not enabled. However this is not recommended for future compatibility.</p>
|
||||
</div>
|
||||
|
||||
|
||||
|
@ -17,7 +17,7 @@
|
||||
<h3>Function Configurations</h3>
|
||||
|
||||
<h4 id="fs_readonly">_FS_READONLY</h4>
|
||||
<p>Read/Write(0) or Read-only(1). Read-only configuration removes writing API functions, <tt>f_write</tt>, <tt>f_sync</tt>, <tt>f_unlink</tt>, <tt>f_mkdir</tt>, <tt>f_chmod</tt>, <tt>f_rename</tt>, <tt>f_truncate</tt>, <tt>f_getfree</tt> and optional writing functions as well.</p>
|
||||
<p>Read/Write (0) or Read-only (1). Read-only configuration removes writing API functions, <tt>f_write</tt>, <tt>f_sync</tt>, <tt>f_unlink</tt>, <tt>f_mkdir</tt>, <tt>f_chmod</tt>, <tt>f_rename</tt>, <tt>f_truncate</tt>, <tt>f_getfree</tt> and optional writing functions as well.</p>
|
||||
|
||||
<h4 id="fs_minimize">_FS_MINIMIZE</h4>
|
||||
<p>This option defines minimization level to remove some basic API functions as follows:</p>
|
||||
@ -39,19 +39,25 @@
|
||||
</table>
|
||||
|
||||
<h4 id="use_find">_USE_FIND</h4>
|
||||
<p>Disable(0) or Enable(1). This option switches filtered directory read feature and related functions, <tt>f_findfirst</tt> and <tt>f_findnext</tt>.</p>
|
||||
<p>Disable (0) or Enable (1) filtered directory read functions, <tt>f_findfirst</tt> and <tt>f_findnext</tt>. Also <tt>_FS_MINIMIZE</tt> needs to be 0 or 1.</p>
|
||||
|
||||
<h4 id="use_mkfs">_USE_MKFS</h4>
|
||||
<p>Disable(0) or Enable(1). This option switches <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>
|
||||
<p>Disable(0) or Enable(1). This option switches fast seek feature 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 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>
|
||||
|
||||
<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>
|
||||
|
||||
<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>
|
||||
|
||||
<h4 id="use_label">_USE_LABEL</h4>
|
||||
<p>Disable(0) or Enable(1). This option switches volume label functions, <tt>f_getlabel</tt> and <tt>f_setlabel</tt>.</p>
|
||||
<p>Disable (0) or Enable (1) volume label functions, <tt>f_getlabel</tt> and <tt>f_setlabel</tt>.</p>
|
||||
|
||||
<h4 id="use_forward">_USE_FORWARD</h4>
|
||||
<p>Disable(0) or Enable(1). This option switches <tt>f_forward</tt> function. also <tt>_FS_TINY</tt> needs to be set to 1.</p>
|
||||
<p>Disable (0) or Enable (1) <tt>f_forward</tt> function.</p>
|
||||
|
||||
</div>
|
||||
|
||||
@ -88,23 +94,23 @@
|
||||
</table>
|
||||
|
||||
<h4 id="use_lfn">_USE_LFN</h4>
|
||||
<p>This option switches the LFN feature. When enable the LFN feature, Unicode handling functions <tt>option/unicode.c</tt> must be added to the project. The LFN working buffer occupies <tt>(_MAX_LFN + 1) * 2</tt> bytes. When use stack for the working buffer, take care on stack overflow. When use heap memory for the working buffer, memory management functions, <tt>ff_memalloc</tt> and <tt>ff_memfree</tt>, must be added to the project.</p>
|
||||
<p>This option switches the support for long file name (LFN). When enable the LFN, Unicode support functions <tt>option/unicode.c</tt> need to be added to the project. The working buffer occupies <tt>(_MAX_LFN + 1) * 2</tt> bytes and additional 608 bytes when exFAT enabled. When use stack for the working buffer, take care on stack overflow. When use heap memory for the working buffer, memory management functions, <tt>ff_memalloc</tt> and <tt>ff_memfree</tt>, need to be added to the project.</p>
|
||||
<table class="lst1">
|
||||
<tr><th>Value</th><th>Description</th></tr>
|
||||
<tr><td>0</td><td>Disable LFN feature. Only 8.3 format can be used.</td></tr>
|
||||
<tr><td>0</td><td>Disable LFN. Only 8.3 format can be used.</td></tr>
|
||||
<tr><td>1</td><td>Enable LFN with static working buffer on the BSS. Always NOT thread-safe.</td></tr>
|
||||
<tr><td>2</td><td>Enable LFN with dynamic working buffer on the STACK.</td></tr>
|
||||
<tr><td>3</td><td>Enable LFN with dynamic working buffer on the HEAP.</td></tr>
|
||||
</table>
|
||||
|
||||
<h4 id="max_lfn">_MAX_LFN</h4>
|
||||
<p>This option defines the size of LFN working buffer from 12 to 255 in unit of character. This option has no effect when LFN feature is disabled.</p>
|
||||
<p>This option defines the size of LFN working buffer from 12 to 255 in unit of character. This option has no effect when LFN is disabled.</p>
|
||||
|
||||
<h4 id="lfn_unicode">_LFN_UNICODE</h4>
|
||||
<p>ANSI/OEM(0) or Unicode(1). This option switches character encoding on the API. To use Unicode (UTF16) string for the path name, enable LFN feature and set this option to 1. This option also affects behavior of string I/O functions. When LFN feature is disabled, this option must be 0. For more information, read <a href="filename.html#uni">here</a>.</p>
|
||||
<p>ANSI/OEM (0) or Unicode (1). This option switches character encoding on the API. To use Unicode (UTF16) string for the path name, enable LFN and set this option to 1. This option also affects behavior of string I/O functions. When LFN is disabled, this option must be 0. For more information, read <a href="filename.html#uni">here</a>.</p>
|
||||
|
||||
<h4 id="strf_encode">_STRF_ENCODE</h4>
|
||||
<p>When Unicode API is selected by <tt>_LFN_UNICODE</tt>, this option defines the assumption of character encoding on the file to be read/written via string I/O functions, <tt>f_gets</tt>, <tt>f_putc</tt>, <tt>f_puts</tt> and <tt>f_printf</tt>. This option has no effect when <tt>_LFN_UNICODE == 0</tt>.</p>
|
||||
<p>When Unicode API is selected by setting <tt>_LFN_UNICODE</tt> 1, this option defines the assumption of character encoding on the file to be read/written via string I/O functions, <tt>f_gets</tt>, <tt>f_putc</tt>, <tt>f_puts</tt> and <tt>f_printf</tt>. This option has no effect when <tt>_LFN_UNICODE = 0</tt>.</p>
|
||||
<table class="lst1">
|
||||
<tr><th>Value</th><th>Description</th></tr>
|
||||
<tr><td>0</td><td>ANSI/OEM</td></tr>
|
||||
@ -114,11 +120,11 @@
|
||||
</table>
|
||||
|
||||
<h4 id="fs_rpath">_FS_RPATH</h4>
|
||||
<p>This option configures relative path feature. Note that directory items read via directory functions are affected by this option. For more information, read <a href="filename.html#nam">here</a>.</p>
|
||||
<p>This option configures relative path function. For more information, read <a href="filename.html#nam">here</a>.</p>
|
||||
<table class="lst1">
|
||||
<tr><th>Value</th><th>Description</th></tr>
|
||||
<tr><td>0</td><td>Disable relative path feature and remove related functions.</td></tr>
|
||||
<tr><td>1</td><td>Enable relative path feature. <tt>f_chdir</tt> and <tt>f_chdrive</tt> function is available.</td></tr>
|
||||
<tr><td>0</td><td>Disable relative path function and remove related functions.</td></tr>
|
||||
<tr><td>1</td><td>Enable relative path function. <tt>f_chdir</tt> and <tt>f_chdrive</tt> function is available.</td></tr>
|
||||
<tr><td>2</td><td><tt>f_getcwd</tt> function is available in addition to 1</td></tr>
|
||||
</table>
|
||||
|
||||
@ -129,22 +135,22 @@
|
||||
<h3>Volume/Drive Configurations</h3>
|
||||
|
||||
<h4 id="volumes">_VOLUMES</h4>
|
||||
<p>This option configures number of volumes (logical drives, from 1 to 9) to be used.</p>
|
||||
<p>This option configures number of volumes (logical drives, from 1 to 10) to be used.</p>
|
||||
|
||||
<h4 id="str_volume_id">_STR_VOLUME_ID</h4>
|
||||
<p>Disable(0) or Enable(1). This option switches string volume ID feature. When enabled, also pre-defined strings in <tt>_VOLUME_STRS</tt> can be used as drive identifier in the path name.</p>
|
||||
<p>Disable (0) or Enable (1). This option switches the support for string volume ID. When enabled, also pre-defined strings in <tt>_VOLUME_STRS</tt> can be used as drive identifier in the path name.</p>
|
||||
|
||||
<h4 id="volume_strs">_VOLUME_STRS</h4>
|
||||
<p>This option defines the drive ID strings for each logical drives. Number of items must be equal to <tt>_VOLUMES</tt>. Valid characters for the drive ID strings are: A-Z and 0-9.</p>
|
||||
<p>This option defines the drive ID strings for each logical drives. Number of items must not be less than <tt>_VOLUMES</tt>. Valid characters for the drive ID string are: A-Z and 0-9.</p>
|
||||
|
||||
<h4 id="multi_partition">_MULTI_PARTITION</h4>
|
||||
<p>Disable(0) or Enable(1). This option switches multi-partition feature. By default (0), each logical drive number is bound to the same physical drive number and only an FAT volume each physical drive are 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 enabled. 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>
|
||||
<p>This set of options defines size of sector on the low level disk I/O interface, <tt>disk_read</tt> and <tt>disk_write</tt> function. Valid numbers are 512, 1024, 2048 and 4096. <tt>_MIN_SS</tt> defines minimum size of sector and <tt>_MAX_SS</tt> defines the maximum size of sector. Always set both 512 for all type of memory cards 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 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>
|
||||
|
||||
<h4 id="use_trim">_USE_TRIM</h4>
|
||||
<p>Disable(0) or Enable(1). This option switches ATA-TRIM feature. To enable Trim feature, 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>
|
||||
|
||||
<h4 id="fs_nofsinfo">_FS_NOFSINFO</h4>
|
||||
<p>0 to 3. If you need to know correct free space on the FAT32 volume, set bit 0 of this option, and <tt>f_getfree</tt> function at first time after volume mount will force a full FAT scan. Bit 1 controls the use of last allocated cluster number.</p>
|
||||
@ -163,55 +169,33 @@
|
||||
<h3>System Configurations</h3>
|
||||
|
||||
<h4 id="fs_tiny">_FS_TINY</h4>
|
||||
<p>Normal(0) or Tiny(1). At the tiny configuration, size of the file object <tt>FIL</tt> is reduced <tt>_MAX_SS</tt> bytes. Instead of private data buffer eliminated from the file object, common sector buffer in the file system object <tt>FATFS</tt> is used for the file data transfer.</p>
|
||||
<p>Normal (0) or Tiny (1). At the tiny configuration, size of the file object <tt>FIL</tt> is reduced <tt>_MAX_SS</tt> bytes. Instead of private data buffer eliminated from the file object, common sector buffer in the file system object <tt>FATFS</tt> is used for the file data transfer.</p>
|
||||
|
||||
<h4 id="fs_exfat">_FS_EXFAT</h4>
|
||||
<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>
|
||||
<p>Use RTC(0) or Do not use RTC(1). This option controls timestamp feature. 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 feature. 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 feature, set <tt>_FS_NORTC</tt> to 0 and add <tt>get_fattime</tt> function to the project to get the current time form RTC. 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 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>
|
||||
|
||||
<h4 id="nortc_time">_NORTC_MON, _NORTC_MDAY, _NORTC_YEAR</h4>
|
||||
<p>This set of options defines default timestamp 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>
|
||||
|
||||
<h4 id="fs_lock">_FS_LOCK</h4>
|
||||
<p>This option switches file lock feature to control duplicated file open and illegal operations to open objects. Note that the file lock feature 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">
|
||||
<tr><th>Value</th><th>Description</th></tr>
|
||||
<tr><td>0</td><td>Disable file lock feature. To avoid volume corruption, application program should avoid illegal open, remove and rename to the open objects.</td></tr>
|
||||
<tr><td>>0</td><td>Enable file lock feature. 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>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>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>
|
||||
</table>
|
||||
|
||||
<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 feature. 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>, must be added to the project. Samples are 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>
|
||||
<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>
|
||||
|
||||
<h4 id="sync_t">_SYNC_t</h4>
|
||||
<p>This option defines O/S dependent sync object type. e.g. <tt>HANDLE</tt>, <tt>ID</tt>, <tt>OS_EVENT*</tt>, <tt>SemaphoreHandle_t</tt> and etc. A header file for O/S definitions needs to be included somewhere in the scope of <tt>ff.c</tt>. This option has no effect when <tt>_FS_REENTRANT == 0</tt>.</p>
|
||||
|
||||
<h4 id="word_access">_WORD_ACCESS</h4>
|
||||
<p>This is an only platform dependent option. It defines which access method is used to the word data on the FAT volume.</p>
|
||||
<table class="lst1">
|
||||
<tr><th>Value</th><th>Description</th></tr>
|
||||
<tr><td>0</td><td>Byte-by-byte access. Always compatible with all platforms.</td></tr>
|
||||
<tr><td>1</td><td>Word access. Code size will be slightly reduced but do not choose this unless under both the following conditions.<br>
|
||||
* Unaligned memory access is always allowed to ALL instructions.<br>
|
||||
* Byte order on the memory is little-endian.</td></tr>
|
||||
</table>
|
||||
<p>Following table shows an example of allowable settings of some type of processors.</p>
|
||||
<pre>
|
||||
ARM7TDMI 0 *2 ColdFire 0 *1 V850E 0 *2
|
||||
Cortex-M3 0 *3 Z80 0/1 V850ES 0/1
|
||||
Cortex-M0 0 *2 x86 0/1 TLCS-870 0/1
|
||||
AVR 0/1 RX600(LE) 0/1 TLCS-900 0/1
|
||||
AVR32 0 *1 RL78 0 *2 R32C 0 *2
|
||||
PIC18 0/1 SH-2 0 *1 M16C 0/1
|
||||
PIC24 0 *2 H8S 0 *1 MSP430 0 *2
|
||||
PIC32 0 *1 H8/300H 0 *1 8051 0/1
|
||||
|
||||
*1:Big-endian.
|
||||
*2:Unaligned memory access is not supported.
|
||||
*3:Some compilers generate LDM/STM for mem_cpy function.
|
||||
</pre>
|
||||
<p>This option defines O/S dependent sync object type. e.g. <tt>HANDLE</tt>, <tt>ID</tt>, <tt>OS_EVENT*</tt>, <tt>SemaphoreHandle_t</tt> and etc. A header file for O/S definitions needs to be included somewhere in the scope of <tt>ff.c</tt>. This option has no effect when <tt>_FS_REENTRANT = 0</tt>.</p>
|
||||
|
||||
</div>
|
||||
|
||||
|
@ -38,7 +38,7 @@ DSTATUS disk_initialize (
|
||||
<div class="para desc">
|
||||
<h4>Description</h4>
|
||||
<p>This function initializes the storage device and put it ready to generic read/write. When the function succeeded, <tt>STA_NOINIT</tt> flag in the return value is cleared.</p>
|
||||
<p>This function is under control of FatFs module. <em>Application program MUST NOT call this function, or FAT structure on the volume can be broken. To re-initialize the file system, use <tt>f_mount</tt> function instead.</em></p>
|
||||
<p><em>Remarks: This function needs to be under control of FatFs module. Application program MUST NOT call this function, or FAT structure on the volume can be broken. To re-initialize the file system, use <tt>f_mount</tt> function instead.</em></p>
|
||||
</div>
|
||||
|
||||
<p class="foot"><a href="../00index_e.html">Return</a></p>
|
||||
|
@ -13,7 +13,7 @@
|
||||
|
||||
<div class="para func">
|
||||
<h2>disk_ioctl</h2>
|
||||
<p>The disk_ioctl function cntrols device specific features and miscellaneous functions other than generic read/write.</p>
|
||||
<p>The disk_ioctl function controls device specific features and miscellaneous functions other than generic read/write.</p>
|
||||
<pre>
|
||||
DRESULT disk_ioctl (
|
||||
BYTE <span class="arg">pdrv</span>, <span class="c">/* [IN] Drive number */</span>
|
||||
@ -61,7 +61,7 @@ DRESULT disk_ioctl (
|
||||
<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_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>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. When this feature is not supported or not a flash memory device, nothing to do for this command. 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 removing a cluster chain and <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 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>
|
||||
</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>
|
||||
@ -82,6 +82,9 @@ DRESULT disk_ioctl (
|
||||
<tr><td>ATA_GET_REV</td><td>Get the revision string into a 16-byte buffer pointed by <tt class="arg">buff</tt>. (ATA/CFC specific command)</td></tr>
|
||||
<tr><td>ATA_GET_MODEL</td><td>Get the model string into a 40-byte buffer pointed by <tt class="arg">buff</tt>. (ATA/CFC specific command)</td></tr>
|
||||
<tr><td>ATA_GET_SN</td><td>Get the serial number string into a 20-byte buffer pointed by <tt class="arg">buff</tt>. (ATA/CFC specific command)</td></tr>
|
||||
<tr><td>ISDIO_READ</td><td>Read a block of iSDIO registers specified by command structure pointed by <tt class="arg">buff</tt>. (FlashAir specific command)</td></tr>
|
||||
<tr><td>ISDIO_WRITE</td><td>Write a block of data to iSDIO registers specified by command structure pointed by <tt class="arg">buff</tt>. (FlashAir specific command)</td></tr>
|
||||
<tr><td>ISDIO_MRITE</td><td>Change bits in an iSDIO register specified by command structure pointed by <tt class="arg">buff</tt>. (FlashAir specific command)</td></tr>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
|
@ -34,7 +34,7 @@ DRESULT disk_read (
|
||||
<dt>sector</dt>
|
||||
<dd>Start sector number in 32-bit LBA.</dd>
|
||||
<dt>count</dt>
|
||||
<dd>Number of sectors to read. FatFs specifies the value in range of from 1 to 128.</dd>
|
||||
<dd>Number of sectors to read.</dd>
|
||||
</dl>
|
||||
</div>
|
||||
|
||||
@ -56,12 +56,12 @@ DRESULT disk_read (
|
||||
|
||||
<div class="para desc">
|
||||
<h4>Description</h4>
|
||||
<p>The data read/write operation to the storage devices is done in unit of <em>sector</em>. FatFs supports the sector size in range of from 512 to 4096 bytes. When FatFs is configured to fixed sector size (<tt>_MIN_SS == MAX_SS</tt>, this will be the most case), the read/write function must work at that sector size. When FatFs is configured to variable sector size (<tt>_MIN_SS < MAX_SS</tt>), sector size is inquired with <tt>disk_ioctl</tt> function following <tt>disk_initialize</tt> function</tt>.
|
||||
<p>The memory address specified by <tt class="arg">buff</tt> is not that always aligned to word boundary because the argument is defined as <tt>BYTE*</tt>. The misaligned read/write request can occure at <a href="appnote.html#fs1">direct transfer</a>. If the bus architecture, especially DMA controller, does not allow misaligned memory access, it should be solved in this function. There are some workarounds described below to avoid this issue.</p>
|
||||
<p>The data read/write operation to the storage devices is done in unit of <em>sector</em>. FatFs supports the sector size in range of from 512 to 4096 bytes. When FatFs is configured to fixed sector size (<tt>_MIN_SS == MAX_SS</tt>, this will be the most case), the read/write function must work at that sector size. When FatFs is configured to variable sector size (<tt>_MIN_SS != MAX_SS</tt>), sector size is inquired with <tt>disk_ioctl</tt> function following <tt>disk_initialize</tt> function.</p>
|
||||
<p>The memory address specified by <tt class="arg">buff</tt> is not that always aligned to word boundary because the argument is defined as <tt>BYTE*</tt>. The unaligned read/write request can occure at <a href="appnote.html#fs1">direct transfer</a>. If the bus architecture, especially DMA controller, does not allow unaligned memory access, it should be solved in this function. There are some workarounds described below to avoid this issue.</p>
|
||||
<ul>
|
||||
<li>Convert word transfer to byte transfer in this function if needed. - Recommended.</li>
|
||||
<li>At the any <tt>f_read</tt> calls, avoid long read request that includes a whole of sector. - Direct transfer will never occure.</li>
|
||||
<li>At the <tt>f_read(fp, data, btr, &br)</tt> call, 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, 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>
|
||||
</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>
|
||||
</div>
|
||||
|
@ -35,11 +35,11 @@ DSTATUS disk_status (
|
||||
<p>The current drive status is returned in combination of status flags described below. FatFs refers only <tt>STA_NOINIT</tt> and <tt>STA_PROTECT</tt>.</p>
|
||||
<dl class="ret">
|
||||
<dt>STA_NOINIT</dt>
|
||||
<dd>Indicates that the device is not initialized. This flag is set on system reset, media removal or failure of <tt>disk_initialize</tt> function. It is cleared on <tt>disk_initialize</tt> function succeeded. Media change that occurs asynchronously must be captured and reflect it to the status flags, or auto-mount feature will not work correctly. If the system does not support media change detect feature, application program needs to force de-initialize the file system object with <tt>f_mount</tt> function after the media change.</dd>
|
||||
<dd>Indicates that the device is not initialized and not ready to work. This flag is set on system reset, media removal or failure of <tt>disk_initialize</tt> function. It is cleared on <tt>disk_initialize</tt> function succeeded. Any media change that occurs asynchronously must be captured and reflect it to the status flags, or auto-mount function will not work correctly. If the system does not support media change detection, application program needs to force de-initialize the file system object and re-mount the volume with <tt>f_mount</tt> function after each media change.</dd>
|
||||
<dt>STA_NODISK</dt>
|
||||
<dd>Indicates that no medium in the drive. This is always cleared on fixed disk drive. Note that FatFs does not refer this flag.</dd>
|
||||
<dd>Indicates that no medium in the drive. This is always cleared at fixed disk drive. Note that FatFs does not refer this flag.</dd>
|
||||
<dt>STA_PROTECT</dt>
|
||||
<dd>Indicates that the medium is write protected. This is always cleared on the drives without write protect feature. Not valid if no medium in the drive.</dd>
|
||||
<dd>Indicates that the medium is write protected. This is always cleared at the drives without write protect function. Not valid if no medium in the drive.</dd>
|
||||
</dl>
|
||||
</div>
|
||||
|
||||
|
@ -34,7 +34,7 @@ DRESULT disk_write (
|
||||
<dt>sector</dt>
|
||||
<dd>Start sector number in 32-bit LBA.</dd>
|
||||
<dt>count</dt>
|
||||
<dd>Number of sectors to write. FatFs specifies the value in range of from 1 to 128.</dd>
|
||||
<dd>Number of sectors to write.</dd>
|
||||
</dl>
|
||||
</div>
|
||||
|
||||
@ -60,8 +60,8 @@ DRESULT disk_write (
|
||||
<h4>Description</h4>
|
||||
<p>The specified memory address is not that always aligned to word boundary because the type of pointer is defined as <tt>BYTE*</tt>. For more information, refer to the description of <a href="dread.html"><tt>disk_read</tt></a> function.</p>
|
||||
<p>Generally, a multiple sector transfer request must not be split into single sector transactions to the storage device, or you will never get good write throughput.</p>
|
||||
<p>FatFs expects delayed write feature of the disk control layer. The write operation to the media need not to be completed due to write operation is in progress or data is stored into the write-back cache when return from this function. But write data on the <tt class="arg">buff</tt> is invalid after return from this function. The write completion request is done by <tt>CTRL_SYNC</tt> command of <tt><a href="dioctl.html">disk_ioctl</a></tt> function. Therefore, if a delayed write feature is implemented, the write throughput will be improved.</p>
|
||||
<p><em>Application program MUST NOT call this function, or FAT structure on the volume can be collapsed.</em></p>
|
||||
<p>FatFs expects delayed write function of the disk control layer. The write operation to the media does not need to be completed when return from this function by what write operation is in progress or data is only stored into the write-back cache. But write data on the <tt class="arg">buff</tt> is invalid after return from this function. The write completion request is done by <tt>CTRL_SYNC</tt> command of <tt><a href="dioctl.html">disk_ioctl</a></tt> function. Therefore, if a delayed write function is implemented, the write throughput will be improved.</p>
|
||||
<p><em>Remarks: Application program MUST NOT call this function, or FAT structure on the volume can be collapsed.</em></p>
|
||||
</div>
|
||||
|
||||
|
||||
|
@ -39,7 +39,7 @@ int f_eof (
|
||||
|
||||
<div class="para desc">
|
||||
<h4>Description</h4>
|
||||
<p>In this revision, this function is implemented as a macro. It has not any validation and mutual exclusion.</p>
|
||||
<p>In this revision, this function is implemented as a macro. It does not have any validation and mutual exclusion.</p>
|
||||
<pre>
|
||||
<span class="k">#define</span> f_eof(fp) ((int)((fp)->fptr == (fp)->fsize))
|
||||
</pre>
|
||||
|
@ -39,9 +39,9 @@ int f_error (
|
||||
|
||||
<div class="para desc">
|
||||
<h4>Description</h4>
|
||||
<p>In this revision, this function is implemented as a macro. It has not any validation and mutual exclusion.</p>
|
||||
<p>In this revision, this function is implemented as a macro. It does not have any validation and mutual exclusion.</p>
|
||||
<pre>
|
||||
<span class="k">#define</span> f_error(fp) ((fp)->flag)
|
||||
<span class="k">#define</span> f_error(fp) ((fp)->err)
|
||||
</pre>
|
||||
</div>
|
||||
|
||||
|
116
firmware/chibios-portapack/ext/fatfs/doc/en/expand.html
Normal file
@ -0,0 +1,116 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
|
||||
<meta http-equiv="Content-Style-Type" content="text/css">
|
||||
<link rel="up" title="FatFs" href="../00index_e.html">
|
||||
<link rel="alternate" hreflang="ja" title="Japanese" href="../ja/lseek.html">
|
||||
<link rel="stylesheet" href="../css_e.css" type="text/css" media="screen" title="ELM Default">
|
||||
<title>FatFs - f_expand</title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
<div class="para func">
|
||||
<h2>f_expand</h2>
|
||||
<p>The f_expand function prepares or allocates a contiguous data area to the file.</p>
|
||||
|
||||
<pre>
|
||||
FRESULT f_expand (
|
||||
FIL* <span class="arg">fp</span>, <span class="c">/* [IN] File object */</span>
|
||||
FSIZE_t <span class="arg">fsz</span>, <span class="c">/* [IN] File size expanded to */</span>
|
||||
BYTE <span class="arg">opt</span> <span class="c">/* [IN] Operation mode */</span>
|
||||
);
|
||||
</pre>
|
||||
</div>
|
||||
|
||||
<div class="para arg">
|
||||
<h4>Parameters</h4>
|
||||
<dl class="par">
|
||||
<dt>fp</dt>
|
||||
<dd>Pointer to the open file object.</dd>
|
||||
<dt>fsz</dt>
|
||||
<dd>Number of bytes in size to prepare or allocate for the file. The data type <tt>FSIZE_t</tt> is an alias of either <tt>DWORD</tt>(32-bit) or <tt>QWORD</tt>(64-bit) depends on the configuration option <tt>_FS_EXFAT</tt>.</dd>
|
||||
<dt>opt</dt>
|
||||
<dd>Operation mode. Prepare only (0) or Allocate now (1).</dd>
|
||||
</dl>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="para ret">
|
||||
<h4>Return Values</h4>
|
||||
<p>
|
||||
<a href="rc.html#ok">FR_OK</a>,
|
||||
<a href="rc.html#de">FR_DISK_ERR</a>,
|
||||
<a href="rc.html#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#tm">FR_TIMEOUT</a>
|
||||
</p>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="para desc">
|
||||
<h4>Description</h4>
|
||||
<p>The <tt>f_expand</tt> function prepares or allocates a contiguous data area to the file. When <tt class="arg">opt</tt> is 1, the function allocates a contiguous data area to the file. Unlike expansion of file by <tt>f_lseek</tt> function, the file must be truncated prior to use this function and read/write pointer of the file stays at top of the file after the function. The file content allocated with this function is <em>undefined</em> because no data is written to the file in this process. The function can fail with <tt>FR_DENIED</tt> due to some reasons below.</p>
|
||||
<ul>
|
||||
<li>No free contiguous space was found.</li>
|
||||
<li>Size of the file was not zero.</li>
|
||||
<li>The file has been opened in read-only mode.</li>
|
||||
<li>Not allowable file size. (>= 4GiB on FAT volume)</li>
|
||||
</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>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>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>
|
||||
</div>
|
||||
|
||||
<div class="para comp">
|
||||
<h4>QuickInfo</h4>
|
||||
<p>Available when <tt>_USE_EXPAND == 1</tt> and <tt>_FS_READONLY == 0</tt>.</p>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="para use">
|
||||
<h4>Example</h4>
|
||||
<pre>
|
||||
<span class="c">/* Creating a contiguous file */</span>
|
||||
|
||||
<span class="c">/* Create a new file */</span>
|
||||
res = f_open(fp = malloc(sizeof (FIL)), "file.dat", FA_WRITE|FA_CREATE_ALWAYS);
|
||||
if (res) { <span class="c">/* Check if the file has been opened */</span>
|
||||
free(fp);
|
||||
...
|
||||
}
|
||||
|
||||
<span class="c">/* Alloacte a 100 MiB of contiguous area to the file */</span>
|
||||
res = f_expand(fp, 104857600, 1);
|
||||
if (res) { <span class="c">/* Check if the file has been expanded */</span>
|
||||
...
|
||||
free(fp);
|
||||
...
|
||||
}
|
||||
<span class="c">/* Now you have a contiguous file accessible with fp */</span>
|
||||
|
||||
</pre>
|
||||
<pre>
|
||||
<span class="c">/* Accessing the file data directly via low-level disk functions */</span>
|
||||
|
||||
<span class="c">/* Get physical location of the file data */</span>
|
||||
drv = fp->obj.fs->drv;
|
||||
sect = fp->obj.fs->database + fp->obj.fs->csize * (fp->obj.sclust - 2);
|
||||
|
||||
<span class="c">/* Write 2048 sectors from top of the file at a time */</span>
|
||||
res = disk_write(drv, buffer, sect, 2048);
|
||||
|
||||
</pre>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="para ref">
|
||||
<h4>See Also</h4>
|
||||
<p><tt><a href="open.html">f_open</a>, <a href="lseek.html">f_lseek</a>, <a href="sfile.html">FIL</a></tt></p>
|
||||
</div>
|
||||
|
||||
<p class="foot"><a href="../00index_e.html">Return</a></p>
|
||||
</body>
|
||||
</html>
|
@ -16,9 +16,9 @@
|
||||
<p>The f_fdisk fucntion divides a physical drive.</p>
|
||||
<pre>
|
||||
FRESULT f_fdisk (
|
||||
BYTE <span class="arg">pdrv</span>, <span class="c">/* [IN] Physical drive number */</span>
|
||||
const DWORD <span class="arg">part[]</span>, <span class="c">/* [IN] Partition size */</span>
|
||||
void* <span class="arg">work</span> <span class="c">/* [IN] Work area */</span>
|
||||
BYTE <span class="arg">pdrv</span>, <span class="c">/* [IN] Physical drive number */</span>
|
||||
const DWORD* <span class="arg">szt</span>, <span class="c">/* [IN] Partition map table */</span>
|
||||
void* <span class="arg">work</span> <span class="c">/* [IN] Work area */</span>
|
||||
);
|
||||
</pre>
|
||||
</div>
|
||||
@ -27,9 +27,9 @@ FRESULT f_fdisk (
|
||||
<h4>Parameters</h4>
|
||||
<dl class="par">
|
||||
<dt>pdrv</dt>
|
||||
<dd>Specifies the <em>physical drive</em> to be divided.</dd>
|
||||
<dt>part[]</dt>
|
||||
<dd>Partition map table. It must have four items.</dd>
|
||||
<dd>Specifies the <em>physical drive</em> to be divided. This is not the logical drive number but the drive identifier passed to the low level disk functions.</dd>
|
||||
<dt>szt</dt>
|
||||
<dd>Pointer to the first item of the partition map table.</dd>
|
||||
<dt>work</dt>
|
||||
<dd>Pointer to the function work area. The size must be at least <tt>_MAX_SS</tt> bytes.</dd>
|
||||
</dl>
|
||||
@ -48,7 +48,7 @@ FRESULT f_fdisk (
|
||||
|
||||
<div class="para desc">
|
||||
<h4>Description</h4>
|
||||
<p>The <tt>f_fdisk</tt> function creates a partition table into the MBR of the physical drive. The partitioning rule is in generic FDISK format, so that it can create upto four primary partitions. Logical volumes in the extended partition is not supported. The <tt class="arg">part[]</tt> with four items specifies how to divide the physical drive. The first item specifies the size of first primary partition and fourth item specifies the fourth primary partition. If the value is less than or equal to 100, it specifies percentage of the partition in the entire disk space. If it is larger than 100, it specifies the partition size in unit of sector.</p>
|
||||
<p>The <tt>f_fdisk</tt> function creates partitions on the physical drive. The partitioning format is in generic FDISK format, so that it can create upto four primary partitions. Logical volumes in the extended partition is not supported. The partition map table with four items specifies how to divide the physical drive. The first item specifies the size of first primary partition and fourth item specifies the fourth primary partition. If the value is less than or equal to 100, it specifies the partition size in percentage of the entire drive space. If it is larger than 100, it specifies the partition size in unit of sector. The partitions are located on the drive in order of from first item.</p>
|
||||
</div>
|
||||
|
||||
<div class="para comp">
|
||||
@ -74,15 +74,10 @@ FRESULT f_fdisk (
|
||||
DWORD plist[] = {50, 50, 0, 0}; <span class="c">/* Divide drive into two partitions */</span>
|
||||
BYTE work[_MAX_SS];
|
||||
|
||||
f_fdisk(0, plist, work); <span class="c">/* Divide physical drive 0 */</span>
|
||||
f_fdisk(0, plist, work); <span class="c">/* Divide physical drive 0 */</span>
|
||||
|
||||
f_mount(&fs, "0:", 0); <span class="c">/* Register work area to the logical drive 0 */</span>
|
||||
f_mkfs("0:", 0, 0); <span class="c">/* Create FAT volume on the logical drive 0. 2nd argument is ignored. */</span>
|
||||
f_mount(0, "0:", 0); <span class="c">/* Unregister work area from the logical drive 0 */</span>
|
||||
|
||||
f_mount(&fs, "1:", 0); <span class="c">/* Register a work area to the logical drive 1 */</span>
|
||||
f_mkfs("1:", 0, 0); <span class="c">/* Create FAT volume on the logical drive 1. 2nd argument is ignored. */</span>
|
||||
f_mount(0, "1:", 0); <span class="c">/* Unregister work area from the logical drive 1 */</span>
|
||||
f_mkfs("0:", FMT_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>
|
||||
|
||||
</pre>
|
||||
</div>
|
||||
|
@ -16,10 +16,10 @@
|
||||
<h3>Format of the path names</h3>
|
||||
<p>The format of path name on the FatFs module is similer to the filename specs of DOS/Windos as follows:</p>
|
||||
<pre>"[<em>drive</em>:][/]<em>directory</em>/<em>file</em>"</pre>
|
||||
<p>The FatFs module supports long file name (LFN) and 8.3 format file name (SFN). The LFN can be used when LFN feature is enabled (<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>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 feature 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>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>
|
||||
<table class="lst2">
|
||||
<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>
|
||||
@ -31,11 +31,12 @@
|
||||
<tr><td>2:file.txt</td><td>A file in the root directory of the drive 2</td><td>A file in the current directory of the drive 2</td></tr>
|
||||
<tr><td>../file.txt</td><td>Invalid name</td><td>A file in the parent directory</td></tr>
|
||||
<tr><td>.</td><td>Invalid name</td><td>This directory</td></tr>
|
||||
<tr><td>..</td><td>Invalid name</td><td>Parent directory of the current directory</td></tr>
|
||||
<tr><td>..</td><td>Invalid name</td><td>Parent directory of the current directory (*)</td></tr>
|
||||
<tr><td>dir1/..</td><td>Invalid name</td><td>The current directory</td></tr>
|
||||
<tr><td>/..</td><td>Invalid name</td><td>The root directory (sticks the top level)</td></tr>
|
||||
</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> or <tt>"ram:swapfile.dat"</tt>.</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>
|
||||
</div>
|
||||
|
||||
<div class="para doc" id="case">
|
||||
@ -47,7 +48,7 @@
|
||||
|
||||
<div class="para doc" id="uni">
|
||||
<h3>Unicode API</h3>
|
||||
<p>The path names are input/output in either ANSI/OEM code or Unicode depends on the configuration options. The type of arguments which specify the path names are defined as <tt>TCHAR</tt>. It is an alias of <tt>char</tt> by default. The code set used to the path name string is ANSI/OEM specifid by <tt><a href="config.html#code_page">_CODE_PAGE</a></tt>. When <tt><a href="config.html#lfn_unicode">_LFN_UNICODE</a></tt> is set to 1, the type of the <tt>TCHAR</tt> is switched to <tt>WCHAR</tt> to support Unicode (UTF-16 encoding). In this case, the LFN feature is fully supported and the Unicode specific characters, such as ✝☪✡☸☭, can also be used for the path name. It also affects data types and encoding of the string I/O functions. To define literal strings, <tt>_T(s)</tt> and <tt>_TEXT(s)</tt> macro are available to select either ANSI/OEM or Unicode automatically. The code shown below is an example to define the literal strings.</p>
|
||||
<p>The path names are input/output in either ANSI/OEM code or Unicode depends on the configuration options. The type of arguments which specify the path names are defined as <tt>TCHAR</tt>. It is an alias of <tt>char</tt> by default. The code set used to the path name string is ANSI/OEM specifid by <tt><a href="config.html#code_page">_CODE_PAGE</a></tt>. When <tt><a href="config.html#lfn_unicode">_LFN_UNICODE</a></tt> is set to 1, the type of the <tt>TCHAR</tt> is switched to <tt>WCHAR</tt> to support Unicode (UTF-16 encoding). In this case, the full-featured LFN specification is supported and the Unicode specific characters, such as ✝☪✡☸☭, can also be used for the path name. It also affects data types and encoding of the string I/O functions. To define literal strings, <tt>_T(s)</tt> and <tt>_TEXT(s)</tt> macro are available to select either ANSI/OEM or Unicode automatically. The code shown below is an example to define the literal strings.</p>
|
||||
<pre>
|
||||
f_open(fp, "filename.txt", FA_READ); <span class="c">/* ANSI/OEM string */</span>
|
||||
f_open(fp, L"filename.txt", FA_READ); <span class="c">/* Unicode string */</span>
|
||||
@ -57,25 +58,25 @@
|
||||
|
||||
<div class="para doc" id="vol">
|
||||
<h3>Volume Management</h3>
|
||||
<p>The FatFs module needs dynamic work area called <em>file system object</em> for each volume (logical drive). It is registered to the FatFs module by <tt>f_mount</tt> function. By default, each logical drive is bound to the physical drive with the same drive number and an FAT volume on the drive is serched by auto detect feature. It loads boot sectors and checks it if it is an FAT boot sector in order of sector 0 as SFD format, 1st partition, 2nd partition, 3rd partition and 4th partition as FDISK format.</p>
|
||||
<p>FatFs module needs dynamic work area, <em>file system object</em>, for each volume (logical drive). It is registered/unregistered to the FatFs module by <tt>f_mount</tt> function. By default, each logical drive is bound to the physical drive with the same drive number and an FAT volume on the drive is serched by the volume mount process. It reads boot sectors and checks it if it is an FAT boot sector in order of sector 0 as SFD format, 1st partition, 2nd partition, 3rd partition and 4th partition as FDISK format.</p>
|
||||
<p>When <tt><a href="config.html#multi_partition">_MULTI_PARTITION</a> == 1</tt> is specified by configuration option, each individual logical drive is bound to the partition on the physical drive specified by volume management table. The volume management table must be defined by user to resolve the relationship between logical drives and partitions. Following code is an example of a volume management table.</p>
|
||||
<pre>
|
||||
Example: Logical drive 0-2 are tied to three pri-partitions on the physical drive 0 (fixed disk)
|
||||
Logical drive 3 is tied to an FAT volume on the physical drive 1 (removable disk)
|
||||
Example: Logical drive 0-2 are tied to three pri-partitions on the physical drive 0 (fixed drive)
|
||||
Logical drive 3 is tied to an FAT volume on the physical drive 1 (removable drive)
|
||||
|
||||
PARTITION VolToPart[] = {
|
||||
{0, 1}, <span class="c">/* Logical drive 0 ==> Physical drive 0, 1st partition */</span>
|
||||
{0, 2}, <span class="c">/* Logical drive 1 ==> Physical drive 0, 2nd partition */</span>
|
||||
{0, 3}, <span class="c">/* Logical drive 2 ==> Physical drive 0, 3rd partition */</span>
|
||||
{1, 0} <span class="c">/* Logical drive 3 ==> Physical drive 1 (auto detection) */</span>
|
||||
{0, 1}, <span class="c">/* "0:" ==> Physical drive 0, 1st partition */</span>
|
||||
{0, 2}, <span class="c">/* "1:" ==> Physical drive 0, 2nd partition */</span>
|
||||
{0, 3}, <span class="c">/* "2:" ==> Physical drive 0, 3rd partition */</span>
|
||||
{1, 0} <span class="c">/* "3:" ==> Physical drive 1, auto detection */</span>
|
||||
};
|
||||
</pre>
|
||||
<div><img src="../img/f7.png" width="828" height="288" alt="relationship between logical drive and physical drive"></div>
|
||||
<div><img src="../res/f7.png" width="828" height="288" alt="relationship between logical drive and physical drive"></div>
|
||||
<p>There are some considerations on using multi-partition configuration.</p>
|
||||
<ul>
|
||||
<li>The physical drive that has two or more mounted partitions must be non-removable. Media change while a system operation is prohibited.</li>
|
||||
<li>Only four primary partitions can be specified. Extended partition is not supported.</li>
|
||||
<li>Windows does not support multiple volumes on the removable storage. Only first parition will be mounted.</li>
|
||||
<li>Windows does not support multiple volumes on the removable storage. Only first parition will be recognized.</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
|
@ -34,7 +34,7 @@ FRESULT f_findfirst (
|
||||
<dt>path</dt>
|
||||
<dd>Pointer to the null-terminated string that specifies the <a href="filename.html">directory name</a> to be opened.</dd>
|
||||
<dt>pattern</dt>
|
||||
<dd>Pointer to the null-terminated string that specifies the name matching pattern to be searched for. It is referred by also subsequent <tt>f_findnext</tt> function, so that the string must be valid while the successive function calls.</dd>
|
||||
<dd>Pointer to the nul-terminated string that specifies the name matching pattern to be searched for. It is referred by also subsequent <tt>f_findnext</tt> function, so that the string must be valid while the successive function calls.</dd>
|
||||
</dl>
|
||||
</div>
|
||||
|
||||
@ -61,11 +61,11 @@ FRESULT f_findfirst (
|
||||
|
||||
<div class="para desc">
|
||||
<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 item 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>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. At LFN configuration, both names of the item, SFN and LFN (if exist), are tested. In this revision, there are some differences listed below between FatFs and standard systems in matching condition.</p>
|
||||
<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>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>
|
||||
<li><tt>"*.*"</tt> never matches any name without extension. (It matches all names at the standard systems)</li>
|
||||
<li>Any pattern terminated with a period never matches any name. (It matches the names without extensiton at the standard systems)</li>
|
||||
<li><tt>"*.*"</tt> never matches any name without extension while it matches any names 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><a href="filename.html#case">DBCS extended characters</a> are compared in case-sensitive at LFN with non-Unicode configuration.</li>
|
||||
</ul>
|
||||
</div>
|
||||
@ -73,7 +73,7 @@ FRESULT f_findfirst (
|
||||
|
||||
<div class="para comp">
|
||||
<h4>QuickInfo</h4>
|
||||
<p>This is a wrapper function of <a href="opendir.html"><tt>f_opendir</tt></a> and <a href="readdir.html"><tt>f_readdir</tt></a> function. Available when <tt>_USE_FIND == 1</tt> and <tt>_FS_MINIMIZE <= 1</tt>.</p>
|
||||
<p>This is a wrapper function of <a href="opendir.html"><tt>f_opendir</tt></a> and <a href="readdir.html"><tt>f_readdir</tt></a> function. Available when <tt>_USE_FIND >= 1</tt> and <tt>_FS_MINIMIZE <= 1</tt>.</p>
|
||||
</div>
|
||||
|
||||
|
||||
@ -87,20 +87,11 @@ void find_image (void)
|
||||
FRESULT fr; <span class="c">/* Return value */</span>
|
||||
DIR dj; <span class="c">/* Directory search object */</span>
|
||||
FILINFO fno; <span class="c">/* File information */</span>
|
||||
<span class="k">#if</span> _USE_LFN
|
||||
char lfn[_MAX_LFN + 1];
|
||||
fno.lfname = lfn;
|
||||
fno.lfsize = _MAX_LFN + 1;
|
||||
<span class="k">#endif</span>
|
||||
|
||||
fr = f_findfirst(&dj, &fno, "", "dsc*.jpg"); <span class="c">/* Start to search for JPEG files with the name started by "dsc" */</span>
|
||||
fr = f_findfirst(&dj, &fno, "", "dsc*.jpg"); <span class="c">/* Start to search for photo files */</span>
|
||||
|
||||
while (fr == FR_OK && fno.fname[0]) { <span class="c">/* Repeat while an item is found */</span>
|
||||
<span class="k">#if</span> _USE_LFN
|
||||
printf("%-12s %s\n", fno.fname, fno.lfname);<span class="c">/* Display the item name */</span>
|
||||
<span class="k">#else</span>
|
||||
printf("%s\n", fno.fname);
|
||||
<span class="k">#endif</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>
|
||||
}
|
||||
f_closedir(&dj);
|
||||
|
@ -59,7 +59,7 @@ FRESULT f_forward (
|
||||
|
||||
<div class="para comp">
|
||||
<h4>QuickInfo</h4>
|
||||
<p>Available when <tt>_USE_FORWARD == 1</tt> and <tt>_FS_TINY == 1</tt>.</p>
|
||||
<p>Available when <tt>_USE_FORWARD == 1</tt>.</p>
|
||||
</div>
|
||||
|
||||
|
||||
@ -112,7 +112,7 @@ FRESULT play_file (
|
||||
if (rc) return rc;
|
||||
|
||||
<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>
|
||||
|
||||
|
@ -51,6 +51,7 @@ FRESULT f_getcwd (
|
||||
<div class="para desc">
|
||||
<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><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>
|
||||
</div>
|
||||
|
||||
|
||||
|
@ -29,7 +29,7 @@ FRESULT f_getlabel (
|
||||
<dt>path</dt>
|
||||
<dd>Pointer to the null-terminated string that specifies the <a href="filename.html">logical drive</a>. Null-string specifies the default drive.</dd>
|
||||
<dt>label</dt>
|
||||
<dd>Pointer to the buffer to store the volume label. The buffer size must be at least 12 items. If the volume has no label, a null-string will be returned. Set null pointer if this information is not needed.</dd>
|
||||
<dd>Pointer to the buffer to store the volume label. The buffer size must be at least 24 items at <tt>_LFN_UNICODE == 0</tt> or 12 items at <tt>_LFN_UNICODE == 1</tt>. If the volume has no label, a null-string will be returned. Set null pointer if this information is not needed.</dd>
|
||||
<dt>vsn</dt>
|
||||
<dd>Pointer to the <tt>DWORD</tt> variable to store the volume serial number. Set null pointer if this information is not needed.</dd>
|
||||
</dl>
|
||||
@ -60,7 +60,7 @@ FRESULT f_getlabel (
|
||||
<div class="para use">
|
||||
<h4>Example</h4>
|
||||
<pre>
|
||||
char str[12];
|
||||
char str[24];
|
||||
|
||||
<span class="c">/* Get volume label of the default drive */</span>
|
||||
f_getlabel("", str, 0);
|
||||
|
@ -17,8 +17,8 @@
|
||||
|
||||
<pre>
|
||||
FRESULT f_lseek (
|
||||
FIL* <span class="arg">fp</span>, <span class="c">/* [IN] File object */</span>
|
||||
DWORD <span class="arg">ofs</span> <span class="c">/* [IN] File read/write pointer */</span>
|
||||
FIL* <span class="arg">fp</span>, <span class="c">/* [IN] File object */</span>
|
||||
FSIZE_t <span class="arg">ofs</span> <span class="c">/* [IN] File read/write pointer */</span>
|
||||
);
|
||||
</pre>
|
||||
</div>
|
||||
@ -29,7 +29,7 @@ FRESULT f_lseek (
|
||||
<dt>fp</dt>
|
||||
<dd>Pointer to the open file object.</dd>
|
||||
<dt>ofs</dt>
|
||||
<dd>Byte offset from top of the file.</dd>
|
||||
<dd>Byte offset from top of the file. The data type <tt>FSIZE_t</tt> is an alias of either <tt>DWORD</tt>(32-bit) or <tt>QWORD</tt>(64-bit) depends on the configuration option <tt>_FS_EXFAT</tt>.</dd>
|
||||
</dl>
|
||||
</div>
|
||||
|
||||
@ -48,19 +48,19 @@ FRESULT f_lseek (
|
||||
|
||||
<div class="para desc">
|
||||
<h4>Description</h4>
|
||||
<p>The <tt>f_lseek</tt> function moves the file read/write pointer of an open file. The offset can be specified in only origin from top of the file. When an offset beyond the file size is specified at write mode, the file size is expanded to the specified offset. The file data in the expanded area is undefined because no data is written to the file. This is suitable to pre-allocate a cluster chain quickly, for fast write operation. After the <tt>f_lseek</tt> function succeeded, the current read/write pointer should be checked in order to make sure the read/write pointer has been moved correctry. In case of the current read/write pointer is not the expected value, either of followings has been occured.</p>
|
||||
<p>The <tt>f_lseek</tt> function moves the file read/write pointer of an open file. The offset can be specified in only origin from top of the file. When an offset beyond the file size is specified at write mode, the file size is expanded to the specified offset. The file data in the expanded area is <em>undefined</em> because no data is written to the file in this process. This is suitable to pre-allocate a cluster chain quickly, for fast write operation. When a contiguous data area needs to be allocated to the file, use <tt>f_expand</tt> function instead. After the <tt>f_lseek</tt> function succeeded, the current read/write pointer should be checked in order to make sure the read/write pointer has been moved correctry. In case of the read/write pointer is not the expected value, either of followings has been occured.</p>
|
||||
<ul>
|
||||
<li>End of file. The specified <tt class="arg">ofs</tt> was clipped at end of the file because the file has been opened in read-only mode.</li>
|
||||
<li>Disk full. There is insufficient free space on the volume to expand the file.</li>
|
||||
<li>Disk full. There is no free space on the volume to expand the file.</li>
|
||||
</ul>
|
||||
<p>The fast seek feature enables fast backward/long seek operations without FAT access by using an on-memory CLMT (cluster link map table). It is applied to <tt>f_read</tt> and <tt>f_write</tt> function as well, however, the file size cannot be expanded by <tt>f_write</tt>, <tt>f_lseek</tt> function while the file is in fast seek mode.</p>
|
||||
<p>The fast seek feature is enabled when the member <tt>cltbl</tt> in the file object is not NULL. The CLMT must be created into the <tt>DWORD</tt> array prior to use the fast seek feature. To create the CLMT, set address of the <tt>DWORD</tt> array to the member <tt>cltbl</tt> in the open file object, set the size of array in unit of items to the first item and call the <tt>f_lseek</tt> function with <tt class="arg">ofs</tt><tt> = CREATE_LINKMAP</tt>. After the function succeeded and CLMT is created, no FAT access is occured in subsequent <tt>f_read</tt>, <tt>f_write</tt>, <tt>f_lseek</tt> function to the file. The number of items used or required is returned into the first item of the array. The number of items to be used is (number of the file fragments + 1) * 2. For example, when the file is fragmented in 5, 12 items in the array will be used. If the function failed with <tt>FR_NOT_ENOUGH_CORE</tt>, the given array size is insufficient for the file.</p>
|
||||
<p>The fast seek function enables fast backward/long seek operations without FAT access by using an on-memory CLMT (cluster link map table). It is applied to <tt>f_read</tt> and <tt>f_write</tt> function as well, however, the file size cannot be expanded by <tt>f_write</tt>, <tt>f_lseek</tt> function while the file is in fast seek mode.</p>
|
||||
<p>The fast seek function is enabled when the member <tt>cltbl</tt> in the file object is not NULL. The CLMT must be created into the <tt>DWORD</tt> array prior to use the fast seek function. To create the CLMT, set address of the <tt>DWORD</tt> array to the member <tt>cltbl</tt> in the open file object, set the size of array in unit of items to the first item and call the <tt>f_lseek</tt> function with <tt class="arg">ofs</tt><tt> = CREATE_LINKMAP</tt>. After the function succeeded and CLMT is created, no FAT access is occured in subsequent <tt>f_read</tt>, <tt>f_write</tt>, <tt>f_lseek</tt> function to the file. The number of items used or required is returned into the first item of the array. The number of items to be used is (number of the file fragments + 1) * 2. For example, when the file is fragmented in 5, 12 items in the array will be used. If the function failed with <tt>FR_NOT_ENOUGH_CORE</tt>, the given array size is insufficient for the file.</p>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="para comp">
|
||||
<h4>QuickInfo</h4>
|
||||
<p>Available when <tt>_FS_MINIMIZE <= 2</tt>. To use fast seek feature, <tt>_USE_FASTSEEK</tt> needs to be set 1.</p>
|
||||
<p>Available when <tt>_FS_MINIMIZE <= 2</tt>. To use fast seek function, <tt>_USE_FASTSEEK</tt> needs to be set 1.</p>
|
||||
</div>
|
||||
|
||||
|
||||
@ -102,7 +102,7 @@ FRESULT f_lseek (
|
||||
res = f_close(fp);
|
||||
</pre>
|
||||
<pre>
|
||||
<span class="c">/* Using fast seek feature */</span>
|
||||
<span class="c">/* Using fast seek function */</span>
|
||||
|
||||
DWORD clmt[SZ_TBL]; <span class="c">/* Cluster link map table buffer */</span>
|
||||
|
||||
@ -110,7 +110,7 @@ FRESULT f_lseek (
|
||||
|
||||
res = f_lseek(fp, ofs1); <span class="c">/* This is normal seek (cltbl is nulled on file open) */</span>
|
||||
|
||||
fp->cltbl = clmt; <span class="c">/* Enable fast seek feature (cltbl != NULL) */</span>
|
||||
fp->cltbl = clmt; <span class="c">/* Enable fast seek function (cltbl != NULL) */</span>
|
||||
clmt[0] = SZ_TBL; <span class="c">/* Set table size */</span>
|
||||
res = f_lseek(fp, CREATE_LINKMAP); <span class="c">/* Create CLMT */</span>
|
||||
...
|
||||
@ -122,7 +122,7 @@ FRESULT f_lseek (
|
||||
|
||||
<div class="para ref">
|
||||
<h4>See Also</h4>
|
||||
<p><tt><a href="open.html">f_open</a>, <a href="truncate.html">f_truncate</a>, <a href="sfile.html">FIL</a></tt></p>
|
||||
<p><tt><a href="open.html">f_open</a>, <a href="truncate.html">f_truncate</a>, <a href="expand.html">f_expand</a>, <a href="sfile.html">FIL</a></tt></p>
|
||||
</div>
|
||||
|
||||
<p class="foot"><a href="../00index_e.html">Return</a></p>
|
||||
|
@ -13,12 +13,14 @@
|
||||
|
||||
<div class="para func">
|
||||
<h2>f_mkfs</h2>
|
||||
<p>The f_mkfs fucntion creates an FAT volume on the logical drive.</p>
|
||||
<p>The f_mkfs fucntion creates an FAT/exFAT volume on the logical drive.</p>
|
||||
<pre>
|
||||
FRESULT f_mkfs (
|
||||
const TCHAR* <span class="arg">path</span>, <span class="c">/* [IN] Logical drive number */</span>
|
||||
BYTE <span class="arg">sfd</span>, <span class="c">/* [IN] Partitioning rule */</span>
|
||||
UINT <span class="arg">au</span> <span class="c">/* [IN] Size of the allocation unit */</span>
|
||||
BYTE <span class="arg">opt</span>, <span class="c">/* [IN] Format options */</span>
|
||||
DWORD <span class="arg">au</span>, <span class="c">/* [IN] Size of the allocation unit */</span>
|
||||
void* <span class="arg">work</span>, <span class="c">/* [-] Working buffer */</span>
|
||||
UINT <span class="arg">len</span> <span class="c">/* [IN] Size of working buffer */</span>
|
||||
);
|
||||
</pre>
|
||||
</div>
|
||||
@ -27,11 +29,15 @@ FRESULT f_mkfs (
|
||||
<h4>Parameters</h4>
|
||||
<dl class="par">
|
||||
<dt>path</dt>
|
||||
<dd>Pointer to the null-terminated string that specifies the <a href="filename.html">logical drive</a> to be formatted. If there is no drive number, it means the default drive.</dd>
|
||||
<dt>sfd</dt>
|
||||
<dd>Specifies partitioning rule (FDISK(0) or SFD(1)). This argument will be ignored on some case.</dd>
|
||||
<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>
|
||||
<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>
|
||||
<dt>au</dt>
|
||||
<dd>Specifies size of the allocation unit (cluter) in number of bytes or sectors. When the value is from 1 to 128, it specifies number of sectors. When the value is <tt>>= _MIN_SS</tt>, it specifies number of bytes. If any invalid value, zero or not power of 2, is given, the cluster size is automatically determined depends on the volume size.</dd>
|
||||
<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>
|
||||
<dt>work</dt>
|
||||
<dd>Pointer to the working buffer for the format process.</dd>
|
||||
<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>
|
||||
</dl>
|
||||
</div>
|
||||
|
||||
@ -43,7 +49,6 @@ FRESULT f_mkfs (
|
||||
<a href="rc.html#nr">FR_NOT_READY</a>,
|
||||
<a href="rc.html#wp">FR_WRITE_PROTECTED</a>,
|
||||
<a href="rc.html#id">FR_INVALID_DRIVE</a>,
|
||||
<a href="rc.html#ne">FR_NOT_ENABLED</a>,
|
||||
<a href="rc.html#ma">FR_MKFS_ABORTED</a>,
|
||||
<a href="rc.html#ip">FR_INVALID_PARAMETER</a>
|
||||
</p>
|
||||
@ -51,11 +56,11 @@ FRESULT f_mkfs (
|
||||
|
||||
<div class="para desc">
|
||||
<h4>Description</h4>
|
||||
<p>The <tt>f_mkfs</tt> function creates an FAT volume on the specified logical drive. When FDISK format is specified, a primary partition occupies entire space of the physical drive is created and then an FAT volume is created on the partition. When SFD format is specified, the FAT volume starts from the first sector of the physical drive.</p>
|
||||
<p>If the logical drive is bound to the specific partition (1-4) by multiple partition feature (<tt><a href="config.html#multi_partition">_MULTI_PARTITION</a></tt>), the FAT volume is created into the partition. In this case, the second argument <tt class="arg">sfd</tt> is ignored. The physical drive must have been partitioned with <tt>f_fdisk</tt> function or any other partitioning tools prior to create the FAT volume with this function.</p>
|
||||
<p>Note that there are two partitioning rules, FDISK and SFD. The FDISK partitioning is usually used for harddisk, MMC, SDC, CFC and U Disk. It can divide a physical drive into one or more partitions with a partition table on the MBR. However Windows does not support multiple partition on the removable disk. The SFD is non-partitioned method. The FAT volume starts from the first sector on the physical drive without partition table. It is usually used for floppy disk, Microdrive, optical disk and any type of super-floppy media.</p>
|
||||
<p>The FAT sub-type, FAT12/FAT16/FAT32, is determined by number of clusters on the volume and nothing else, according to the FAT specification issued by Microsoft. Thus which FAT sub-type is selected, is depends on the volume size and the specified cluster size. The cluster size affects read/write throughput and space usage efficiency. Larger cluster size increases the read/write throughput and decreases the space usage efficiency of the volume.</p>
|
||||
<p>In case of the number of clusters gets near the FAT sub-type boundaries, the function can fail with <tt>FR_MKFS_ABORTED</tt>.</p>
|
||||
<p>The FAT sub-type, FAT12/FAT16/FAT32, of FAT volume except exFAT is determined by only number of clusters on the volume and nothing else, according to the FAT specification issued by Microsoft. Thus which FAT sub-type is selected, is depends on the volume size and the specified cluster size. In case of the combination of FAT type and cluter size specified by argument cannot be valid on the volume, the function will fail with <tt>FR_MKFS_ABORTED</tt>.</p>
|
||||
<p>The allocation unit, also called 'cluster', is a unit of disk space allocation for files. When the size of allocation unit is 32768 bytes, a file with 100 bytes in size occupies 32768 bytes of disk space. The space efficiency of disk usage gets worse as increasing size of allocation unit, but, on the other hand, the read/write performance increases as the size of allocation unit. Therefore the allocation unit is a trade-off between space efficiency and performance. For the large storages in GB order, 32768 bytes or larger cluster (this is automatically selected by default) is recommended for most case unless extremely many files are created on a volume.</p>
|
||||
<p>There are two disk formats, FDISK and SFD. The FDISK format is usually used for harddisk, MMC, SDC, CFC and U Disk. It can divide a physical drive into one or more partitions with a partition table on the MBR (maser boot record, the first sector of the physical drive). The SFD (super-floppy disk) is non-partitioned disk format. The FAT volume starts at the first sector of the physical drive without any disk partitioning. It is usually used for floppy disk, Microdrive, optical disk and most type of super-floppy media. Some systems support only either one of two formats and other is not supported.</p>
|
||||
<p>When <tt>FM_SFD</tt> is not specified, a primary partition occupies whole drive space is created and then the FAT volume is created in it. When <tt>FM_SFD</tt> is specified, the FAT volume occupies from the first sector of the drive is created.</p>
|
||||
<p>If the logical drive to be formatted is bound to the specific partition (1-4) by support of multiple partition, <tt><a href="config.html#multi_partition">_MULTI_PARTITION</a></tt>, the FAT volume is created into the partition and <tt>FM_SFD</tt> flag is ignored. The physical drive needs to be partitioned with <tt>f_fdisk</tt> function or any other partitioning tools prior to create the FAT volume with this function.</p>
|
||||
</div>
|
||||
|
||||
<div class="para comp">
|
||||
@ -69,19 +74,20 @@ FRESULT f_mkfs (
|
||||
<span class="c">/* Format default drive and create a file */</span>
|
||||
int main (void)
|
||||
{
|
||||
FATFS fs; <span class="c">/* File system object (volume work area) */</span>
|
||||
FIL fil; <span class="c">/* File object */</span>
|
||||
FRESULT res; <span class="c">/* API result code */</span>
|
||||
UINT bw; <span class="c">/* Bytes written */</span>
|
||||
FATFS fs; <span class="c">/* File system object */</span>
|
||||
FIL fil; <span class="c">/* File object */</span>
|
||||
FRESULT res; <span class="c">/* API result code */</span>
|
||||
UINT bw; <span class="c">/* Bytes written */</span>
|
||||
BYTE work[_MAX_SS]; <span class="c">/* Work area (larger is better for process time) */</span>
|
||||
|
||||
|
||||
<span class="c">/* Register work area (do not care about error) */</span>
|
||||
f_mount(&fs, "", 0);
|
||||
|
||||
<span class="c">/* Create FAT volume with default cluster size */</span>
|
||||
res = f_mkfs("", 0, 0);
|
||||
<span class="c">/* Create FAT volume */</span>
|
||||
res = f_mkfs("", FM_ANY, 0, work, sizeof work);
|
||||
if (res) ...
|
||||
|
||||
<span class="c">/* Register work area */</span>
|
||||
f_mount(&fs, "", 0);
|
||||
|
||||
<span class="c">/* Create a file as new */</span>
|
||||
res = f_open(&fil, "hello.txt", FA_CREATE_NEW | FA_WRITE);
|
||||
if (res) ...
|
||||
@ -95,12 +101,14 @@ int main (void)
|
||||
|
||||
<span class="c">/* Unregister work area */</span>
|
||||
f_mount(0, "", 0);
|
||||
|
||||
...
|
||||
</pre>
|
||||
</div>
|
||||
|
||||
<div class="para ref">
|
||||
<h4>See Also</h4>
|
||||
<p><tt><a href="filename.html#vol">Volume management</a>, <a href="fdisk.html">f_fdisk</a></tt></p>
|
||||
<p><a href="../res/mkfs.xls">Example of volume size and format parameters</a>, <a href="filename.html#vol">Volume management</a>, <tt><a href="fdisk.html">f_fdisk</a></tt></p>
|
||||
</div>
|
||||
|
||||
<p class="foot"><a href="../00index_e.html">Return</a></p>
|
||||
|
@ -31,7 +31,7 @@ FRESULT f_mount (
|
||||
<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>
|
||||
<dt>opt</dt>
|
||||
<dd>Initialization option. 0: Do not mount now (to be mounted later), 1: Force mounted the volume to check if the FAT volume is ready to work.</dd>
|
||||
<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>
|
||||
</dl>
|
||||
</div>
|
||||
|
||||
@ -49,15 +49,15 @@ FRESULT f_mount (
|
||||
|
||||
<div class="para desc">
|
||||
<h4>Description</h4>
|
||||
<p>The <tt>f_mount</tt> function registers/unregisters a file system object used for the logical drive to the FatFs module as follows:</p>
|
||||
<p>The <tt>f_mount</tt> function registers/unregisters a file system object used for the volume (logical drive) to the FatFs module as follows:</p>
|
||||
<ol>
|
||||
<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.</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>Performs volume mount process to the drive if forced mount is specified.</li>
|
||||
</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>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. 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, 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>
|
||||
<ul>
|
||||
<li>File system object is not 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>
|
||||
|
@ -33,14 +33,14 @@ FRESULT f_open (
|
||||
<dt>mode</dt>
|
||||
<dd>Mode flags that specifies the type of access and open method for the file. It is specified by a combination of following flags.<br>
|
||||
<table class="lst">
|
||||
<tr><th>Value</th><th>Description</th></tr>
|
||||
<tr><th>Value</th><th>Meaning</th></tr>
|
||||
<tr><td>FA_READ</td><td>Specifies read access to the object. Data can be read from the file.</tr>
|
||||
<tr><td>FA_WRITE</td><td>Specifies write access to the object. Data can be written to the file. Combine with <tt>FA_READ</tt> for read-write access.</td></tr>
|
||||
<tr><td>FA_OPEN_EXISTING</td><td>Opens the file. The function fails if the file is not existing. (Default)</td></tr>
|
||||
<tr><td>FA_OPEN_ALWAYS</td><td>Opens the file if it is existing. If not, a new file will be created.<br>
|
||||
To append data to the file, use <a href="lseek.html"><tt>f_lseek</tt></a> function after the file open in this method.</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_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>
|
||||
</table>
|
||||
</dd>
|
||||
</dl>
|
||||
@ -74,7 +74,7 @@ To append data to the file, use <a href="lseek.html"><tt>f_lseek</tt></a> functi
|
||||
|
||||
<div class="para desc">
|
||||
<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 <a href="fdisk.html"><tt>f_fdisk</tt></a> function can work after this procedure.</p>
|
||||
<p>Before using any file function, a work area (file system object) must be registered to the logical drive with <a href="mount.html"><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>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>
|
||||
</div>
|
||||
@ -82,7 +82,7 @@ To append data to the file, use <a href="lseek.html"><tt>f_lseek</tt></a> functi
|
||||
|
||||
<div class="para comp">
|
||||
<h4>QuickInfo</h4>
|
||||
<p>Always available. The mode flags, <tt>FA_WRITE, FA_CREATE_ALWAYS, FA_CREATE_NEW and FA_OPEN_ALWAYS</tt>, are not available when <tt>_FS_READONLY == 1</tt>.</p>
|
||||
<p>Always available. Only <tt>FA_READ</tt> and <tt>FA_OPEN_EXISTING</tt> are supported when <tt>_FS_READONLY == 1</tt>.</p>
|
||||
</div>
|
||||
|
||||
|
||||
|
@ -14,10 +14,13 @@
|
||||
<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>
|
||||
|
||||
<dl class="ret">
|
||||
|
||||
<dt id="ok">FR_OK (0)</dt>
|
||||
<dd>The function succeeded.</dd>
|
||||
|
||||
<dt id="de">FR_DISK_ERR</dt>
|
||||
<dd>An unrecoverable hard error occured in the lower layer, <tt>disk_read</tt>, <tt>disk_write</tt> or <tt>disk_ioctl</tt> function.<br>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>
|
||||
|
||||
<dt id="ie">FR_INT_ERR</dt>
|
||||
<dd>Assertion failed. An insanity is detected in the internal process. One of the following possibilities is suspected.
|
||||
<ul>
|
||||
@ -26,14 +29,19 @@
|
||||
</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.
|
||||
</dd>
|
||||
|
||||
<dt id="nr">FR_NOT_READY</dt>
|
||||
<dd>The storage device cannot work due to a failure of <a href="dinit.html"><tt>disk_initialize</tt></a> function due to no medium or any other reason.</dd>
|
||||
|
||||
<dt id="nf">FR_NO_FILE</dt>
|
||||
<dd>Could not find the file.</dd>
|
||||
|
||||
<dt id="np">FR_NO_PATH</dt>
|
||||
<dd>Could not find the path.</dd>
|
||||
|
||||
<dt id="in">FR_INVALID_NAME</dt>
|
||||
<dd>The given string is invalid as the <a href="filename.html">path name</a>.</dd>
|
||||
|
||||
<dt id="dn">FR_DENIED</dt>
|
||||
<dd>The required access was denied due to one of the following reasons:
|
||||
<ul>
|
||||
@ -43,11 +51,13 @@ Note that if once this error occured at any operation to an open file, the file
|
||||
<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>Could not create the file or directory due to the directory table is full.</li>
|
||||
<li>Could not create the directory due to the volume is full.</li>
|
||||
<li>Could not allocate a contiguous area to the file.</li>
|
||||
</ul>
|
||||
</dd>
|
||||
|
||||
<dt id="ex">FR_EXIST</dt>
|
||||
<dd>Name collision. Any object that has the same name is already existing.</dd>
|
||||
|
||||
<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:
|
||||
<ul>
|
||||
@ -56,26 +66,35 @@ Note that if once this error occured at any operation to an open file, the file
|
||||
<li>The corresponding physical drive is not ready due to a media removal.</li>
|
||||
</ul>
|
||||
</dd>
|
||||
|
||||
<dt id="wp">FR_WRITE_PROTECTED</dt>
|
||||
<dd>Any write mode operation against the write-protected media.</dd>
|
||||
|
||||
<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>
|
||||
|
||||
<dt id="ne">FR_NOT_ENABLED</dt>
|
||||
<dd>Work area for the logical drive has not been registered by <tt>f_mount</tt> function.</dd>
|
||||
|
||||
<dt id="ns">FR_NO_FILESYSTEM</dt>
|
||||
<dd>There is no valid FAT volume on the drive.</dd>
|
||||
|
||||
<dt id="ma">FR_MKFS_ABORTED</dt>
|
||||
<dd>The <tt>f_mkfs</tt> function aborted before start in format due to a reason as follows:
|
||||
<ul>
|
||||
<li>The disk/partition size is too small.</li>
|
||||
<li>Not allowable cluster size for this disk. This can occure when number of clusters gets near the boundaries of FAT sub-types.</li>
|
||||
<li>There is no partition related to the logical drive. (Related option: <tt><a href="config.html#multi_partition">_MULTI_PARTITION</a></tt>)</li>
|
||||
<li>It is pmpossible to formart with the given parameters.</li>
|
||||
<li>The size of volume is too small.</li>
|
||||
<li>The size of given work area is too small.</li>
|
||||
<li>The partition bound to the logical drive coulud not be found. (Related option: <tt><a href="config.html#multi_partition">_MULTI_PARTITION</a></tt>)</li>
|
||||
</ul>
|
||||
</dd>
|
||||
|
||||
<dt id="tm">FR_TIMEOUT</dt>
|
||||
<dd>The function was canceled due to a timeout of <a href="appnote.html#reentrant">thread-safe control</a>. (Related option: <tt><a href="config.html#timeout">_TIMEOUT</a></tt>)</dd>
|
||||
|
||||
<dt id="lo">FR_LOCKED</dt>
|
||||
<dd>The operation to the object was rejected by <a href="appnote.html#dup">file sharing control</a>. (Related option: <tt><a href="config.html#fs_lock">_FS_LOCK</a></tt>)</dd>
|
||||
|
||||
<dt id="nc">FR_NOT_ENOUGH_CORE</dt>
|
||||
<dd>Not enough memory for the operation. There is one of the following reasons:
|
||||
<ul>
|
||||
@ -83,8 +102,10 @@ Note that if once this error occured at any operation to an open file, the file
|
||||
<li>Size of the given buffer is insufficient for the size required.</li>
|
||||
</ul>
|
||||
</dd>
|
||||
|
||||
<dt id="tf">FR_TOO_MANY_OPEN_FILES</dt>
|
||||
<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>
|
||||
<dd>The given parameter is invalid or there is any inconsistent.</dd>
|
||||
</dl>
|
||||
|
@ -34,7 +34,7 @@ FRESULT f_read (
|
||||
<dt>btr</dt>
|
||||
<dd>Number of bytes to read in range of <tt>UINT</tt> type.</dd>
|
||||
<dt>br</dt>
|
||||
<dd>Pointer to the <tt>UINT</tt> variable to return number of bytes read. The value is always valid after the function call regardless of the result.</dd>
|
||||
<dd>Pointer to the <tt>UINT</tt> variable to return number of bytes read. The value is always valid after the function call regardless of the result code.</dd>
|
||||
</dl>
|
||||
</div>
|
||||
|
||||
@ -53,7 +53,7 @@ FRESULT f_read (
|
||||
|
||||
<div class="para desc">
|
||||
<h4>Description</h4>
|
||||
<p>The file read/write pointer of the file object advances 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> is less than <tt class="arg">btr</tt>, it means the read/write pointer reached end of the file during read operation.</p>
|
||||
</div>
|
||||
|
||||
|
||||
|
@ -13,7 +13,7 @@
|
||||
|
||||
<div class="para func">
|
||||
<h2>f_readdir</h2>
|
||||
<p>The f_readdir function reads directory entries.</p>
|
||||
<p>The f_readdir function reads an item of the directory.</p>
|
||||
<pre>
|
||||
FRESULT f_readdir (
|
||||
DIR* <span class="arg">dp</span>, <span class="c">/* [IN] Directory object */</span>
|
||||
@ -26,9 +26,9 @@ FRESULT f_readdir (
|
||||
<h4>Parameters</h4>
|
||||
<dl class="par">
|
||||
<dt>dp</dt>
|
||||
<dd>Pointer to the directory object created by <tt>f_opendir</tt> function.</dd>
|
||||
<dd>Pointer to the open directory object or null pointer.</dd>
|
||||
<dt>fno</dt>
|
||||
<dd>Pointer to the file information structure to store the information about read item.</dd>
|
||||
<dd>Pointer to the <a href="sfileinfo.html">file information structure</a> to store the information about read item.</dd>
|
||||
</dl>
|
||||
</div>
|
||||
|
||||
@ -48,13 +48,14 @@ FRESULT f_readdir (
|
||||
|
||||
<div class="para desc">
|
||||
<h4>Description</h4>
|
||||
<p>The <tt>f_readdir</tt> function reads directory items, informations about file and directory, in sequence. All items in the directory can be read by calling <tt>f_readdir</tt> function repeatedly. When relative path feature is enabled (<tt><a href="config.html#fs_rpath">_FS_RPATH</a> >= 1</tt>), dot entries (<tt>"."</tt> and <tt>".."</tt>) are not filtered out and they will appear in the read items. When all directory items have been read and no item to read, a null string is stored into the <tt>fno->fname[]</tt> without any error. When a null pointer is given to the <tt class="arg">fno</tt>, the read index of the directory object is rewinded.</p>
|
||||
<p>When LFN feature is enabled, <tt>fno->lfname</tt> and <tt>fno->lfsize</tt> in the file information structure must be initialized with valid value prior to use it. The <tt>lfname</tt> points the LFN read buffer. The <tt>lfsize</tt> is size of the LFN read buffer in unit of <tt>TCHAR</tt>. If the LFN is not needed, set a null pointer to the <tt>lfname</tt> and the LFN is not returned. A null string will be returned into the LFN read buffer in case of following conditions.</p>
|
||||
<p>The <tt>f_readdir</tt> function reads a directory item, informations about the object. All items in the directory can be read in sequence by <tt>f_readdir</tt> function calls. Dot entries (<tt>"."</tt> and <tt>".."</tt>) in the sub-directory are filtered out and they will never appear in the read items. When all directory items have been read and no item to read, a nul string is stored into the <tt>fno->fname[]</tt> without any error. When a null pointer is given to the <tt class="arg">fno</tt>, the read index of the directory object is rewinded.</p>
|
||||
<p>When support of long file name (LFN) is enabled, a member <tt>altname[]</tt> is defined in the file information structure to store the short file name of the object. In case of the some conditions listed below, short file name is stored into the <tt>fname[]</tt> and <tt>altname[]</tt> has a null string.</p>
|
||||
<ul>
|
||||
<li>The directory item has no LFN information. In this case, lower case characters can be contained in the <tt>fname[]</tt>.</li>
|
||||
<li>Either the size of read buffer or LFN working buffer is insufficient for the LFN.</li>
|
||||
<li>The LFN contains any Unicode character that cannot be converted to OEM code. (Not the case at Unicode API configuration)</li>
|
||||
<li>The item has no long file name. (Not the case at exFAT volume)</li>
|
||||
<li>Setting of <tt>_MAX_LFN</tt> is insufficient for the long file name. (Not the case at <tt>_MAX_LFN == 255</tt>)</li>
|
||||
<li>The long file name contains any character not allowed in ANSI/OEM code. (Not the case at <tt>_LFN_UNICODE == 1</tt>)</li>
|
||||
</ul>
|
||||
<p>There is a problem on reading a directory of exFAT volume. The exFAT does not support short file name. This means no name can be returned on the condition above. If it is the case, a "?" is returned as file name to indicate that the object is not accessible. To avoid this problem, configure FatFs <tt>_LFN_UNICODE = 1</tt> and <tt>_MAX_LFN = 255</tt> to support the full feature of LFN specification.</p>
|
||||
</div>
|
||||
|
||||
|
||||
@ -68,40 +69,28 @@ FRESULT f_readdir (
|
||||
<h4>Sample Code</h4>
|
||||
<pre>
|
||||
FRESULT scan_files (
|
||||
char* path <span class="c">/* Start node to be scanned (also used as work area) */</span>
|
||||
char* path <span class="c">/* Start node to be scanned (***also used as work area***) */</span>
|
||||
)
|
||||
{
|
||||
FRESULT res;
|
||||
FILINFO fno;
|
||||
DIR dir;
|
||||
int i;
|
||||
char *fn; <span class="c">/* This function assumes non-Unicode configuration */</span>
|
||||
<span class="k">#if</span> _USE_LFN
|
||||
static char lfn[_MAX_LFN + 1]; <span class="c">/* Buffer to store the LFN */</span>
|
||||
fno.lfname = lfn;
|
||||
fno.lfsize = sizeof lfn;
|
||||
<span class="k">#endif</span>
|
||||
UINT i;
|
||||
static FILINFO fno;
|
||||
|
||||
|
||||
res = f_opendir(&dir, path); <span class="c">/* Open the directory */</span>
|
||||
if (res == FR_OK) {
|
||||
i = strlen(path);
|
||||
for (;;) {
|
||||
res = f_readdir(&dir, &fno); <span class="c">/* Read a directory item */</span>
|
||||
if (res != FR_OK || fno.fname[0] == 0) break; <span class="c">/* Break on error or end of dir */</span>
|
||||
if (fno.fname[0] == '.') continue; <span class="c">/* Ignore dot entry */</span>
|
||||
<span class="k">#if</span> _USE_LFN
|
||||
fn = *fno.lfname ? fno.lfname : fno.fname;
|
||||
<span class="k">#else</span>
|
||||
fn = fno.fname;
|
||||
<span class="k">#endif</span>
|
||||
if (fno.fattrib & AM_DIR) { <span class="c">/* It is a directory */</span>
|
||||
sprintf(&path[i], "/%s", fn);
|
||||
res = scan_files(path);
|
||||
path[i] = 0;
|
||||
i = strlen(path);
|
||||
sprintf(&path[i], "/%s", fno.fname);
|
||||
res = scan_files(path); <span class="c">/* Enter the directory */</span>
|
||||
if (res != FR_OK) break;
|
||||
path[i] = 0;
|
||||
} else { <span class="c">/* It is a file. */</span>
|
||||
printf("%s/%s\n", path, fn);
|
||||
printf("%s/%s\n", path, fno.fname);
|
||||
}
|
||||
}
|
||||
f_closedir(&dir)
|
||||
@ -109,6 +98,23 @@ FRESULT scan_files (
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
int main (void)
|
||||
{
|
||||
FATFS fs;
|
||||
FRESULT res;
|
||||
char buff[256];
|
||||
|
||||
|
||||
res = f_mount(&fs, "", 1);
|
||||
if (res == FR_OK) {
|
||||
strcpy(buff, "/");
|
||||
res = scan_files(buff);
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
</pre>
|
||||
</div>
|
||||
|
||||
|
@ -16,20 +16,15 @@
|
||||
<p>The <tt>DIR</tt> structure is used for the work area to read a directory by <tt>f_oepndir</tt>, <tt>f_readdir</tt>, <tt>f_findfirst</tt> and <tt>f_findnext</tt> function. Application program must not modify any member in this structure, or any data on the FAT volume can be collapsed.</p>
|
||||
<pre>
|
||||
<span class="k">typedef</span> <span class="k">struct</span> {
|
||||
FATFS* fs; <span class="c">/* Pointer to the owner file system object */</span>
|
||||
WORD id; <span class="c">/* Owner file system mount ID */</span>
|
||||
WORD index; <span class="c">/* Index of directory entry to start to search next */</span>
|
||||
DWORD sclust; <span class="c">/* Table start cluster (0:Root directory) */</span>
|
||||
_FDID obj; <span class="c">/* Owner file sytem object and object identifier */</span>
|
||||
DWORD dptr; <span class="c">/* Current read/write offset */</span>
|
||||
DWORD clust; <span class="c">/* Current cluster */</span>
|
||||
DWORD sect; <span class="c">/* Current sector */</span>
|
||||
BYTE* dir; <span class="c">/* Pointer to the current SFN entry in the win[] */</span>
|
||||
BYTE* fn; <span class="c">/* Pointer to the SFN buffer (in/out) {file[8],ext[3],status[1]} */</span>
|
||||
<span class="k">#if</span> _FS_LOCK
|
||||
UINT lockid; <span class="c">/* Sub-directory lock ID (0:Root directory) */</span>
|
||||
<span class="k">#endif</span>
|
||||
<span class="k">#if</span> _USE_LFN
|
||||
WCHAR* lfn; <span class="c">/* Pointer to the LFN buffer (in/out) */</span>
|
||||
WORD lfn_idx; <span class="c">/* Index of the LFN entris (0xFFFF:No LFN) */</span>
|
||||
DWORD blk_ofs; <span class="c">/* Offset of the entry block (0xFFFFFFFF:Invalid) */</span>
|
||||
WCHAR* lfn; <span class="c">/* Pointer to the LFN working buffer (in/out) */</span>
|
||||
<span class="k">#endif</span>
|
||||
<span class="k">#if</span> _USE_FIND
|
||||
const TCHAR* pat; <span class="c">/* Ponter to the matching pattern */</span>
|
||||
|
@ -49,13 +49,14 @@ FRESULT f_setlabel (
|
||||
|
||||
<div class="para desc">
|
||||
<h4>Description</h4>
|
||||
<p>When the string has a drive number, the volume label will be set to the volume specified by the drive number. If not, the volume label will be set to the default drive. If length of the given volume label is zero, the volume label on the volume will be removed. The format of the volume label is similar to the short file name but there are some differences shown below:</p>
|
||||
<p>When the string has a drive number, the volume label will be set to the volume specified by the drive number. If not, the volume label will be set to the default drive. If length of the given volume label is zero, the volume label on the volume will be removed. The format of the volume label on the FAT volume is similar to the file name but there are some differences shown below:</p>
|
||||
<ul>
|
||||
<li>11 bytes or less in length as conversion into OEM code page. LFN feature is not applied to the volume label.</li>
|
||||
<li>Cannot contain period.</li>
|
||||
<li>Can contain spaces anywhere in it. Trailing spaces are truncated off.</li>
|
||||
<li>Spaces can be contained anywhere in the volume label. Trailing spaces are truncated off at FAT volume.</li>
|
||||
<li>Period is not allowed.</li>
|
||||
<li>Up to 11 bytes long as conversion of OEM code page at FAT volume.</li>
|
||||
<li>Up to 11 characters long at exFAT volume. Case information is preserved.</li>
|
||||
</ul>
|
||||
<p>Remark: The standard system (Windows) has a problem on handling of the volume label with a heading <tt>\xE5</tt>. To avoid this problem, this function rejects such volume labels as invalid name.</p>
|
||||
<p>Remark: The standard system (Windows) has a problem at handling of the volume label with a heading <tt>\xE5</tt> on the FAT volume. To avoid this problem, this function rejects such volume label as invalid name.</p>
|
||||
</div>
|
||||
|
||||
<div class="para comp">
|
||||
|
@ -16,17 +16,20 @@
|
||||
<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>
|
||||
<pre>
|
||||
<span class="k">typedef</span> <span class="k">struct</span> {
|
||||
BYTE fs_type; <span class="c">/* FAT sub-type (0:Not mounted, FS_FAT12/FS_FAT16/FS_FAT32) */</span>
|
||||
BYTE fs_type; <span class="c">/* File system type (0, FS_FAT12, FS_FAT16, FS_FAT32 or FS_EXFAT) */</span>
|
||||
BYTE drv; <span class="c">/* Physical drive number */</span>
|
||||
BYTE csize; <span class="c">/* Sectors per cluster (1,2,4,...,128) */</span>
|
||||
BYTE n_fats; <span class="c">/* Number of FAT copies (1,2) */</span>
|
||||
BYTE wflag; <span class="c">/* win[] flag (b0:win[] is dirty) */</span>
|
||||
BYTE fsi_flag; <span class="c">/* FSINFO flags (b7:Disabled, b0:Dirty) */</span>
|
||||
WORD id; <span class="c">/* File system mount ID */</span>
|
||||
WORD n_rootdir; <span class="c">/* Number of root directory entries (FAT12/16) */</span>
|
||||
WORD csize; <span class="c">/* Sectors per cluster */</span>
|
||||
<span class="k">#if</span> _MAX_SS != _MIN_SS
|
||||
WORD ssize; <span class="c">/* Sector size (512,1024,2048 or 4096) */</span>
|
||||
<span class="k">#endif</span>
|
||||
<span class="k">#if _FS_EXFAT</span>
|
||||
BYTE* dirbuf; <span class="c">/* Directory entry block scratchpad buffer */</span>
|
||||
<span class="k">#endif</span>
|
||||
<span class="k">#if</span> _FS_REENTRANT
|
||||
_SYNC_t sobj; <span class="c">/* Identifier of sync object */</span>
|
||||
<span class="k">#endif</span>
|
||||
@ -36,6 +39,11 @@
|
||||
<span class="k">#endif</span>
|
||||
<span class="k">#if</span> _FS_RPATH
|
||||
DWORD cdir; <span class="c">/* Cluster number of current directory (0:root) */</span>
|
||||
<span class="k">#if _FS_EXFAT</span>
|
||||
DWORD cdc_scl; <span class="c">/* Containing directory start cluster (invalid when cdir is 0) */</span>
|
||||
DWORD cdc_size; <span class="c">/* b31-b8:Size of containing directory, b7-b0: Chain status */</span>
|
||||
DWORD cdc_ofs; <span class="c">/* Offset in the containing directory (invalid when cdir is 0) */</span>
|
||||
<span class="k">#endif</span>
|
||||
<span class="k">#endif</span>
|
||||
DWORD n_fatent; <span class="c">/* Number of FAT entries (Number of clusters + 2) */</span>
|
||||
DWORD fsize; <span class="c">/* Sectors per FAT */</span>
|
||||
|
@ -17,15 +17,12 @@
|
||||
|
||||
<pre>
|
||||
<span class="k">typedef</span> <span class="k">struct</span> {
|
||||
FATFS* fs; <span class="c">/* Pointer to the owner file system object */</span>
|
||||
WORD id; <span class="c">/* Owner file system mount ID */</span>
|
||||
_FDID obj; <span class="c">/* Owner file sytem object and object identifier */</span>
|
||||
BYTE flag; <span class="c">/* File object status flags */</span>
|
||||
BYTE err; <span class="c">/* Abort flag (error code) */</span>
|
||||
DWORD fptr; <span class="c">/* File read/write pointer (Byte offset origin from top of the file) */</span>
|
||||
DWORD fsize; <span class="c">/* File size in unit of byte */</span>
|
||||
DWORD sclust; <span class="c">/* File start cluster */</span>
|
||||
FSIZE_t fptr; <span class="c">/* File read/write pointer (Byte offset origin from top of the file) */</span>
|
||||
DWORD clust; <span class="c">/* Current cluster of fptr (One cluster behind if fptr is on the cluster boundary. Invalid if fptr == 0.) */</span>
|
||||
DWORD dsect; <span class="c">/* Current data sector (Can be invalid if fptr is on the cluster boundary.)*/</span>
|
||||
DWORD sect; <span class="c">/* Current data sector (Can be invalid if fptr is on the cluster boundary.)*/</span>
|
||||
<span class="k">#if</span> !_FS_READONLY
|
||||
DWORD dir_sect; <span class="c">/* Sector number containing the directory entry */</span>
|
||||
BYTE* dir_ptr; <span class="c">/* Ponter to the directory entry in the window */</span>
|
||||
@ -33,9 +30,6 @@
|
||||
<span class="k">#if</span> _USE_FASTSEEK
|
||||
DWORD* cltbl; <span class="c">/* Pointer to the cluster link map table (Nulled on file open. Set by application.) */</span>
|
||||
<span class="k">#endif</span>
|
||||
<span class="k">#if</span> _FS_LOCK
|
||||
UINT lockid; <span class="c">/* Fle lock ID */</span>
|
||||
<span class="k">#endif</span>
|
||||
<span class="k">#if</span> !_FS_TINY
|
||||
BYTE buf[_MAX_SS]; <span class="c">/* File private data transfer buffer (Always valid if fptr is not on the sector boundary but can be invalid if fptr is on the sector boundary.) */</span>
|
||||
<span class="k">#endif</span>
|
||||
|
@ -16,14 +16,15 @@
|
||||
<p>The <tt>FILINFO</tt> structure holds information about the object returned by <tt>f_readdir</tt>, <tt>f_findfirst</tt>, <tt>f_findnext</tt> and <tt>f_stat</tt> function.</p>
|
||||
<pre>
|
||||
<span class="k">typedef struct</span> {
|
||||
DWORD fsize; <span class="c">/* File size */</span>
|
||||
WORD fdate; <span class="c">/* Last modified date */</span>
|
||||
WORD ftime; <span class="c">/* Last modified time */</span>
|
||||
BYTE fattrib; <span class="c">/* Attribute */</span>
|
||||
TCHAR fname[13]; <span class="c">/* Short file name (8.3 format) */</span>
|
||||
<span class="k">#if</span> _USE_LFN
|
||||
TCHAR* lfname; <span class="c">/* Pointer to the LFN buffer */</span>
|
||||
int lfsize; <span class="c">/* Size of the LFN buffer in unit of TCHAR */</span>
|
||||
FSIZE_t fsize; <span class="c">/* File size */</span>
|
||||
WORD fdate; <span class="c">/* Last modified date */</span>
|
||||
WORD ftime; <span class="c">/* Last modified time */</span>
|
||||
BYTE fattrib; <span class="c">/* Attribute */</span>
|
||||
<span class="k">#if</span> _USE_LFN != 0
|
||||
TCHAR altname[13]; <span class="c">/* Alternative object name */</span>
|
||||
TCHAR fname[_MAX_LFN + 1]; <span class="c">/* Primary object name */</span>
|
||||
<span class="k">#else</span>
|
||||
TCHAR fname[13]; <span class="c">/* Object name */</span>
|
||||
<span class="k">#endif</span>
|
||||
} FILINFO;
|
||||
</pre>
|
||||
@ -32,9 +33,9 @@
|
||||
<h4>Members</h4>
|
||||
<dl>
|
||||
<dt>fsize</dt>
|
||||
<dd>Indicates size of the file in unit of byte. Always zero for directories.</dd>
|
||||
<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>
|
||||
<dt>fdate</dt>
|
||||
<dd>Indicates the date that 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>
|
||||
<dt>bit15:9</dt>
|
||||
<dd>Year origin from 1980 (0..127)</dd>
|
||||
@ -45,7 +46,7 @@
|
||||
</dl>
|
||||
</dd>
|
||||
<dt>ftime</dt>
|
||||
<dd>Indicates the time that the file was modified or the directory was created.<br>
|
||||
<dd>Indicates the time when the file was modified or the directory was created.<br>
|
||||
<dl>
|
||||
<dt>bit15:11</dt>
|
||||
<dd>Hour (0..23)</dd>
|
||||
@ -58,11 +59,9 @@
|
||||
<dt>fattrib</dt>
|
||||
<dd>Indicates the file/directory attribute in combination of <tt>AM_DIR</tt>, <tt>AM_RDO</tt>, <tt>AM_HID</tt>, <tt>AM_SYS</tt> and <tt>AM_ARC</tt>.</dd>
|
||||
<dt>fname[]</dt>
|
||||
<dd>The object name in 8.3 format (SFN) null-terminated string is stored. It is always upper case at non-LFN configuration but it can be returned with lower case at LFN configuration. A null string is stored when no item to read and this structure is invalid.</dd>
|
||||
<dt>lfname</dt>
|
||||
<dd>Pointer to the string buffer to store the long file name (LFN). This member must be initialized by application program prior to use this structure. Set a null pointer if LFN is not needed. Not available at non-LFN configuration.</dd>
|
||||
<dt>lfsize</dt>
|
||||
<dd>Size of the LFN buffer in unit of TCHAR. This member must be initialized by application program prior to use this structure. Not available at non-LFN configuration.</dd>
|
||||
<dd>The null-terminated object name is stored. A null string is stored when no item to read and it indicates this structure is invalid.</dd>
|
||||
<dt>altname[]</dt>
|
||||
<dd>Alternative object name is stored if available. This member is not available at non-LFN configuration.</dd>
|
||||
</dl>
|
||||
|
||||
<p class="foot"><a href="../00index_e.html">Return</a></p>
|
||||
|
@ -15,7 +15,7 @@
|
||||
<h2>f_size</h2>
|
||||
<p>The f_size function gets the size of a file.</p>
|
||||
<pre>
|
||||
DWORD f_size (
|
||||
FSIZE_t f_size (
|
||||
FIL* <span class="arg">fp</span> <span class="c">/* [IN] File object */</span>
|
||||
);
|
||||
</pre>
|
||||
@ -39,9 +39,9 @@ DWORD f_size (
|
||||
|
||||
<div class="para desc">
|
||||
<h4>Description</h4>
|
||||
<p>In this revision, the <tt>f_size</tt> function is implemented as a macro. It has not any validation and mutual exclusion.</p>
|
||||
<p>In this revision, the <tt>f_size</tt> function is implemented as a macro. It does not have any validation and mutual exclusion.</p>
|
||||
<pre>
|
||||
<span class="k">#define</span> f_size(fp) ((fp)->fsize)
|
||||
<span class="k">#define</span> f_size(fp) ((fp)->obj.objsize)
|
||||
</pre>
|
||||
</div>
|
||||
|
||||
|
@ -54,8 +54,7 @@ FRESULT f_stat (
|
||||
|
||||
<div class="para desc">
|
||||
<h4>Description</h4>
|
||||
<p>The <tt>f_stat</tt> function checks the existence of a file or sub-directory. If not exist, the function returns with <tt>FR_NO_FILE</tt>. If exist, the function returns with <tt>FR_OK</tt> and the informations of the object, file size, timestamp, attribute and SFN, are stored to the file information structure. For details of the file information, refer to the <tt>FILINFO</tt> structure and <a href="readdir.html"><tt>f_readdir</tt></a> function.</p>
|
||||
<p>When LFN feature is enabled, <tt>lfname</tt> in the file information structure must be NULLed prior to use it.</p>
|
||||
<p>The <tt>f_stat</tt> function checks the existence of a file or sub-directory. If not exist, the function returns with <tt>FR_NO_FILE</tt>. If exist, the function returns with <tt>FR_OK</tt> and the informations of the object, file size, timestamp and attribute, are stored to the file information structure. For details of the file information, refer to the <tt>FILINFO</tt> structure and <a href="readdir.html"><tt>f_readdir</tt></a> function.</p>
|
||||
</div>
|
||||
|
||||
|
||||
@ -74,23 +73,20 @@ FRESULT f_stat (
|
||||
|
||||
printf("Test for 'file.txt'...\n");
|
||||
|
||||
<span class="k">#if</span> _USE_LFN
|
||||
fno.lfname = 0;
|
||||
<span class="k">#endif</span>
|
||||
fr = f_stat("file.txt", &fno);
|
||||
switch (fr) {
|
||||
|
||||
case FR_OK:
|
||||
printf("Size: %u\n", fno.fsize);
|
||||
printf("Size: %lu\n", fno.fsize);
|
||||
printf("Timestamp: %u/%02u/%02u, %02u:%02u\n",
|
||||
(fno.fdate >> 9) + 1980, fno.fdate >> 5 & 15, fno.fdate & 31,
|
||||
fno.ftime >> 11, fno.ftime >> 5 & 63);
|
||||
printf("Attributes: %c%c%c%c%c\n",
|
||||
(fno.fattrib & AM_DIR) ? 'D' : '-',
|
||||
(fno.fattrib & AM_RDO) ? 'R' : '-',
|
||||
(fno.fattrib & AM_HID) ? 'H' : '-',
|
||||
(fno.fattrib & AM_SYS) ? 'S' : '-',
|
||||
(fno.fattrib & AM_ARC) ? 'A' : '-');
|
||||
(fno.fattrib & AM_DIR) ? 'D' : '-',
|
||||
(fno.fattrib & AM_RDO) ? 'R' : '-',
|
||||
(fno.fattrib & AM_HID) ? 'H' : '-',
|
||||
(fno.fattrib & AM_SYS) ? 'S' : '-',
|
||||
(fno.fattrib & AM_ARC) ? 'A' : '-');
|
||||
break;
|
||||
|
||||
case FR_NO_FILE:
|
||||
|
@ -15,7 +15,7 @@
|
||||
<h2>f_tell</h2>
|
||||
<p>The f_tell function gets the current read/write pointer of a file.</p>
|
||||
<pre>
|
||||
DWORD f_tell (
|
||||
FSIZE_t f_tell (
|
||||
FIL* <span class="arg">fp</span> <span class="c">/* [IN] File object */</span>
|
||||
);
|
||||
</pre>
|
||||
@ -39,7 +39,7 @@ DWORD f_tell (
|
||||
|
||||
<div class="para desc">
|
||||
<h4>Description</h4>
|
||||
<p>In this revision, the <tt>f_tell</tt> function is implemented as a macro. It has not any validation and mutual exclusion.</p>
|
||||
<p>In this revision, the <tt>f_tell</tt> function is implemented as a macro. It does not have any validation and mutual exclusion.</p>
|
||||
<pre>
|
||||
<span class="k">#define</span> f_tell(fp) ((fp)->fptr)
|
||||
</pre>
|
||||
|
@ -36,6 +36,7 @@ FRESULT f_truncate (
|
||||
<a href="rc.html#ok">FR_OK</a>,
|
||||
<a href="rc.html#de">FR_DISK_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#tm">FR_TIMEOUT</a>
|
||||
</p>
|
||||
|
@ -59,7 +59,7 @@ FRESULT f_unlink (
|
||||
If condition of the object to be removed is applicable to the following terms, the function will be rejected.<ul>
|
||||
<li>The file/sub-directory must not have read-only attribute (<tt>AM_RDO</tt>), or the function will be rejected with <tt>FR_DENIED</tt>.</li>
|
||||
<li>The sub-directory must be empty and must not be current directory, or the function will be rejected with <tt>FR_DENIED</tt>.</li>
|
||||
<li>The file/sub-directory must not be opened, or the <em>FAT volume can be collapsed</em>. It will be rejected safely when <a href="appnote.html#dup">file lock feature</a> is enabled.</li>
|
||||
<li>The file/sub-directory must not be opened, or the <em>FAT volume can be collapsed</em>. It will be rejected safely when <a href="appnote.html#dup">file lock function</a> is enabled.</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
|
@ -85,7 +85,7 @@ FRESULT set_timestamp (
|
||||
|
||||
<div class="para comp">
|
||||
<h4>QuickInfo</h4>
|
||||
<p>Available when <tt>_FS_READONLY == 0</tt> and <tt>_FS_MINIMIZE == 0</tt>.</p>
|
||||
<p>Available when <tt>_FS_READONLY == 0</tt> and <tt>_USE_CHMOD == 1</tt>.</p>
|
||||
</div>
|
||||
|
||||
|
||||
|
@ -34,7 +34,7 @@ FRESULT f_write (
|
||||
<dt>btw</dt>
|
||||
<dd>Specifies number of bytes to write in range of <tt>UINT</tt> type.</dd>
|
||||
<dt>bw</dt>
|
||||
<dd>Pointer to the <tt>UINT</tt> variable to return the number of bytes written. The value is always valid after the function call regardless of the result.</dd>
|
||||
<dd>Pointer to the <tt>UINT</tt> variable to return the number of bytes written. The value is always valid after the function call regardless of the result code.</dd>
|
||||
</dl>
|
||||
</div>
|
||||
|
||||
@ -53,7 +53,7 @@ FRESULT f_write (
|
||||
|
||||
<div class="para desc">
|
||||
<h4>Description</h4>
|
||||
<p>The read/write pointer of the file object advances 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> 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>
|
||||
</div>
|
||||
|
||||
|
||||
|
Before Width: | Height: | Size: 11 KiB |
Before Width: | Height: | Size: 19 KiB |
Before Width: | Height: | Size: 7.7 KiB |
Before Width: | Height: | Size: 19 KiB |
@ -17,6 +17,7 @@
|
||||
<li><a href="#memory">メモリ使用量</a></li>
|
||||
<li><a href="#reduce">モジュール サイズの縮小</a></li>
|
||||
<li><a href="#lfn">長いファイル名</a></li>
|
||||
<li><a href="#exfat">exFATファイルシステム</a></li>
|
||||
<li><a href="#unicode">Unicode入出力への対応</a></li>
|
||||
<li><a href="#reentrant">リエントランシー</a></li>
|
||||
<li><a href="#dup">多重ファイル アクセス</a></li>
|
||||
@ -41,9 +42,9 @@ FatFsモジュールはANSI C(C89)準拠で記述されているので、普通
|
||||
|
||||
<h4>システム構成</h4>
|
||||
<p>下に示す依存関係図は、FatFsモジュール利用の組み込みシステムにおける代表的な構成を示します。</p>
|
||||
<p><img src="../img/modules.png" width="580" height="280" alt="システム構成図"></p>
|
||||
<p><img src="../res/modules.png" width="580" height="280" alt="システム構成図"></p>
|
||||
<p>(a) FatFs用に書かれたディスク モジュールがある場合は、そのまま追加するだけです。 (b) しかし、多くの既存のディスク モジュールはそのAPIをFatFsに合わせるため、グルー関数が必要になるでしょう。</p>
|
||||
<p><img src="../img/funcs.png" width="680" height="420" alt="functional diagram"></p>
|
||||
<p><img src="../res/funcs.png" width="750" height="420" alt="functional diagram"></p>
|
||||
|
||||
<h4>ユーザの作成する関数</h4>
|
||||
<p>ポーティング作業は、要求されるデバイス制御関数を用意することが全てで、それ以外にすることは何もありません。既に動作しているデバイス制御モジュールがあるなら、そのAPIをFatFsに合わせるかグルー関数を介してつなぐだけで済みますが、無い場合はほかから移植するか最初から書くかする必要があります。定義されている全ての関数が常に必要なわけではありません。例えば、リード オンリ構成では書き込み系関数は必要ありません。次の表に構成オプションと要求される関数の対応を示します。</p>
|
||||
@ -63,13 +64,13 @@ FatFsモジュールはANSI C(C89)準拠で記述されているので、普通
|
||||
<div class="para doc" id="limits">
|
||||
<h3>限界値</h3>
|
||||
<ul>
|
||||
<li>FATタイプ: FAT12, FAT16, FAT32。</li>
|
||||
<li>ファイルシステム: FAT12, FAT16, FAT32(r0.0) および exFAT(r1.0)。</li>
|
||||
<li>同時オープン ファイル数: 無制限。(利用可能メモリによる)</li>
|
||||
<li>同時マウント ボリューム数: 最大 10。</li>
|
||||
<li>ファイル サイズ: 最大 4G-1バイト。</li>
|
||||
<li>ボリューム サイズ: 最大 2Tバイト(512バイト/セクタ時)。</li>
|
||||
<li>クラスタ サイズ: 最大 64Kバイト(512バイト/セクタ時)。</li>
|
||||
<li>セクタ サイズ: 512, 1024, 2048, 4096バイト。</li>
|
||||
<li>ファイル サイズ: 最大 4GiB - 1 (FATボリューム) および、事実上無制限(exFATボリューム)。</li>
|
||||
<li>ボリューム サイズ: 最大 2TiB (512B/セクタ時)。</li>
|
||||
<li>クラスタ サイズ: 最大 128セクタ (FATボリューム) および、最大 16MiB (exFATボリューム)。</li>
|
||||
<li>セクタ サイズ: 512B, 1KiB, 2KiB, 4KiB。</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
@ -78,70 +79,72 @@ FatFsモジュールはANSI C(C89)準拠で記述されているので、普通
|
||||
<p>次の表にいくつかのターゲットにおけるメモリ使用量の例を示します。テスト時の構成オプションはその下の通りです。数値の単位はバイトで、<em>V</em>はボリューム数、<em>F</em>は同時オープン ファイル数を示します。コンパイラの最適化オプションはコード サイズとしています。</p>
|
||||
<table class="lst2">
|
||||
<tr><th></th><th>ARM7<small><br>32bit</small></th><th>ARM7<small><br>Thumb</small></th><th>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>VC6</td></tr>
|
||||
<tr class="cal"> <td>_WORD_ACCESS</td><td>0</td><td>0</td><td>0</td><td>1</td><td>0</td><td>0</td><td>0</td><td>1</td><td>0</td><td>1</td><td>1</td></tr>
|
||||
<!-- ARM Thumb CM3 AVR H8 PIC24 RL78 V850ES SH-2A RX600 IA-32 -->
|
||||
<tr class="lst3 ral"><td class="cal">text (Full, R/W)</td><td>10.6k</td><td>7.1k</td><td>6.5k</td><td>13.3k</td><td>10.9k</td><td>11.7k</td><td>13.3k</td><td>8.1k</td><td>9.0k</td><td>6.0k</td><td>7.9k</td></tr>
|
||||
<tr class="ral"> <td class="cal">text (Min, R/W)</td> <td>6.7k</td><td>4.6k</td><td>4.2k</td> <td>8.6k</td> <td>7.3k</td> <td>7.7k</td> <td>9.1k</td><td>5.3k</td><td>5.8k</td><td>3.9k</td><td>5.2k</td></tr>
|
||||
<tr class="ral"> <td class="cal">text (Full, R/O)</td> <td>4.8k</td><td>3.2k</td><td>2.9k</td> <td>6.2k</td> <td>5.2k</td> <td>5.5k</td> <td>6.5k</td><td>3.8k</td><td>4.0k</td><td>2.9k</td><td>3.7k</td></tr>
|
||||
<tr class="ral"> <td class="cal">text (Min, R/O)</td> <td>3.6k</td><td>2.5k</td><td>2.3k</td> <td>4.6k</td> <td>4.1k</td> <td>4.3k</td> <td>5.0k</td><td>3.0k</td><td>3.1k</td><td>2.2k</td><td>2.9k</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>(_FS_TINY == 0)</td><td>V*560<br>+ F*550</td><td>V*560<br>+ F*550</td><td>V*560<br>+ F*550</td><td>V*560<br>+ F*544</td><td>V*560<br>+ F*550</td><td>V*560<br>+ F*544</td><td>V*560<br>+ F*544</td><td>V*560<br>+ F*544</td><td>V*560<br>+ F*550</td><td>V*560<br>+ F*550</td><td>V*560<br>+ F*550</td></tr>
|
||||
<tr class="ral"> <td class="cal">Work area<br>(_FS_TINY == 1)</td><td>V*560<br>+ F*36</td><td>V*560<br>+ F*36</td><td>V*560<br>+ F*36</td><td>V*560<br>+ F*32</td><td>V*560<br>+ F*36</td><td>V*560<br>+ F*32</td><td>V*560<br>+ F*32</td><td>V*560<br>+ F*36</td><td>V*560<br>+ F*36</td><td>V*560<br>+ F*36</td><td>V*560<br>+ F*36</td></tr>
|
||||
<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 -->
|
||||
<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 (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 (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 (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">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 == 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>
|
||||
<pre>
|
||||
FatFs R0.11 options:
|
||||
FatFs R0.12 options:
|
||||
_FS_READONLY 0 (R/W) or 1 (R/O)
|
||||
_FS_MINIMIZE 0 (Full basic function) or 3 (Minimized function)
|
||||
_VOLUMES V (Number of logical drives to be used)
|
||||
_WORD_ACCESS 0 or 1 (Set by processor architecture)
|
||||
(Any other options are left not changed from default setting)
|
||||
_FS_MINIMIZE 0 (Full, with all basic functions) or 3 (Min, with fully minimized)
|
||||
_FS_TINY 0 (Default) or 1 (Tiny file object)
|
||||
And any other options are left not changed from default setting.
|
||||
</pre>
|
||||
</div>
|
||||
|
||||
<div class="para doc" id="reduce">
|
||||
<h3>モジュール サイズの縮小</h3>
|
||||
<p>次の表は<a href="config.html">構成オプション</a>の設定値によりどの機能が削除されるかを示します。使用するAPI関数の行にxが無ければその関数は使用可能です。</p>
|
||||
<p>次の表は<a href="config.html">構成オプション</a>の設定値によりどの機能が削除されるかを示します。API関数の行にxが無ければその関数は使用可能です。</p>
|
||||
<table class="lst2">
|
||||
<tr><td rowspan="2">Function</td><td colspan="4">_FS_MINIMIZE</td><td colspan="2">_FS_READONLY</td><td colspan="2">_USE_STRFUNC</td><td colspan="3">_FS_RPATH</td><td colspan="2">_USE_LABEL</td><td colspan="2">_USE_MKFS</td><td colspan="2">_USE_FORWARD</td><td colspan="2">_MULTI_PARTITION</td></tr>
|
||||
<tr><td>0</td><td>1</td><td>2</td><td>3</td><td>0</td><td>1</td><td>0 </td><td>1/2</td><td>0</td><td>1</td><td>2</td><td>0</td><td>1</td><td>0</td><td>1</td><td>0</td><td>1</td><td>0/1</td><td>2</td></tr>
|
||||
<tr class="lst3"><td>f_mount</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr>
|
||||
<tr><td>f_open</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr>
|
||||
<tr><td>f_close</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr>
|
||||
<tr><td>f_read</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr>
|
||||
<tr><td>f_write</td><td></td><td></td><td></td><td></td><td></td><td>x</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr>
|
||||
<tr><td>f_sync</td><td></td><td></td><td></td><td></td><td></td><td>x</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr>
|
||||
<tr><td>f_lseek</td><td></td><td></td><td></td><td>x</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr>
|
||||
<tr><td>f_opendir</td><td></td><td></td><td>x</td><td>x</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr>
|
||||
<tr><td>f_closedir</td><td></td><td></td><td>x</td><td>x</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr>
|
||||
<tr><td>f_readdir</td><td></td><td></td><td>x</td><td>x</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr>
|
||||
<tr><td>f_stat</td><td></td><td>x</td><td>x</td><td>x</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr>
|
||||
<tr><td>f_getfree</td><td></td><td>x</td><td>x</td><td>x</td><td></td><td>x</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr>
|
||||
<tr><td>f_truncate</td><td></td><td>x</td><td>x</td><td>x</td><td></td><td>x</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr>
|
||||
<tr><td>f_unlink</td><td></td><td>x</td><td>x</td><td>x</td><td></td><td>x</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr>
|
||||
<tr><td>f_mkdir</td><td></td><td>x</td><td>x</td><td>x</td><td></td><td>x</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr>
|
||||
<tr><td>f_chmod</td><td></td><td>x</td><td>x</td><td>x</td><td></td><td>x</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr>
|
||||
<tr><td>f_utime</td><td></td><td>x</td><td>x</td><td>x</td><td></td><td>x</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr>
|
||||
<tr><td>f_rename</td><td></td><td>x</td><td>x</td><td>x</td><td></td><td>x</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr>
|
||||
<tr><td>f_chdir</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td>x</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr>
|
||||
<tr><td>f_chdrive</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td>x</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr>
|
||||
<tr><td>f_getcwd</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td>x</td><td>x</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr>
|
||||
<tr><td>f_getlabel</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td>x</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr>
|
||||
<tr><td>f_setlabel</td><td></td><td></td><td></td><td></td><td></td><td>x</td><td></td><td></td><td></td><td></td><td></td><td>x</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr>
|
||||
<tr><td>f_forward</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td>x</td><td></td><td></td><td></td></tr>
|
||||
<tr><td>f_mkfs</td><td></td><td></td><td></td><td></td><td></td><td>x</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td>x</td><td></td><td></td><td></td><td></td><td></td></tr>
|
||||
<tr><td>f_fdisk</td><td></td><td></td><td></td><td></td><td></td><td>x</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td>x</td><td></td><td></td><td></td><td>x</td><td></td></tr>
|
||||
<tr><td>f_putc</td><td></td><td></td><td></td><td></td><td></td><td>x</td><td>x</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr>
|
||||
<tr><td>f_puts</td><td></td><td></td><td></td><td></td><td></td><td>x</td><td>x</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr>
|
||||
<tr><td>f_printf</td><td></td><td></td><td></td><td></td><td></td><td>x</td><td>x</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr>
|
||||
<tr><td>f_gets</td><td></td><td></td><td></td><td></td><td></td><td></td><td>x</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr>
|
||||
<tr><td rowspan="2">Function</td><td colspan="4">_FS_<br>MINIMIZE</td><td colspan="2">_FS_<br>READONLY</td><td colspan="2">_USE_<br>STRFUNC</td><td colspan="3">_FS_<br>RPATH</td><td colspan="2">_USE_<br>FIND</td><td colspan="2">_USE_<br>CHMOD</td><td colspan="2">_USE_<br>EXPAND</td><td colspan="2">_USE_<br>LABEL</td><td colspan="2">_USE_<br>MKFS</td><td colspan="2">_USE_<br>FORWARD</td><td colspan="2">_MULTI_<br>PARTITION</td></tr>
|
||||
<tr> <td>0</td><td>1</td><td>2</td><td>3</td><td>0</td><td>1</td><td>0</td><td>1</td><td>0</td><td>1</td><td>2</td><td>0</td><td>1</td><td>0</td><td>1</td><td>0</td><td>1</td><td>0</td><td>1</td><td>0</td><td>1</td><td>0</td><td>1</td><td>0</td><td>1</td></tr>
|
||||
<tr class="lst3">
|
||||
<td>f_mount</td> <td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td></tr>
|
||||
<tr><td>f_open</td> <td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td></tr>
|
||||
<tr><td>f_close</td> <td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td></tr>
|
||||
<tr><td>f_read</td> <td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td></tr>
|
||||
<tr><td>f_write</td> <td> </td><td> </td><td> </td><td> </td><td> </td><td>x</td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td></tr>
|
||||
<tr><td>f_sync</td> <td> </td><td> </td><td> </td><td> </td><td> </td><td>x</td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td></tr>
|
||||
<tr><td>f_lseek</td> <td> </td><td> </td><td> </td><td>x</td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td></tr>
|
||||
<tr><td>f_opendir</td> <td> </td><td> </td><td>x</td><td>x</td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td></tr>
|
||||
<tr><td>f_closedir</td> <td> </td><td> </td><td>x</td><td>x</td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td></tr>
|
||||
<tr><td>f_readdir</td> <td> </td><td> </td><td>x</td><td>x</td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td></tr>
|
||||
<tr><td>f_findfirst</td><td> </td><td> </td><td>x</td><td>x</td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td>x</td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td></tr>
|
||||
<tr><td>f_findnext</td> <td> </td><td> </td><td>x</td><td>x</td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td>x</td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td></tr>
|
||||
<tr><td>f_stat</td> <td> </td><td>x</td><td>x</td><td>x</td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td></tr>
|
||||
<tr><td>f_getfree</td> <td> </td><td>x</td><td>x</td><td>x</td><td> </td><td>x</td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td></tr>
|
||||
<tr><td>f_truncate</td> <td> </td><td>x</td><td>x</td><td>x</td><td> </td><td>x</td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td></tr>
|
||||
<tr><td>f_unlink</td> <td> </td><td>x</td><td>x</td><td>x</td><td> </td><td>x</td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td></tr>
|
||||
<tr><td>f_mkdir</td> <td> </td><td>x</td><td>x</td><td>x</td><td> </td><td>x</td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td></tr>
|
||||
<tr><td>f_rename</td> <td> </td><td>x</td><td>x</td><td>x</td><td> </td><td>x</td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td></tr>
|
||||
<tr><td>f_chdir</td> <td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td>x</td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td></tr>
|
||||
<tr><td>f_chdrive</td> <td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td>x</td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td></tr>
|
||||
<tr><td>f_getcwd</td> <td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td>x</td><td>x</td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td></tr>
|
||||
<tr><td>f_chmod</td> <td> </td><td> </td><td> </td><td> </td><td> </td><td>x</td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td>x</td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td></tr>
|
||||
<tr><td>f_utime</td> <td> </td><td> </td><td> </td><td> </td><td> </td><td>x</td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td>x</td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td></tr>
|
||||
<tr><td>f_getlabel</td> <td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td>x</td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td></tr>
|
||||
<tr><td>f_setlabel</td> <td> </td><td> </td><td> </td><td> </td><td> </td><td>x</td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td>x</td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td></tr>
|
||||
<tr><td>f_expand</td> <td> </td><td> </td><td> </td><td> </td><td> </td><td>x</td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td>x</td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td></tr>
|
||||
<tr><td>f_forward</td> <td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td>x</td><td> </td><td> </td><td> </td></tr>
|
||||
<tr><td>f_mkfs</td> <td> </td><td> </td><td> </td><td> </td><td> </td><td>x</td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td>x</td><td> </td><td> </td><td> </td><td> </td><td> </td></tr>
|
||||
<tr><td>f_fdisk</td> <td> </td><td> </td><td> </td><td> </td><td> </td><td>x</td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td>x</td><td> </td><td> </td><td> </td><td>x</td><td> </td></tr>
|
||||
<tr><td>f_putc</td> <td> </td><td> </td><td> </td><td> </td><td> </td><td>x</td><td>x</td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td></tr>
|
||||
<tr><td>f_puts</td> <td> </td><td> </td><td> </td><td> </td><td> </td><td>x</td><td>x</td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td></tr>
|
||||
<tr><td>f_printf</td> <td> </td><td> </td><td> </td><td> </td><td> </td><td>x</td><td>x</td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td></tr>
|
||||
<tr><td>f_gets</td> <td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td>x</td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td></tr>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<div class="para doc" id="lfn">
|
||||
<h3>長いファイル名</h3>
|
||||
<p>FatFsモジュールは、長いファイル名(LFN)をサポートします。ファイルに付けられた2つの異なる名前(短いファル名と長いファイル名)は、<tt>f_readdir</tt>関数を除くファイル操作関数において透過です。デフォルト構成では、LFN機能はOFFになっています。LFN機能を有効にするには、<tt><a href="config.html#use_lfn">_USE_LFN</a></tt>を1,2または3に設定し、<tt>option/unicode.c</tt>をプロジェクトに追加します。LFN機能は、加えてある程度のワーク エリア(LFN操作バッファ)を必要とします。バッファ長は使用できるメモリに応じて<tt><a href="config.html#max_lfn">_MAX_LFN</a></tt>オプションで構成されることができます。LFNの長さは最大255文字に達するので、LFN完全対応のためには<tt>_MAX_LFN</tt>は255に設定されるべきです。与えられたファイル名に対してバッファ長が不足した場合、ファイル関数は<tt>FR_INVALID_NAME</tt>で失敗します。</p>
|
||||
<p>ファイル関数に再入を行う条件の下でLFN機能を使用する場合は、<tt>_USE_LFN</tt>は2または3に設定されなければなりません。この場合、ファイル関数はワーク エリアを動的に確保(スタックまたはヒープ)します。ワーク エリアのサイズは、<tt>(_MAX_LFN + 1) * 2</tt>バイトになるので、スタック等のサイズはそれを考慮した十分な余裕がなければなりません。</p>
|
||||
<p>FatFsモジュールは、長いファイル名(LFN)をサポートします。ファイルに付けられた2つの異なる名前(短いファル名と長いファイル名)は、<tt>f_readdir</tt>関数を除くファイル操作関数において透過です。デフォルト構成では、LFN機能はOFFになっています。LFN機能を有効にするには、<tt><a href="config.html#use_lfn">_USE_LFN</a></tt>を1,2または3に設定し、<tt>option/unicode.c</tt>をプロジェクトに追加します。LFN機能は、加えてある程度のワーク エリア(LFN操作バッファ)を必要とします。バッファ長は使用できるメモリに応じて<tt><a href="config.html#max_lfn">_MAX_LFN</a></tt>で構成されることができます。LFNの長さは最大255文字に達するので、LFN完全対応のためには<tt>_MAX_LFN</tt>は255に設定されるべきです。与えられたファイル名に対してバッファ長が不足した場合、ファイル関数は<tt>FR_INVALID_NAME</tt>で失敗します。</p>
|
||||
<p>ファイル関数に再入を行う条件の下でLFN機能を使用する場合は、<tt>_USE_LFN</tt>は2または3に設定されなければなりません。この場合、ファイル関数はワーク エリアを動的に確保(スタックまたはヒープ)します。ワーク エリアのサイズは、<tt>(_MAX_LFN + 1) * 2</tt>バイト(exFAT利用時はさらに+608バイト)になるので、スタック等のサイズはそれを考慮した十分な余裕がなければなりません。</p>
|
||||
<table class="lst2 rset">
|
||||
<caption>LFN構成 at CM3</caption>
|
||||
<tr><th><tt>_CODE_PAGE</tt></th><th>追加コード</th></tr>
|
||||
@ -152,21 +155,29 @@ _WORD_ACCESS 0 or 1 (Set by processor architecture)
|
||||
<tr><td>950(Big5)</td><td>+111k</td></tr>
|
||||
</table>
|
||||
<p>LFN機能の上手な使い方は、それを使わないということです。実際、組み込み用途ではLFN機能がどうしても必要になるということはほとんど無いはずです。LFNを有効にすると、選択されたコード ページに応じてモジュール サイズが増大します。右の表に各コード ページにおけるLFNを有効にしたときのモジュール サイズの違いを示します。特に、CJK地域では数万の文字が使われていますが、不幸なことにそれは巨大なOEM-Unicode相互変換テーブルを要求し、モジュール サイズは劇的に増大します。その結果、それらのコード ページにおいてLFNを有効にしたFatFsモジュールは、多くの8ビット マイコンにインプリメントすることができません。</p>
|
||||
<p>LFN機能のハードルはそれだけではありません。マイクロソフト社はFATファイル システムについていくつかの特許を保有しています。いずれもLFN機能の実装に関するもので、その利用に対して$0.25/unitのライセンス料を要求しています。このため、商用製品でLFN機能を利用するときは、最終仕向地によってはライセンスが必要になります。最近のFAT32ドライバの多くはLFN機能を含んでいるため、それらの使用に当たってライセンスが必要になりますが、FatFsではLFN機能を構成オプションで任意にON/OFFできるため、無効にしてライセンス問題を回避することもできます。</p>
|
||||
<p>LFN機能のハードルはそれだけではありません。マイクロソフト社はFATファイルシステムについていくつかの特許を保有しています。いずれもLFN機能の実装に関するもので、その利用に対して$0.25/unitのライセンス料を要求しています。このため、商用製品でLFN機能を利用する場合は、製品の最終仕向地によってはライセンスが必要になります。最近のFAT32ドライバの多くはLFN機能を含んでいるため、それらの使用に当たってライセンスが必要になりますが、FatFsは構成オプションでLFN機能を任意にON/OFFできるため、無効にしてライセンス問題を回避することもできます。</p>
|
||||
</div>
|
||||
|
||||
<div class="para doc" id="unicode">
|
||||
<h3>Unicode入出力への対応</h3>
|
||||
<p>FatFs API上におけるファイル名等の文字列データの入出力は、デフォルトではANSI/OEMコードで行われますが、これをUnicode(UTF-16)に切り替えることもできます(<tt><a href="config.html#lfn_unicode">_LFN_UNICODE</a></tt>オプションで設定)。つまり、これはFatFsがLFN機能に完全対応していることを意味します。Unicodeのファイル名に関する詳細は、<a href="filename.html#uni">パス名のフォーマット</a>を参照してください。</p>
|
||||
<p>FatFs API上におけるファイル名等の文字列データの入出力は、デフォルトではANSI/OEMコードで行われますが、これをUnicode(UTF-16)に切り替えることもできます(<tt><a href="config.html#lfn_unicode">_LFN_UNICODE</a></tt>で設定)。つまり、これはFatFsがLFN機能に完全対応していることを意味します。Unicodeのファイル名に関する詳細は、<a href="filename.html#uni">パス名のフォーマット</a>を参照してください。</p>
|
||||
</div>
|
||||
|
||||
<div class="para doc" id="exfat">
|
||||
<h3>exFATファイルシステム</h3>
|
||||
<p>exFAT(Microsoft's Extended File Allocation Table)ファイルシステムは、既に組み込みシステムや情報家電で広く使われているFATファイルシステムを置き換える目的で開発されました。exFATは、64GiB以上のSDメモリ カードで標準ファイルシステムに採用されるなど、FATに並びリムーバブル メディアの標準ファイルシステムの一つとなりつつあります。</p>
|
||||
<p>exFATボリュームでは、FATボリュームで制約となっていた4GiB以上のサイズのファイルを扱え、ファイルシステムのオーバーヘッド(特にファイル アロケーション ディレイ)も大幅に低減され、書き込みスループットがFATより向上しています。しかし、現リビジョンのFatFsでは、実装上の理由から不連続ファイルへのサイズ拡大を伴う書き込み時のとき、スループットがFATより低下します。<tt>f_expand</tt>関数による連続領域の割り当て機能は、この問題の回避に有効かもしれません。</p>
|
||||
<p>exFATはマイクロソフト社が開発したものなので、マイクロソフト社はexFATについていくつかの特許を保有しています。FatFsのexFAT機能は、それの US. Pat. App. Pub. No. 2009/0164440 A1 に基づいた実装です。このため、商用製品でexFAT機能を利用する場合、製品の最終仕向地によってはライセンスが必要になります。最近のFATドライバの多くはexFAT機能を含んでいるため、それらの使用に当たってライセンスが必要になりますが、FatFsは構成オプションでexFAT機能を任意にON/OFFできるため、無効にしてライセンス問題を回避することもできます。</p>
|
||||
<p><em>exFATを有効にすると、FatFsモジュールのC89互換は失われます(64ビット整数型が必要なため)。</em></p>
|
||||
</div>
|
||||
|
||||
<div class="para doc" id="reentrant">
|
||||
<h3>リエントランシー</h3>
|
||||
<p>互いに異なるボリュームに対するファイル操作は構成にかかわらずリエントラントで、常に同時平行に動作できます。</p>
|
||||
<p>同じボリュームに対してはデフォルトではリエントラントではありませんが、<tt><a href="config.html#fs_reentrant">_FS_REENTRANT</a></tt>オプションでリエントラント(スレッド セーフ)にすることはできます。この場合、OS依存の同期オブジェクト操作関数<tt>ff_cre_syncobj, ff_del_syncobj, ff_req_grant, ff_rel_grant</tt>関数もまたプロジェクトに追加されなければなりません。サンプル コードと解説は<tt>option/syncobj.c</tt>にあります。</p>
|
||||
<p>互いに異なるボリュームに対するファイル操作は、<tt>_USE_LFN == 1</tt>を除いて構成にかかわらずリエントラントで、常に同時平行に動作できます。</p>
|
||||
<p>同じボリュームに対してはデフォルトではリエントラントではありませんが、<tt><a href="config.html#fs_reentrant">_FS_REENTRANT</a></tt>でリエントラント(スレッド セーフ)にすることはできます。この場合、OS依存の同期オブジェクト操作関数<tt>ff_cre_syncobj, ff_del_syncobj, ff_req_grant, ff_rel_grant</tt>関数もまたプロジェクトに追加されなければなりません。サンプル コードと解説は<tt>option/syncobj.c</tt>にあります。</p>
|
||||
<p>この場合、あるタスクがボリュームを使用中に他のタスクからそのボリュームに対するファイル関数が呼び出されると、そのアクセスは先のタスクがファイル関数を抜けるまでサスペンドされます。待ち時間が<tt>_TIMEOUT</tt>で指定された期間を越えた場合、その関数は<tt>FR_TIMEOUT</tt>でアボートします。いくつかのRTOSではタイムアウト機能はサポートされないかも知れません。</p>
|
||||
<p>ひとつの例外が<tt>f_mount, f_mkfs, f_fdisk</tt>関数にあります。これらのボリューム制御関数は同じボリューム(または関連する物理ドライブ)に対してリエントラントではありません。これらの関数を使用するときは、アプリケーション レベルで排他制御しなければなりません。</p>
|
||||
<p>注: このセクションはFatFsモジュールそれ自体のリエントランシーについて説明しています。<tt>_FS_REENTRANT</tt>は、各ファイル システム オブジェクトの排他制御を行うのみで、下位のディスク関数への再入を防止するものではありません。たとえば、シングル ボリューム構成では<tt>disk_status</tt>関数のみ再入される可能性があり、マルチ ボリューム構成ではどのディスク関数も再入される可能性があります。このように、複数のタスクから同時にFatFs APIを使う条件では、ディスクI/Oモジュールはスレッド セーフである必要があります。</p>
|
||||
<p>注: このセクションはFatFsモジュールそれ自体のリエントランシーについて説明しています。<tt>_FS_REENTRANT</tt>は、各ファイルシステム オブジェクトの排他制御を行うのみで、下位のディスク関数への再入を防止するものではありません。たとえば、シングル ボリューム構成では<tt>disk_status</tt>関数のみ再入される可能性があり、マルチ ボリューム構成ではどのディスク関数も再入される可能性があります。このように、複数のタスクから同時にFatFs APIを使う条件では、ディスクI/Oモジュールはスレッド セーフである必要があります。</p>
|
||||
</div>
|
||||
|
||||
<div class="para doc" id="dup">
|
||||
@ -179,15 +190,15 @@ _WORD_ACCESS 0 or 1 (Set by processor architecture)
|
||||
<h3>効率的なファイル アクセス</h3>
|
||||
<p>小規模な組込システムでのファイルの読み書きにおける効率の良いアクセスのため、アプリケーション プログラマはFatFsモジュールの中でどのような処理が行われているか考慮すべきです。ストレージ上のデータは<tt>f_read</tt>関数により次のシーケンスで転送されます。</p>
|
||||
<p>図1. セクタ ミスアラインド リード (ショート)<br>
|
||||
<img src="../img/f1.png" width="490" height="110" alt="fig.1">
|
||||
<img src="../res/f1.png" width="490" height="110" alt="fig.1">
|
||||
</p>
|
||||
<p>図2. セクタ ミスアラインド リード (ロング)<br>
|
||||
<img src="../img/f2.png" width="490" height="140" alt="fig.2">
|
||||
<img src="../res/f2.png" width="490" height="140" alt="fig.2">
|
||||
</p>
|
||||
<p>図3. セクタ アラインド リード<br>
|
||||
<img src="../img/f3.png" width="490" height="119" alt="fig.3">
|
||||
<img src="../res/f3.png" width="490" height="119" alt="fig.3">
|
||||
</p>
|
||||
<p>ファイルI/Oバッファはセクタの一部のデータを読み書きするためのセクタ バッファを意味します。セクタ バッファは、それぞれのファイル オブジェクト内のプライベート セクタ バッファまたはファイル システム オブジェクト内の共有セクタ バッファのどちらかです。バッファ構成オプションの<tt><a href="config.html#fs_tiny">_FS_TINY</a></tt>は、データ転送にどちらを使うかを決定します。タイニー バッファ(1)が選択されるとデータ メモリの消費はそれぞれのファイル オブジェクトで<tt>_MAX_SS</tt>バイト減少されます。この場合、FatFsモジュールはファイル データの転送とFAT/ディレクトリ アクセスにファイル システム オブジェクト内のセクタ バッファだけを使用します。タイニー バッファの欠点は、セクタ バッファにキャッシュされたFATデータがファイル データの転送により失われ、クラスタ境界の毎にリロードされなければならないことです。でも、悪くない性能と少ないメモリ消費の視点から多くのアプリケーションに適するでしょう。</p>
|
||||
<p>ファイルI/Oバッファはセクタの一部のデータを読み書きするためのセクタ バッファを意味します。セクタ バッファは、それぞれのファイル オブジェクト内のプライベート セクタ バッファまたはファイルシステム オブジェクト内の共有セクタ バッファのどちらかです。バッファ構成オプションの<tt><a href="config.html#fs_tiny">_FS_TINY</a></tt>は、データ転送にどちらを使うかを決定します。タイニー バッファ(1)が選択されるとデータ メモリの消費はそれぞれのファイル オブジェクトで<tt>_MAX_SS</tt>バイト減少されます。この場合、FatFsモジュールはファイル データの転送とFAT/ディレクトリ アクセスにファイルシステム オブジェクト内のセクタ バッファだけを使用します。タイニー バッファの欠点は、セクタ バッファにキャッシュされたFATデータがファイル データの転送により失われ、クラスタ境界の毎にリロードされなければならないことです。でも、悪くない性能と少ないメモリ消費の視点から多くのアプリケーションに適するでしょう。</p>
|
||||
<p>図1はセクタの一部のデータがファイルI/Oバッファを経由で転送されることを示します。図2に示される長いデータの転送では、転送データの中間の1セクタまたはそれ以上のセクタにまたがる転送データがアプリケーション バッファに直接転送されています。図3は転送データ全体がセクタ境界にアライメントされている場合を示しています。この場合、ファイルI/Oバッファは使用されません。直接転送においては最大の範囲のセクタが<tt>disk_read</tt>関数で一度に読み込まれますが、クラスタ境界を越えるマルチ セクタ転送はそれが隣接であっても行われません。</p>
|
||||
<p>このように、セクタにアライメントしたファイルの読み書きへの配慮はバッファ経由のデータ転送を避け、読み書き性能は改善されるでしょう。その効果に加え、タイニー構成でキャッシュされたFATデータがファイル データの転送によりフラッシュされず、非タイニー構成と同じ性能を小さなメモリ フットプリントで達成できます。</p>
|
||||
</div>
|
||||
@ -198,12 +209,12 @@ _WORD_ACCESS 0 or 1 (Set by processor architecture)
|
||||
<h4>マルチ セクタ書き込み</h4>
|
||||
<div class="rset">
|
||||
図6. マルチ/シングル セクタ ライトの比較<br>
|
||||
<img src="../img/f6.png" width="630" height="148" alt="fig.6">
|
||||
<img src="../res/f6.png" width="630" height="148" alt="fig.6">
|
||||
</div>
|
||||
<p>フラッシュ メモリ メディアの書き込み速度はシングル セクタ書き込みの時に最も低いものになり、一回のトランザクションで転送されるセクタ数が大きくなるほど書き込み速度は向上します(図6)。この効果はバス速度が高速になるほど大きく、10倍以上の差が現れることも珍しくありません。<a href="../img/rwtest2.png">テスト結果</a>は、マルチ セクタ書き込み(W:16K, 32 sectors)がシングル セクタ書き込み(W:100, 1 sector)よりどの程度速いかを明確に示しています。大容量メディアほどシングル セクタ書き込みが遅くなる点もまた重要です。書き込みトランザクションの回数はまた、メディアの寿命にも影響してきます。つまり、同じ量のデータを書き込む場合、図6上のシングル セクタ書き込みは、図6下のマルチ セクタ書き込みに比べて16倍早くフラッシュ メモリ メディアを消耗させてしまうということです。</p>
|
||||
<p>フラッシュ メモリ メディアの書き込み速度はシングル セクタ書き込みの時に最も低いものになり、一回のトランザクションで転送されるセクタ数が大きくなるほど書き込み速度は向上します(図6)。この効果はバス速度が高速になるほど大きく、10倍以上の差が現れることも珍しくありません。<a href="../res/rwtest2.png">テスト結果</a>は、マルチ セクタ書き込み(W:16K, 32 sectors)がシングル セクタ書き込み(W:100, 1 sector)よりどの程度速いかを明確に示しています。大容量メディアほどシングル セクタ書き込みが遅くなる点もまた重要です。書き込みトランザクションの回数はまた、メディアの寿命にも影響してきます。つまり、同じ量のデータを書き込む場合、図6上のシングル セクタ書き込みは、図6下のマルチ セクタ書き込みに比べて16倍早くフラッシュ メモリ メディアを消耗させてしまうということです。</p>
|
||||
<p>このように、アプリケーションはなるべく大きなブロック(クラスタ サイズまたは2の累乗セクタ境界にアライメントした)で読み書きを行う必要があります。もちろん、アプリケーションからメディアに至る全てのレイヤがマルチ セクタ転送に対応していないと意味がありません。残念ながら、既存のオープン ソースのドライバの多くはマルチ セクタ転送に未対応です。なお、FatFsモジュールおよびサンプル ドライバはマルチ セクタ転送に対応しています。</p>
|
||||
<h4>明示的なメモリ消去</h4>
|
||||
<p>通常のファイル消去では、記録されたデータに対して何らかの制御が行われるわけではなく、単にFAT上に未使用クラスタとして記録されているだけです。このため、ファイルが消去されたあともそれらは有効なメモリ ブロックとしてフラッシュ メモリ上に残ります。そこで、ファイルを消去するとき、占有していたデータ セクタを明示的に消去(つまり未使用ブロックにする)することにより、メディア内の空きブロックを増やすことができます。これにより、次にそのブロックに書き込むときの消去動作が無くなり、書き込み性能が向上する可能性があります。また、ウェアレベリングに使えるブロックが増え、メディアの耐久性も向上するかも知れません。この機能を有効にするには、構成オプションの<tt><a href="config.html#use_trim">_USE_TRIM</a></tt>に1を設定します。これはフラッシュ メモリ メディアの内部動作に期待した制御なので、効果があるとは限りません。また、ファイル消去の時間が延びることも考慮に入れるべきです。</p>
|
||||
<p>通常のファイル消去では、記録されたデータに対して何らかの処理が行われるわけではなく、単にFAT上にその領域を未使用と記録しているだけです。このため、ファイルが消去されたあともそれらは有効なデータ ブロックとしてフラッシュ メモリ上に残ります。そこで、ファイルを消去するとき、占有していたデータ セクタを明示的に消去(つまり未使用ブロックにする)することにより、メディア内の空きブロックを増やすことができます。これにより、次にそのブロックに書き込むときの消去動作が無くなり、書き込み性能が向上する可能性があります。また、ウェアレベリングに使えるブロックが増え、メディアの耐久性も向上するかも知れません。この機能を有効にするには、<tt><a href="config.html#use_trim">_USE_TRIM</a></tt>に1を設定します。これはフラッシュ メモリ ドライブの内部動作に期待した制御なので、効果があるとは限りません。また、ファイル消去の時間が延びることも考慮に入れるべきです。</p>
|
||||
</div>
|
||||
|
||||
<div class="para doc" id="critical">
|
||||
@ -211,11 +222,11 @@ _WORD_ACCESS 0 or 1 (Set by processor architecture)
|
||||
<p>ストレージ上のFAT構造を操作している途中で、停電、不正なメディアの取り外し、回復不能なデータ エラー等の障害が発生すると、処理が中途半端な状態で中断され、その結果としてFATボリュームの構造が破壊される可能性があります。次にFatFsモジュールにおけるクリチカル セクションと、その間の障害により起きうるエラーの状態を示します。</p>
|
||||
<div class="lset">
|
||||
図4. 長いクリチカル セクション<br>
|
||||
<img src="../img/f4.png" width="320" height="436" alt="fig.4">
|
||||
<img src="../res/f4.png" width="320" height="436" alt="fig.4">
|
||||
</div>
|
||||
<div class="lset">
|
||||
図5. 最小化したクリチカル セクション<br>
|
||||
<img src="../img/f5.png" width="320" height="436" alt="fig.5">
|
||||
<img src="../res/f5.png" width="320" height="436" alt="fig.5">
|
||||
</div>
|
||||
<br class="clr">
|
||||
<p>赤で示したセクションを実行中に中断が発生した場合、クロス リンクが発生して操作中のファイルやディレクトリが失われる可能性があります。黄色で示したセクションを実行中に中断が発生した場合、次のうちいずれかまたは複数の結果が生じる可能性があります。</p>
|
||||
@ -233,27 +244,30 @@ _WORD_ACCESS 0 or 1 (Set by processor architecture)
|
||||
<h3>APIの拡張的使用例</h3>
|
||||
<p>FatFs APIの拡張的使用例です。有用なコードがあった場合は、随時追加していきます。。</p>
|
||||
<ol>
|
||||
<li><a href="../img/app1.c">追記モードでのオープン/新規作成</a></li>
|
||||
<li><a href="../img/app2.c">ディレクトリを空にする</a></li>
|
||||
<li><a href="../img/app3.c">ファイルに連続領域を割り当てる</a></li>
|
||||
<li><a href="../img/app4.c">ディスクI/Oモジュールの機能/互換性チェッカー</a></li>
|
||||
<li><a href="../img/mkfatimg.zip">FATイメージ作成ツール</a></li>
|
||||
<li><a href="../res/app1.c">追記モードでのオープン/新規作成</a>(R0.12以前)</li>
|
||||
<li><a href="../res/app2.c">ディレクトリを空にする</a></li>
|
||||
<li><a href="../res/app3.c">ファイルに連続領域を割り当てる</a>(R0.11a以前)</li>
|
||||
<li><a href="../res/app4.c">ディスクI/Oモジュールの機能/互換性チェッカー</a></li>
|
||||
<li><a href="../res/mkfatimg.zip">FATイメージ作成ツール</a></li>
|
||||
</ol>
|
||||
</div>
|
||||
|
||||
<div class="para doc" id="license">
|
||||
<h3>FatFsのライセンスについて</h3>
|
||||
<p>ソース ファイルにライセンス条件が記述されているので、利用の際はそれに従うこと。原文は英語ですが、参考までに以下に日本語訳を示しておきます。</p>
|
||||
<p>FatFsは、作者(ChaN)の個人プロジェクトとして開発されています。現在のリビジョンにおいてコントリビューターはいないため、作者の書いたソース コード以外は含まれません。ソース ファイルにライセンス条件が記述されているので、利用の際はそれに従うこと。原文は英語ですが、参考までに以下に日本語訳を示しておきます。</p>
|
||||
<pre>
|
||||
/*----------------------------------------------------------------------------/
|
||||
/ FatFs - FAT file system module R0.11 (C)ChaN, 2015
|
||||
/ FatFs - Generic FAT file system module R0.12a /
|
||||
/-----------------------------------------------------------------------------/
|
||||
/ FatFsモジュールはフリーソフトウェアで、次に示す条件の下に公開されています。
|
||||
/
|
||||
/ Copyright (C) 2015, ChaN, all right reserved.
|
||||
/ Copyright (C) 2016, ChaN, all right reserved.
|
||||
/
|
||||
/ 1. ソースコードで再配布するときは、その中に上記の著作権表示、この条文、および
|
||||
/ 次の免責事項を保持すること
|
||||
/ FatFsモジュールはオープンソースソフトウェアです。FatFsの再配布および使用は、
|
||||
/ ソースコードかバイナリ形式か、また変更の有無にかかわらず、次の条件が満たされ
|
||||
/ る場合に限り許可されます。
|
||||
/
|
||||
/ 1. ソースコードで再配布するときは、その中に上記の著作権表示、この条件、および
|
||||
/ 次の免責事項を保持すること。
|
||||
/
|
||||
/ このソフトウェアは、著作権者らおよびコントリビューターらによって<em>現状のまま</em>
|
||||
/ 提供されており、<em>いかなる保証もありません</em>。
|
||||
@ -261,7 +275,7 @@ _WORD_ACCESS 0 or 1 (Set by processor architecture)
|
||||
/ 損害についても、<em>責任を負いません</em>。
|
||||
/----------------------------------------------------------------------------*/
|
||||
</pre>
|
||||
<p>このようにFatFsはBSDライクなライセンスとしていますが、一つ大きな違いがあります。FatFsは主に組み込み向けとして開発されたため、バイナリ形式(ソース コードを含まない形式全て)での再配布については、商用での使いやすさを考慮して配布時の条件を設けていません。つまり、バイナリ配布の場合は、FatFsおよびそのライセンス文書についてドキュメントに明記してもしなくてもかまいません。これは、一条項BSDライセンスと等価ということです。もちろん、GNU GPLなどほとんど全てのオープン ソース ライセンスの下のプロジェクトにおいて共存可能です。FatFsに何らかの修正や拡張を加えてソース コードで再配布する場合は、矛盾しない他のオープン ソース ライセンス(GNU GPLや修正BSDライセンスなど)に変更することも可能です。</p>
|
||||
<p>このようにFatFsはBSDライクなライセンスとしていますが、一つ大きな違いがあります。FatFsは主に組み込み向けとして開発されたため、バイナリ形式(ソース コードを含まない形式全て)での再配布については、商用での使いやすさを考慮して配布時の条件を設けていません。つまり、バイナリ配布の場合は、FatFsおよびそのライセンス文書についてドキュメントに明記してもしなくてもかまいません。これは、一条項BSDライセンスと等価ということです。もちろん、GNU GPLなどほとんど全てのオープン ソース ライセンスの下のプロジェクトにおいて共存可能です。FatFsからフォークを作成し公開する場合は、矛盾しない他のオープン ソース ライセンス(GNU GPLや修正BSDライセンスなど)に変更することも可能です。</p>
|
||||
</div>
|
||||
|
||||
<p class="foot"><a href="../00index_j.html">戻る</a></p>
|
||||
|
@ -43,19 +43,25 @@ div.doc h4 {margin-top: 2em }
|
||||
</table>
|
||||
|
||||
<h4 id="use_find">_USE_FIND</h4>
|
||||
<p>フィルタ付きディレクトリ読み出し機能の構成(0:無効 または 1:有効)。有効にすると、<tt>f_findfirst</tt>、<tt>f_findnext</tt>関数が利用可能になります。</p>
|
||||
<p>フィルタ付きディレクトリ読み出し機能の構成(0:無効 または 1:有効)。有効にすると、<tt>f_findfirst</tt>、<tt>f_findnext</tt>関数が利用可能になります。<tt>_FS_MINIMIZE</tt>は、1以下でなければなりません。</p>
|
||||
|
||||
<h4 id="use_mkfs">_USE_MKFS</h4>
|
||||
<p>ボリューム作成機能の構成(0:無効 または 1:有効)。有効にすると<tt>f_mkfs</tt>関数が利用可能になります。</p>
|
||||
|
||||
<h4 id="use_fastseek">_USE_FASTSEEK</h4>
|
||||
<p>高速シーク機能の構成(0:無効 または 1:有効)。有効にすると、<tt>f_lseek</tt>、<tt>f_read</tt>、<tt>f_write</tt>関数の高速化モードが利用可能になります。詳しくは、<a href="lseek.html">こちら</a>を参照してください。</p>
|
||||
<p>高速シーク機能の構成(0:無効 または 1:有効)。有効にすると、<tt>f_lseek</tt>、<tt>f_read</tt>、<tt>f_write</tt>関数において高速化モードが利用可能になります。詳しくは、<a href="lseek.html">こちら</a>を参照してください。</p>
|
||||
|
||||
<h4 id="use_expand">_USE_EXPAND</h4>
|
||||
<p>連続領域割り当て機能の構成(0:無効 または 1:有効)。有効にすると<tt>f_expand</tt>関数が利用可能になります。<tt>_FS_READONLY</tt>は0でなければなりません。</p>
|
||||
|
||||
<h4 id="use_chmod">_USE_CHMOD</h4>
|
||||
<p>メタデータ操作機能の構成(0:無効 または 1:有効)。有効にすると、<tt>f_chmod</tt>、<tt>f_utime</tt>関数が利用可能になります。<tt>_FS_READONLY</tt>は0でなければなりません。</p>
|
||||
|
||||
<h4 id="use_label">_USE_LABEL</h4>
|
||||
<p>ボリューム ラベル操作機能の構成(0:無効 または 1:有効)。有効にすると、<tt>f_getlabel</tt>、<tt>f_setlabel</tt>関数が利用可能になります。</p>
|
||||
<p>ボリューム ラベル操作機能の構成(0:無効 または 1:有効)。有効にすると、<tt>f_getlabel</tt>、<tt>f_setlabel</tt>関数(<tt>_FS_READONLY == 0</tt>のとき)が利用可能になります。</p>
|
||||
|
||||
<h4 id="use_forward">_USE_FORWARD</h4>
|
||||
<p>ストリーミング読み出し機能の構成(0:無効 または 1:有効)。これと<tt>_FS_TINY</tt>を有効にすると、<tt>f_forward</tt>関数が利用可能になります。</p>
|
||||
<p>ストリーミング読み出し機能(<tt>f_forward</tt>関数)の構成(0:無効 または 1:有効)。</p>
|
||||
|
||||
</div>
|
||||
|
||||
@ -92,13 +98,13 @@ div.doc h4 {margin-top: 2em }
|
||||
</table>
|
||||
|
||||
<h4 id="use_lfn">_USE_LFN</h4>
|
||||
<p>LFN(長いファイル名)対応を設定します。LFN機能を有効にするときは、Unicode操作関数<tt>option/unicode.c</tt>をプロジェクトに加える必要があります。また、LFN操作バッファ(<tt>(_MAX_LFN + 1) * 2</tt>バイトを占有)を使用します。バッファをスタックに確保するときは、スタック オーバ フローに注意する必要があります。ヒープに確保するときは、メモリ操作関数、<tt>ff_memalloc</tt>と<tt>ff_memfree</tt>(<tt>option/syscall.c</tt>にサンプルあり)、をプロジェクトに加える必要があります。</p>
|
||||
<p>LFN(長いファイル名)対応を設定します。LFN機能を有効にするときは、Unicode操作関数<tt>option/unicode.c</tt>をプロジェクトに加える必要があります。また、LFN操作のワーク エリアとして<tt>(_MAX_LFN + 1) * 2</tt>バイト(exFAT構成時はさらに608バイト)を使用します。このため、バッファをスタックに確保するときは、スタック オーバ フローに注意する必要があります。ヒープに確保するときは、メモリ操作関数(<tt>ff_memalloc</tt>と<tt>ff_memfree</tt>(<tt>option/syscall.c</tt>にサンプルあり))をプロジェクトに加える必要があります。</p>
|
||||
<table class="lst1">
|
||||
<tr><th>値</th><th>解説</th></tr>
|
||||
<tr><td>0</td><td>LFN機能を使わない。8.3形式の名前のみ使用可能。</td></tr>
|
||||
<tr><td>1</td><td>LFN機能を使う。LFN操作バッファは静的に確保。常にスレッド セーフではない。</td></tr>
|
||||
<tr><td>2</td><td>LFN機能を使う。LFN操作バッファはスタックから確保。</td></tr>
|
||||
<tr><td>3</td><td>LFN機能を使う。LFN操作バッファはヒープから確保。</td></tr>
|
||||
<tr><td>1</td><td>LFN機能を使う。ワーク エリアは静的に確保。常にスレッド セーフではない。</td></tr>
|
||||
<tr><td>2</td><td>LFN機能を使う。ワーク エリアはスタックに確保。</td></tr>
|
||||
<tr><td>3</td><td>LFN機能を使う。ワーク エリアはヒープに確保。</td></tr>
|
||||
</table>
|
||||
|
||||
<h4 id="max_lfn">_MAX_LFN</h4>
|
||||
@ -169,6 +175,9 @@ div.doc h4 {margin-top: 2em }
|
||||
<h4 id="fs_tiny">_FS_TINY</h4>
|
||||
<p>ファイル データ転送バッファの構成(0:ノーマル または 1:タイニ)。タイニ構成では、ファイル オブジェクト<tt>FIL</tt>内のプライベート セクタ バッファが削除され、<tt>_MAX_SS</tt>バイト小さくなります。ファイル データの転送には、代わりにファイル システム オブジェクト<tt>FATFS</tt>内のボリューム共有セクタ バッファが使われます。</p>
|
||||
|
||||
<h4 id="fs_exfat">_FS_EXFAT</h4>
|
||||
<p>exFATのサポート(0:使用しない または 1:使用する)。exFATを使用するには、LFN機能を有効にしなければなりません。また、exFATの完全サポートのためには、<tt>_LFN_UNICODE = 1</tt>と<tt>_MAX_LFN = 255</tt>の設定が推奨されます。exFAT機能では64ビット整数を使用するため、これを有効にするとC89(ANSI C)互換が失われます。</p>
|
||||
|
||||
<h4 id="fs_nortc">_FS_NORTC</h4>
|
||||
<p>RTC機能の使用の設定(0:使用する または 1:使用しない)。システムがRTC(カレンダ時計)をサポートしない場合は、1をセットします。この場合、FatFsが変更を加えたオブジェクトのタイムスタンプはデフォルトの日時を持ちます。RTCが使用可能なときは、0を設定し、<tt>get_fattime</tt>関数をプロジェクトに加えます。リード オンリ構成ではこのオプションは意味を持ちません。</p>
|
||||
|
||||
@ -193,31 +202,6 @@ div.doc h4 {margin-top: 2em }
|
||||
<h4 id="sync_t">_SYNC_t</h4>
|
||||
<p>O/S定義の同期オブジェクトの型を設定します。例: <tt>HANDLE</tt>、<tt>ID</tt>、<tt>OS_EVENT*</tt>、<tt>SemaphoreHandle_t</tt>など。また、O/S機能のヘッダ ファイルを<tt>ff.c</tt>のスコープ内にインクルードする必要があります。<tt>_FS_REENTRANT</tt>が0のときは意味を持ちません。</p>
|
||||
|
||||
<h4 id="word_access">_WORD_ACCESS</h4>
|
||||
<p>ボリューム上のワード データへのアクセス方法を設定します。唯一のプラットフォーム依存オプションです。</p>
|
||||
<table class="lst1">
|
||||
<tr><th>値</th><th>解説</th></tr>
|
||||
<tr><td>0</td><td>Byte-by-byteアクセス。全てのプラットフォームでコンパチブル。</td></tr>
|
||||
<tr><td>1</td><td>ワード アクセス。コード サイズが少し減るが、次の条件を共に満たしていない限り選択できない。<br>
|
||||
・非アライン メモリ アクセスが常に全ての命令で使用可能。<br>
|
||||
・メモリ上のバイト順がリトル エンディアン。</td></tr>
|
||||
</table>
|
||||
<p>次にいくつかのプロセッサにおける許可された設定を示します。</p>
|
||||
<pre>
|
||||
ARM7TDMI 0 *2 ColdFire 0 *1 V850E 0 *2
|
||||
Cortex-M3 0 *3 Z80 0/1 V850ES 0/1
|
||||
Cortex-M0 0 *2 x86 0/1 TLCS-870 0/1
|
||||
AVR 0/1 RX600(LE) 0/1 TLCS-900 0/1
|
||||
AVR32 0 *1 RL78 0 *2 R32C 0 *2
|
||||
PIC18 0/1 SH-2 0 *1 M16C 0/1
|
||||
PIC24 0 *2 H8S 0 *1 MSP430 0 *2
|
||||
PIC32 0 *1 H8/300H 0 *1 8051 0/1
|
||||
|
||||
*1:ビッグ エンディアン
|
||||
*2:非アライン メモリ アクセス不可
|
||||
*3:いくつかのコンパイラがmem_cpy関数にLDM/STM命令を生成する
|
||||
</pre>
|
||||
|
||||
</div>
|
||||
|
||||
<p class="foot"><a href="../00index_j.html">戻る</a></p>
|
||||
|
@ -80,6 +80,9 @@ DRESULT disk_ioctl (
|
||||
<tr><td>ATA_GET_REV</td><td>リビジョン コードを<tt class="arg">buff</tt>の示す16バイトのバッファに読み出します。(ATA/CFカード専用)</td></tr>
|
||||
<tr><td>ATA_GET_MODEL</td><td>モデル コードを<tt class="arg">buff</tt>の示す40バイトのバッファに読み出します。(ATA/CFカード専用)</td></tr>
|
||||
<tr><td>ATA_GET_SN</td><td>シリアル番号を<tt class="arg">buff</tt>の示す20バイトのバッファに読み出します。(ATA/CFカード専用)</td></tr>
|
||||
<tr><td>ISDIO_READ</td><td><tt class="arg">buff</tt>の示すコマンド構造体に従いiSDIOレジスタからデータを読み出します。(FlashAir専用)</td></tr>
|
||||
<tr><td>ISDIO_WRITE</td><td><tt class="arg">buff</tt>の示すコマンド構造体に従いiSDIOレジスタにデータを書き込みます。(FlashAir専用)</td></tr>
|
||||
<tr><td>ISDIO_MRITE</td><td><tt class="arg">buff</tt>の示すコマンド構造体に従いiSDIOレジスタの一部のビットを書き換えます。(FlashAir専用)</td></tr>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
|
@ -34,7 +34,7 @@ DRESULT disk_read (
|
||||
<dt>sector</dt>
|
||||
<dd>読み出しを開始するセクタ番号。32ビットLBAで指定されます。</dd>
|
||||
<dt>count</dt>
|
||||
<dd>読み出すセクタ数が1~128の範囲で指定されます。</dd>
|
||||
<dd>読み出すセクタ数(1以上の値)が指定されます。</dd>
|
||||
</dl>
|
||||
</div>
|
||||
|
||||
@ -45,11 +45,11 @@ DRESULT disk_read (
|
||||
<dt>RES_OK (0)</dt>
|
||||
<dd>正常終了。</dd>
|
||||
<dt>RES_ERROR</dt>
|
||||
<dd>読み込み中にエラーが発生し、その回復にも失敗した。</dd>
|
||||
<dd>回復不能なエラーにより、読み出し操作を完了できなかった。</dd>
|
||||
<dt>RES_PARERR</dt>
|
||||
<dd>パラメータが不正。</dd>
|
||||
<dt>RES_NOTRDY</dt>
|
||||
<dd>ストレージ デバイスが動作可能状態ではない(初期化されていない)。</dd>
|
||||
<dd>ストレージ デバイスが動作可能な状態ではない (初期化されていない)。</dd>
|
||||
</dl>
|
||||
</div>
|
||||
|
||||
|
@ -30,11 +30,11 @@ DRESULT disk_write (
|
||||
<dt>pdrv</dt>
|
||||
<dd>対象のデバイスを識別する物理ドライブ番号(0-9)が指定されます。</dd>
|
||||
<dt>buff</dt>
|
||||
<dd>ストレージ デバイスに書き込むセクタ データが格納された<em>バイト配列</em>が指定されます。バイト数は、セクタ サイズ*<tt class="arg">count</tt>となります。</dd>
|
||||
<dd>ストレージ デバイスに書き込むセクタ データが格納された<em>バイト配列</em>が指定されます。データのバイト数は、セクタ サイズ*<tt class="arg">count</tt>となります。</dd>
|
||||
<dt>sector</dt>
|
||||
<dd>書き込みを開始するセクタ番号。32ビットLBAで指定されます。</dd>
|
||||
<dt>count</dt>
|
||||
<dd>書き込むセクタ数が1~128の範囲で指定されます。</dd>
|
||||
<dd>書き込むセクタ数(1以上の値)が指定されます。</dd>
|
||||
</dl>
|
||||
</div>
|
||||
|
||||
@ -45,13 +45,13 @@ DRESULT disk_write (
|
||||
<dt>RES_OK (0)</dt>
|
||||
<dd>正常終了。</dd>
|
||||
<dt>RES_ERROR</dt>
|
||||
<dd>書き込み中にエラーが発生し、その回復にも失敗した。</dd>
|
||||
<dd>回復不能なエラーにより、書き込み操作を完了できなかった。</dd>
|
||||
<dt>RES_WRPRT</dt>
|
||||
<dd>メディアが書き込み禁止状態。</dd>
|
||||
<dt>RES_PARERR</dt>
|
||||
<dd>パラメータが不正。</dd>
|
||||
<dt>RES_NOTRDY</dt>
|
||||
<dd>ストレージ デバイスが動作可能状態ではない(初期化されていない)。</dd>
|
||||
<dd>ストレージ デバイスが動作可能な状態ではない (初期化されていない)。</dd>
|
||||
</dl>
|
||||
</div>
|
||||
|
||||
|
116
firmware/chibios-portapack/ext/fatfs/doc/ja/expand.html
Normal file
@ -0,0 +1,116 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
|
||||
<html lang="ja">
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
||||
<meta http-equiv="Content-Style-Type" content="text/css">
|
||||
<link rel="up" title="FatFs" href="../00index_j.html">
|
||||
<link rel="alternate" hreflang="ja" title="English" href="../en/expand.html">
|
||||
<link rel="stylesheet" href="../css_j.css" type="text/css" media="screen" title="ELM Default">
|
||||
<title>FatFs - f_expand</title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
<div class="para func">
|
||||
<h2>f_expand</h2>
|
||||
<p>ファイルに連続したデータ領域を割り当てます。</p>
|
||||
|
||||
<pre>
|
||||
FRESULT f_expand (
|
||||
FIL* <span class="arg">fp</span>, <span class="c">/* [IN] ファイル オブジェクト構造体へのポインタ */</span>
|
||||
FSIZE_t <span class="arg">fsz</span>, <span class="c">/* [IN] 割り当てサイズ */</span>
|
||||
BYTE <span class="arg">opt</span> <span class="c">/* [IN] 動作オプション */</span>
|
||||
);
|
||||
</pre>
|
||||
</div>
|
||||
|
||||
<div class="para arg">
|
||||
<h4>Parameters</h4>
|
||||
<dl class="par">
|
||||
<dt>fp</dt>
|
||||
<dd>対象となるファイル オブジェクト構造体へのポインタを指定します。</dd>
|
||||
<dt>fsz</dt>
|
||||
<dd>ファイルに割り当てるバイト単位のサイズ。データ型<tt>FSIZE_t</tt>は、<tt>DWORD</tt>(32-bit)または<tt>QWORD</tt>(64-bit)のエリアスで、exFATサポートの有無により切り替わります。</dd>
|
||||
<dt>opt</dt>
|
||||
<dd>実際に割り当てを行うかどうか指定するフラグ。</dd>
|
||||
</dl>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="para ret">
|
||||
<h4>Return Values</h4>
|
||||
<p>
|
||||
<a href="rc.html#ok">FR_OK</a>,
|
||||
<a href="rc.html#de">FR_DISK_ERR</a>,
|
||||
<a href="rc.html#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#tm">FR_TIMEOUT</a>
|
||||
</p>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="para desc">
|
||||
<h4>解説</h4>
|
||||
<p><tt class="arg">opt</tt>に1を指定すると、ファイルに連続したデータ領域を割り当てます。<tt>f_lseek</tt>によるサイズ拡張とは異なり、対象ファイルのサイズは0(つまりデータ領域未割り当て)でなければなりません。また、リード/ライト ポインタは、ファイル先頭に留まります。この関数により割り当てられたファイルの内容は未定義なので、それに対して何の前提も持つべきではありません。この関数は、次の理由により<tt>FR_DENIED</tt>で失敗することがあります。</p>
|
||||
<ul>
|
||||
<li>ボリューム上に連続した空き領域が見つからなかった。</li>
|
||||
<li>ファイルのサイズが0ではなかった。</li>
|
||||
<li>ファイルが非書き込みモードで開かれている。</li>
|
||||
<li>指定されたファイル サイズが無効。(FATボリューム上で >=4GiB)</li>
|
||||
</ul>
|
||||
<p><tt class="arg">opt</tt>に0を指定したときは、連続したデータ領域を探すのみで、その時点ではファイルへの割り当てを行わず、代わりにそれを検索開始ポイントとしてファイル システム オブジェクトにセットします。これにより、そのボリューム上で別の操作(FAT変更を伴う)が行われない限り、書き込まれるファイルは少なくともそのサイズまでは連続性が保証され、遅延無く書き込めることになります。</p>
|
||||
<p>時間的制約のあるファイル読み書き操作において、連続データ領域を割り当てられたファイルは有利となります。これは、分割されたファイルによりもたらされる無用なランダム アクセスが減ることにより、ファイル システムやストレージ デバイスの処理のオーバーヘッドが削減されるからです。特にexFATボリューム上の連続ファイルでは一切のFATアクセスが発生せず、効率的なシーケンシャル アクセスが行えます。</p>
|
||||
<p>連続ファイルに対して低レベルI/Oを使用したさらに効率的な直接アクセスも容易に行えますが、これは将来の互換性の点で推奨はされません。</p>
|
||||
</div>
|
||||
|
||||
<div class="para comp">
|
||||
<h4>対応情報</h4>
|
||||
<p><tt>_USE_EXPAND == 1</tt>で、かつ<tt>_FS_READONLY == 0</tt>のとき使用可能です。</p>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="para use">
|
||||
<h4>使用例</h4>
|
||||
<pre>
|
||||
<span class="c">/* 連続ファイルの作成 */</span>
|
||||
|
||||
<span class="c">/* 新しいファイルの作成 */</span>
|
||||
res = f_open(fp = malloc(sizeof (FIL)), "file.dat", FA_WRITE|FA_CREATE_ALWAYS);
|
||||
if (res) { <span class="c">/* ファイルが開かれたかチェック */</span>
|
||||
free(fp);
|
||||
...
|
||||
}
|
||||
|
||||
<span class="c">/* 100 MiB の連続領域を割り当てる */</span>
|
||||
res = f_expand(fp, 104857600, 1);
|
||||
if (res) { <span class="c">/* 割り当てられたかチェック */</span>
|
||||
...
|
||||
free(fp);
|
||||
...
|
||||
}
|
||||
<span class="c">/* 連続ファイル作成成功 fp でアクセス可能 */</span>
|
||||
|
||||
</pre>
|
||||
<pre>
|
||||
<span class="c">/* ファイル システムを介さず直接アクセスする例 */</span>
|
||||
|
||||
<span class="c">/* ファイル データの物理的位置を取得 */</span>
|
||||
drv = fp->obj.fs->drv;
|
||||
sect = fp->obj.fs->database + fp->obj.fs->csize * (fp->obj.sclust - 2);
|
||||
|
||||
<span class="c">/* ファイル先頭から2048セクタを書き込み */</span>
|
||||
res = disk_write(drv, buffer, sect, 2048);
|
||||
|
||||
</pre>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="para ref">
|
||||
<h4>参照</h4>
|
||||
<p><tt><a href="open.html">f_open</a>, <a href="lseek.html">f_lseek</a>, <a href="sfile.html">FIL</a></tt></p>
|
||||
</div>
|
||||
|
||||
<p class="foot"><a href="../00index_j.html">戻る</a></p>
|
||||
</body>
|
||||
</html>
|
@ -16,9 +16,9 @@
|
||||
<p>物理ドライブを分割します。</p>
|
||||
<pre>
|
||||
FRESULT f_fdisk (
|
||||
BYTE <span class="arg">pdrv</span>, <span class="c">/* [IN] 物理ドライブ番号 */</span>
|
||||
const DWORD <span class="arg">part[]</span>, <span class="c">/* [IN] 区画マップ テーブル */</span>
|
||||
void* <span class="arg">work</span> <span class="c">/* [-] ワークエリア */</span>
|
||||
BYTE <span class="arg">pdrv</span>, <span class="c">/* [IN] 物理ドライブ番号 */</span>
|
||||
const DWORD* <span class="arg">szt</span>, <span class="c">/* [IN] 区画サイズ テーブル */</span>
|
||||
void* <span class="arg">work</span> <span class="c">/* [-] ワークエリア */</span>
|
||||
);
|
||||
</pre>
|
||||
</div>
|
||||
@ -27,9 +27,9 @@ FRESULT f_fdisk (
|
||||
<h4>引数</h4>
|
||||
<dl class="par">
|
||||
<dt>pdrv</dt>
|
||||
<dd>分割する<em>物理ドライブ</em>のドライブ番号を指定します。</dd>
|
||||
<dt>part[]</dt>
|
||||
<dd>区画マップ テーブルへのポインタを指定します。</dd>
|
||||
<dd>分割する<em>物理ドライブ</em>を指定します。これは論理ドライブ番号ではなく、ディスク関数に渡される物理ドライブ番号です。</dd>
|
||||
<dt>szt</dt>
|
||||
<dd>区画サイズ テーブルの先頭項目へのポインタを指定します。</dd>
|
||||
<dt>work</dt>
|
||||
<dd>ワークエリアへのポインタを指定します。サイズは<tt>_MAX_SS</tt>バイト必要です。</dd>
|
||||
</dl>
|
||||
@ -48,7 +48,7 @@ FRESULT f_fdisk (
|
||||
|
||||
<div class="para desc">
|
||||
<h4>説明</h4>
|
||||
<p>この関数は、指定された物理ドライブのMBRに区画テーブルを作成します。区画分けは一般的なFDISK形式で行うため、最大4つの基本区画を作成することができます。拡張区画には対応していません。区画マップテーブル<tt class="arg">part[]</tt>にはドライブをどのように分割するか指定して渡します。この配列は4つの項目から成り、先頭の項目が1番目の、最後の項目が4番目の区画のサイズを示します。値が100以下の場合、ドライブの総容量に対する割合をパーセント単位で指定します。100を超える値の場合はセクタ数の直接指定になります。</p>
|
||||
<p>この関数は、指定された物理ドライブのMBRに区画テーブルを作成します。区画分けは一般的なFDISK形式で行うため、最大4つの基本区画を作成することができます。拡張区画には対応していません。区画サイズ テーブルにはドライブをどのように分割するか指定します。この配列は4つの項目から成り、先頭の項目が1番目の区画のサイズを示します。項目の値が100以下の場合、その区画のドライブの総容量に対する割合をパーセント単位で指定します。100を超える値の場合はセクタ数の直接指定になります。ドライブ上への区画の配置順は、項目順になります。</p>
|
||||
</div>
|
||||
|
||||
<div class="para comp">
|
||||
@ -71,27 +71,22 @@ FRESULT f_fdisk (
|
||||
<span class="c">/* 新しい物理ドライブ(0)の初期化 */</span>
|
||||
|
||||
FATFS fs;
|
||||
DWORD plist[] = {50, 50, 0, 0}; <span class="c">/* 2分割 */</span>
|
||||
DWORD plist[] = {50, 50, 0, 0}; <span class="c">/* 第1区画,第2区画それぞれに50%ずつ割り当て */</span>
|
||||
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_mount(&fs "0:", 0);
|
||||
f_mkfs("0:", 0, 0); <span class="c">/* 論理ドライブ 0 のフォーマット. 第二引数は無視される. */</span>
|
||||
f_mount(0, "0:", 0);
|
||||
|
||||
f_mount(&fs, "1:", 0);
|
||||
f_mkfs("1:", 0, 0); <span class="c">/* 論理ドライブ 0 のフォーマット. 第二引数は無視される. */</span>
|
||||
f_mount(0, "1:", 0);
|
||||
f_mkfs("0:", FMT_ANY, work, sizeof work); <span class="c">/* 論理ドライブ 0: のフォーマット */</span>
|
||||
f_mkfs("1:", FMT_ANY, work, sizeof work); <span class="c">/* 論理ドライブ 1: のフォーマット */</span>
|
||||
|
||||
</pre>
|
||||
</div>
|
||||
|
||||
<div class="para ref">
|
||||
<h4>See Also</h4>
|
||||
<p><tt><a href="filename.html#vol">Volume management</a>, <a href="mkfs.html">f_mkfs</a></tt></p>
|
||||
<h4>参照</h4>
|
||||
<p><tt><a href="filename.html#vol">ボリューム管理</a>, <a href="mkfs.html">f_mkfs</a></tt></p>
|
||||
</div>
|
||||
|
||||
<p class="foot"><a href="../00index_j.html">Return</a></p>
|
||||
<p class="foot"><a href="../00index_j.html">戻る</a></p>
|
||||
</body>
|
||||
</html>
|
||||
|
@ -33,7 +33,8 @@
|
||||
<tr><td>dir1/..</td><td>無効</td><td>カレント ディレクトリ</td></tr>
|
||||
<tr><td>/..</td><td>無効</td><td>ルート ディレクトリ(その上は辿れない)</td></tr>
|
||||
</table>
|
||||
<p>また、<tt><a href="config.html#str_volume_id">_STR_VOLUME_ID</a></tt>オプションを有効にすることでドライブ番号の識別には数字のほか、<tt>"sd:file1.txt"</tt>や<tt>"ram:swapfile.dat"</tt>のように、任意の文字列を使用することも可能になります。</p>
|
||||
<p>また、<tt><a href="config.html#str_volume_id">_STR_VOLUME_ID</a></tt>オプションを有効にすることでドライブ番号の識別には数字のほか、<tt>"sd:file1.txt"</tt>や<tt>"ram:swapfile.dat"</tt>のように、任意の文字列(もちろんDOS/Windowsライクなドライブ文字も)を使用することも可能になります。</p>
|
||||
<p><em>【注意】現リビジョン(R0.12)では、exFATボリューム上においてダブル ドット<tt>".."</tt>はシングル ドット<tt>"."</tt>として機能し、親ディレクトリを辿ることはできません。</em></p>
|
||||
</div>
|
||||
|
||||
<div class="para doc" id="case">
|
||||
@ -55,20 +56,20 @@
|
||||
|
||||
<div class="para doc" id="vol">
|
||||
<h3>ボリューム管理</h3>
|
||||
<p>デフォルトの構成では、それぞれの論理ドライブは同じ番号の物理ドライブに1:1で結びつけられていて、自動検出機能によりその物理ドライブ上の一つのFATボリュームがマウントされます。FATボリュームの検出は、セクタ0、第一区画~第四区画の順に行われます。</p>
|
||||
<p>デフォルトの構成では、それぞれの論理ドライブは同じ番号の物理ドライブに1:1で結びつけられていて、自動検出機能によりその物理ドライブ上の一つのFATボリュームがマウントされます。FATボリュームの検出は、セクタ0(SFD)、第一区画~第四区画(FDISK)の順に行われます。</p>
|
||||
<p><tt><a href="config.html#multi_partition">_MULTI_PARTITION</a></tt>に1を指定すると、それぞれの論理ドライブに対して個別に物理ドライブ番号と区画を指定できるようになります。この構成では、論理ドライブと区画の対応を解決するためのテーブルを次に示すように定義する必要があります。</p>
|
||||
<pre>
|
||||
例:論理ドライブ0~2を物理ドライブ0(非リムーバブル)の3つの基本区画に割り当て、
|
||||
論理ドライブ3を物理ドライブ1(リムーバブル)に割り当てる場合。
|
||||
|
||||
PARTITION VolToPart[] = {
|
||||
{0, 1}, <span class="c">/* 論理ドライブ 0 ==> 物理ドライブ 0, 第1区画 */</span>
|
||||
{0, 2}, <span class="c">/* 論理ドライブ 1 ==> 物理ドライブ 0, 第2区画 */</span>
|
||||
{0, 3}, <span class="c">/* 論理ドライブ 2 ==> 物理ドライブ 0, 第3区画 */</span>
|
||||
{1, 0} <span class="c">/* 論理ドライブ 3 ==> 物理ドライブ 1, 自動検出 */</span>
|
||||
{0, 1}, <span class="c">/* "0:" ==> 物理ドライブ 0, 第1区画 */</span>
|
||||
{0, 2}, <span class="c">/* "1:" ==> 物理ドライブ 0, 第2区画 */</span>
|
||||
{0, 3}, <span class="c">/* "2:" ==> 物理ドライブ 0, 第3区画 */</span>
|
||||
{1, 0} <span class="c">/* "3:" ==> 物理ドライブ 1, 自動検出 */</span>
|
||||
};
|
||||
</pre>
|
||||
<div><img src="../img/f7.png" width="828" height="288" alt="論理ドライブと物理ドライブの関係"></div>
|
||||
<div><img src="../res/f7.png" width="828" height="288" alt="論理ドライブと物理ドライブの関係"></div>
|
||||
<p>複数区画指定を使用する場合、次の点に注意しなければなりません。
|
||||
<ul>
|
||||
<li>複数のマウントされた区画を持つ物理ドライブは、非リムーバブルでなければならず、システム動作中のメディア交換は禁止。</li>
|
||||
|
@ -62,7 +62,7 @@ FRESULT f_findfirst (
|
||||
<div class="para desc">
|
||||
<h4>解説</h4>
|
||||
<p><tt class="arg">path</tt>で指定されるディレクトリを開き、そのディレクトリ内の項目の検索を開始します。正常終了すると、ディレクトリ オブジェクト構造体が作成され、最初に検索名文字列に名前がマッチした項目の情報が<tt class="arg">fno</tt>の指定するファイル情報構造体にストアされます。名前のマッチする項目が見つからなかった場合は、<tt>fno->fname[]</tt>にヌル文字列が返されます。ファイル情報構造体の使い方については、<a href="readdir.html"><tt>f_readdir</tt></a>関数を参照してください。</p>
|
||||
<p>マッチ パターン文字列は、ワイルドカード文字(<tt>?</tt>と<tt>*</tt>)を含むことができます。<tt>?</tt>は任意の1文字に、<tt>*</tt>は0文字以上の任意の文字列にマッチします。LFN構成では、SFNとLFN(あれば)の両方に対してテストを行います。現リビジョンではパターン マッチングにおいて次の点で標準システムとは異なる動作となります。</p>
|
||||
<p>マッチ パターン文字列は、ワイルドカード文字(<tt>?</tt>と<tt>*</tt>)を含むことができます。<tt>?</tt>は任意の1文字に、<tt>*</tt>は0文字以上の任意の文字列にマッチします。LFN構成では、<tt>_USE_FIND = 1</tt>のとき<tt>fname[]</tt>のみテストし、<tt>_USE_FIND = 2</tt>のときは<tt>altname[]</tt>もテストします。現リビジョンではパターン マッチングにおいて次の点で標準システムとは異なる動作となります。</p>
|
||||
<ul>
|
||||
<li><tt>"*.*"</tt>は拡張子なしの名前にマッチしない。(標準システムでは全ての名前にマッチ)</li>
|
||||
<li>ピリオドで終わるパターンは、どの名前にもマッチしない。(標準システムでは拡張子無しの名前にマッチ)</li>
|
||||
@ -73,7 +73,7 @@ FRESULT f_findfirst (
|
||||
|
||||
<div class="para comp">
|
||||
<h4>対応情報</h4>
|
||||
<p>この関数は、<a href="opendir.html"><tt>f_opendir</tt></a>関数および<a href="readdir.html"><tt>f_readdir</tt></a>関数のラッパー関数です。<tt>_USE_FIND == 1</tt>で、かつ<tt>_FS_MINIMIZE <= 1</tt>のとき使用可能になります。</p>
|
||||
<p>この関数は、<a href="opendir.html"><tt>f_opendir</tt></a>関数および<a href="readdir.html"><tt>f_readdir</tt></a>関数のラッパー関数です。<tt>_USE_FIND >= 1</tt>で、かつ<tt>_FS_MINIMIZE <= 1</tt>のとき使用可能になります。</p>
|
||||
</div>
|
||||
|
||||
|
||||
@ -84,23 +84,14 @@ FRESULT f_findfirst (
|
||||
|
||||
void find_image (void)
|
||||
{
|
||||
FRESULT fr; <span class="c">/* 戻り値 */</span>
|
||||
FRESULT fr; <span class="c">/* API戻り値 */</span>
|
||||
DIR dj; <span class="c">/* ディレクトリ オブジェクト */</span>
|
||||
FILINFO fno; <span class="c">/* ファイル情報構造体 */</span>
|
||||
<span class="k">#if</span> _USE_LFN
|
||||
char lfn[_MAX_LFN + 1];
|
||||
fno.lfname = lfn;
|
||||
fno.lfsize = _MAX_LFN + 1;
|
||||
<span class="k">#endif</span>
|
||||
FILINFO fno; <span class="c">/* ファイル情報 */</span>
|
||||
|
||||
fr = f_findfirst(&dj, &fno, "", "dsc*.jpg"); <span class="c">/* "dsc"で始まるJPEGファイルを検索 */</span>
|
||||
|
||||
while (fr == FR_OK && fno.fname[0]) { <span class="c">/* 見つかる間繰り返し */</span>
|
||||
<span class="k">#if</span> _USE_LFN
|
||||
printf("%s %s\n", fno.fname, fno.lfname);<span class="c">/* 見つけた項目の名前を表示 */</span>
|
||||
<span class="k">#else</span>
|
||||
printf("%s\n", fno.fname);
|
||||
<span class="k">#endif</span>
|
||||
printf("%s\n", fno.fname); <span class="c">/* 見つけた項目の名前を表示 */</span>
|
||||
fr = f_findnext(&dj, &fno); <span class="c">/* 次を検索 */</span>
|
||||
}
|
||||
f_closedir(&dj);
|
||||
|
@ -54,7 +54,7 @@ FRESULT f_findnext (
|
||||
|
||||
<div class="para comp">
|
||||
<h4>対応情報</h4>
|
||||
<p>この関数は、<a href="readdir.html"><tt>f_readdir</tt></a>関数のラッパー関数です。<tt>_USE_FIND == 1</tt>で、かつ<tt>_FS_MINIMIZE <= 1</tt>のとき使用可能になります。</p>
|
||||
<p>この関数は、<a href="readdir.html"><tt>f_readdir</tt></a>関数のラッパー関数です。<tt>_USE_FIND >= 1</tt>で、かつ<tt>_FS_MINIMIZE <= 1</tt>のとき使用可能になります。</p>
|
||||
</div>
|
||||
|
||||
|
||||
|
@ -60,7 +60,7 @@ FRESULT f_forward (
|
||||
|
||||
<div class="para comp">
|
||||
<h4>対応情報</h4>
|
||||
<p><tt>_USE_FORWARD == 1</tt>で、且つ<tt>_FS_TINY == 1</tt>のときに使用可能です。</p>
|
||||
<p><tt>_USE_FORWARD == 1</tt>のときに使用可能です。</p>
|
||||
</div>
|
||||
|
||||
|
||||
@ -113,7 +113,7 @@ FRESULT play_file (
|
||||
if (rc) return rc;
|
||||
|
||||
<span class="c">/* 全てのデータが転送されるかエラーが発生するまで続ける */</span>
|
||||
while (rc == FR_OK && !f_eof(&fil)) {
|
||||
while (rc == FR_OK && !f_eof(&fil)) {
|
||||
|
||||
<span class="c">/* ほかの処理... */</span>
|
||||
|
||||
|
@ -51,6 +51,7 @@ FRESULT f_getcwd (
|
||||
<div class="para desc">
|
||||
<h4>解説</h4>
|
||||
<p>カレント ドライブのカレント ディレクトリのフル パス文字列を取得します。<tt>_VOLUMES</tt>が2以上のときは、論理ドライブ番号の付加されたパス名となります。</p>
|
||||
<p><em>現リビジョン(R0.12)では、exFATボリューム上ではカレント ディレクトリを得ることが出来ません。常にルート ディレクトリを返します。</em></p>
|
||||
</div>
|
||||
|
||||
|
||||
|
@ -78,7 +78,7 @@ FRESULT f_getfree (
|
||||
tot_sect = (fs->n_fatent - 2) * fs->csize;
|
||||
fre_sect = fre_clust * fs->csize;
|
||||
|
||||
<span class="c">/* ボリューム全体のサイズと空きのサイズを表示 (512バイト/セクタと仮定) */</span>
|
||||
<span class="c">/* ボリュームのサイズと空きサイズを表示 (512バイト/セクタと仮定) */</span>
|
||||
printf("%10lu KiB total drive space.\n%10lu KiB available.\n",
|
||||
tot_sect / 2, fre_sect / 2);
|
||||
</pre>
|
||||
|
@ -29,7 +29,7 @@ FRESULT f_getlabel (
|
||||
<dt>path</dt>
|
||||
<dd>対象となる論理ドライブの<a href="filename.html">パス名</a>を示すヌル文字<tt>'\0'</tt>終端の文字列へのポインタを指定します。ヌル文字列の場合は、デフォルト ドライブを指定したことになります。</dd>
|
||||
<dt>label</dt>
|
||||
<dd>ボリューム名を格納する配列へのポインタを指定します。少なくとも12要素のサイズが必要です。ボリューム名がない場合はヌル文字列が返されます。この情報が不要なときはヌル ポインタを指定してください。</dd>
|
||||
<dd>ボリューム名を格納する配列へのポインタを指定します。<tt>_LFN_UNICODE == 0</tt>では少なくとも24要素、<tt>_LFN_UNICODE == 1</tt>では少なくとも12要素のサイズが必要です。ボリューム名がない場合はヌル文字列が返されます。この情報が不要なときはヌル ポインタを指定してください。</dd>
|
||||
<dt>vsn</dt>
|
||||
<dd>ボリューム シリアル番号を格納する<tt>DWORD</tt>型変数へのポインタを指定します。この情報が不要なときはヌル ポインタを指定してください。</dd>
|
||||
</dl>
|
||||
@ -60,7 +60,7 @@ FRESULT f_getlabel (
|
||||
<div class="para use">
|
||||
<h4>使用例</h4>
|
||||
<pre>
|
||||
char str[12];
|
||||
char str[24];
|
||||
|
||||
<span class="c">/* デフォルト ドライブのボリューム名を得る */</span>
|
||||
f_getlabel("", str, 0);
|
||||
|
@ -16,8 +16,8 @@
|
||||
<p>ファイルのリード/ライト ポインタを移動します。また、高速シーク機能使用時にはCLMT(後述)の作成にも使用します。</p>
|
||||
<pre>
|
||||
FRESULT f_lseek (
|
||||
FIL* <span class="arg">fp</span>, <span class="c">/* [IN] ファイル オブジェクト構造体へのポインタ */</span>
|
||||
DWORD <span class="arg">ofs</span> <span class="c">/* [IN] 移動先オフセット */</span>
|
||||
FIL* <span class="arg">fp</span>, <span class="c">/* [IN] ファイル オブジェクト構造体へのポインタ */</span>
|
||||
FSIZE_t <span class="arg">ofs</span> <span class="c">/* [IN] 移動先オフセット */</span>
|
||||
);
|
||||
</pre>
|
||||
</div>
|
||||
@ -28,7 +28,7 @@ FRESULT f_lseek (
|
||||
<dt>fp</dt>
|
||||
<dd>対象となるファイル オブジェクト構造体へのポインタを指定します。</dd>
|
||||
<dt>ofs</dt>
|
||||
<dd>移動先のオフセット(リード/ライト ポインタ)値。ファイル先頭からのオフセットをバイト単位で指定します。</dd>
|
||||
<dd>移動先のオフセット(リード/ライト ポインタ)値。ファイル先頭からのオフセットをバイト単位で指定します。データ型<tt>FSIZE_t</tt>は、<tt>DWORD</tt>(32-bit)または<tt>QWORD</tt>(64-bit)のエリアスで、exFATサポートの有無により切り替わります。</dd>
|
||||
</dl>
|
||||
</div>
|
||||
|
||||
@ -48,7 +48,7 @@ FRESULT f_lseek (
|
||||
|
||||
<div class="para desc">
|
||||
<h4>解説</h4>
|
||||
<p>ファイルのリード/ライト ポインタ(次に読み出し・書き込みされるバイトのオフセット)を移動します。オフセットの原点はファイル先頭です。書き込みモードでファイル サイズより大きな値を指定すると、そこまでファイル サイズが拡張され、拡張された部分のデータは未定義となります。データを遅延無く高速に書き込みたいときは、予めこの関数で必要なサイズまでファイル サイズを拡張しておくと良いでしょう。<tt>f_lseek</tt>関数が正常終了したあとは、リード/ライト ポインタが正しく移動したかチェックするべきです。リード/ライト ポインタが指定より小さいときは、次の原因が考えられます。</p>
|
||||
<p>ファイルのリード/ライト ポインタ(次に読み出し・書き込みされるバイトのオフセット)を移動します。オフセットの原点はファイル先頭です。書き込みモードでファイル サイズより大きな値を指定すると、そこまでファイル サイズが拡張され、拡張された部分のデータは未定義となります。データを遅延無く高速に書き込みたいときは、予めこの関数で必要なサイズまでファイル サイズを拡張しておくと良いでしょう。ファイルに連続したデータ領域を割り当てる必要があるときは、<tt>f_expand</tt>関数を使用してください。<tt>f_lseek</tt>関数が正常終了したあとは、リード/ライト ポインタが正しく移動したかチェックするべきです。リード/ライト ポインタが指定より小さいときは、次の原因が考えられます。</p>
|
||||
<ul>
|
||||
<li>非書き込みモードまたは高速シーク モードのため、ファイル サイズでクリップされた。</li>
|
||||
<li>ファイル拡張中にディスクが満杯になった。</li>
|
||||
@ -122,7 +122,7 @@ FRESULT f_lseek (
|
||||
|
||||
<div class="para ref">
|
||||
<h4>参照</h4>
|
||||
<p><tt><a href="open.html">f_open</a>, <a href="sfile.html">FIL</a></tt></p>
|
||||
<p><tt><a href="open.html">f_open</a>, <a href="truncate.html">f_truncate</a>, <a href="expand.html">f_expand</a>, <a href="sfile.html">FIL</a></tt></p>
|
||||
</div>
|
||||
|
||||
<p class="foot"><a href="../00index_j.html">戻る</a></p>
|
||||
|
@ -13,12 +13,14 @@
|
||||
|
||||
<div class="para func">
|
||||
<h2>f_mkfs</h2>
|
||||
<p>論理ドライブ上にFATボリュームを作成します。</p>
|
||||
<p>論理ドライブ上にFAT/exFATボリュームを作成(フォーマット)します。</p>
|
||||
<pre>
|
||||
FRESULT f_mkfs (
|
||||
const TCHAR* <span class="arg">path</span>, <span class="c">/* [IN] 論理ドライブ番号 */</span>
|
||||
BYTE <span class="arg">sfd</span>, <span class="c">/* [IN] 区画作成方法 */</span>
|
||||
UINT <span class="arg">au</span> <span class="c">/* [IN] クラス タサイズ */</span>
|
||||
const TCHAR* <span class="arg">path</span>, <span class="c">/* [IN] 論理ドライブ番号 */</span>
|
||||
BYTE <span class="arg">opt</span>, <span class="c">/* [IN] フォーマット オプション */</span>
|
||||
DWORD <span class="arg">au</span>, <span class="c">/* [IN] クラスタ サイズ */</span>
|
||||
void* <span class="arg">work</span>, <span class="c">/* [-] ワーク エリア */</span>
|
||||
UINT <span class="arg">len</span> <span class="c">/* [IN] ワーク エリアのサイズ */</span>
|
||||
);
|
||||
</pre>
|
||||
</div>
|
||||
@ -27,11 +29,15 @@ FRESULT f_mkfs (
|
||||
<h4>引数</h4>
|
||||
<dl class="par">
|
||||
<dt>path</dt>
|
||||
<dd>対象の論理ドライブを示す<a href="filename.html">パス名</a>を示すヌル文字<tt>'\0'</tt>終端の文字列へのポインタを指定します。ドライブ番号を含まない場合は、カレント ドライブを意味します。</dd>
|
||||
<dt>sfd</dt>
|
||||
<dd>パーテーション形式。(0(FDISK) または 1(SFD))</dd>
|
||||
<dd>フォーマット対象の論理ドライブを示す<a href="filename.html">パス名</a>を示すヌル文字<tt>'\0'</tt>終端の文字列へのポインタを指定します。ドライブ番号を含まない場合は、デフォルト ドライブを意味します。論理ドライブには<tt>f_mount</tt>関数でワークエリアが与えられている必要はありません。</dd>
|
||||
<dt>opt</dt>
|
||||
<dd>フォーマット オプション。<tt>FM_FAT, FM_FAT32, FM_EXFAT</tt>の各フラグの組み合わせ(<tt>FM_ANY</tt>は、これらのOR値)で作成するFATボリュームのタイプを指定します。複数のタイプが指定された場合、その中のいずれかが自動選択されます。exFATが無効のときは、<tt>FM_EXFAT</tt>は無視されます。<tt>FM_SFD</tt>フラグを指定すると、SFD形式(後述)でボリュームを配置します。</dd>
|
||||
<dt>au</dt>
|
||||
<dd>クラスタ サイズをバイト数またはセクタ数で指定します。値が1~128の範囲場合は、セクタ数を示します。値が<tt>_MIN_SS</tt>以上の場合は、バイト数を示します。無効値(0または2の累乗でない値など)を指定した場合、ボリュームのサイズに応じたデフォルトのクラスタ サイズが自動選択されます。</dd>
|
||||
<dd>クラスタ サイズをバイト単位で指定します。有効値は、セクタ サイズのN倍となります。Nは2の累乗で、FAT/FAT32ボリュームでは1~128、exFATボリュームでは1~32768です。0を指定した場合は、ボリュームのサイズと選択されたFATタイプに応じたデフォルトのクラスタ サイズが選択されます。</dd>
|
||||
<dt>work</dt>
|
||||
<dd>ワークエリアへのポインタを指定します。</dd>
|
||||
<dt>len</dt>
|
||||
<dd>ワークエリアのサイズをバイト単位で指定します。ワークエリアのサイズは少なくとも関連するドライブのセクタサイズは必要です。また、十分に大きなサイズを与えることにより、書き込みトランザクションの回数が減ってフォーマット時間を短縮できます。</dd>
|
||||
</dl>
|
||||
</div>
|
||||
|
||||
@ -41,7 +47,6 @@ FRESULT f_mkfs (
|
||||
<a href="rc.html#ok">FR_OK</a>,
|
||||
<a href="rc.html#de">FR_DISK_ERR</a>,
|
||||
<a href="rc.html#nr">FR_NOT_READY</a>,
|
||||
<a href="rc.html#ne">FR_NOT_ENABLED</a>,
|
||||
<a href="rc.html#ma">FR_MKFS_ABORTED</a>,
|
||||
<a href="rc.html#ip">FR_INVALID_PARAMETER</a>
|
||||
</p>
|
||||
@ -49,14 +54,13 @@ FRESULT f_mkfs (
|
||||
|
||||
<div class="para desc">
|
||||
<h4>説明</h4>
|
||||
<p>物理ドライブ上にFATボリュームを作成(フォーマット)します。FDISK形式が指定された場合は、物理ドライブ全体を占める基本区画(パーテーション)が作成され、その中にFATボリュームが作成されます。SFD形式では、FATボリュームが物理ドライブの先頭セクタからベタで作成されます。</p>
|
||||
<p>マルチ パーテーション機能(<tt><a href="config.html#multi_partition">_MULTI_PARTITION</a></tt>)が有効で、かつフォーマット対象の論理ドライブが特定の区画(1~4)に結び付けられている場合は、その区画の中にFATボリュームが作成されます。<tt class="arg">sfd</tt>は無視され、その物理ドライブはこれに先立ち、<tt>f_fdisk</tt>関数または他のツールで適切に区画設定されている必要があります。</p>
|
||||
<p>パーテーション形式には、FDISK形式とSFD形式の二通りあります。FDISK形式は、ハードディスク、MMC、SDC、CFC、U Diskなどで標準的に使用されます。FDISK形式では一台の物理ドライブ上に一つまたは複数の区画を作成することができます。区画管理情報はMBR(物理ドライブの先頭セクタ)に記録されます。SFD形式は単に何の分割も行わない形式で、ボリュームは物理ドライブの先頭セクタから開始します。SFD形式は、フロッピー ディスク、マイクロドライブ、光学ディスク、およびその他スーパー フロッピー メディアで標準的に使用されています。</p>
|
||||
<p>FATタイプ(FAT12/FAT16/FAT32)は、そのボリューム上の<em>クラスタ数によってのみ決定</em>される決まり[FAT仕様書より]になっていて、それ以外の要因はありません。したがって、どのFATタイプになるかはボリューム サイズとクラスタ サイズに依存します。クラスタ サイズは大きくするほど性能が上がります。</p>
|
||||
<p>クラスタ数がFATタイプの境界に近くなるときは、<tt>FR_MKFS_ABORTED</tt>で関数が失敗する可能性があります。</p>
|
||||
<p>exFAT以外のボリュームのFATタイプ(FAT12/FAT16/FAT32)は、そのボリューム上の<em>クラスタ数によってのみ決定</em>される決まり[FAT仕様書より]になっていて、それ以外の要因はありません。したがって、どのFATタイプになるかはボリューム サイズとクラスタ サイズに依存します。そのボリュームのサイズにおいて、指定されたFATタイプとクラスタ サイズの組み合わせが成立し得ないときは、関数は<tt>FR_MKFS_ABORTED</tt>で失敗します。</p>
|
||||
<p>クラスタとは、データ格納領域の管理の単位のことで、これを単位にファイルにデータ領域が割り当てられます。たとえば、クラスタ サイズが32768のときは、100バイトのファイルも32768バイトのスペースを消費することになります。このように、クラスタ サイズを大きくするほどボリュームの利用効率が悪くなりますが、その一方で読み書きの性能は上がります。クラスタ サイズによる利用効率と性能はトレード オフの関係にあります。GBクラスのストレージでは、極端に多くのファイルを扱わない限り32768バイト以上に(デフォルト指定ではそのようになる)しておくとよいでしょう。</p>
|
||||
<p>パーテーション形式には、FDISK形式とSFD形式の二通りあります。FDISK形式は、ハードディスク、マルチメディアカード、SDカード、CFカード、USBメモリなどで標準的に使用されます。FDISK形式では一台の物理ドライブ上に一つまたは複数の区画を作成することができ、区画管理情報はMBR(物理ドライブの先頭セクタ)に記録されます。SFD形式は単に何の分割も行わない形式で、ボリュームは物理ドライブの先頭セクタから開始します。SFD形式は、フロッピー ディスク、マイクロドライブ、光学ディスク、およびその他スーパー フロッピー メディアで標準的に使用されています。システムによっては、FDISK形式またはSFD形式のどちらか一方のみをサポートし他方をサポートしません。</p>
|
||||
<p><tt>FM_SFD</tt>が指定されないときはFDISK形式となり、その物理ドライブ全体を占める1個の基本区画(パーテーション)が作成され、その中にFATボリュームが作成されます。<tt>FM_SFD</tt>が指定されたときはSFD形式となり、FATボリュームがその物理ドライブの先頭セクタからベタで作成されます。</p>
|
||||
<p>マルチ パーテーション機能(<tt><a href="config.html#multi_partition">_MULTI_PARTITION</a></tt>)により、その論理ドライブが特定の区画(1~4)に結び付けられている場合は、その区画の中にFATボリュームが作成されます。<tt>FM_SFD</tt>の指定は無視され、その物理ドライブはこれに先立ち、<tt>f_fdisk</tt>関数または他のツールで適切に区画設定されている必要があります。</p>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="para comp">
|
||||
<h4>対応情報</h4>
|
||||
<p><tt>_FS_READONLY == 0</tt>で、且つ<tt>_USE_MKFS == 1</tt>のとき使用可能です。</p>
|
||||
@ -69,19 +73,20 @@ FRESULT f_mkfs (
|
||||
<span class="c">/* Format default drive and create a file */</span>
|
||||
int main (void)
|
||||
{
|
||||
FATFS fs; <span class="c">/* File system object (volume work area) */</span>
|
||||
FIL fil; <span class="c">/* File object */</span>
|
||||
FRESULT res; <span class="c">/* API result code */</span>
|
||||
UINT bw; <span class="c">/* Bytes written */</span>
|
||||
FATFS fs; <span class="c">/* File system object */</span>
|
||||
FIL fil; <span class="c">/* File object */</span>
|
||||
FRESULT res; <span class="c">/* API result code */</span>
|
||||
UINT bw; <span class="c">/* Bytes written */</span>
|
||||
BYTE work[_MAX_SS]; <span class="c">/* Work area (larger is better for process time) */</span>
|
||||
|
||||
|
||||
<span class="c">/* Register work area (do not care about error) */</span>
|
||||
f_mount(&fs, "", 0);
|
||||
|
||||
<span class="c">/* Create FAT volume with default cluster size */</span>
|
||||
res = f_mkfs("", 0, 0);
|
||||
<span class="c">/* Create FAT volume */</span>
|
||||
res = f_mkfs("", FM_ANY, 0, work, sizeof work);
|
||||
if (res) ...
|
||||
|
||||
<span class="c">/* Register work area */</span>
|
||||
f_mount(&fs, "", 0);
|
||||
|
||||
<span class="c">/* Create a file as new */</span>
|
||||
res = f_open(&fil, "hello.txt", FA_CREATE_NEW | FA_WRITE);
|
||||
if (res) ...
|
||||
@ -93,15 +98,14 @@ int main (void)
|
||||
<span class="c">/* Close the file */</span>
|
||||
f_close(&fil);
|
||||
|
||||
<span class="c">/* Unregister work area */</span>
|
||||
f_mount(0, "", 0);
|
||||
...
|
||||
</pre>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="para ref">
|
||||
<h4>参照</h4>
|
||||
<p><tt><a href="filename.html#vol">ボリューム管理</a>, <a href="fdisk.html">f_fdisk</a></tt></p>
|
||||
<p><a href="../res/mkfs.xls">ボリューム サイズとフォーマット パラメータ</a>, <a href="filename.html#vol">ボリューム管理</a>, <tt><a href="fdisk.html">f_fdisk</a></tt></p>
|
||||
</div>
|
||||
|
||||
|
||||
|
@ -18,7 +18,7 @@
|
||||
FRESULT f_mount (
|
||||
FATFS* <span class="arg">fs</span>, <span class="c">/* [IN] ファイル システム オブジェクト */</span>
|
||||
const TCHAR* <span class="arg">path</span>, <span class="c">/* [IN] 論理ドライブ番号 */</span>
|
||||
BYTE <span class="arg">opt</span> <span class="c">/* [IN] オプション */</span>
|
||||
BYTE <span class="arg">opt</span> <span class="c">/* [IN] 動作オプション */</span>
|
||||
);
|
||||
</pre>
|
||||
</div>
|
||||
|
@ -37,9 +37,10 @@ FRESULT f_open (
|
||||
<tr><td>FA_READ</td><td>読み出しモードで開きます。読み書きする場合は<tt>FA_WRITE</tt>と共に指定します。</td></tr>
|
||||
<tr><td>FA_WRITE</td><td>書き込みモードで開きます。読み書きする場合は<tt>FA_READ</tt>と共に指定します。</td></tr>
|
||||
<tr><td>FA_OPEN_EXISTING</td><td>既存のファイルを開きます。ファイルが無いときはエラーになります。(デフォルト)</td></tr>
|
||||
<tr><td>FA_OPEN_ALWAYS</td><td>既存のファイルを開きます。ファイルが無いときはファイルを作成します。追記の場合は、この方法でオープンした後、<a href="lseek.html"><tt>f_lseek</tt></a>関数でファイルの最後尾に移動してください。</td></tr>
|
||||
<tr><td>FA_CREATE_NEW</td><td>ファイルを作成します。同名のファイルがある場合は、<tt>FR_EXIST</tt>で失敗します。</td></tr>
|
||||
<tr><td>FA_CREATE_ALWAYS</td><td>ファイルを作成します。同名のファイルがある場合は、サイズを0にしてから開きます。</td></tr>
|
||||
<tr><td>FA_OPEN_ALWAYS</td><td>既存のファイルを開きます。ファイルが無いときはファイルを作成します。</td></tr>
|
||||
<tr><td>FA_OPEN_APPEND</td><td><tt>FA_OPEN_ALWAYS</tt>と同じですが、リード/ライト ポインタはファイルの最後尾にセットされます。</td></tr>
|
||||
</table>
|
||||
</dd>
|
||||
</dl>
|
||||
@ -75,13 +76,13 @@ FRESULT f_open (
|
||||
<h4>解説</h4>
|
||||
<p>既存のファイルを開いたり、新しいファイルを作成します。関数が成功するとファイル オブジェクトが作成され、以降そのファイルに対するアクセスに使用します。ファイルを閉じるときは、<a href="close.html"><tt>f_close</tt></a>関数を使用します。何らかの変更が行われたファイルがその後正しく閉じられなかった場合、そのファイルが破損する場合があります。</p>
|
||||
<p>既に開かれているファイルを開く必要がある場合は、<a href="appnote.html#dup">多重アクセス制御</a>を参照してください。しかし、一つのファイルに対する書き込みモードを含む重複オープンは常に禁止です。</p>
|
||||
<p>ファイル アクセスを開始する前に、<a href="mount.html"><tt>f_mount</tt></a>関数を使ってそれぞれの論理ドライブにワーク エリア(ファイル システム オブジェクト)を与える必要があります。この初期化の後、その論理ドライブに対して全てのファイル関数が使えるようになります。</p>
|
||||
<p>ファイル アクセスを開始する前に、<a href="mount.html"><tt>f_mount</tt></a>関数を使ってそれぞれの論理ドライブにワーク エリア(ファイル システム オブジェクト)を与える必要があります。この初期化の後、その論理ドライブに対して全てのファイル関数が使えるようになります。<tt>f_mkfs</tt>関数と<tt>f_fdsk</tt>関数は、ワークエリア無しでも使えます。</p>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="para comp">
|
||||
<h4>対応情報</h4>
|
||||
<p>全ての構成で使用可能です。<tt>_FS_READONLY == 1</tt>のときは、<tt>FA_WRITE, FA_CREATE_ALWAYS, FA_CREATE_NEW, FA_OPEN_ALWAYS</tt>の各フラグはサポートされません。</p>
|
||||
<p>全ての構成で使用可能です。<tt>_FS_READONLY == 1</tt>のときは、<tt>FA_READ</tt>と<tt>FA_OPEN_EXISTING</tt>以外の各フラグはサポートされません。</p>
|
||||
</div>
|
||||
|
||||
|
||||
|
@ -37,11 +37,11 @@
|
||||
<dd>そのオブジェクトに対する操作の拒否。原因としては次のようなことが考えられます。
|
||||
<ul>
|
||||
<li>書き込み禁止属性(<tt>AM_RDO</tt>)を持つファイルを書き込みモードで開こうとした。</li>
|
||||
<li>書き込み禁止属性を持つファイルやディレクトリを削除しようとした。</li>
|
||||
<li>書き込み禁止属性を持つオブジェクトを削除しようとした。</li>
|
||||
<li>空でないディレクトリまたはカレント ディレクトリを削除しようとした。</li>
|
||||
<li><tt>FA_READ</tt>フラグを付けずに開いたファイルに対して読み出しを行った。</li>
|
||||
<li><tt>FA_WRITE</tt>フラグを付けずに開いたファイルに対して書き込みまたはそれに類する操作を行った。</li>
|
||||
<li>ボリュームまたはディレクトリ テーブルが満杯でファイルやディレクトリを作成できなかった。</li>
|
||||
<li><tt>FA_WRITE</tt>フラグを付けずに開いたファイルに対して変更を加えようとした。</li>
|
||||
<li>ボリュームまたは静的ディレクトリが満杯でオブジェクトの新規作成ができなかった。</li>
|
||||
</ul>
|
||||
</dd>
|
||||
<dt id="ex">FR_EXIST</dt>
|
||||
@ -65,8 +65,9 @@
|
||||
<dt id="ma">FR_MKFS_ABORTED</dt>
|
||||
<dd><tt>f_mkfs</tt>関数の処理が開始前に中断された。原因としては次のようなことが考えられます。
|
||||
<ul>
|
||||
<li>ボリュームが小さすぎる。</li>
|
||||
<li>FATタイプの計算に矛盾が見つかった。クラスタ数がFATタイプの境界付近になるときに発生する場合があります。</li>
|
||||
<li>指定されたパラメータでのフォーマットが不可能。</li>
|
||||
<li>ボリュームのサイズが小さすぎる。</li>
|
||||
<li>与えられたワークエリアが小さすぎる。</li>
|
||||
<li>その論理ドライブに対応する区画が見つからなかった。(関連オプション: <tt><a href="config.html#multi_partition">_MULTI_PARTITION</a></tt>)</li>
|
||||
</ul>
|
||||
</dd>
|
||||
|
@ -28,7 +28,7 @@ FRESULT f_readdir (
|
||||
<dt>dp</dt>
|
||||
<dd><tt>f_opendir</tt>関数で作成された有効なディレクトリ オブジェクトへのポインタを指定します。</dd>
|
||||
<dt>fno</dt>
|
||||
<dd>読み出したディレクトリ項目を格納するファイル情報構造体へのポインタを指定します。</dd>
|
||||
<dd>読み出したディレクトリ項目を格納する<a href="sfileinfo.html">ファイル情報構造体</a>へのポインタ、またはヌル ポインタを指定します。</dd>
|
||||
</dl>
|
||||
</div>
|
||||
|
||||
@ -48,17 +48,16 @@ FRESULT f_readdir (
|
||||
|
||||
<div class="para desc">
|
||||
<h4>解説</h4>
|
||||
<p>ディレクトリの項目(ファイルおよびサブ ディレクトリ)を順次読み出します。この関数を繰り返し実行することによりそのディレクトリの全ての項目を読み出すことができます。得られるファイル情報の詳細については <tt>FILINFO</tt>構造体を参照してください。全ての項目が読み出され、読み出す項目がもう無いときは、<tt>fno->fname[]</tt>にヌル文字列が返されます。<tt class="arg">fno</tt>にヌル ポインタを指定すると、そのディレクトリのリード インデックスを先頭に巻き戻します。また、この関数は次に示すように関連する構成オプションにより動作が変わります。</p>
|
||||
<p>ドット エントリ(<tt>"."</tt>と<tt>".."</tt>)は、相対パスが有効なとき(<tt><a href="config.html#fs_rpath">_FS_RPATH</a> >= 1</tt>)にのみ出力に現れます。</p>
|
||||
<p>LFN機能が有効な時は、この関数の呼び出しに先立って<tt>fno->lfname</tt>と<tt>fno->lfsize</tt>が有効な値で初期化されていなければなりません。<tt>lfname</tt>はLFNを格納するバッファを示し、<tt>lfsize</tt>はそのバッファの要素数を示します。LFNを読み出す必要がないときは、<tt>lfname</tt>にヌル ポインタをセットしてください。次の条件に一つでも該当する場合は、LFN格納バッファにヌル文字列が返されます。</p>
|
||||
<p>ディレクトリの項目(ファイルおよびサブ ディレクトリ)の情報を順次読み出します。この関数を繰り返し実行することによりそのディレクトリの全ての項目を読み出すことができます。得られるファイル情報の詳細については <tt>FILINFO</tt>構造体を参照してください。全ての項目が読み出され、読み出す項目がもう無いときは、<tt>fno->fname[]</tt>にヌル文字列が返されます。<tt class="arg">fno</tt>にヌル ポインタを指定すると、そのディレクトリのリード インデックスを先頭に巻き戻します。サブ ディレクトリのドット エントリ(<tt>"."</tt>と<tt>".."</tt>)は、出力に現れません。</p>
|
||||
<p>LFN構成では、<tt>altname[]</tt>が新たに定義され、そのオブジェクトの短いファイル名がストアされます。次の条件のときは長いファイル名を返せないので<tt>fname[]</tt>に短いファイル名がストアされ、<tt>altname[]</tt>はヌル文字列になります。</p>
|
||||
<ul>
|
||||
<li>その項目にLFNが存在しない。このとき、<tt>fname[]</tt>に英小文字が含まれる場合があります。</li>
|
||||
<li>LFNの長さに対してLFN格納バッファまたはLFN操作バッファのサイズが不十分。</li>
|
||||
<li>LFNに現在のOEMコードで表現できない文字が含まれている。(非Unicode構成のとき)</li>
|
||||
<li>オブジェクトが長いファイル名を持っていない。(exFATボリュームでは該当せず)</li>
|
||||
<li><tt>_MAX_LFN</tt>の設定がその長いファイル名の長さに対して不十分 (<tt>_MAX_LFN == 255</tt>では該当せず)</li>
|
||||
<li>長いファイル名にANSI/OEMコードに無い文字が含まれている。(<tt>_LFN_UNICODE == 1</tt>では該当せず)</li>
|
||||
</ul>
|
||||
<p>exFATボリュームのディレクトリを読み出すとき、構成によっては問題が発生します。exFATでは短いファイル名がサポートされません。つまり、上記の条件のとき代わりに返すファイル名が無いということです。このような場合は<tt>fname[]</tt>に"?"が返され、そのオブジェクトにアクセスできないことを示します。この問題を避けるには、FatFsの構成を<tt>_LFN_UNICODE = 1</tt>および<tt>_MAX_LFN = 255</tt>として長いファイル名に完全対応とする必要があります。</p>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="para comp">
|
||||
<h4>対応情報</h4>
|
||||
<p><tt>_FS_MINIMIZE <= 1</tt>のときに使用可能です。</p>
|
||||
@ -68,44 +67,50 @@ FRESULT f_readdir (
|
||||
<div class="para use">
|
||||
<h4>使用例</h4>
|
||||
<pre>
|
||||
FATFS fs;
|
||||
char buff[256];
|
||||
|
||||
FRESULT scan_files (
|
||||
char* path <span class="c">/* 開始ノード (ワークエリアとしても使用) */</span>
|
||||
)
|
||||
{
|
||||
FRESULT res;
|
||||
FILINFO fno;
|
||||
DIR dir;
|
||||
int i;
|
||||
char *fn; <span class="c">/* 非Unicode構成を想定 */</span>
|
||||
<span class="k">#if</span> _USE_LFN
|
||||
static char lfn[_MAX_LFN + 1];
|
||||
fno.lfname = lfn;
|
||||
fno.lfsize = sizeof lfn;
|
||||
<span class="k">#endif</span>
|
||||
UINT i;
|
||||
static FILINFO fno;
|
||||
|
||||
|
||||
res = f_opendir(&dir, path); <span class="c">/* ディレクトリを開く */</span>
|
||||
if (res == FR_OK) {
|
||||
i = strlen(path);
|
||||
for (;;) {
|
||||
res = f_readdir(&dir, &fno); <span class="c">/* ディレクトリ項目を1個読み出す */</span>
|
||||
if (res != FR_OK || fno.fname[0] == 0) break; <span class="c">/* エラーまたは項目無しのときは抜ける */</span>
|
||||
if (fno.fname[0] == '.') continue; <span class="c">/* ドットエントリは無視 */</span>
|
||||
<span class="k">#if</span> _USE_LFN
|
||||
fn = *fno.lfname ? fno.lfname : fno.fname;
|
||||
<span class="k">#else</span>
|
||||
fn = fno.fname;
|
||||
<span class="k">#endif</span>
|
||||
if (fno.fattrib & AM_DIR) { <span class="c">/* ディレクトリ */</span>
|
||||
sprintf(&path[i], "/%s", fn);
|
||||
res = scan_files(path);
|
||||
path[i] = 0;
|
||||
i = strlen(path);
|
||||
sprintf(&path[i], "/%s", fno.fname);
|
||||
res = scan_files(path); <span class="c">/* 一つ下へ */</span>
|
||||
if (res != FR_OK) break;
|
||||
path[i] = 0;
|
||||
} else { <span class="c">/* ファイル */</span>
|
||||
printf("%s/%s\n", path, fn);
|
||||
printf("%s/%s\n", path, fno.fname);
|
||||
}
|
||||
}
|
||||
f_closedir(&dir);
|
||||
f_closedir(&dir)
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
int main (void)
|
||||
{
|
||||
FRESULT res;
|
||||
|
||||
|
||||
res = f_mount(&fs, "", 1);
|
||||
if (res == FR_OK) {
|
||||
strcpy(buff, "/");
|
||||
res = scan_files(buff);
|
||||
}
|
||||
|
||||
return res;
|
||||
|
@ -16,20 +16,15 @@
|
||||
<p><tt>DIR</tt>構造体は、<tt>f_opendir/f_readdir/f_findfirst/f_findnext</tt>関数のワーク エリアとして使用されます。アプリケーションは、この構造体のメンバを書き換えてはなりません。</p>
|
||||
<pre>
|
||||
<span class="k">typedef</span> <span class="k">struct</span> {
|
||||
FATFS* fs; <span class="c">/* 親ファイル システム オブジェクトへのポインタ */</span>
|
||||
WORD id; <span class="c">/* 親ファイル システム オブジェクトのマウントID */</span>
|
||||
WORD index; <span class="c">/* 次に検索開始するディレクトリ インデックス番号 */</span>
|
||||
DWORD sclust; <span class="c">/* テーブル開始クラスタ (0:ルート) */</span>
|
||||
_FDID obj; <span class="c">/* オブジェクトID */</span>
|
||||
DOWRD dptr; <span class="c">/* 現在のread/writeオフセット */</span>
|
||||
DWORD clust; <span class="c">/* 現在のクラスタ番号 */</span>
|
||||
DWORD sect; <span class="c">/* 現在のセクタ番号 */</span>
|
||||
BYTE* dir; <span class="c">/* 現在のSFNエントリ(Win[]内)へのポインタ */</span>
|
||||
BYTE* fn; <span class="c">/* SFNバッファへのポインタ (in/out) {file[8],ext[3],status[1]} */</span>
|
||||
<span class="k">#if</span> _FS_LOCK
|
||||
UINT lockid; <span class="c">/* サブ ディレクトリ ロックID (0:ルート) */</span>
|
||||
<span class="k">#endif</span>
|
||||
<span class="k">#if</span> _USE_LFN
|
||||
DWORD blk_ofs; <span class="c">/* 現在のエントリブロックの先頭 (0xFFFFFFFF:無効) */</span>
|
||||
WCHAR* lfn; <span class="c">/* LFNバッファへのポインタ (in/out) */</span>
|
||||
WORD lfn_idx; <span class="c">/* LFNエントリの先頭インデックス (0xFFFF:無効) */</span>
|
||||
<span class="k">#endif</span>
|
||||
<span class="k">#if</span> _USE_FIND
|
||||
const TCHAR* pat; <span class="c">/* マッチング パターンへのポインタ */</span>
|
||||
|
@ -49,11 +49,12 @@ FRESULT f_setlabel (
|
||||
|
||||
<div class="para desc">
|
||||
<h4>解説</h4>
|
||||
<p>文字列の先頭にドライブ番号を含む場合は、その論理ドライブに対して設定されます。含まない場合は、デフォルト ドライブに設定されます。ボリューム ラベルを削除するときは、ヌル文字列を指定します。ボリューム ラベルのフォーマットは、ファイル名(SFN)とほぼ同じですが、次の点が異なります。</p>
|
||||
<p>文字列の先頭にドライブ番号を含む場合は、その論理ドライブに対して設定されます。含まない場合は、デフォルト ドライブに設定されます。ボリューム ラベルを削除するときは、ヌル文字列を指定します。FATボリューム上では、ボリューム ラベルのフォーマットは、ファイル名とほぼ同じですが、次の点が異なります。</p>
|
||||
<ul>
|
||||
<li>OEMコード換算で11バイト以下。ボリューム ラベルにはLFN拡張は適用されません。</li>
|
||||
<li>任意の位置にスペースを置くことができる。ただし、FATボリュームではトレーリング スペースは除去される。</li>
|
||||
<li>ピリオドを含むことはできない。</li>
|
||||
<li>任意の位置にスペースを置くことができる。ただし、最後尾となるスペースは除去される。</li>
|
||||
<li>FATボリュームでは、OEMコード換算で11バイト以下。</li>
|
||||
<li>exFATボリュームでは、11文字以下で、大文字小文字は保持される。</li>
|
||||
</ul>
|
||||
<p>【補足】 標準システム(Windows)では<tt>\xE5</tt>で始まるボーリューム ラベル(CP932なら「薔薇」など)の扱いに問題があります。このため、この関数ではそのような名前は無効として処理しています。</p>
|
||||
</div>
|
||||
|
@ -17,17 +17,20 @@
|
||||
|
||||
<pre>
|
||||
<span class="k">typedef</span> <span class="k">struct</span> {
|
||||
BYTE fs_type; <span class="c">/* FATタイプ (0:無効, FS_FAT12, FS_FAT16 or FS_FAT32) */</span>
|
||||
BYTE fs_type; <span class="c">/* ファイル システム (0, FS_FAT12, FS_FAT16, FS_FAT32 or FS_EXFAT) */</span>
|
||||
BYTE drv; <span class="c">/* 物理ドライブ番号 */</span>
|
||||
BYTE csize; <span class="c">/* クラスタ当たりのセクタ数 (1,2,4,8,...,128) */</span>
|
||||
BYTE n_fats; <span class="c">/* FATの多重化数 (1,2) */</span>
|
||||
BYTE wflag; <span class="c">/* win[]ダーティ フラグ */</span>
|
||||
BYTE fsi_flag; <span class="c">/* FSINFOフラグ (b7:Disabled, b0:Dirty) */</span>
|
||||
WORD id; <span class="c">/* ファイル システム マウントID */</span>
|
||||
WORD n_rootdir; <span class="c">/* ルート ディレクトリのエントリ数 (FAT12/16) */</span>
|
||||
WORD csize; <span class="c">/* クラスタ当たりのセクタ数 */</span>
|
||||
<span class="k">#if</span> _MAX_SS != _MIN_SS
|
||||
WORD ssize; <span class="c">/* セクタ サイズ (512, 1024, 2048 or 4096) */</span>
|
||||
<span class="k">#endif</span>
|
||||
<span class="k">#if</span> _FS_EXFAT
|
||||
BYTE* dirbuf; <span class="c">/* ディレクトリ エントリ ブロック操作バッファへのポインタ */</span>
|
||||
<span class="k">#endif</span>
|
||||
<span class="k">#if</span> _FS_REENTRANT
|
||||
_SYNC_t sobj; <span class="c">/* 同期オブジェクトID */</span>
|
||||
<span class="k">#endif</span>
|
||||
@ -37,6 +40,11 @@
|
||||
<span class="k">#endif</span>
|
||||
<span class="k">#if</span> _FS_RPATH
|
||||
DWORD cdir; <span class="c">/* カレント ディレクトリのクラスタ番号 (0:ルート) */</span>
|
||||
<span class="k">#if</span> _FS_EXFAT
|
||||
DWORD cdc_scl; <span class="c">/* カレント ディレクトリを含むディレクトリの開始クラスタ番号 (cdir == 0では無効) */</span>
|
||||
DWORD cdc_size; <span class="c">/* b31-b8:カレント ディレクトリを含むディレクトリのサイズ, b7-b0: チェーン ステータス */</span>
|
||||
DWORD cdc_ofs; <span class="c">/* カレント ディレクトリを含むディレクトリ内の位置 (cdir == 0では無効) */</span>
|
||||
<span class="k">#endif</span>
|
||||
<span class="k">#endif</span>
|
||||
DWORD n_fatent; <span class="c">/* FATエントリ数 (総クラスタ数 + 2) */</span>
|
||||
DWORD fsize; <span class="c">/* FAT 1個のセクタ数 */</span>
|
||||
|
@ -17,14 +17,11 @@
|
||||
|
||||
<pre>
|
||||
<span class="k">typedef</span> <span class="k">struct</span> {
|
||||
FATFS* fs; <span class="c">/* 親ファイル システム オブジェクトへのポインタ */</span>
|
||||
WORD id; <span class="c">/* 親ファイル システム オブジェクトのマウントID */</span>
|
||||
_FDID obj; <span class="c">/* オブジェクトID */</span>
|
||||
BYTE flag; <span class="c">/* ファイル ステータス フラグ */</span>
|
||||
BYTE err; <span class="c">/* エラー中断フラグ */</span>
|
||||
DWORD fptr; <span class="c">/* ファイル読み書きポインタ (ファイル先頭からのバイト オフセット) */</span>
|
||||
DWORD fsize; <span class="c">/* ファイル サイズ(バイト単位) */</span>
|
||||
DWORD sclust; <span class="c">/* ファイル開始クラスタ番号 (0:割り当て無し) */</span>
|
||||
DWORD clust; <span class="c">/* 現在のクラスタ (fptrが0のときは無効、fptrがクラスタ境界上のときは前のクラスタ) */</span>
|
||||
FSIZE_t fptr; <span class="c">/* ファイル読み書きポインタ (ファイル先頭からのバイト オフセット) */</span>
|
||||
DWORD clust; <span class="c">/* 現在のクラスタ (fptrがクラスタ境界上のときは前のクラスタ、fptrが0のときは無効) */</span>
|
||||
DWORD dsect; <span class="c">/* 現在のデータ セクタ */</span>
|
||||
<span class="k">#if</span> !_FS_READONLY
|
||||
DWORD dir_sect; <span class="c">/* このファイルのディレクトリ エントリのあるセクタ */</span>
|
||||
|
@ -16,14 +16,15 @@
|
||||
<p><tt>FILINFO</tt>構造体は、<tt>f_stat/f_readdir/f_findfirst/f_findnext</tt>関数で返されるオブジェクトに関する情報を保持します。</p>
|
||||
<pre>
|
||||
<span class="k">typedef</span> <span class="k">struct</span> {
|
||||
DWORD fsize; <span class="c">/* ファイル サイズ */</span>
|
||||
WORD fdate; <span class="c">/* 最後に更新された日付 */</span>
|
||||
WORD ftime; <span class="c">/* 最後に更新された時刻 */</span>
|
||||
BYTE fattrib; <span class="c">/* アトリビュート */</span>
|
||||
TCHAR fname[13]; <span class="c">/* 短いファイル名 (8.3フォーマット) */</span>
|
||||
<span class="k">#if</span> _USE_LFN
|
||||
TCHAR* lfname; <span class="c">/* 長いファイル名のバッファへのポインタ */</span>
|
||||
int lfsize; <span class="c">/* 長いファイル名のバッファのサイズ [文字数] */</span>
|
||||
FSIZE_t fsize; <span class="c">/* ファイル サイズ */</span>
|
||||
WORD fdate; <span class="c">/* 最後に更新された日付 */</span>
|
||||
WORD ftime; <span class="c">/* 最後に更新された時刻 */</span>
|
||||
BYTE fattrib; <span class="c">/* アトリビュート */</span>
|
||||
<span class="k">#if</span> _USE_LFN != 0
|
||||
TCHAR altname[13]; <span class="c">/* 代替ファイル名 */</span>
|
||||
TCHAR fname[_MAX_LFN + 1]; <span class="c">/* 主ファイル名 */</span>
|
||||
<span class="k">#else</span>
|
||||
TCHAR fname[13]; <span class="c">/* ファイル名 */</span>
|
||||
<span class="k">#endif</span>
|
||||
} FILINFO;
|
||||
</pre>
|
||||
@ -32,7 +33,7 @@
|
||||
<h4>メンバ</h4>
|
||||
<dl>
|
||||
<dt>fsize</dt>
|
||||
<dd>ファイルのバイト単位のサイズが格納されます。ディレクトリの場合は常に0です。</dd>
|
||||
<dd>ファイルのバイト単位のサイズが格納されます。ディレクトリの場合は常に0です。データ型<tt>FSIZE_t</tt>は、<tt>DWORD</tt>(32-bit)または<tt>QWORD</tt>(64-bit)のエリアスで、exFATサポートの有無により切り替わります。</dd>
|
||||
<dt>fdate</dt>
|
||||
<dd>ファイルの変更された日付、またはディレクトリの作成された日付が格納されます。<br>
|
||||
<dl>
|
||||
@ -58,11 +59,9 @@
|
||||
<dt>fattrib</dt>
|
||||
<dd>属性フラグが格納されます。フラグは<tt>AM_DIR, AM_RDO, AM_HID, AM_SYS, AM_ARC</tt>の組み合わせとなります。</dd>
|
||||
<dt>fname[]</dt>
|
||||
<dd>8.3形式の名前(SFN)が<tt>'\0'</tt>で終わる文字列として格納されます。非LFN構成のときは、常に大文字で返されます。LFN構成のときは、文字列に含まれるASCII英字が小文字になる場合があります。</dd>
|
||||
<dt>lfname</dt>
|
||||
<dd>長いファイル名(LFN)を格納するバッファへのポインタ。このメンバは、この構造体を使用する前にアプリケーションにより初期化されなければなりません。NULLが設定されるとLFNは返されません。非LFN構成のときはこのメンバは存在しません。</dd>
|
||||
<dt>lfsize</dt>
|
||||
<dd>長いファイル名を格納するバッファのサイズ(要素数)。このメンバは、この構造体を使用する前にアプリケーションにより初期化されなければなりません。非LFN構成のときはこのメンバは存在しません。</dd>
|
||||
<dd>オブジェクト名が<tt>'\0'</tt>で終わる文字列として格納されます。読み出すべき項目が無いときは、ヌル文字列が返され、この構造体が無効であることを示します。</dd>
|
||||
<dt>altname[]</dt>
|
||||
<dd>代替ファイル名があるときは、それが<tt>'\0'</tt>で終わる文字列として格納されます。非LFN構成のときは、このメンバはありません。</dd>
|
||||
</dl>
|
||||
|
||||
<p class="foot"><a href="../00index_j.html">戻る</a></p>
|
||||
|
@ -15,7 +15,7 @@
|
||||
<h2>f_size</h2>
|
||||
<p>ファイルのサイズを取得します。</p>
|
||||
<pre>
|
||||
DWORD f_size (
|
||||
FSIZE_t f_size (
|
||||
FIL* <span class="arg">fp</span> <span class="c">/* [IN] ファイル オブジェクト */</span>
|
||||
);
|
||||
</pre>
|
||||
@ -41,7 +41,7 @@ DWORD f_size (
|
||||
<h4>解説</h4>
|
||||
<p>この関数は、現リビジョンではマクロとして実装されています。ファイル オブジェクトの正当性チェックや排他制御は行いません。</p>
|
||||
<pre>
|
||||
<span class="k">#define</span> f_size(fp) ((fp)->fsize)
|
||||
<span class="k">#define</span> f_size(fp) ((fp)->obj.objsize)
|
||||
</pre>
|
||||
</div>
|
||||
|
||||
|
@ -54,8 +54,7 @@ FRESULT f_stat (
|
||||
|
||||
<div class="para desc">
|
||||
<h4>解説</h4>
|
||||
<p>指定されたファイルまたはサブ ディレクトリの存在を調べます。存在しない場合は、<tt>FR_NO_FILE</tt>が帰ります。存在する場合は<tt>FR_OK</tt>が帰り、ファイル情報構造体にそれ関する情報(サイズ、タイムスタンプ、属性および短いファイル名)がストアされます。</p>
|
||||
<p>LFN構成のときは、ファイル情報構造体を使う前に<tt>fno.lfname</tt>をヌルに設定しておく必要があります。</p>
|
||||
<p>指定されたファイルまたはサブ ディレクトリの存在を調べます。存在しない場合は、<tt>FR_NO_FILE</tt>が帰ります。存在する場合は<tt>FR_OK</tt>が帰り、それ関する情報(サイズ、タイムスタンプおよび属性)がファイル情報構造体にストアされます。</p>
|
||||
</div>
|
||||
|
||||
|
||||
@ -74,23 +73,20 @@ FRESULT f_stat (
|
||||
|
||||
printf("Test for 'file.txt'...\n");
|
||||
|
||||
<span class="k">#if</span> _USE_LFN
|
||||
fno.lfname = 0;
|
||||
<span class="k">#endif</span>
|
||||
fr = f_stat("file.txt", &fno);
|
||||
switch (fr) {
|
||||
|
||||
case FR_OK:
|
||||
printf("Size: %u\n", fno.fsize);
|
||||
printf("Size: %lu\n", fno.fsize);
|
||||
printf("Timestamp: %u/%02u/%02u, %02u:%02u\n",
|
||||
(fno.fdate >> 9) + 1980, fno.fdate >> 5 & 15, fno.fdate & 31,
|
||||
fno.ftime >> 11, fno.ftime >> 5 & 63);
|
||||
printf("Attributes: %c%c%c%c%c\n",
|
||||
(fno.fattrib & AM_DIR) ? 'D' : '-',
|
||||
(fno.fattrib & AM_RDO) ? 'R' : '-',
|
||||
(fno.fattrib & AM_HID) ? 'H' : '-',
|
||||
(fno.fattrib & AM_SYS) ? 'S' : '-',
|
||||
(fno.fattrib & AM_ARC) ? 'A' : '-');
|
||||
(fno.fattrib & AM_DIR) ? 'D' : '-',
|
||||
(fno.fattrib & AM_RDO) ? 'R' : '-',
|
||||
(fno.fattrib & AM_HID) ? 'H' : '-',
|
||||
(fno.fattrib & AM_SYS) ? 'S' : '-',
|
||||
(fno.fattrib & AM_ARC) ? 'A' : '-');
|
||||
break;
|
||||
|
||||
case FR_NO_FILE:
|
||||
|
@ -15,7 +15,7 @@
|
||||
<h2>f_tell</h2>
|
||||
<p>現在のリード/ライト ポインタを取得します。</p>
|
||||
<pre>
|
||||
DWORD f_tell (
|
||||
FSIZE_t f_tell (
|
||||
FIL* <span class="arg">fp</span> <span class="c">/* [IN] ファイル オブジェクト */</span>
|
||||
);
|
||||
</pre>
|
||||
|
@ -1,5 +1,6 @@
|
||||
/*------------------------------------------------------------/
|
||||
/ Open or create a file in append mode
|
||||
/ (This function was sperseded by FA_OPEN_APPEND at FatFs R0.12a)
|
||||
/------------------------------------------------------------*/
|
||||
|
||||
FRESULT open_append (
|
@ -6,7 +6,8 @@
|
||||
/ If the file has been opened without FA_WRITE flag, it only checks if
|
||||
/ the file is contiguous and returns the resulut.
|
||||
/-----------------------------------------------------------------------/
|
||||
/ This function can work with FatFs R0.09 to R0.11a.
|
||||
/ This function can work with FatFs R0.09 - R0.11a.
|
||||
/ It is incompatible with R0.12+. Use f_expand function instead.
|
||||
/----------------------------------------------------------------------*/
|
||||
|
||||
/* Declarations of FatFs internal functions accessible from applications.
|
Before Width: | Height: | Size: 1.4 KiB After Width: | Height: | Size: 1.4 KiB |
Before Width: | Height: | Size: 1.4 KiB After Width: | Height: | Size: 1.4 KiB |
Before Width: | Height: | Size: 1.0 KiB After Width: | Height: | Size: 1.0 KiB |
Before Width: | Height: | Size: 2.3 KiB After Width: | Height: | Size: 2.3 KiB |
Before Width: | Height: | Size: 2.4 KiB After Width: | Height: | Size: 2.4 KiB |
Before Width: | Height: | Size: 1.4 KiB After Width: | Height: | Size: 1.4 KiB |
BIN
firmware/chibios-portapack/ext/fatfs/doc/res/f7.png
Normal file
After Width: | Height: | Size: 30 KiB |
BIN
firmware/chibios-portapack/ext/fatfs/doc/res/funcs.png
Normal file
After Width: | Height: | Size: 22 KiB |
Before Width: | Height: | Size: 5.4 KiB After Width: | Height: | Size: 5.4 KiB |
Before Width: | Height: | Size: 3.8 KiB After Width: | Height: | Size: 3.8 KiB |
Before Width: | Height: | Size: 3.7 KiB After Width: | Height: | Size: 3.7 KiB |
Before Width: | Height: | Size: 2.3 KiB After Width: | Height: | Size: 2.3 KiB |
BIN
firmware/chibios-portapack/ext/fatfs/doc/res/mkfs.xls
Normal file
BIN
firmware/chibios-portapack/ext/fatfs/doc/res/modules.png
Normal file
After Width: | Height: | Size: 17 KiB |
BIN
firmware/chibios-portapack/ext/fatfs/doc/res/rwtest1.png
Normal file
After Width: | Height: | Size: 27 KiB |
Before Width: | Height: | Size: 8.0 KiB After Width: | Height: | Size: 8.0 KiB |
Before Width: | Height: | Size: 2.9 KiB After Width: | Height: | Size: 2.9 KiB |
@ -10,7 +10,7 @@ R0.00 (February 26, 2006)
|
||||
|
||||
R0.01 (April 29, 2006)
|
||||
|
||||
First stable version.
|
||||
The first release.
|
||||
|
||||
|
||||
|
||||
@ -193,7 +193,7 @@ R0.10 (October 02, 2013)
|
||||
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 error code.
|
||||
Fixed f_open(), f_mkdir() and f_setlabel() can return incorrect value on error.
|
||||
|
||||
|
||||
|
||||
@ -243,3 +243,25 @@ R0.11a (September 05, 2015)
|
||||
Fixed errors in the case conversion teble of Unicode (cc*.c).
|
||||
|
||||
|
||||
|
||||
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.
|
||||
Removed an option _WORD_ACCESS.
|
||||
Fixed errors in the case conversion table of Unicode (cc*.c).
|
||||
|
||||
|
||||
|
||||
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.
|
||||
Fixed compilation fails at some configurations, _USE_FASTSEEK and _USE_FORWARD.
|
||||
Fixed wrong memory read in create_name().
|
||||
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
FatFs Module Source Files R0.11
|
||||
FatFs Module Source Files R0.12a
|
||||
|
||||
|
||||
FILES
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*-----------------------------------------------------------------------*/
|
||||
/* Low level disk I/O module skeleton for FatFs (C)ChaN, 2014 */
|
||||
/* Low level disk I/O module skeleton for FatFs (C)ChaN, 2016 */
|
||||
/*-----------------------------------------------------------------------*/
|
||||
/* If a working storage control module is available, it should be */
|
||||
/* attached to the FatFs via a glue function rather than modifying it. */
|
||||
@ -8,14 +8,11 @@
|
||||
/*-----------------------------------------------------------------------*/
|
||||
|
||||
#include "diskio.h" /* FatFs lower layer API */
|
||||
#include "usbdisk.h" /* Example: Header file of existing USB MSD control module */
|
||||
#include "atadrive.h" /* Example: Header file of existing ATA harddisk control module */
|
||||
#include "sdcard.h" /* Example: Header file of existing MMC/SDC contorl module */
|
||||
|
||||
/* Definitions of physical drive number for each drive */
|
||||
#define ATA 0 /* Example: Map ATA harddisk to physical drive 0 */
|
||||
#define MMC 1 /* Example: Map MMC/SD card to physical drive 1 */
|
||||
#define USB 2 /* Example: Map USB MSD to physical drive 2 */
|
||||
#define DEV_RAM 0 /* Example: Map Ramdisk to physical drive 0 */
|
||||
#define DEV_MMC 1 /* Example: Map MMC/SD card to physical drive 1 */
|
||||
#define DEV_USB 2 /* Example: Map USB MSD to physical drive 2 */
|
||||
|
||||
|
||||
/*-----------------------------------------------------------------------*/
|
||||
@ -30,21 +27,21 @@ DSTATUS disk_status (
|
||||
int result;
|
||||
|
||||
switch (pdrv) {
|
||||
case ATA :
|
||||
result = ATA_disk_status();
|
||||
case DEV_RAM :
|
||||
result = RAM_disk_status();
|
||||
|
||||
// translate the reslut code here
|
||||
|
||||
return stat;
|
||||
|
||||
case MMC :
|
||||
case DEV_MMC :
|
||||
result = MMC_disk_status();
|
||||
|
||||
// translate the reslut code here
|
||||
|
||||
return stat;
|
||||
|
||||
case USB :
|
||||
case DEB_USB :
|
||||
result = USB_disk_status();
|
||||
|
||||
// translate the reslut code here
|
||||
@ -68,21 +65,21 @@ DSTATUS disk_initialize (
|
||||
int result;
|
||||
|
||||
switch (pdrv) {
|
||||
case ATA :
|
||||
result = ATA_disk_initialize();
|
||||
case DEV_RAM :
|
||||
result = RAM_disk_initialize();
|
||||
|
||||
// translate the reslut code here
|
||||
|
||||
return stat;
|
||||
|
||||
case MMC :
|
||||
case DEV_MMC :
|
||||
result = MMC_disk_initialize();
|
||||
|
||||
// translate the reslut code here
|
||||
|
||||
return stat;
|
||||
|
||||
case USB :
|
||||
case DEV_USB :
|
||||
result = USB_disk_initialize();
|
||||
|
||||
// translate the reslut code here
|
||||
@ -101,7 +98,7 @@ DSTATUS disk_initialize (
|
||||
DRESULT disk_read (
|
||||
BYTE pdrv, /* Physical drive nmuber to identify the drive */
|
||||
BYTE *buff, /* Data buffer to store read data */
|
||||
DWORD sector, /* Sector address in LBA */
|
||||
DWORD sector, /* Start sector in LBA */
|
||||
UINT count /* Number of sectors to read */
|
||||
)
|
||||
{
|
||||
@ -109,16 +106,16 @@ DRESULT disk_read (
|
||||
int result;
|
||||
|
||||
switch (pdrv) {
|
||||
case ATA :
|
||||
case DEV_RAM :
|
||||
// translate the arguments here
|
||||
|
||||
result = ATA_disk_read(buff, sector, count);
|
||||
result = RAM_disk_read(buff, sector, count);
|
||||
|
||||
// translate the reslut code here
|
||||
|
||||
return res;
|
||||
|
||||
case MMC :
|
||||
case DEV_MMC :
|
||||
// translate the arguments here
|
||||
|
||||
result = MMC_disk_read(buff, sector, count);
|
||||
@ -127,7 +124,7 @@ DRESULT disk_read (
|
||||
|
||||
return res;
|
||||
|
||||
case USB :
|
||||
case DEV_USB :
|
||||
// translate the arguments here
|
||||
|
||||
result = USB_disk_read(buff, sector, count);
|
||||
@ -146,11 +143,10 @@ DRESULT disk_read (
|
||||
/* Write Sector(s) */
|
||||
/*-----------------------------------------------------------------------*/
|
||||
|
||||
#if _USE_WRITE
|
||||
DRESULT disk_write (
|
||||
BYTE pdrv, /* Physical drive nmuber to identify the drive */
|
||||
const BYTE *buff, /* Data to be written */
|
||||
DWORD sector, /* Sector address in LBA */
|
||||
DWORD sector, /* Start sector in LBA */
|
||||
UINT count /* Number of sectors to write */
|
||||
)
|
||||
{
|
||||
@ -158,16 +154,16 @@ DRESULT disk_write (
|
||||
int result;
|
||||
|
||||
switch (pdrv) {
|
||||
case ATA :
|
||||
case DEV_RAM :
|
||||
// translate the arguments here
|
||||
|
||||
result = ATA_disk_write(buff, sector, count);
|
||||
result = RAM_disk_write(buff, sector, count);
|
||||
|
||||
// translate the reslut code here
|
||||
|
||||
return res;
|
||||
|
||||
case MMC :
|
||||
case DEV_MMC :
|
||||
// translate the arguments here
|
||||
|
||||
result = MMC_disk_write(buff, sector, count);
|
||||
@ -176,7 +172,7 @@ DRESULT disk_write (
|
||||
|
||||
return res;
|
||||
|
||||
case USB :
|
||||
case DEV_USB :
|
||||
// translate the arguments here
|
||||
|
||||
result = USB_disk_write(buff, sector, count);
|
||||
@ -188,14 +184,13 @@ DRESULT disk_write (
|
||||
|
||||
return RES_PARERR;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
/*-----------------------------------------------------------------------*/
|
||||
/* Miscellaneous Functions */
|
||||
/*-----------------------------------------------------------------------*/
|
||||
|
||||
#if _USE_IOCTL
|
||||
DRESULT disk_ioctl (
|
||||
BYTE pdrv, /* Physical drive nmuber (0..) */
|
||||
BYTE cmd, /* Control code */
|
||||
@ -206,19 +201,19 @@ DRESULT disk_ioctl (
|
||||
int result;
|
||||
|
||||
switch (pdrv) {
|
||||
case ATA :
|
||||
case DEV_RAM :
|
||||
|
||||
// Process of the command for the ATA drive
|
||||
// Process of the command for the RAM drive
|
||||
|
||||
return res;
|
||||
|
||||
case MMC :
|
||||
case DEV_MMC :
|
||||
|
||||
// Process of the command for the MMC/SD card
|
||||
|
||||
return res;
|
||||
|
||||
case USB :
|
||||
case DEV_USB :
|
||||
|
||||
// Process of the command the USB drive
|
||||
|
||||
@ -227,4 +222,4 @@ DRESULT disk_ioctl (
|
||||
|
||||
return RES_PARERR;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -9,9 +9,6 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define _USE_WRITE 1 /* 1: Enable disk_write function */
|
||||
#define _USE_IOCTL 1 /* 1: Enable disk_ioctl fucntion */
|
||||
|
||||
#include "integer.h"
|
||||
|
||||
|
||||
@ -67,6 +64,9 @@ DRESULT disk_ioctl (BYTE pdrv, BYTE cmd, void* buff);
|
||||
#define MMC_GET_CID 12 /* Get CID */
|
||||
#define MMC_GET_OCR 13 /* Get OCR */
|
||||
#define MMC_GET_SDSTAT 14 /* Get SD status */
|
||||
#define ISDIO_READ 55 /* Read data form SD iSDIO register */
|
||||
#define ISDIO_WRITE 56 /* Write data to SD iSDIO register */
|
||||
#define ISDIO_MRITE 57 /* Masked write data to SD iSDIO register */
|
||||
|
||||
/* ATA/CF specific ioctl command */
|
||||
#define ATA_GET_REV 20 /* Get F/W revision */
|
||||
|
@ -1,11 +1,13 @@
|
||||
/*---------------------------------------------------------------------------/
|
||||
/ FatFs - FAT file system module include R0.11a (C)ChaN, 2015
|
||||
/----------------------------------------------------------------------------/
|
||||
/ FatFs module is a free software that opened under license policy of
|
||||
/ following conditions.
|
||||
/*----------------------------------------------------------------------------/
|
||||
/ FatFs - Generic FAT file system module R0.12a /
|
||||
/-----------------------------------------------------------------------------/
|
||||
/
|
||||
/ Copyright (C) 2015, ChaN, all right reserved.
|
||||
/ Copyright (C) 2016, ChaN, all right reserved.
|
||||
/
|
||||
/ FatFs module is an open source software. Redistribution and use of FatFs in
|
||||
/ source and binary forms, with or without modification, are permitted provided
|
||||
/ that the following condition is met:
|
||||
|
||||
/ 1. Redistributions of source code must retain the above copyright notice,
|
||||
/ this condition and the following disclaimer.
|
||||
/
|
||||
@ -13,11 +15,11 @@
|
||||
/ and any warranties related to this software are DISCLAIMED.
|
||||
/ The copyright owner or contributors be NOT LIABLE for any damages caused
|
||||
/ by use of this software.
|
||||
/---------------------------------------------------------------------------*/
|
||||
/----------------------------------------------------------------------------*/
|
||||
|
||||
|
||||
#ifndef _FATFS
|
||||
#define _FATFS 64180 /* Revision ID */
|
||||
#define _FATFS 80186 /* Revision ID */
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
@ -25,6 +27,7 @@ extern "C" {
|
||||
|
||||
#include "integer.h" /* Basic integer types */
|
||||
#include "ffconf.h" /* FatFs configuration options */
|
||||
|
||||
#if _FATFS != _FFCONF
|
||||
#error Wrong configuration file (ffconf.h).
|
||||
#endif
|
||||
@ -52,8 +55,8 @@ extern PARTITION VolToPart[]; /* Volume - Partition resolution table */
|
||||
|
||||
/* Type of path name strings on FatFs API */
|
||||
|
||||
#if _LFN_UNICODE /* Unicode string */
|
||||
#if !_USE_LFN
|
||||
#if _LFN_UNICODE /* Unicode (UTF-16) string */
|
||||
#if _USE_LFN == 0
|
||||
#error _LFN_UNICODE must be 0 at non-LFN cfg.
|
||||
#endif
|
||||
#ifndef _INC_TCHAR
|
||||
@ -61,14 +64,25 @@ typedef WCHAR TCHAR;
|
||||
#define _T(x) L ## x
|
||||
#define _TEXT(x) L ## x
|
||||
#endif
|
||||
|
||||
#else /* ANSI/OEM string */
|
||||
#ifndef _INC_TCHAR
|
||||
typedef char TCHAR;
|
||||
#define _T(x) x
|
||||
#define _TEXT(x) x
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
/* Type of file size variables */
|
||||
|
||||
#if _FS_EXFAT
|
||||
#if _USE_LFN == 0
|
||||
#error LFN must be enabled when enable exFAT
|
||||
#endif
|
||||
typedef QWORD FSIZE_t;
|
||||
#else
|
||||
typedef DWORD FSIZE_t;
|
||||
#endif
|
||||
|
||||
|
||||
@ -76,60 +90,87 @@ typedef char TCHAR;
|
||||
/* File system object structure (FATFS) */
|
||||
|
||||
typedef struct {
|
||||
BYTE fs_type; /* FAT sub-type (0:Not mounted) */
|
||||
BYTE fs_type; /* File system type (0:N/A) */
|
||||
BYTE drv; /* Physical drive number */
|
||||
BYTE csize; /* Sectors per cluster (1,2,4...128) */
|
||||
BYTE n_fats; /* Number of FAT copies (1 or 2) */
|
||||
BYTE n_fats; /* Number of FATs (1 or 2) */
|
||||
BYTE wflag; /* win[] flag (b0:dirty) */
|
||||
BYTE fsi_flag; /* FSINFO flags (b7:disabled, b0:dirty) */
|
||||
WORD id; /* File system mount ID */
|
||||
WORD n_rootdir; /* Number of root directory entries (FAT12/16) */
|
||||
WORD csize; /* Cluster size [sectors] */
|
||||
#if _MAX_SS != _MIN_SS
|
||||
WORD ssize; /* Bytes per sector (512, 1024, 2048 or 4096) */
|
||||
WORD ssize; /* Sector size (512, 1024, 2048 or 4096) */
|
||||
#endif
|
||||
#if _USE_LFN != 0
|
||||
WCHAR* lfnbuf; /* LFN working buffer */
|
||||
#endif
|
||||
#if _FS_EXFAT
|
||||
BYTE* dirbuf; /* Directory entry block scratchpad buffer */
|
||||
#endif
|
||||
#if _FS_REENTRANT
|
||||
_SYNC_t sobj; /* Identifier of sync object */
|
||||
#endif
|
||||
#if !_FS_READONLY
|
||||
DWORD last_clust; /* Last allocated cluster */
|
||||
DWORD free_clust; /* Number of free clusters */
|
||||
DWORD last_clst; /* Last allocated cluster */
|
||||
DWORD free_clst; /* Number of free clusters */
|
||||
#endif
|
||||
#if _FS_RPATH
|
||||
#if _FS_RPATH != 0
|
||||
DWORD cdir; /* Current directory start cluster (0:root) */
|
||||
#if _FS_EXFAT
|
||||
DWORD cdc_scl; /* Containing directory start cluster (invalid when cdir is 0) */
|
||||
DWORD cdc_size; /* b31-b8:Size of containing directory, b7-b0: Chain status */
|
||||
DWORD cdc_ofs; /* Offset in the containing directory (invalid when cdir is 0) */
|
||||
#endif
|
||||
DWORD n_fatent; /* Number of FAT entries, = number of clusters + 2 */
|
||||
DWORD fsize; /* Sectors per FAT */
|
||||
DWORD volbase; /* Volume start sector */
|
||||
DWORD fatbase; /* FAT start sector */
|
||||
DWORD dirbase; /* Root directory start sector (FAT32:Cluster#) */
|
||||
DWORD database; /* Data start sector */
|
||||
#endif
|
||||
DWORD n_fatent; /* Number of FAT entries (number of clusters + 2) */
|
||||
DWORD fsize; /* Size of an FAT [sectors] */
|
||||
DWORD volbase; /* Volume base sector */
|
||||
DWORD fatbase; /* FAT base sector */
|
||||
DWORD dirbase; /* Root directory base sector/cluster */
|
||||
DWORD database; /* Data base sector */
|
||||
DWORD winsect; /* Current sector appearing in the win[] */
|
||||
BYTE win[_MAX_SS]; /* Disk access window for Directory, FAT (and file data at tiny cfg) */
|
||||
} FATFS;
|
||||
|
||||
|
||||
|
||||
/* Object ID and allocation information (_FDID) */
|
||||
|
||||
typedef struct {
|
||||
FATFS* fs; /* Pointer to the owner file system object */
|
||||
WORD id; /* Owner file system mount ID */
|
||||
BYTE attr; /* Object attribute */
|
||||
BYTE stat; /* Object chain status (b1-0: =0:not contiguous, =2:contiguous (no data on FAT), =3:got flagmented, b2:sub-directory stretched) */
|
||||
DWORD sclust; /* Object start cluster (0:no cluster or root directory) */
|
||||
FSIZE_t objsize; /* Object size (valid when sclust != 0) */
|
||||
#if _FS_EXFAT
|
||||
DWORD n_cont; /* Size of coutiguous part, clusters - 1 (valid when stat == 3) */
|
||||
DWORD c_scl; /* Containing directory start cluster (valid when sclust != 0) */
|
||||
DWORD c_size; /* b31-b8:Size of containing directory, b7-b0: Chain status (valid when c_scl != 0) */
|
||||
DWORD c_ofs; /* Offset in the containing directory (valid when sclust != 0) */
|
||||
#endif
|
||||
#if _FS_LOCK != 0
|
||||
UINT lockid; /* File lock ID origin from 1 (index of file semaphore table Files[]) */
|
||||
#endif
|
||||
} _FDID;
|
||||
|
||||
|
||||
|
||||
/* File object structure (FIL) */
|
||||
|
||||
typedef struct {
|
||||
FATFS* fs; /* Pointer to the related file system object (**do not change order**) */
|
||||
WORD id; /* Owner file system mount ID (**do not change order**) */
|
||||
BYTE flag; /* Status flags */
|
||||
_FDID obj; /* Object identifier */
|
||||
BYTE flag; /* File status flags */
|
||||
BYTE err; /* Abort flag (error code) */
|
||||
DWORD fptr; /* File read/write pointer (Zeroed on file open) */
|
||||
DWORD fsize; /* File size */
|
||||
DWORD sclust; /* File start cluster (0:no cluster chain, always 0 when fsize is 0) */
|
||||
DWORD clust; /* Current cluster of fpter (not valid when fprt is 0) */
|
||||
DWORD dsect; /* Sector number appearing in buf[] (0:invalid) */
|
||||
FSIZE_t fptr; /* File read/write pointer (Zeroed on file open) */
|
||||
DWORD clust; /* Current cluster of fpter (invalid when fprt is 0) */
|
||||
DWORD sect; /* Sector number appearing in buf[] (0:invalid) */
|
||||
#if !_FS_READONLY
|
||||
DWORD dir_sect; /* Sector number containing the directory entry */
|
||||
BYTE* dir_ptr; /* Pointer to the directory entry in the win[] */
|
||||
#endif
|
||||
#if _USE_FASTSEEK
|
||||
DWORD* cltbl; /* Pointer to the cluster link map table (Nulled on file open) */
|
||||
#endif
|
||||
#if _FS_LOCK
|
||||
UINT lockid; /* File lock ID origin from 1 (index of file semaphore table Files[]) */
|
||||
DWORD* cltbl; /* Pointer to the cluster link map table (nulled on open, set by application) */
|
||||
#endif
|
||||
#if !_FS_TINY
|
||||
BYTE buf[_MAX_SS]; /* File private data read/write window */
|
||||
@ -141,23 +182,17 @@ typedef struct {
|
||||
/* Directory object structure (DIR) */
|
||||
|
||||
typedef struct {
|
||||
FATFS* fs; /* Pointer to the owner file system object (**do not change order**) */
|
||||
WORD id; /* Owner file system mount ID (**do not change order**) */
|
||||
WORD index; /* Current read/write index number */
|
||||
DWORD sclust; /* Table start cluster (0:Root dir) */
|
||||
_FDID obj; /* Object identifier */
|
||||
DWORD dptr; /* Current read/write offset */
|
||||
DWORD clust; /* Current cluster */
|
||||
DWORD sect; /* Current sector */
|
||||
BYTE* dir; /* Pointer to the current SFN entry in the win[] */
|
||||
BYTE* fn; /* Pointer to the SFN (in/out) {file[8],ext[3],status[1]} */
|
||||
#if _FS_LOCK
|
||||
UINT lockid; /* File lock ID (index of file semaphore table Files[]) */
|
||||
#endif
|
||||
#if _USE_LFN
|
||||
WCHAR* lfn; /* Pointer to the LFN working buffer */
|
||||
WORD lfn_idx; /* Last matched LFN index number (0xFFFF:No LFN) */
|
||||
BYTE* dir; /* Pointer to the directory item in the win[] */
|
||||
BYTE fn[12]; /* SFN (in/out) {body[8],ext[3],status[1]} */
|
||||
#if _USE_LFN != 0
|
||||
DWORD blk_ofs; /* Offset of current entry block being processed (0xFFFFFFFF:Invalid) */
|
||||
#endif
|
||||
#if _USE_FIND
|
||||
const TCHAR* pat; /* Pointer to the name matching pattern */
|
||||
const TCHAR* pat; /* Pointer to the name matching pattern */
|
||||
#endif
|
||||
} DIR;
|
||||
|
||||
@ -166,14 +201,15 @@ typedef struct {
|
||||
/* File information structure (FILINFO) */
|
||||
|
||||
typedef struct {
|
||||
DWORD fsize; /* File size */
|
||||
WORD fdate; /* Last modified date */
|
||||
WORD ftime; /* Last modified time */
|
||||
BYTE fattrib; /* Attribute */
|
||||
TCHAR fname[13]; /* Short file name (8.3 format) */
|
||||
#if _USE_LFN
|
||||
TCHAR* lfname; /* Pointer to the LFN buffer */
|
||||
UINT lfsize; /* Size of LFN buffer in TCHAR */
|
||||
FSIZE_t fsize; /* File size */
|
||||
WORD fdate; /* Modified date */
|
||||
WORD ftime; /* Modified time */
|
||||
BYTE fattrib; /* File attribute */
|
||||
#if _USE_LFN != 0
|
||||
TCHAR altname[13]; /* Altenative file name */
|
||||
TCHAR fname[_MAX_LFN + 1]; /* Primary file name */
|
||||
#else
|
||||
TCHAR fname[13]; /* File name */
|
||||
#endif
|
||||
} FILINFO;
|
||||
|
||||
@ -196,7 +232,7 @@ typedef enum {
|
||||
FR_INVALID_DRIVE, /* (11) The logical drive number is invalid */
|
||||
FR_NOT_ENABLED, /* (12) The volume has no work area */
|
||||
FR_NO_FILESYSTEM, /* (13) There is no valid FAT volume */
|
||||
FR_MKFS_ABORTED, /* (14) The f_mkfs() aborted due to any parameter error */
|
||||
FR_MKFS_ABORTED, /* (14) The f_mkfs() aborted due to any problem */
|
||||
FR_TIMEOUT, /* (15) Could not get a grant to access the volume within defined period */
|
||||
FR_LOCKED, /* (16) The operation is rejected according to the file sharing policy */
|
||||
FR_NOT_ENOUGH_CORE, /* (17) LFN working buffer could not be allocated */
|
||||
@ -211,12 +247,11 @@ typedef enum {
|
||||
|
||||
FRESULT f_open (FIL* fp, const TCHAR* path, BYTE mode); /* Open or create a file */
|
||||
FRESULT f_close (FIL* fp); /* Close an open file object */
|
||||
FRESULT f_read (FIL* fp, void* buff, UINT btr, UINT* br); /* Read data from a file */
|
||||
FRESULT f_write (FIL* fp, const void* buff, UINT btw, UINT* bw); /* Write data to a file */
|
||||
FRESULT f_forward (FIL* fp, UINT(*func)(const BYTE*,UINT), UINT btf, UINT* bf); /* Forward data to the stream */
|
||||
FRESULT f_lseek (FIL* fp, DWORD ofs); /* Move file pointer of a file object */
|
||||
FRESULT f_truncate (FIL* fp); /* Truncate file */
|
||||
FRESULT f_sync (FIL* fp); /* Flush cached data of a writing file */
|
||||
FRESULT f_read (FIL* fp, void* buff, UINT btr, UINT* br); /* Read data from the file */
|
||||
FRESULT f_write (FIL* fp, const void* buff, UINT btw, UINT* bw); /* Write data to the file */
|
||||
FRESULT f_lseek (FIL* fp, FSIZE_t ofs); /* Move file pointer of the file object */
|
||||
FRESULT f_truncate (FIL* fp); /* Truncate the file */
|
||||
FRESULT f_sync (FIL* fp); /* Flush cached data of the writing file */
|
||||
FRESULT f_opendir (DIR* dp, const TCHAR* path); /* Open a directory */
|
||||
FRESULT f_closedir (DIR* dp); /* Close an open directory */
|
||||
FRESULT f_readdir (DIR* dp, FILINFO* fno); /* Read a directory item */
|
||||
@ -226,26 +261,28 @@ FRESULT f_mkdir (const TCHAR* path); /* Create a sub directory */
|
||||
FRESULT f_unlink (const TCHAR* path); /* Delete an existing file or directory */
|
||||
FRESULT f_rename (const TCHAR* path_old, const TCHAR* path_new); /* Rename/Move a file or directory */
|
||||
FRESULT f_stat (const TCHAR* path, FILINFO* fno); /* Get file status */
|
||||
FRESULT f_chmod (const TCHAR* path, BYTE attr, BYTE mask); /* Change attribute of the file/dir */
|
||||
FRESULT f_utime (const TCHAR* path, const FILINFO* fno); /* Change times-tamp of the file/dir */
|
||||
FRESULT f_chmod (const TCHAR* path, BYTE attr, BYTE mask); /* Change attribute of a file/dir */
|
||||
FRESULT f_utime (const TCHAR* path, const FILINFO* fno); /* Change timestamp of a file/dir */
|
||||
FRESULT f_chdir (const TCHAR* path); /* Change current directory */
|
||||
FRESULT f_chdrive (const TCHAR* path); /* Change current drive */
|
||||
FRESULT f_getcwd (TCHAR* buff, UINT len); /* Get current directory */
|
||||
FRESULT f_getfree (const TCHAR* path, DWORD* nclst, FATFS** fatfs); /* Get number of free clusters on the drive */
|
||||
FRESULT f_getlabel (const TCHAR* path, TCHAR* label, DWORD* vsn); /* Get volume label */
|
||||
FRESULT f_setlabel (const TCHAR* label); /* Set volume label */
|
||||
FRESULT f_forward (FIL* fp, UINT(*func)(const BYTE*,UINT), UINT btf, UINT* bf); /* Forward data to the stream */
|
||||
FRESULT f_expand (FIL* fp, FSIZE_t szf, BYTE opt); /* Allocate a contiguous block to the file */
|
||||
FRESULT f_mount (FATFS* fs, const TCHAR* path, BYTE opt); /* Mount/Unmount a logical drive */
|
||||
FRESULT f_mkfs (const TCHAR* path, BYTE sfd, UINT au); /* Create a file system on the volume */
|
||||
FRESULT f_fdisk (BYTE pdrv, const DWORD szt[], void* work); /* Divide a physical drive into some partitions */
|
||||
FRESULT f_mkfs (const TCHAR* path, BYTE opt, DWORD au, void* work, UINT len); /* Create a FAT volume */
|
||||
FRESULT f_fdisk (BYTE pdrv, const DWORD* szt, void* work); /* Divide a physical drive into some partitions */
|
||||
int f_putc (TCHAR c, FIL* fp); /* Put a character to the file */
|
||||
int f_puts (const TCHAR* str, FIL* cp); /* Put a string to the file */
|
||||
int f_printf (FIL* fp, const TCHAR* str, ...); /* Put a formatted string to the file */
|
||||
TCHAR* f_gets (TCHAR* buff, int len, FIL* fp); /* Get a string from the file */
|
||||
|
||||
#define f_eof(fp) ((int)((fp)->fptr == (fp)->fsize))
|
||||
#define f_eof(fp) ((int)((fp)->fptr == (fp)->obj.objsize))
|
||||
#define f_error(fp) ((fp)->err)
|
||||
#define f_tell(fp) ((fp)->fptr)
|
||||
#define f_size(fp) ((fp)->fsize)
|
||||
#define f_size(fp) ((fp)->obj.objsize)
|
||||
#define f_rewind(fp) f_lseek((fp), 0)
|
||||
#define f_rewinddir(dp) f_readdir((dp), 0)
|
||||
|
||||
@ -265,7 +302,7 @@ DWORD get_fattime (void);
|
||||
#endif
|
||||
|
||||
/* Unicode support functions */
|
||||
#if _USE_LFN /* Unicode - OEM code conversion */
|
||||
#if _USE_LFN != 0 /* Unicode - OEM code conversion */
|
||||
WCHAR ff_convert (WCHAR chr, UINT dir); /* OEM-Unicode bidirectional conversion */
|
||||
WCHAR ff_wtoupper (WCHAR chr); /* Unicode upper-case conversion */
|
||||
#if _USE_LFN == 3 /* Memory functions */
|
||||
@ -289,60 +326,39 @@ int ff_del_syncobj (_SYNC_t sobj); /* Delete a sync object */
|
||||
/* Flags and offset address */
|
||||
|
||||
|
||||
/* File access control and file status flags (FIL.flag) */
|
||||
|
||||
/* File access mode and open method flags (3rd argument of f_open) */
|
||||
#define FA_READ 0x01
|
||||
#define FA_OPEN_EXISTING 0x00
|
||||
|
||||
#if !_FS_READONLY
|
||||
#define FA_WRITE 0x02
|
||||
#define FA_OPEN_EXISTING 0x00
|
||||
#define FA_CREATE_NEW 0x04
|
||||
#define FA_CREATE_ALWAYS 0x08
|
||||
#define FA_OPEN_ALWAYS 0x10
|
||||
#define FA__WRITTEN 0x20
|
||||
#define FA__DIRTY 0x40
|
||||
#endif
|
||||
#define FA_OPEN_APPEND 0x30
|
||||
|
||||
/* Fast seek controls (2nd argument of f_lseek) */
|
||||
#define CREATE_LINKMAP ((FSIZE_t)0 - 1)
|
||||
|
||||
/* FAT sub type (FATFS.fs_type) */
|
||||
/* Format options (2nd argument of f_mkfs) */
|
||||
#define FM_FAT 0x01
|
||||
#define FM_FAT32 0x02
|
||||
#define FM_EXFAT 0x04
|
||||
#define FM_ANY 0x07
|
||||
#define FM_SFD 0x08
|
||||
|
||||
/* Filesystem type (FATFS.fs_type) */
|
||||
#define FS_FAT12 1
|
||||
#define FS_FAT16 2
|
||||
#define FS_FAT32 3
|
||||
#define FS_EXFAT 4
|
||||
|
||||
|
||||
/* File attribute bits for directory entry */
|
||||
|
||||
/* File attribute bits for directory entry (FILINFO.fattrib) */
|
||||
#define AM_RDO 0x01 /* Read only */
|
||||
#define AM_HID 0x02 /* Hidden */
|
||||
#define AM_SYS 0x04 /* System */
|
||||
#define AM_VOL 0x08 /* Volume label */
|
||||
#define AM_LFN 0x0F /* LFN entry */
|
||||
#define AM_DIR 0x10 /* Directory */
|
||||
#define AM_ARC 0x20 /* Archive */
|
||||
#define AM_MASK 0x3F /* Mask of defined bits */
|
||||
|
||||
|
||||
/* Fast seek feature */
|
||||
#define CREATE_LINKMAP 0xFFFFFFFF
|
||||
|
||||
|
||||
|
||||
/*--------------------------------*/
|
||||
/* Multi-byte word access macros */
|
||||
|
||||
#if _WORD_ACCESS == 1 /* Enable word access to the FAT structure */
|
||||
#define LD_WORD(ptr) (WORD)(*(WORD*)(BYTE*)(ptr))
|
||||
#define LD_DWORD(ptr) (DWORD)(*(DWORD*)(BYTE*)(ptr))
|
||||
#define ST_WORD(ptr,val) *(WORD*)(BYTE*)(ptr)=(WORD)(val)
|
||||
#define ST_DWORD(ptr,val) *(DWORD*)(BYTE*)(ptr)=(DWORD)(val)
|
||||
#else /* Use byte-by-byte access to the FAT structure */
|
||||
#define LD_WORD(ptr) (WORD)(((WORD)*((BYTE*)(ptr)+1)<<8)|(WORD)*(BYTE*)(ptr))
|
||||
#define LD_DWORD(ptr) (DWORD)(((DWORD)*((BYTE*)(ptr)+3)<<24)|((DWORD)*((BYTE*)(ptr)+2)<<16)|((WORD)*((BYTE*)(ptr)+1)<<8)|*(BYTE*)(ptr))
|
||||
#define ST_WORD(ptr,val) *(BYTE*)(ptr)=(BYTE)(val); *((BYTE*)(ptr)+1)=(BYTE)((WORD)(val)>>8)
|
||||
#define ST_DWORD(ptr,val) *(BYTE*)(ptr)=(BYTE)(val); *((BYTE*)(ptr)+1)=(BYTE)((WORD)(val)>>8); *((BYTE*)(ptr)+2)=(BYTE)((DWORD)(val)>>16); *((BYTE*)(ptr)+3)=(BYTE)((DWORD)(val)>>24)
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|