fatfs v0.10b Mar 19,2014:

- Fixed a hard error in the disk I/O layer can collapse the directory entry.
- Fixed LFN entry is not deleted on delete/rename an object with lossy converted SFN.
This commit is contained in:
savelij13 2025-09-11 10:02:42 +03:00
parent 93faa45738
commit fb65f51fbe
64 changed files with 575 additions and 520 deletions

View File

@ -1,11 +1,10 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html lang="en"> <html lang="en">
<head> <head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta http-equiv="Content-Style-Type" content="text/css"> <meta http-equiv="Content-Style-Type" content="text/css">
<meta http-equiv="cache-control" content="no-cache">
<meta name="description" content="Open source FAT file system module for embedded projects"> <meta name="description" content="Open source FAT file system module for embedded projects">
<link rel="start" title="Site Top" href="../../">
<link rel="up" title="Freewares" href="../../fsw_e.html">
<link rel="alternate" hreflang="ja" title="Japanese version" href="00index_j.html"> <link rel="alternate" hreflang="ja" title="Japanese version" href="00index_j.html">
<link rel="stylesheet" href="css_e.css" type="text/css" media="screen" title="ELM Default"> <link rel="stylesheet" href="css_e.css" type="text/css" media="screen" title="ELM Default">
<title>FatFs - Generic FAT File System Module</title> <title>FatFs - Generic FAT File System Module</title>
@ -17,7 +16,7 @@
<div class="abst"> <div class="abst">
<img src="img/layers.png" class="rset" width="245" height="255" alt="layer"> <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 is written in compliance with ANSI C and completely separated from the disk I/O layer. Therefore it is independent of hardware architecture. It can be incorporated into low cost microcontrollers, such as AVR, 8051, PIC, ARM, Z80, 68k and etc..., without any change. Petit FatFs module is also available <a href="http://elm-chan.org/fsw/ff/00index_p.html">here</a>.</p> <p>FatFs is a generic FAT file system module for small embedded systems. The FatFs is written in compliance with ANSI C and completely separated from the disk I/O layer. Therefore it is independent of hardware architecture. It can be incorporated into small microcontrollers with limited resource, such as AVR, 8051, PIC, ARM, Z80, 68k 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> <h4>Features</h4>
<ul> <ul>
@ -63,7 +62,7 @@
<li><a href="en/chdir.html">f_chdir</a> - Change current directory</li> <li><a href="en/chdir.html">f_chdir</a> - Change current directory</li>
<li><a href="en/chdrive.html">f_chdrive</a> - Change current drive</li> <li><a href="en/chdrive.html">f_chdrive</a> - Change current drive</li>
<li><a href="en/getcwd.html">f_getcwd</a> - Retrieve the current directory</li> <li><a href="en/getcwd.html">f_getcwd</a> - Retrieve the current directory</li>
<li><a href="en/getfree.html">f_getfree</a> - Get free clusters</li> <li><a href="en/getfree.html">f_getfree</a> - Get free space on the volume</li>
<li><a href="en/getlabel.html">f_getlabel</a> - Get volume label</li> <li><a href="en/getlabel.html">f_getlabel</a> - Get volume label</li>
<li><a href="en/setlabel.html">f_setlabel</a> - Set volume label</li> <li><a href="en/setlabel.html">f_setlabel</a> - Set volume label</li>
<li><a href="en/mkfs.html">f_mkfs</a> - Create a file system on the drive</li> <li><a href="en/mkfs.html">f_mkfs</a> - Create a file system on the drive</li>
@ -81,8 +80,8 @@
<div class="para"> <div class="para">
<h3>Disk I/O Interface</h3> <h3>Device Control Interface</h3>
<p>Since the FatFs module is completely separated from disk I/O layer, it requires following functions to access the storage device. When O/S related feature is enabled, it will require process/memory functions in addition. However the low level disk I/O module is not a part of FatFs module, so that it must be provided by user. The sample implementations are also available in the downloads.</p> <p>Since the FatFs module is a file system driver, it is completely separated from physical devices, such as memory card, harddisk and any type of storage devices. The low level device control module is not a part of FatFs module. FatFs accesses the storage device via a simple interface described below. These functions are provided by implementer. Sample implementations for some platforms are also available in the downloads.</p>
<ul> <ul>
<li><a href="en/dstat.html">disk_status</a> - Get device status</li> <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/dinit.html">disk_initialize</a> - Initialize device</li>
@ -98,20 +97,22 @@
<h3>Resources</h3> <h3>Resources</h3>
<p>The FatFs module is a free software opened for education, research and development. You can use, modify and/or redistribute it for personal projects or commercial products without any restriction under your responsibility. For further information, refer to the application note.</p> <p>The FatFs module is a free software opened for education, research and development. You can use, modify and/or redistribute it for personal projects or commercial products without any restriction under your responsibility. For further information, refer to the application note.</p>
<ul> <ul>
<li><a href="http://elm-chan.org/fsw/ff/bd/"><em>FatFs User Forum</em></a></li> <li><a href="http://elm-chan.org/fsw/ff/bd/"><em>FatFs User Forum</em></a></li>
<li>Read first: <a href="en/appnote.html">FatFs module application note</a></li> <li>Read first: <a href="en/appnote.html">FatFs module application note</a></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>Latest Information: <a href="http://elm-chan.org/fsw/ff/00index_e.html">http://elm-chan.org/fsw/ff/00index_e.html</a></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://nemuisan.blog.bai.ne.jp/">Nemuisan's Blog</a>↗ (Well written implementations for STM32F/SDIO and LPC2300/MCI)</li>
<li><a href="http://www.microsoft.com/whdc/system/platform/firmware/fatgen.mspx">FAT32 Specification by Microsoft</a> (The reference document on FAT file system)</li> <li><a href="http://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://elm-chan.org/docs/fat.html">The basics of FAT file system [ja]</a></li> <li><a href="http://www.microsoft.com/whdc/system/platform/firmware/fatgen.mspx">FAT32 Specification by Microsoft</a>↗ (The reference document on FAT file system)</li>
<li><a href="http://elm-chan.org/docs/mmc/mmc_e.html">How to Use MMC/SDC</a></li> <li><a href="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/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="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> </ul>
</div> </div>
<hr> <hr>
<p class="foot"><a href="http://elm-chan.org/fsw/ff/00index_e.html">Go to FatFs home page</a></p> <p class="foot"><a href="../../fsw_e.html">Return</a></p>
</body> </body>
</html> </html>

View File

@ -1,36 +1,37 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html lang="ja"> <html lang="ja">
<head> <head>
<meta http-equiv="Content-Type" content="text/html; charset=Shift_JIS"> <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta http-equiv="Content-Style-Type" content="text/css"> <meta http-equiv="Content-Style-Type" content="text/css">
<meta name="description" content="組み込みシステム向け汎用FATファイル・システム"> <meta http-equiv="cache-control" content="no-cache">
<meta name="description" content="組み込みシステム向け汎用FATファイル・システム">
<link rel="start" title="Site Top" href="../../index_j.html"> <link rel="start" title="Site Top" href="../../index_j.html">
<link rel="up" title="Freewares" href="../../fsw.html"> <link rel="up" title="Freewares" href="../../fsw.html">
<link rel="alternate" hreflang="en" title="英文" href="00index_e.html"> <link rel="alternate" hreflang="en" title="英文" href="00index_e.html">
<link rel="stylesheet" href="css_j.css" type="text/css" media="screen" title="ELM Default"> <link rel="stylesheet" href="css_j.css" type="text/css" media="screen" title="ELM Default">
<title>FatFs 汎用FATファイルシステム・モジュール</title> <title>FatFs 汎用FATファイルシステム・モジュール</title>
</head> </head>
<body> <body>
<h1>FatFs 汎用FATファイルシステム・モジュール</h1> <h1>FatFs 汎用FATファイルシステム・モジュール</h1>
<hr> <hr>
<div class="abst"> <div class="abst">
<img src="img/layers.png" class="rset" width="245" height="255" alt="layer"> <img src="img/layers.png" class="rset" width="245" height="255" alt="layer">
<p>FatFsは小規模な組み込みシステム向けの汎用FATファイルシステム・モジュールです。ANSI C準拠でハードウェア・アーキテクチャには依存しないので、必要なワーク・エリアが確保できれば、8051, PIC, AVR, SH, Z80, 68k, H8, ARMなど安価なマイコンでも使用可能です。FatFsをシュリンクした<a href="http://elm-chan.org/fsw/ff/00index_p.html">ぷちFatFs</a>もあります。</p> <p>FatFsは小規模な組み込みシステム向けの汎用FATファイルシステム・モジュールです。ANSI C準拠でハードウェア・アーキテクチャには依存しないので、必要なワーク・エリアが確保できれば、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> <h4>FatFsモジュールの特徴</h4>
<ul> <ul>
<li>Windows互換 FATファイル・システム</li> <li>Windows互換 FATファイル・システム</li>
<li>プラットフォーム非依存</li> <li>プラットフォーム非依存</li>
<li>コンパクトなコードとRAM使用量</li> <li>コンパクトなコードとRAM使用量</li>
<li>多くの構成オプション: <li>多くの構成オプション:
<ul> <ul>
<li>複数のボリューム(物理ドライブ・区画)</li> <li>複数のボリューム(物理ドライブ・区画)</li>
<li>DBCSを含む複数のANSI/OEMコード・ページ</li> <li>DBCSを含む複数のANSI/OEMコード・ページ</li>
<li>長いファイル名(LFN) (Unicode APIも選択可)</li> <li>長いファイル名(LFN) (Unicode APIも選択可)</li>
<li>マルチタスク関連</li> <li>マルチタスク関連</li>
<li>マルチ・セクタ・サイズ</li> <li>マルチ・セクタ・サイズ</li>
<li>リード・オンリー構成、一部APIの削除、バッファ構成、その他…</li> <li>リード・オンリー構成、一部APIの削除、バッファ構成、その他…</li>
</ul> </ul>
</li> </li>
</ul> </ul>
@ -38,79 +39,80 @@
<div class="para"> <div class="para">
<h3>上位レイヤ・インターフェース</h3> <h3>上位レイヤ・インターフェース</h3>
<p>FatFsモジュールは、アプリケーション・レイヤに対し、次のファイル操作関数(API)を提供します。つまり、このリストはFatFsにできることをシンプルに示しています。</p> <p>FatFsモジュールは、アプリケーション・レイヤに対し、次のファイル操作関数(API)を提供します。つまり、このリストはFatFsにできることをシンプルに示しています。</p>
<ul> <ul>
<li><a href="ja/mount.html">f_mount</a> - ワークエリアの登録・削除</li> <li><a href="ja/mount.html">f_mount</a> - ワークエリアの登録・抹消</li>
<li><a href="ja/open.html">f_open</a> - ファイルのオープン・作成</li> <li><a href="ja/open.html">f_open</a> - ファイルのオープン・作成</li>
<li><a href="ja/close.html">f_close</a> - ファイルのクローズ</li> <li><a href="ja/close.html">f_close</a> - ファイルのクローズ</li>
<li><a href="ja/read.html">f_read</a> - ファイルの読み出し</li> <li><a href="ja/read.html">f_read</a> - ファイルの読み出し</li>
<li><a href="ja/write.html">f_write</a> - ファイルの書き込み</li> <li><a href="ja/write.html">f_write</a> - ファイルの書き込み</li>
<li><a href="ja/lseek.html">f_lseek</a> - リード/ライト・ポインタの移動, ファイルの拡張</li> <li><a href="ja/lseek.html">f_lseek</a> - リード/ライト・ポインタの移動, ファイルの拡張</li>
<li><a href="ja/truncate.html">f_truncate</a> - ファイル・サイズの切り詰め</li> <li><a href="ja/truncate.html">f_truncate</a> - ファイル・サイズの切り詰め</li>
<li><a href="ja/sync.html">f_sync</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/forward.html">f_forward</a> - ファイル・データをストリーム関数に転送</li>
<li><a href="ja/stat.html">f_stat</a> - ファイル/サブ・ディレクトリの存在チェックと情報の取得</li> <li><a href="ja/stat.html">f_stat</a> - ファイル/サブ・ディレクトリの存在チェックと情報の取得</li>
<li><a href="ja/opendir.html">f_opendir</a> - ディレクトリのオープン</li> <li><a href="ja/opendir.html">f_opendir</a> - ディレクトリのオープン</li>
<li><a href="ja/closedir.html">f_closedir</a> - ディレクトリのクローズ</li> <li><a href="ja/closedir.html">f_closedir</a> - ディレクトリのクローズ</li>
<li><a href="ja/readdir.html">f_readdir</a> - ディレクトリの読み出し</li> <li><a href="ja/readdir.html">f_readdir</a> - ディレクトリの読み出し</li>
<li><a href="ja/mkdir.html">f_mkdir</a> - サブ・ディレクトリの作成</li> <li><a href="ja/mkdir.html">f_mkdir</a> - サブ・ディレクトリの作成</li>
<li><a href="ja/unlink.html">f_unlink</a> - ファイル/サブ・ディレクトリの削除</li> <li><a href="ja/unlink.html">f_unlink</a> - ファイル/サブ・ディレクトリの削除</li>
<li><a href="ja/chmod.html">f_chmod</a> - ファイル/サブ・ディレクトリの属性の変更</li> <li><a href="ja/chmod.html">f_chmod</a> - ファイル/サブ・ディレクトリの属性の変更</li>
<li><a href="ja/utime.html">f_utime</a> - ファイル/サブ・ディレクトリのタイムスタンプの変更</li> <li><a href="ja/utime.html">f_utime</a> - ファイル/サブ・ディレクトリのタイムスタンプの変更</li>
<li><a href="ja/rename.html">f_rename</a> - ファイル/サブ・ディレクトリの名前変更・移動</li> <li><a href="ja/rename.html">f_rename</a> - ファイル/サブ・ディレクトリの名前変更・移動</li>
<li><a href="ja/chdir.html">f_chdir</a> - カレント・ディレクトリの変更</li> <li><a href="ja/chdir.html">f_chdir</a> - カレント・ディレクトリの変更</li>
<li><a href="ja/chdrive.html">f_chdrive</a> - カレント・ドライブの変更</li> <li><a href="ja/chdrive.html">f_chdrive</a> - カレント・ドライブの変更</li>
<li><a href="ja/getcwd.html">f_getcwd</a> - カレント・ディレクトリの取得</li> <li><a href="ja/getcwd.html">f_getcwd</a> - カレント・ディレクトリの取得</li>
<li><a href="ja/getfree.html">f_getfree</a> - ボリューム空き領域の取得</li> <li><a href="ja/getfree.html">f_getfree</a> - ボリューム空き領域の取得</li>
<li><a href="ja/getlabel.html">f_getlabel</a> - ボリューム・ラベルの取得</li> <li><a href="ja/getlabel.html">f_getlabel</a> - ボリューム・ラベルの取得</li>
<li><a href="ja/setlabel.html">f_setlabel</a> - ボリューム・ラベルの設定</li> <li><a href="ja/setlabel.html">f_setlabel</a> - ボリューム・ラベルの設定</li>
<li><a href="ja/mkfs.html">f_mkfs</a> - 論理ドライブのフォーマット</li> <li><a href="ja/mkfs.html">f_mkfs</a> - 論理ドライブのフォーマット</li>
<li><a href="ja/fdisk.html">f_fdisk</a> - 物理ドライブの分割</li> <li><a href="ja/fdisk.html">f_fdisk</a> - 物理ドライブの分割</li>
<li><a href="ja/gets.html">f_gets</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/putc.html">f_putc</a> - 文字の書き込み</li>
<li><a href="ja/puts.html">f_puts</a> - 文字列の書き込み</li> <li><a href="ja/puts.html">f_puts</a> - 文字列の書き込み</li>
<li><a href="ja/printf.html">f_printf</a> - 書式化文字列の書き込み</li> <li><a href="ja/printf.html">f_printf</a> - 書式化文字列の書き込み</li>
<li><a href="ja/tell.html">f_tell</a> - 現在のリード/ライト・ポインタの取得</li> <li><a href="ja/tell.html">f_tell</a> - 現在のリード/ライト・ポインタの取得</li>
<li><a href="ja/eof.html">f_eof</a> - ファイル終端の有無の取得</li> <li><a href="ja/eof.html">f_eof</a> - ファイル終端の有無の取得</li>
<li><a href="ja/size.html">f_size</a> - ファイル・サイズの取得</li> <li><a href="ja/size.html">f_size</a> - ファイル・サイズの取得</li>
<li><a href="ja/error.html">f_error</a> - ファイルのエラーの有無の取得</li> <li><a href="ja/error.html">f_error</a> - ファイルのエラーの有無の取得</li>
</ul> </ul>
</div> </div>
<div class="para"> <div class="para">
<h3>下位レイヤ・インターフェース</h3> <h3>下位レイヤ・インターフェース</h3>
<p>FatFsモジュールは、単なるファイル・システム・レイヤなので、ストレージ・デバイス制御レイヤは含まれません。使用するストレージに対応した制御関数は、ユーザによって提供される必要があります。FatFsモジュールは、下位レイヤに対し少なくとも次のインターフェースを要求します。OS関連機能を有効にしたときは、これに加えてプロセス/メモリ関連関数も必要になります。サンプル・プロジェクトに下位レイヤの実装例を示します。</p> <p>FatFsモジュールは、単なるファイル・システム・レイヤなので、ストレージ・デバイス制御レイヤは含まれません。使用するストレージに対応した制御関数は、ユーザによって提供される必要があります。FatFsモジュールは、下位レイヤに対し少なくとも次のインターフェースを要求します。OS関連機能を有効にしたときは、これに加えてプロセス/メモリ関連関数も必要になります。サンプル・プロジェクトに下位レイヤの実装例を示します。</p>
<ul> <ul>
<li><a href="ja/dstat.html">disk_status</a> - デバイスの状態取得</li> <li><a href="ja/dstat.html">disk_status</a> - デバイスの状態取得</li>
<li><a href="ja/dinit.html">disk_initialize</a> - デバイスの初期化</li> <li><a href="ja/dinit.html">disk_initialize</a> - デバイスの初期化</li>
<li><a href="ja/dread.html">disk_read</a> - データの読み出し</li> <li><a href="ja/dread.html">disk_read</a> - データの読み出し</li>
<li><a href="ja/dwrite.html">disk_write</a> - データの書き込み</li> <li><a href="ja/dwrite.html">disk_write</a> - データの書き込み</li>
<li><a href="ja/dioctl.html">disk_ioctl</a> - その他のデバイス制御</li> <li><a href="ja/dioctl.html">disk_ioctl</a> - その他のデバイス制御</li>
<li><a href="ja/fattime.html">get_fattime</a> - 日付・時刻の取得</li> <li><a href="ja/fattime.html">get_fattime</a> - 日付・時刻の取得</li>
</ul> </ul>
</div> </div>
<div class="para"> <div class="para">
<h3>資料</h3> <h3>資料</h3>
<p>FatFsモジュールはフリー・ソフトウェアとして教育・研究・開発用に公開しています。どのような利用目的個人利用から商用まででも使用・改変・配布について一切の制限はありませんが、全て利用者の責任の下での利用とします。詳しくはアプリケーション・ートを参照してください。</p> <p>FatFsモジュールはフリー・ソフトウェアとして教育・研究・開発用に公開しています。どのような利用目的個人利用から商用まででも使用・改変・配布について一切の制限はありませんが、全て利用者の責任の下での利用とします。詳しくはアプリケーション・ートを参照してください。</p>
<ul> <ul>
<li><a href="http://elm-chan.org/fsw/ff/bd/"><em>FatFsユーザ・フォーラム</em></a></li> <li><a href="http://elm-chan.org/fsw/ff/bd/"><em>FatFsユーザ・フォーラム</em></a></li>
<li>最初に読め: <a href="ja/appnote.html">FatFsモジュール・アプリケーション・ート</a></li> <li>最初に読め: <a href="ja/appnote.html">FatFsモジュール・アプリケーション・ート</a></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://elm-chan.org/fsw/ff/00index_j.html">http://elm-chan.org/fsw/ff/00index_j.html</a></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://nemuisan.blog.bai.ne.jp/">ねむいさんのぶろぐ</a>↗ (Well written implementations for STM32F/SDIO and LPC2300/MCI)</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="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://elm-chan.org/docs/fat.html">FATファイル・システム概要</a> (↑を読むためのガイド)</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="http://elm-chan.org/docs/mmc/mmc.html">MMCの使いかた</a></li> <li><a href="http://elm-chan.org/docs/fat.html">FATファイル・システム概要</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="http://elm-chan.org/docs/mmc/mmc.html">MMCの使いかた</a></li>
<li><a href="img/rwtest2.png">パフォーマンス・テスト2</a> (LPC2368/72MHz with MMC via MCI)</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>
</ul> </ul>
</div> </div>
<hr> <hr>
<p class="foot"><a href="http://elm-chan.org/fsw/ff/00index_j.html">FatFsホームページへ</a></p> <p class="foot"><a href="../../fsw.html">戻る</a></p>
</body> </body>
</html> </html>

View File

@ -7,6 +7,8 @@ a:active {color: darkmagenta; overflow: hidden; outline:none; position: relative
abbr {border-width: 1px;} abbr {border-width: 1px;}
p {margin: 0 0 0.3em 1em;} p {margin: 0 0 0.3em 1em;}
i {margin: 0 0.3em 0 0;}
b {margin: 0 0.1em;}
em {font-style: normal; font-weight: bold; margin: 0 0.1em;} em {font-style: normal; font-weight: bold; margin: 0 0.1em;}
strong {} strong {}
pre {border: 1px dashed gray; margin: 0.5em 1em; padding: 0.5em; line-height: 1.2em; font-size: 85%; font-family: "Consolas", "Courier New", monospace; background-color: white;} pre {border: 1px dashed gray; margin: 0.5em 1em; padding: 0.5em; line-height: 1.2em; font-size: 85%; font-family: "Consolas", "Courier New", monospace; background-color: white;}
@ -28,8 +30,8 @@ div.para {clear: both; font-family: serif;}
div.ret a {font-size: 0.85em; font-family: "Consolas", "Courier New", monospace; } div.ret a {font-size: 0.85em; font-family: "Consolas", "Courier New", monospace; }
.equ {text-indent: 0; margin: 1em 2em 1em;} .equ {text-indent: 0; margin: 1em 2em 1em;}
.indent {margin-left: 2em;} .indent {margin-left: 2em;}
.rset {float: right; margin: 0 0 0.5em 0.5em;} .rset {float: right; margin: 0.3em 0 0.5em 0.5em;}
.lset {float: left; margin: 0 0.5em 0.5em 0.5em;} .lset {float: left; margin: 0.3em 0.5em 0.5em 0.5em;}
ul.flat li {list-style-type: none; margin: 0;} ul.flat li {list-style-type: none; margin: 0;}
a.imglnk img {border: 1px solid;} a.imglnk img {border: 1px solid;}
.iequ {white-space: nowrap; font-weight: bold;} .iequ {white-space: nowrap; font-weight: bold;}

View File

@ -10,6 +10,8 @@ a:active {color: darkmagenta; overflow: hidden; outline:none; position: relative
abbr {border-width: 1px;} abbr {border-width: 1px;}
p {text-indent: 1em; margin: 0 0 0.3em 0.5em;} p {text-indent: 1em; margin: 0 0 0.3em 0.5em;}
i {margin: 0 0.3em 0 0;}
b {margin: 0 0.1em;}
em {font-style: normal; font-weight: bold; margin: 0 0.1em;} em {font-style: normal; font-weight: bold; margin: 0 0.1em;}
strong {} strong {}
pre {border: 1px dashed gray; margin: 0.5em 1em; padding: 0.5em; line-height: 1.2em; letter-spacing: 0; font-size: 0.85em; font-family: "Consolas", "Courier New", "lr ƒSƒVƒbƒN", monospace; background-color: white;} pre {border: 1px dashed gray; margin: 0.5em 1em; padding: 0.5em; line-height: 1.2em; letter-spacing: 0; font-size: 0.85em; font-family: "Consolas", "Courier New", "lr ƒSƒVƒbƒN", monospace; background-color: white;}
@ -31,8 +33,8 @@ div.para {clear: both; font-family: "
div.ret a {font-size: 0.85em; font-family: "Consolas", "Courier New", monospace; } div.ret a {font-size: 0.85em; font-family: "Consolas", "Courier New", monospace; }
.equ {text-indent: 0; margin: 1em 2em 1em;} .equ {text-indent: 0; margin: 1em 2em 1em;}
.indent {margin-left: 2em;} .indent {margin-left: 2em;}
.rset {float: right; margin: 0 0 0.5em 0.5em;} .rset {float: right; margin: 0.3em 0 0.5em 0.5em;}
.lset {float: left; margin: 0 0.5em 0.5em 0.5em;} .lset {float: left; margin: 0.3em 0.5em 0.5em 0.5em;}
ul.flat li {list-style-type: none; margin: 0;} ul.flat li {list-style-type: none; margin: 0;}
a.imglnk img {border: 1px solid;} a.imglnk img {border: 1px solid;}
.iequ {white-space: nowrap; font-weight: bold;} .iequ {white-space: nowrap; font-weight: bold;}

1
doc/css_p.css Normal file
View File

@ -0,0 +1 @@
body {margin: 8px; background-color: #ffecf0; font-color: black; font-family: serif; line-height: 133%; max-width: 1024px;}

View File

@ -44,7 +44,7 @@ The FatFs module assumes that size of char/short/long are 8/16/32 bit and int is
<p>The dependency diagram shown below is a typical configuration of the embedded system with FatFs module.</p> <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><img src="../img/modules.png" width="580" height="280" alt="dependency diagram"></p>
<p>(a) If a working disk module with FatFs API is provided, no additional function is needed. (b) To attach existing disk drivers with different API, glue functions are needed to translate the APIs between FatFs and the drivers.</p> <p>(a) If a working disk module with FatFs 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="450" alt="functional diagram"></p> <p><img src="../img/funcs.png" width="680" height="430" alt="functional diagram"></p>
<h4>Which function is required?</h4> <h4>Which function is required?</h4>
<p>You need to provide only low level disk I/O functions that required by FatFs module and nothing else. If a working disk module for the target is already existing, you need to write only glue functions to attach it to the FatFs module. If not, you need to port any other disk module or write it from scratch. Most of defined functions are not that always required. For example, disk write function is not required in read-only configuration. Following table shows which function is required depends on configuration options.</p> <p>You need to provide only low level disk I/O functions that required by FatFs module and nothing else. If a working disk module for the target is already existing, you need to write only glue functions to attach it to the FatFs module. If not, you need to port any other disk module or write it from scratch. Most of defined functions are not that always required. For example, disk write function is not required in read-only configuration. Following table shows which function is required depends on configuration options.</p>
@ -54,8 +54,8 @@ The FatFs module assumes that size of char/short/long are 8/16/32 bit and int is
<tr><td>disk_write<br>get_fattime<br>disk_ioctl (CTRL_SYNC)</td><td>_FS_READONLY == 0</td></tr> <tr><td>disk_write<br>get_fattime<br>disk_ioctl (CTRL_SYNC)</td><td>_FS_READONLY == 0</td></tr>
<tr><td>disk_ioctl (GET_SECTOR_COUNT)<br>disk_ioctl (GET_BLOCK_SIZE)</td><td>_USE_MKFS == 1</td></tr> <tr><td>disk_ioctl (GET_SECTOR_COUNT)<br>disk_ioctl (GET_BLOCK_SIZE)</td><td>_USE_MKFS == 1</td></tr>
<tr><td>disk_ioctl (GET_SECTOR_SIZE)</td><td>_MAX_SS != _MIN_SS</td></tr> <tr><td>disk_ioctl (GET_SECTOR_SIZE)</td><td>_MAX_SS != _MIN_SS</td></tr>
<tr><td>disk_ioctl (CTRL_ERASE_SECTOR)</td><td>_USE_ERASE == 1</td></tr> <tr><td>disk_ioctl (CTRL_TRIM)</td><td>_USE_TRIM == 1</td></tr>
<tr><td>ff_convert<br>ff_wtoupper</td><td>_USE_LFN &gt;= 1</td><td>Unicode support functions.<br>Available in option/cc*.c.</td></tr> <tr><td>ff_convert<br>ff_wtoupper</td><td>_USE_LFN &gt;= 1</td><td>Unicode support functions.<br>Available in option/unicode.c.</td></tr>
<tr><td>ff_cre_syncobj<br>ff_del_syncobj<br>ff_req_grant<br>ff_rel_grant</td><td>_FS_REENTRANT == 1</td><td rowspan="2">O/S dependent functions.<br>Samples available in option/syscall.c.</td></tr> <tr><td>ff_cre_syncobj<br>ff_del_syncobj<br>ff_req_grant<br>ff_rel_grant</td><td>_FS_REENTRANT == 1</td><td rowspan="2">O/S dependent functions.<br>Samples available in option/syscall.c.</td></tr>
<tr><td>ff_mem_alloc<br>ff_mem_free</td><td>_USE_LFN == 3</td></tr> <tr><td>ff_mem_alloc<br>ff_mem_free</td><td>_USE_LFN == 3</td></tr>
</table> </table>
@ -67,10 +67,10 @@ The FatFs module assumes that size of char/short/long are 8/16/32 bit and int is
<li>FAT sub-types: FAT12, FAT16 and FAT32.</li> <li>FAT sub-types: FAT12, FAT16 and FAT32.</li>
<li>Number of open files: Unlimited, depends on available memory.</li> <li>Number of open files: Unlimited, depends on available memory.</li>
<li>Number of volumes: Upto 10.</li> <li>Number of volumes: Upto 10.</li>
<li>File size: Depends on FAT specs. (upto 4G-1 bytes)</li> <li>File size: Depends on the FAT specs. (upto 4G-1 bytes)</li>
<li>Volume size: Depends on FAT specs. (upto 2T bytes at 512 bytes/sector)</li> <li>Volume size: Depends on the FAT specs. (upto 2T bytes at 512 bytes/sector)</li>
<li>Cluster size: Depends on FAT specs. (upto 64K bytes at 512 bytes/sector)</li> <li>Cluster size: Depends on the FAT specs. (upto 64K bytes at 512 bytes/sector)</li>
<li>Sector size: Depends on FAT specs. (512..4096 bytes)</li> <li>Sector size: Depends on the FAT specs. (512, 1024, 2048 and 4096 bytes)</li>
</ul> </ul>
</div> </div>
@ -151,7 +151,7 @@ _FS_LOCK 0 (Disable file lock control)
<div class="para" id="lfn"> <div class="para" id="lfn">
<h3>Long File Name</h3> <h3>Long File Name</h3>
<p>The FatFs module has started to support long file name (LFN) at revision 0.07. The two different file names, SFN and LFN, of a file is transparent in the file functions except for f_readdir function. To enable LFN feature, set <tt>_USE_LFN</tt> to 1, 2 or 3, and add a Unicode code conversion function <tt>ff_convert()</tt> and <tt>ff_wtoupper()</tt> to the project. The LFN feature requiers a certain working buffer in addition. The buffer size can be configured by <tt>_MAX_LFN</tt> corresponding to the available memory size. The size of long file name 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 given file name, the file function fails with <tt>FR_INVALID_NAME</tt>. When enable the LFN feature with re-entrant 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 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>_USE_LFN</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>_MAX_LFN</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 enable the LFN feature with re-entrant configuration, <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>
<table class="lst2 rset"> <table class="lst2 rset">
<caption>LFN cfg on ARM7TDMI</caption> <caption>LFN cfg on ARM7TDMI</caption>
<tr><th>Code page</th><th>Program size</th></tr> <tr><th>Code page</th><th>Program size</th></tr>
@ -167,13 +167,13 @@ _FS_LOCK 0 (Disable file lock control)
<div class="para" id="unicode"> <div class="para" id="unicode">
<h3>Unicode API</h3> <h3>Unicode API</h3>
<p>By default, FatFs uses ANSI/OEM code set on the API under LFN configuration. FatFs can also switch the character encoding to Unicode on the API (<tt>_LFN_UNICODE</tt>). This means the FatFs supports the True-LFN feature. For more information, refer to the description in the <a href="filename.html">file name</a>.</p> <p>By default, FatFs uses ANSI/OEM code set on the API under LFN configuration. FatFs can also switch the character encoding to Unicode on the API by <tt>_LFN_UNICODE</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">file name</a>.</p>
</div> </div>
<div class="para" id="reentrant"> <div class="para" id="reentrant">
<h3>Re-entrancy</h3> <h3>Re-entrancy</h3>
<p>The file operations to the different volume is always re-entrant and can work simultaneously. The file operations to the same volume is not re-entrant but it can also be configured to thread-safe with <tt>_FS_REENTRANT</tt> option. In this case, also the OS dependent synchronization object control functions, <tt>ff_cre_syncobj(), ff_del_syncobj(), ff_req_grant() and ff_rel_grant()</tt> must be added to the project.</p> <p>The file operations to the different volume is always re-entrant and can work simultaneously. The file operations to the same volume is not re-entrant but it can also be configured to thread-safe by <tt>_FS_REENTRANT</tt> option. In this case, also the OS dependent synchronization object control functions, <tt>ff_cre_syncobj(), ff_del_syncobj(), ff_req_grant() and ff_rel_grant()</tt> must 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 in use by any other task, the file function is suspended until that task leaves file function. If wait time exceeded a period defined by <tt>_TIMEOUT</tt>, the file function will abort with <tt>FR_TIMEOUT</tt>. The timeout feature might not be supported by some RTOS.</p> <p>When a file function is called while the volume is in use by any other task, the file function is suspended until that task leaves the file function. If wait time exceeded a period defined by <tt>_TIMEOUT</tt>, the file function will abort with <tt>FR_TIMEOUT</tt>. The timeout feature might not be supported by some RTOS.</p>
<p>There is an exception for <tt>f_mount(), f_mkfs(), f_fdisk()</tt> function. These functions are not re-entrant to the same volume or corresponding physical drive. When use these functions, all other tasks must unmount the volume and avoid to access the volume.</p> <p>There is an exception for <tt>f_mount(), f_mkfs(), f_fdisk()</tt> function. These functions are not re-entrant to the same volume or corresponding physical drive. When use these functions, all other tasks must unmount the volume and avoid to access the volume.</p>
<p>Note that this section describes on the re-entrancy of the FatFs module itself but also the low level disk I/O layer will need to be re-entrant.</p> <p>Note that this section describes on the re-entrancy of the FatFs module itself but also the low level disk I/O layer will need to be re-entrant.</p>
</div> </div>
@ -181,37 +181,37 @@ _FS_LOCK 0 (Disable file lock control)
<div class="para" id="dup"> <div class="para" id="dup">
<h3>Duplicated File Access</h3> <h3>Duplicated File Access</h3>
<p>FatFs module does not support the read/write collision control of duplicated open to a file. The duplicated open is permitted only when each of open method to a file is read mode. The duplicated open with one or more write mode to a file is always prohibited, and also open file must not be renamed and deleted. A violation of these rules can cause data colluption.</p> <p>FatFs module does not support the read/write collision control of duplicated open to a file. The duplicated open is permitted only when each of open method to a file is read mode. The duplicated open with one or more write mode to a file is always prohibited, and also open file must not be renamed and deleted. A violation of these rules can cause data colluption.</p>
<p>The file lock control can also be available by <tt>_FS_LOCK</tt> option. The value defines the number of open objects to manage simultaneously. In this case, if any open, rename or remove that violating the file shareing rule that described above is attempted, the file function will fail with <tt>FR_LOCKED</tt>. If number of open files and sub-directories gets larger than <tt>_FS_LOCK</tt>, the open function will fail with <tt>FR_TOO_MANY_OPEN_FILES</tt>.</p> <p>The file lock control can be enabled by <tt>_FS_LOCK</tt> option. The value of option defines the number of open objects to manage simultaneously. In this case, if any open, rename or remove that violating the file shareing rule that described above is attempted, the file function will fail with <tt>FR_LOCKED</tt>. If number of open objects, files and sub-directories, is equal to <tt>_FS_LOCK</tt>, an extra <tt>f_open(), f_optndir()</tt> function will fail with <tt>FR_TOO_MANY_OPEN_FILES</tt>.</p>
</div> </div>
<div class="para" id="fs1"> <div class="para" id="fs1">
<h3>Performance Effective File Access</h3> <h3>Performance Effective File Access</h3>
<p>For good performance to read/write files on the small embedded system, 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>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 miss-aligned read (short)<br> <p>Figure 1. Sector misaligned read (short)<br>
<img src="../img/f1.png" width="490" height="110" alt=""> <img src="../img/f1.png" width="490" height="110" alt="">
</p> </p>
<p>Figure 2. Sector miss-aligned read (long)<br> <p>Figure 2. Sector misaligned read (long)<br>
<img src="../img/f2.png" width="490" height="140" alt=""> <img src="../img/f2.png" width="490" height="140" alt="">
</p> </p>
<p>Figure 3. Sector aligned read<br> <p>Figure 3. Fully sector aligned read<br>
<img src="../img/f3.png" width="490" height="119" alt=""> <img src="../img/f3.png" width="490" height="119" alt="">
</p> </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>_FS_TINY</tt> determins which sector buffer is used for the file data transfer. When tiny buffer (1) is selected, data memory consumption is reduced 512 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 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>_FS_TINY</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 mis-aligned part of the file, is transferred via the file I/O buffer. On 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 never across the cluster boundary even if it is contiguous.</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 avoids 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> <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> </div>
<div class="para" id="fs2"> <div class="para" id="fs2">
<h3>Considerations on Flash Memory Media</h3> <h3>Considerations on Flash Memory Media</h3>
<p>To maximize the write performance of flash memory media, such as SDC and CFC, it must be controlled in consideration of its characteristitcs.</p> <p>To maximize the write performance of flash memory media, such as SDC, CFC and U Disk, it must be controlled in consideration of its characteristitcs.</p>
<h4>Using Mutiple-Sector Write</h4> <h4>Using Mutiple-Sector Write</h4>
<div class="rset"> <div class="rset">
Figure 6. Comparison between Multiple/Single Sector Write<br> Figure 6. Comparison between Multiple/Single Sector Write<br>
<img src="../img/f6.png" width="630" height="148" alt="fig.6"> <img src="../img/f6.png" width="630" height="148" alt="fig.6">
</div> </div>
<p>The write throughput of the flash memory media becomes the worst at single sector write and it increases proportional to the number of sectors per a write transaction. This effect more appers at more fast bus clock and its ratio often becomes grater than ten. The number of write transaction also affects the life time of the media. Therefore the application program should write the data in large block as possible. The ideal block size is cluster size or power of 2 bytes and the byte offset should be aligned to the block. Of course all layers between the application and the media must support multiple sector write feature, however most of open-source disk drivers lack it. Do not split a multiple sector write request into single sector writes or the write throughput gets poor. Note that FatFs module and its sample disk drivers supprt multiple sector read/write 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. 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. The number of write transactions also affects the life time of the flash memory media. 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 disk 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>
<h4>Forcing Memory Erase</h4> <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, the number of free blocks on the flash memory will be increased. This may skip internal block erase operation to the data block on next write. As the result the write performance might be improved. To enable this feature, set <tt>_USE_ERASE</tt> to 1. Note that this is a feature with expectation of internal process of the flash memory media. It may not always effective and <tt>f_remove()</tt> function will take a time to remove a large file. Most applications will not need this feature.</p> <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>_USE_ERASE</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>
</div> </div>
<div class="para" id="critical"> <div class="para" id="critical">
@ -245,6 +245,7 @@ Figure 5. Minimized critical section<br>
<li><a href="../img/app2.c">Empty a directory</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/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/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>
</ol> </ol>
</div> </div>
@ -252,7 +253,7 @@ Figure 5. Minimized critical section<br>
<h3>About FatFs License</h3> <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 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>
<pre>/*----------------------------------------------------------------------------/ <pre>/*----------------------------------------------------------------------------/
/ FatFs - FAT file system module R0.10a (C)ChaN, 2014 / FatFs - FAT file system module R0.10b (C)ChaN, 2014
/-----------------------------------------------------------------------------/ /-----------------------------------------------------------------------------/
/ FatFs module is a generic FAT file system module for small embedded systems. / FatFs module is a generic FAT file system module for small embedded systems.
/ This is a free software that opened for education, research and commercial / This is a free software that opened for education, research and commercial
@ -266,7 +267,7 @@ Figure 5. Minimized critical section<br>
/ * Redistributions of source code must retain the above copyright notice. / * Redistributions of source code must retain the above copyright notice.
/ /
/-----------------------------------------------------------------------------/</pre> /-----------------------------------------------------------------------------/</pre>
<p>Therefore FatFs license is one of the BSD-style licenses but there is a significant feature. Because FatFs is for embedded projects, the conditions of redistributions in binary form, such as embedded code, hex file, binary library and any form without source code, are not specified in order to extend usability to commercial use. The documentation of the distributions need not include about FatFs and its license document, and it may also. This is equivalent to the BSD 1-Clause License. Of course FatFs is compatible with the projects under GNU GPL. When redistribute the FatFs with any modification, the license can also be changed to GNU GPL or BSD-style license.</p> <p>Therefore FatFs license is one of the BSD-style licenses but there is a significant feature. Because FatFs is for embedded projects, the conditions of redistributions in binary form, such as embedded code, hex file, binary library or any forms without source code, are not specified in order to extend usability for commercial products. The documentation of the distributions need not include about FatFs and its license document, and it may also. This is equivalent to the BSD 1-Clause License. Of course FatFs is compatible with the projects under GNU GPL. When redistribute the FatFs with any modification or branch it as a fork, the license can also be changed to GNU GPL, BSD-style license or any free software licenses that not conflict with FatFs license.</p>
</div> </div>
<p class="foot"><a href="../00index_e.html">Return</a></p> <p class="foot"><a href="../00index_e.html">Return</a></p>

View File

@ -46,7 +46,7 @@ FRESULT f_close (
<div class="para desc"> <div class="para desc">
<h4>Description</h4> <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>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 it is not recommended for future compatibility.</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>
</div> </div>

View File

@ -44,7 +44,7 @@ FRESULT f_closedir (
<div class="para desc"> <div class="para desc">
<h4>Description</h4> <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>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 it is not recommended for future compatibility.</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>
</div> </div>

View File

@ -13,7 +13,7 @@
<div class="para func"> <div class="para func">
<h2>disk_initialize</h2> <h2>disk_initialize</h2>
<p>The disk_initialize function initializes the disk drive.</p> <p>The disk_initialize function initializes the storage device.</p>
<pre> <pre>
DSTATUS disk_initialize ( DSTATUS disk_initialize (
BYTE <span class="arg">pdrv</span> <span class="c">/* [IN] Physical drive number */</span> BYTE <span class="arg">pdrv</span> <span class="c">/* [IN] Physical drive number */</span>
@ -25,7 +25,7 @@ DSTATUS disk_initialize (
<h4>Parameter</h4> <h4>Parameter</h4>
<dl class="par"> <dl class="par">
<dt>pdrv</dt> <dt>pdrv</dt>
<dd>Specifies the physical drive number to initialize.</dd> <dd>Physical drive number to identify the target device.</dd>
</dl> </dl>
</div> </div>
@ -37,8 +37,8 @@ DSTATUS disk_initialize (
<div class="para desc"> <div class="para desc">
<h4>Description</h4> <h4>Description</h4>
<p>This function initializes a physical drive and put it ready to generic read/write data. When the function succeeded, <tt>STA_NOINIT</tt> flag in the return value is cleared.</p> <p>This function initializes a storage device and put it ready to generic read/write data. When the function succeeded, <tt>STA_NOINIT</tt> flag in the return value is cleared.</p>
<p><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> This function is called on volume mount process by FatFs module to manage the media change.</p> <p><em>Application program MUST NOT call this function, or FAT structure on the volume can be broken. To re-initialize the file system, use <tt>f_mount()</tt> function instead.</em> This function is called at volume mount process by FatFs module to manage the media change.</p>
</div> </div>
<p class="foot"><a href="../00index_e.html">Return</a></p> <p class="foot"><a href="../00index_e.html">Return</a></p>

View File

@ -53,23 +53,38 @@ DRESULT disk_ioctl (
<div class="para desc"> <div class="para desc">
<h4>Description</h4> <h4>Description</h4>
<p>The FatFs module uses only device independent commands described below. Any device dependent functions and user defined functions are not used.</p> <p>The FatFs module requires only five device independent commands described below.</p>
<table class="lst"> <table class="lst">
<caption>Standard ioctl command used by FatFs</caption>
<tr><th>Command</th><th>Description</th></tr> <tr><th>Command</th><th>Description</th></tr>
<tr><td>CTRL_SYNC</td><td>Make sure that the device has finished pending write process. If the disk I/O module has a write back cache, the dirty buffers must be written back to the media immediately. If each write operation to the media is completed within the <tt>disk_write()</tt> function, nothing to do for this command.</td></tr> <tr><td>CTRL_SYNC</td><td>Make sure that the device has finished pending write process. If the disk I/O module has a write back cache, the dirty buffers must be written back to the media immediately. Nothing to do for this command if each write operation to the media is completed within the <tt>disk_write()</tt> function. Required at <tt>_FS_READONLY == 0</tt>.</td></tr>
<tr><td>GET_SECTOR_COUNT</td><td>Returns number of available sectors on the drive into the <tt>DWORD</tt> variable pointed by <tt class="arg">buff</tt>. This command is used by only <tt>f_mkfs()</tt> and <tt>f_fdisk()</tt> function to determine the volume/partition size to be created.</td></tr> <tr><td>GET_SECTOR_COUNT</td><td>Returns number of available sectors on the drive into the <tt>DWORD</tt> variable pointed by <tt class="arg">buff</tt>. This command is used by only <tt>f_mkfs()</tt> and <tt>f_fdisk()</tt> function to determine the volume/partition size to be created. Required at <tt>_USE_MKFS == 1</tt> or <tt>_MULTI_PARTITION == 1</tt>.</td></tr>
<tr><td>GET_SECTOR_SIZE</td><td>Returns sector size of the media into the <tt>WORD</tt> variable pointed by <tt class="arg">buff</tt>. Valid return values of this command are 512, 1024, 2048 or 4096. This command is never used at fixed sector size configuration, <tt>_MAX_SS == _MIN_SS</tt>, and it must work at that sector size.</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 or 4096. This command is required at variable sector size configuration, <tt>_MAX_SS &gt; _MIN_SS</tt>. Never used at fixed sector size configuration, <tt>_MAX_SS == _MIN_SS</tt>, and it must work at that sector size.</td></tr>
<tr><td>GET_BLOCK_SIZE</td><td>Returns erase block size of the flash memory 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 disk media. This command is used by only <tt>f_mkfs()</tt> function and it attempts to align data area to the erase block boundary.</td></tr> <tr><td>GET_BLOCK_SIZE</td><td>Returns erase block size of the flash memory 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 disk 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_ERASE_SECTOR</td><td>Erases a part of the flash memory specified by a <tt>DWORD</tt> array {&lt;start sector&gt;, &lt;end sector&gt;} pointed by <tt class="arg">buff</tt>. This is similar command to Trim command of ATA device. When this feature is not supported or not a flash memory media, nothing to do for this command. The FatFs does not check the result code and the file function is not affected even if the sectors ware not erased well. This command is called on removing a cluster chain and <tt>f_mkfs()</tt> function when <tt>_USE_ERASE</tt> is 1.</td></tr> <tr><td>CTRL_ERASE_SECTOR</td><td>Informs device that the data on the block of sectors specified by a <tt>DWORD</tt> array {&lt;start sector&gt;, &lt;end sector&gt;} pointed by <tt class="arg">buff</tt> is no longer needed and may be erased. The device would force erased the memory block. This is a command similar to Trim command of ATA device. When this feature is not supported or not a flash memory media, nothing to do for this command. The FatFs does not check the result code and the file function is not affected even if the sectors ware not erased well. This command is called on removing a cluster chain and <tt>f_mkfs()</tt> function. Required at <tt>_USE_ERASE == 1</tt>.</td></tr>
</table>
<p>FatFs never uses any device dependent command and user defined command. Following table shows an example of non-standard commands usable for some applications.</p>
<table class="lst">
<caption>Example of optional ioctl command</caption>
<tr><th>Command</th><th>Description</th></tr>
<tr><td>CTRL_FORMAT</td><td>Create a physical format on the media. If <tt class="arg">buff</tt> is not null, it is pointer to the call-back function for progress notification.</td></tr>
<tr><td>CTRL_POWER_IDLE</td><td>Put the device idle state. <tt>STA_NOINIT</tt> in status flag may not be set if the device would go active state by generic read/write function.</td></tr>
<tr><td>CTRL_POWER_OFF</td><td>Put the device off state. Shut-down the power to the device and deinitialize the device interface if needed. <tt>STA_NOINIT</tt> in status flag must be set. The device goes active state by <tt>disk_initialize()</tt> function.</td></tr>
<tr><td>CTRL_LOCK</td><td>Lock media eject mechanism.</td></tr>
<tr><td>CTRL_UNLOCK</td><td>Unlock media eject mechanism.</td></tr>
<tr><td>CTRL_EJECT</td><td>Eject media cartridge. <tt>STA_NOINIT</tt> and <tt>STA_NODISK</tt> in status flag are set after the function succeeded.</td></tr>
<tr><td>MMC_GET_TYPE</td><td>Get card type. The type flags, bit0:MMCv3, bit1:SDv1, bit2:SDv2+ and bit3:LBA, is stored to a BYTE variable pointed by <tt class="arg">buff</tt>. (MMC/SDC specific command)</td></tr>
<tr><td>MMC_GET_CSD</td><td>Get CSD register into a 16-byte buffer pointed by <tt class="arg">buff</tt>. (MMC/SDC specific command)</td></tr>
<tr><td>MMC_GET_CID</td><td>Get CID register into a 16-byte buffer pointed by <tt class="arg">buff</tt>. (MMC/SDC specific command)</td></tr>
<tr><td>MMC_GET_OCR</td><td>Get OCR register into a 4-byte buffer pointed by <tt class="arg">buff</tt>. (MMC/SDC specific command)</td></tr>
<tr><td>MMC_GET_SDSTAT</td><td>Get SDSTATUS register into a 64-byte buffer pointed by <tt class="arg">buff</tt>. (SDC specific command)</td></tr>
<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>
</table> </table>
</div> </div>
<div class="para comp">
<h4>QuickInfo</h4>
<p>This function is not needed when <tt>_FS_READONLY == 1</tt> and <tt>_MAX_SS == _MIN_SS</tt>.</p>
</div>
<p class="foot"><a href="../00index_e.html">Return</a></p> <p class="foot"><a href="../00index_e.html">Return</a></p>
</body> </body>
</html> </html>

View File

@ -39,7 +39,7 @@ DSTATUS disk_status (
<dt>STA_NODISK</dt> <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 on fixed disk drive. Note that FatFs does not refer this flag.</dd>
<dt>STA_PROTECT</dt> <dt>STA_PROTECT</dt>
<dd>Indicates that the medium is write protected. This is always cleared on the drive without write protect feature. Not valid while no medium in the drive.</dd> <dd>Indicates that the medium is write protected. This is always cleared on the drives without write protect feature. Not valid while no medium in the drive.</dd>
</dl> </dl>
</div> </div>

View File

@ -58,7 +58,7 @@ DRESULT disk_write (
<div class="para desc"> <div class="para desc">
<h4>Description</h4> <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>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>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 functions. The write operation to the media need not to be completed due to write operation is in progress or only stored it into the cache buffer when return from this function. But 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 delayed write feature is implemented, the write throughput may be improved.</p> <p>FatFs expects delayed write feature of the disk functions. The write operation to the media need not to be completed due to write operation is in progress or only stored it into the cache buffer when return from this function. But 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 delayed write feature is implemented, the write throughput may be improved.</p>
<p><em>Application program MUST NOT call this function, or FAT structure on the volume can be collapsed.</em></p> <p><em>Application program MUST NOT call this function, or FAT structure on the volume can be collapsed.</em></p>

View File

@ -48,7 +48,7 @@ FRESULT f_fdisk (
<div class="para desc"> <div class="para desc">
<h4>Description</h4> <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. Extended partition is not supported. The <tt class="arg">part[]</tt> array 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 means percentage of the partition in the entire disk space. If it is larger than 100, it means partition size in unit of sector.</p> <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>
</div> </div>
<div class="para comp"> <div class="para comp">
@ -80,7 +80,7 @@ FRESULT f_fdisk (
f_mkfs("0:", 0, 0); <span class="c">/* Create FAT volume on the logical drive 0. 2nd argument is ignored. */</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(0, "0:", 0); <span class="c">/* Unregister work area from the logical drive 0 */</span>
f_mount(&amp;fs, "1:", 0); <span class="c">/* Give a work area to the logical drive 1 */</span> f_mount(&amp;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_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_mount(0, "1:", 0); <span class="c">/* Unregister work area from the logical drive 1 */</span>

View File

@ -15,11 +15,11 @@
<div class="para" id="nam"> <div class="para" id="nam">
<h3>Format of the path names</h3> <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> <p>The format of path name on the FatFs module is similer to the filename specs of DOS/Windos as follows:</p>
<pre>"[drive#:][/]directory/file"</pre> <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>_USE_LFN &gt; 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 the drive number is omitted, it 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 LFN feature is enabled (<tt>_USE_LFN &gt; 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 they are recognized as end of the path name at non-LFN configuration. Trailing spaces and dots are ignored.</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 they are recognized as end of the path name at non-LFN configuration. Trailing spaces and dots are ignored.</p>
<p>In default configuration (<tt>_FS_RPATH == 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 are not allowed. Heading separator is ignored and it can be exist or omitted. The default drive number is fixed to 0.</p> <p>In default configuration (<tt>_FS_RPATH == 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 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 set with <a href="chdir.html">f_chdir</a> function. Dot names are also allowed for the path name. The default drive is the current drive set with <a href="chdrive.html">f_chdrive</a> function.</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 with <a href="chdir.html">f_chdir</a> function. Dot names are also allowed for the path name. The default drive is the current drive set with <a href="chdrive.html">f_chdrive</a> function.</p>
<table class="lst2"> <table class="lst2">
<tr><td>Path name</td><td>_FS_RPATH == 0</td><td>_FS_RPATH == 1</td></tr> <tr><td>Path name</td><td>_FS_RPATH == 0</td><td>_FS_RPATH == 1</td></tr>
<tr class="lst3"><td>file.txt</td><td>A file in the root directory of the drive 0</td><td>A file in the current directory of the current drive</td></tr> <tr class="lst3"><td>file.txt</td><td>A file in the root directory of the drive 0</td><td>A file in the current directory of the current drive</td></tr>

View File

@ -17,8 +17,8 @@
<pre> <pre>
FRESULT f_getlabel ( FRESULT f_getlabel (
const TCHAR* <span class="arg">path</span>, <span class="c">/* [IN] Drive number */</span> const TCHAR* <span class="arg">path</span>, <span class="c">/* [IN] Drive number */</span>
TCHAR* <span class="arg">buff</span>, <span class="c">/* [OUT] Volume label */</span> TCHAR* <span class="arg">label</span>, <span class="c">/* [OUT] Volume label */</span>
DWORD* <span class="arg">sn</span> <span class="c">/* [OUT] Volume serial number */</span> DWORD* <span class="arg">vsn</span> <span class="c">/* [OUT] Volume serial number */</span>
); );
</pre> </pre>
</div> </div>
@ -28,9 +28,9 @@ FRESULT f_getlabel (
<dl class="par"> <dl class="par">
<dt>path</dt> <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> <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>buff</dt> <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 12 items. If the volume has no label, a null-string will be returned. Set null pointer if this information is not needed.</dd>
<dt>sn</dt> <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> <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> </dl>
</div> </div>

View File

@ -49,13 +49,13 @@ FRESULT f_lseek (
<div class="para desc"> <div class="para desc">
<h4>Description</h4> <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 in 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 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>
<ul> <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>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 insufficient free space on the volume to expand the file.</li>
</ul> </ul>
<p>Fast seek feature is enabled when <tt>_USE_FASTSEEK</tt> is set to 1 and the member <tt>cltbl</tt> in the file object is not NULL. This feature enables fast backward/long seek operations without FAT access by using CLMT (cluster link map table). The fast seek feature is also applied to <tt>f_read()/f_write()</tt> function, however, the file size cannot be expanded by <tt>f_write()/f_lseek()</tt> function.</p> <p>Fast seek feature is enabled when <tt>_USE_FASTSEEK</tt> is set to 1 and the member <tt>cltbl</tt> in the file object is not NULL. This feature enables fast backward/long seek operations without FAT access by using CLMT (cluster link map table). The fast seek feature is also applied to <tt>f_read()/f_write()</tt> function, however, the file size cannot be expanded by <tt>f_write()/f_lseek()</tt> function.</p>
<p>The CLMT must be created in the user defined <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 file object, set the array size in unit of items into 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()/f_write()/f_lseek()</tt> function to the file. If the function failed with <tt>FR_NOT_ENOUGH_CORE</tt>, the given array size is insufficient for the file and number of items required is returned into the first item of the array. The required array size is (number of fragments + 1) * 2 items. For example, when the file is fragmented in 5, 12 items will be required for the CLMT.</p> <p>The CLMT must be created in the user defined <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 file object, set the array size in unit of items into 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 at subsequent <tt>f_read()/f_write()/f_lseek()</tt> function to the file. If the function failed with <tt>FR_NOT_ENOUGH_CORE</tt>, the given array size is insufficient for the file and number of items required is returned into the first item of the array. The required array size is (number of fragments + 1) * 2 items. For example, when the file is fragmented in 5, 12 items will be required for the CLMT.</p>
</div> </div>

View File

@ -13,10 +13,10 @@
<div class="para func"> <div class="para func">
<h2>f_mount</h2> <h2>f_mount</h2>
<p>The f_mount fucntion registers/unregisters file system object (work area) to the FatFs module.</p> <p>The f_mount fucntion registers/unregisters file system object to the FatFs module.</p>
<pre> <pre>
FRESULT f_mount ( FRESULT f_mount (
FATFS* <span class="arg">fatfs</span>, <span class="c">/* [IN] File system object */</span> FATFS* <span class="arg">fs</span>, <span class="c">/* [IN] File system object */</span>
const TCHAR* <span class="arg">path</span>, <span class="c">/* [IN] Logical drive number */</span> const TCHAR* <span class="arg">path</span>, <span class="c">/* [IN] Logical drive number */</span>
BYTE <span class="arg">opt</span> <span class="c">/* [IN] Initialization option */</span> BYTE <span class="arg">opt</span> <span class="c">/* [IN] Initialization option */</span>
); );
@ -26,12 +26,12 @@ FRESULT f_mount (
<div class="para arg"> <div class="para arg">
<h4>Parameters</h4> <h4>Parameters</h4>
<dl class="par"> <dl class="par">
<dt>fatfs</dt> <dt>fs</dt>
<dd>Pointer to the file system object to be registered. Null pointer unregisters the registered file system object.</dd> <dd>Pointer to the new file system object to be registered. Null pointer unregisters the registered file system object.</dd>
<dt>path</dt> <dt>path</dt>
<dd>Pointer to the null-terminated string that specifies the <a href="filename.html">logical drive</a>. If there is no drive number, it means the default drive.</dd> <dd>Pointer to the null-terminated string that specifies the <a href="filename.html">logical drive</a>. The string with no drive number means the default drive.</dd>
<dt>opt</dt> <dt>opt</dt>
<dd>Initialization option. 0: Do not mount now (to be mounted later), 1: Force mounted the volume to check if the volume is available.</dd> <dd>Initialization option. 0: Do not mount now (to be mounted later), 1: Force mounted the volume to check if the FAT volume is available.</dd>
</dl> </dl>
</div> </div>
@ -53,17 +53,17 @@ FRESULT f_mount (
<ol> <ol>
<li>Determines the logical drive which specified by <tt class="arg">path</tt>.</li> <li>Determines the logical drive which specified by <tt class="arg">path</tt>.</li>
<li>Clears and unregisters the regsitered work area of the drive.</li> <li>Clears and unregisters the regsitered work area of the drive.</li>
<li>Clears and registers the work area to the drive if <tt class="arg">fatfs</tt> is not NULL.</li> <li>Clears and registers the new work area to the drive if <tt class="arg">fs</tt> is not NULL.</li>
<li>Performs volume mount process to the drive if forced mount is specified.</li> <li>Performs volume mount process to the drive if forced mount is specified.</li>
</ol> </ol>
<p>The file system object is the work area needed for each logical drive. It must be given to the logical drive with this function prior to use any other file functions. To unregister a work area, specify a NULL to the <tt class="arg">fatfs</tt>, and then the work area can be discarded. </p> <p>The file system object is the work area needed for each logical drive. It must be given to the logical drive with this function prior to use any other file functions except for <tt>f_fdisk()</tt> function. To unregister a work area, specify a NULL to the <tt class="arg">fs</tt>, and then the work area can be discarded.</p>
<p>If forced mount 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 mount 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>
<ul> <ul>
<li>File system object is not initialized. It is cleared by <tt>f_mount()</tt>.</li> <li>File system object is not initialized. It is cleared by <tt>f_mount()</tt>.</li>
<li>Physical drive is not initialized. It is de-initialized by system reset or media change.</li> <li>Physical drive is not initialized. It is de-initialized by system reset or media removal.</li>
</ul> </ul>
<p>If the function with forced mount failed, it means that the file system object is registered but the volume is currently not available. Mount process will also be attempted in subsequent file access functions.</p> <p>If the function with forced mount failed, it means that the file system object has been registered successfully but the volume is currently not ready to use. Mount process will also be attempted in subsequent file access functions.</p>
<p>If implementation of the disk I/O layer lacks media change detection, application program needs to perform a <tt>f_mount()</tt> after media change to force cleared the file system object.</p> <p>If implementation of the disk I/O layer lacks media change detection, application program needs to perform a <tt>f_mount()</tt> after each media change to force cleared the file system object.</p>
</div> </div>

View File

@ -29,7 +29,7 @@ FRESULT f_open (
<dt>fp</dt> <dt>fp</dt>
<dd>Pointer to the blank file object structure to be created.</dd> <dd>Pointer to the blank file object structure to be created.</dd>
<dt>path</dt> <dt>path</dt>
<dd>Pointer to a null-terminated string that specifies the <a href="filename.html">file name</a> to create or open.</dd> <dd>Pointer to a null-terminated string that specifies the <a href="filename.html">file name</a> to open or create.</dd>
<dt>mode</dt> <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> <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"> <table class="lst">

View File

@ -55,7 +55,7 @@ FRESULT f_opendir (
<div class="para desc"> <div class="para desc">
<h4>Description</h4> <h4>Description</h4>
<p>The <tt>f_opendir()</tt> function opens an exsisting directory and creates the directory object for subsequent calls.</p> <p>The <tt>f_opendir()</tt> function opens an exsisting directory and creates a directory object for subsequent <tt>f_readdir()</tt> function.</p>
</div> </div>

View File

@ -29,9 +29,9 @@ int f_printf (
<dt>fp</dt> <dt>fp</dt>
<dd>Pointer to the open file object structure.</dd> <dd>Pointer to the open file object structure.</dd>
<dt>fmt</dt> <dt>fmt</dt>
<dd>Pointer to the null terminated format string.</dd> <dd>Pointer to the null terminated format string. The terminator charactor will not be written.</dd>
<dt>...</dt> <dt>...</dt>
<dd>Optional arguments.</dd> <dd>Optional arguments...</dd>
</dl> </dl>
</div> </div>
@ -56,7 +56,7 @@ int f_printf (
<div class="para comp"> <div class="para comp">
<h4>QuickInfo</h4> <h4>QuickInfo</h4>
<p>Available when <tt>_FS_READONLY == 0</tt> and <tt>_USE_STRFUNC</tt> is 1 or 2. When it is set to 2, <tt>'\n'</tt>s contained in the output are converted to <tt>"\r\n"</tt>.</p> <p>Available when <tt>_FS_READONLY == 0</tt> and <tt>_USE_STRFUNC</tt> is 1 or 2. When it is set to 2, <tt>'\n'</tt>s contained in the output are converted to <tt>'\r'+'\n'</tt>.</p>
<p>When FatFs is configured to Unicode API (<tt>_LFN_UNICODE == 1</tt>), data types on the srting fuctions, <tt>f_putc()</tt>, <tt>f_puts()</tt>, <tt>f_printf()</tt> and <tt>f_gets()</tt>, is also switched to Unicode. The character encoding on the file to be read/written via those functions is selected by <tt>_STRF_ENCODE</tt> option.</p> <p>When FatFs is configured to Unicode API (<tt>_LFN_UNICODE == 1</tt>), data types on the srting fuctions, <tt>f_putc()</tt>, <tt>f_puts()</tt>, <tt>f_printf()</tt> and <tt>f_gets()</tt>, is also switched to Unicode. The character encoding on the file to be read/written via those functions is selected by <tt>_STRF_ENCODE</tt> option.</p>
</div> </div>

View File

@ -48,7 +48,7 @@ int f_putc (
<div class="para comp"> <div class="para comp">
<h4>QuickInfo</h4> <h4>QuickInfo</h4>
<p>Available when <tt>_FS_READONLY == 0</tt> and <tt>_USE_STRFUNC</tt> is 1 or 2. When it is set to 2, a <tt>'\n'</tt> is converted to <tt>"\r\n"</tt>.</p> <p>Available when <tt>_FS_READONLY == 0</tt> and <tt>_USE_STRFUNC</tt> is 1 or 2. When it is set to 2, a <tt>'\n'</tt> is converted to <tt>'\r'+'\n'</tt>.</p>
</div> </div>

View File

@ -26,7 +26,7 @@ int f_puts (
<h4>Parameters</h4> <h4>Parameters</h4>
<dl class="par"> <dl class="par">
<dt>str</dt> <dt>str</dt>
<dd>Pointer to the null terminated string to be written. The null character will not be written.</dd> <dd>Pointer to the null terminated string to be written. The terminator character will not be written.</dd>
<dt>fp</dt> <dt>fp</dt>
<dd>Pointer to the open file object structure.</dd> <dd>Pointer to the open file object structure.</dd>
</dl> </dl>
@ -48,7 +48,7 @@ int f_puts (
<div class="para comp"> <div class="para comp">
<h4>QuickInfo</h4> <h4>QuickInfo</h4>
<p>Available when <tt>_FS_READONLY == 0</tt> and <tt>_USE_STRFUNC</tt> is 1 or 2. When it is set to 2, <tt>'\n'</tt>s contained in the string are converted to <tt>"\r\n"</tt>.</p> <p>Available when <tt>_FS_READONLY == 0</tt> and <tt>_USE_STRFUNC</tt> is 1 or 2. When it is set to 2, <tt>'\n'</tt>s contained in the string are converted to <tt>'\r'+'\n'</tt>.</p>
</div> </div>

View File

@ -17,14 +17,14 @@
<dt id="ok">FR_OK (0)</dt> <dt id="ok">FR_OK (0)</dt>
<dd>The function succeeded.</dd> <dd>The function succeeded.</dd>
<dt id="de">FR_DISK_ERR</dt> <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.</dd> <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> <dt id="ie">FR_INT_ERR</dt>
<dd>Assertion failed. An insanity is detected in the internal process. One of the following possibilities are suspected. <dd>Assertion failed. An insanity is detected in the internal process. One of the following possibilities is suspected.
<ul> <ul>
<li>There is any error of the FAT structure on the volume.</li>
<li>Work area (file system object, file object or etc...) is broken by stack overflow or any other application. This is the reason in most case.</li> <li>Work area (file system object, file object or etc...) is broken by stack overflow or any other application. This is the reason in most case.</li>
<li>An <tt>FR_DISK_ERR</tt> has occured on the file object.</li> <li>There is any error of the FAT structure on the volume.</li>
</ul> </ul>
Note that if once this error occured at any operation to an open file, the file object is aborted and all operations to the file except for close will be rejected.
</dd> </dd>
<dt id="nr">FR_NOT_READY</dt> <dt id="nr">FR_NOT_READY</dt>
<dd>The disk drive cannot work due to incorrect medium removal or <tt>disk_initialize()</tt> function failed.</dd> <dd>The disk drive cannot work due to incorrect medium removal or <tt>disk_initialize()</tt> function failed.</dd>
@ -69,7 +69,7 @@
<dt id="tm">FR_TIMEOUT</dt> <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>_TIMEOUT</tt>)</dd> <dd>The function was canceled due to a timeout of <a href="appnote.html#reentrant">thread-safe control</a>. (Related option: <tt>_TIMEOUT</tt>)</dd>
<dt id="lo">FR_LOCKED</dt> <dt id="lo">FR_LOCKED</dt>
<dd>The function was rejected by <a href="appnote.html#dup">file sharing control</a>. (Related option: <tt>_FS_LOCK</tt>)</dd> <dd>The operation to the object was rejected by <a href="appnote.html#dup">file sharing control</a>. (Related option: <tt>_FS_LOCK</tt>)</dd>
<dt id="nc">FR_NOT_ENOUGH_CORE</dt> <dt id="nc">FR_NOT_ENOUGH_CORE</dt>
<dd>Not enough memory for the operation. There is one of the following reasons: <dd>Not enough memory for the operation. There is one of the following reasons:
<ul> <ul>

View File

@ -54,7 +54,7 @@ FRESULT f_read (
<div class="para desc"> <div class="para desc">
<h4>Description</h4> <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 the end of 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 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>
</div> </div>

View File

@ -54,7 +54,7 @@ FRESULT f_readdir (
<ul> <ul>
<li>The directory item has no LFN information.</li> <li>The directory item has no LFN information.</li>
<li>Either the size of read buffer or LFN working buffer is insufficient for the LFN.</li> <li>Either the size of read buffer or LFN working buffer is insufficient for the LFN.</li>
<li>The LFN contains any Unicode charactrer that cannot be converted to OEM code. (not the case at Unicode API cfg.)</li> <li>The LFN contains any Unicode character that cannot be converted to OEM code. (not the case at Unicode API cfg.)</li>
</ul> </ul>
<p>When the directory item has no LFN information, lower case characters can be contained in the <tt>fname[]</tt>.</p> <p>When the directory item has no LFN information, lower case characters can be contained in the <tt>fname[]</tt>.</p>
</div> </div>

View File

@ -23,13 +23,13 @@
DWORD clust; <span class="c">/* Current cluster */</span> DWORD clust; <span class="c">/* Current cluster */</span>
DWORD sect; <span class="c">/* Current sector */</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* dir; <span class="c">/* Pointer to the current SFN entry in the win[] */</span>
BYTE* fn; <span class="c">/* Pointer to the SFN (in/out) {file[8],ext[3],status[1]} */</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 <span class="k">#if</span> _FS_LOCK
UINT lockid; <span class="c">/* Sub-directory lock ID (0:Root directory) */</span> UINT lockid; <span class="c">/* Sub-directory lock ID (0:Root directory) */</span>
<span class="k">#endif</span> <span class="k">#endif</span>
<span class="k">#if</span> _USE_LFN <span class="k">#if</span> _USE_LFN
WCHAR* lfn; <span class="c">/* Pointer to the LFN working buffer */</span> WCHAR* lfn; <span class="c">/* Pointer to the LFN buffer (in/out) */</span>
WORD lfn_idx; <span class="c">/* Index of top of last matched LFN entris (0xFFFF:No LFN) */</span> WORD lfn_idx; <span class="c">/* Index of the LFN entris (0xFFFF:No LFN) */</span>
<span class="k">#endif</span> <span class="k">#endif</span>
} DIR; } DIR;
</pre> </pre>

View File

@ -16,7 +16,7 @@
<p>The f_setlabel function sets/removes the label of a volume.</p> <p>The f_setlabel function sets/removes the label of a volume.</p>
<pre> <pre>
FRESULT f_setlabel ( FRESULT f_setlabel (
const TCHAR* <span class="arg">name</span> <span class="c">/* [IN] Volume label to be set */</span> const TCHAR* <span class="arg">label</span> <span class="c">/* [IN] Volume label to be set */</span>
); );
</pre> </pre>
</div> </div>
@ -24,7 +24,7 @@ FRESULT f_setlabel (
<div class="para arg"> <div class="para arg">
<h4>Parameters</h4> <h4>Parameters</h4>
<dl class="par"> <dl class="par">
<dt>name</dt> <dt>label</dt>
<dd>Pointer to the null-terminated string that specifies the volume label to be set.</dd> <dd>Pointer to the null-terminated string that specifies the volume label to be set.</dd>
</dl> </dl>
</div> </div>
@ -49,11 +49,11 @@ FRESULT f_setlabel (
<div class="para desc"> <div class="para desc">
<h4>Description</h4> <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 the volume label is a null-string, the volume label on the volume will be removed. The format of the volume label is similar to the SFN 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 label will be set to the default drive. If the given string is a null-string, 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>
<ul> <ul>
<li>11 bytes or less in length as local character code.</li> <li>11 bytes or less in length as local character code. LFN extention is not applied to the volume label.</li>
<li>Cannot contain period.</li> <li>Cannot contain period.</li>
<li>Can contain spaces anywhere in the name.</li> <li>Can contain spaces anywhere in the volume label. Trailing spaces are truncated off.</li>
</ul> </ul>
</div> </div>

View File

@ -54,7 +54,7 @@ FRESULT f_stat (
<div class="para desc"> <div class="para desc">
<h4>Description</h4> <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, size, timestamp and attribute, are stored to the file information structure. For details, refer to the <tt>FILINFO</tt> structure and <a href="readdir.html"><tt>f_readdir()</tt></a> function. </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, 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>
</div> </div>

View File

@ -46,7 +46,7 @@ FRESULT f_sync (
<div class="para desc"> <div class="para desc">
<h4>Description</h4> <h4>Description</h4>
<p>The <tt>f_sync()</tt> function performs the same process as <tt>f_close()</tt> function but the file is left opened and can continue read/write/seek operations to the file. This is suitable for the applications that open files for a long time in write mode, such as data logger. Performing <tt>f_sync()</tt> function of periodic or immediataly after <tt>f_write()</tt> function can minimize the risk of data loss due to a sudden blackout or an unintentional media removal. For more information, refer to <a href="appnote.html#critical">application note</a>.</p> <p>The <tt>f_sync()</tt> function performs the same process as <tt>f_close()</tt> function but the file is left opened and can continue read/write/seek operations to the file. This is suitable for the applications that open files for a long time in write mode, such as data logger. Performing <tt>f_sync()</tt> function of periodic or immediataly after <tt>f_write()</tt> function can minimize the risk of data loss due to a sudden blackout or an unintentional media removal. For more information, refer to <a href="appnote.html#critical">application note</a>.</p>
<p>However the <tt>f_sync()</tt> function immediataly before <tt>f_close()</tt> function has no advantage because it performs <tt>f_sync()</tt> function in it. In other words, the differnce between those functions is that the file object is invalidated or not.</p> <p>However there is no sense in <tt>f_sync()</tt> function immediataly before <tt>f_close()</tt> function because it performs <tt>f_sync()</tt> function in it. In other words, the differnce between those functions is that the file object is invalidated or not.</p>
</div> </div>

View File

@ -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> 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 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 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 can also be rejected with <tt>FR_LOCKED</tt> 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 can be rejected with <tt>FR_LOCKED</tt> when <a href="appnote.html#dup">file lock feature</a> is enabled.</li>
</ul> </ul>
</div> </div>

View File

@ -14,7 +14,7 @@ FRESULT empty_directory (
FILINFO fno; FILINFO fno;
#if _USE_LFN #if _USE_LFN
fno.lfname = 0; /* Eliminate LFN output */ fno.lfname = 0; /* Disable LFN output */
#endif #endif
fr = f_opendir(&dir, path); fr = f_opendir(&dir, path);
if (fr == FR_OK) { if (fr == FR_OK) {
@ -23,7 +23,7 @@ FRESULT empty_directory (
for (;;) { for (;;) {
fr = f_readdir(&dir, &fno); fr = f_readdir(&dir, &fno);
if (fr != FR_OK || !fno.fname[0]) break; if (fr != FR_OK || !fno.fname[0]) break;
if (fno.fname[0] == '.') continue; if (_FS_RPATH && fno.fname[0] == '.') continue;
j = 0; j = 0;
do do
path[i+j] = fno.fname[j]; path[i+j] = fno.fname[j];
@ -59,7 +59,7 @@ int main (void)
if (fr) { if (fr) {
printf("Function failed. (%u)\n", fr); printf("Function failed. (%u)\n", fr);
return 1; return fr;
} else { } else {
printf("All contents in the %s are successfully removed.\n", buff); printf("All contents in the %s are successfully removed.\n", buff);
return 0; return 0;

View File

@ -6,7 +6,7 @@
/ If the file has been opened without FA_WRITE flag, it only checks if / If the file has been opened without FA_WRITE flag, it only checks if
/ the file is contiguous and returns the resulut. */ / the file is contiguous and returns the resulut. */
#if _FATFS != 29000 /* Check if R0.10a */ #if _FATFS != 8051 /* Check if R0.10b */
#error This function may not be compatible with this revision of FatFs module. #error This function may not be compatible with this revision of FatFs module.
#endif #endif

Binary file not shown.

Before

Width:  |  Height:  |  Size: 11 KiB

After

Width:  |  Height:  |  Size: 14 KiB

View File

@ -44,19 +44,19 @@ FatFsモジュールはANSI C(C89)準拠で記述されているので、普通
<h4>システム構成</h4> <h4>システム構成</h4>
<p>下に示す依存関係図は、FatFsモジュール利用の組み込みシステムにおける代表的な構成を示します。</p> <p>下に示す依存関係図は、FatFsモジュール利用の組み込みシステムにおける代表的な構成を示します。</p>
<p><img src="../img/modules.png" width="580" height="280" alt="システム構成図"></p> <p><img src="../img/modules.png" width="580" height="280" alt="システム構成図"></p>
<p>(a) FatFs用に書かれたディスク・モジュールがある場合は、そのまま接続するだけです。 (b) しかし、多くの既存のディスク・モジュールはそのAPIをFatFsに合わせるため、グルー関数が必要になるでしょう。</p> <p>(a) FatFs用に書かれたディスク・モジュールがある場合は、そのまま追加するだけです。 (b) しかし、多くの既存のディスク・モジュールはそのAPIをFatFsに合わせるため、グルー関数が必要になるでしょう。</p>
<p><img src="../img/funcs.png" width="680" height="450" alt="functional diagram"></p> <p><img src="../img/funcs.png" width="680" height="430" alt="functional diagram"></p>
<h4>ユーザの作成する関数</h4> <h4>ユーザの作成する関数</h4>
<p>必要なのは FatFsモジュールの要求するディスク関数を用意することだけで、それ以外にすることはありません。既に動作しているディスク関数があるなら、その APIを FatFsに合わせるかグルー関数でつなぐだけで済みますが、無い場合はほかから移植するか最初から書くかする必要があります。定義されている全ての関数が常に必要なわけではありません。例えば、リード・オンリー構成では書き込み系関数は必要ありません。次の表に構成オプションと要求される関数の対応を示します。</p> <p>必要なのはFatFsモジュールの要求するディスク関数を用意することだけで、それ以外にすることはありません。既に動作しているディスク・モジュールがあるなら、そのAPIをFatFsに合わせるかグルー関数を介してつなぐだけで済みますが、無い場合はほかから移植するか最初から書くかする必要があります。定義されている全ての関数が常に必要なわけではありません。例えば、リード・オンリー構成では書き込み系関数は必要ありません。次の表に構成オプションと要求される関数の対応を示します。</p>
<table class="lst2"> <table class="lst2">
<tr><th>ユーザ作成関数</th><th>必要となる条件</th><th>備考</th></tr> <tr><th>必要な関数</th><th>必要となる条件</th><th>備考</th></tr>
<tr><td>disk_status<br>disk_initialize<br>disk_read</td><td>常時</td><td rowspan="5">ffsample.zip (サンプル)<br>その他web上に多数</td></tr> <tr><td>disk_status<br>disk_initialize<br>disk_read</td><td>常時</td><td rowspan="5">ffsample.zip (サンプル)<br>その他web上に多数</td></tr>
<tr><td>disk_write<br>get_fattime<br>disk_ioctl (CTRL_SYNC)</td><td>_FS_READONLY == 0</td></tr> <tr><td>disk_write<br>get_fattime<br>disk_ioctl (CTRL_SYNC)</td><td>_FS_READONLY == 0</td></tr>
<tr><td>disk_ioctl (GET_SECTOR_COUNT)<br>disk_ioctl (GET_BLOCK_SIZE)</td><td>_USE_MKFS == 1</td></tr> <tr><td>disk_ioctl (GET_SECTOR_COUNT)<br>disk_ioctl (GET_BLOCK_SIZE)</td><td>_USE_MKFS == 1</td></tr>
<tr><td>disk_ioctl (GET_SECTOR_SIZE)</td><td>_MAX_SS != _MIN_SS</td></tr> <tr><td>disk_ioctl (GET_SECTOR_SIZE)</td><td>_MAX_SS != _MIN_SS</td></tr>
<tr><td>disk_ioctl (CTRL_ERASE_SECTOR)</td><td>_USE_ERASE == 1</td></tr> <tr><td>disk_ioctl (CTRL_ERASE_SECTOR)</td><td>_USE_ERASE == 1</td></tr>
<tr><td>ff_convert<br>ff_wtoupper</td><td>_USE_LFN &gt;= 1</td><td>option/cc*.c</td></tr> <tr><td>ff_convert<br>ff_wtoupper</td><td>_USE_LFN &gt;= 1</td><td>option/unicode.c</td></tr>
<tr><td>ff_cre_syncobj<br>ff_rel_grant<br>ff_req_grant<br>ff_del_syncobj</td><td>_FS_REENTRANT == 1</td><td rowspan="2">option/syscall.c (サンプル)</td></tr> <tr><td>ff_cre_syncobj<br>ff_rel_grant<br>ff_req_grant<br>ff_del_syncobj</td><td>_FS_REENTRANT == 1</td><td rowspan="2">option/syscall.c (サンプル)</td></tr>
<tr><td>ff_mem_alloc<br>ff_mem_free</td><td>_USE_LFN == 3</td></tr> <tr><td>ff_mem_alloc<br>ff_mem_free</td><td>_USE_LFN == 3</td></tr>
</table> </table>
@ -152,8 +152,8 @@ _FS_LOCK 0 (Disable file lock control)
<div class="para" id="lfn"> <div class="para" id="lfn">
<h3>長いファイル名</h3> <h3>長いファイル名</h3>
<p>FatFsモジュールはR0.07から長いファイル名(LFN)をサポートしました。ファイルに付けられた2つの異なる名前(短いファル名と長いファイル名)は、<tt>f_readdir()</tt>を除くファイル操作関数において透過です。LFN機能を有効にするには、<tt>_USE_LFN</tt>を1,2または3に設定し、Unicode変換関数<tt>ff_convert(), ff_wtoupper()</tt>をプロジェクトに追加します。これらの関数は、<tt>option/cc*.c</tt>に含まれています。LFN機能は、加えてある程度のワーク・エリア(LFN操作バッファ)を必要とします。バッファ長は使用できるメモリに応じて<tt>_MAX_LFN</tt>オプションで構成されることができます。LFNの長さは最大255文字に達するので、LFN完全対応のためには<tt>_MAX_LFN</tt>は255に設定されるべきです。与えられたファイル名に対してバッファ長が不足した場合、ファイル関数は<tt>FR_INVALID_NAME</tt>で失敗します。</p> <p>FatFsモジュールは、長いファイル名(LFN)をサポートします。ファイルに付けられた2つの異なる名前(短いファル名と長いファイル名)は、<tt>f_readdir()</tt>を除くファイル操作関数において透過です。デフォルト構成では、LFN機能はOFFになっています。LFN機能を有効にするには、<tt>_USE_LFN</tt>を1,2または3に設定し、<tt>option/unicode.c</tt>をプロジェクトに追加します。LFN機能は、加えてある程度のワーク・エリア(LFN操作バッファ)を必要とします。バッファ長は使用できるメモリに応じて<tt>_MAX_LFN</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>ファイル関数に再入を行う条件の下でLFN機能を使用する場合は、<tt>_USE_LFN</tt>は2または3に設定されなければなりません。この場合、ファイル関数はワーク・エリアを動的に確保(スタックまたはヒープ)します。バッファ・サイズは、<tt>(_MAX_LFN + 1) * 2</tt>バイトになるので、スタック等のサイズはそれを考慮した十分なサイズでなければなりません。</p>
<table class="lst2 rset"> <table class="lst2 rset">
<caption>LFN cfg on ARM7</caption> <caption>LFN cfg on ARM7</caption>
<tr><th>コードページ</th><th>コードサイズ[bytes]</th></tr> <tr><th>コードページ</th><th>コードサイズ[bytes]</th></tr>
@ -216,7 +216,7 @@ _FS_LOCK 0 (Disable file lock control)
図6. マルチ/シングル・セクタ・ライトの比較<br> 図6. マルチ/シングル・セクタ・ライトの比較<br>
<img src="../img/f6.png" width="630" height="148" alt="fig.6"> <img src="../img/f6.png" width="630" height="148" alt="fig.6">
</div> </div>
<p>フラッシュ・メモリ・メディアの書き込み速度はシングル・セクタ書き込みの時に最も低いものになり、一回のトランザクションで転送されるセクタ数が大きくなるほど書き込み速度は向上します。この効果はバス速度が高速になるほど顕著で、10倍以上の差が現れることも珍しくありません。書き込みトランザクションの回数はまた、メディアの寿命にも影響してきます。このため、アプリケーションはなるべく大きなブロック(クラスタ・サイズまたは2の累乗セクタ境界にアライメントした)で読み書きを行う必要があります。もちろん、アプリケーションからメディアに至る全てのレイヤがマルチ・セクタ転送に対応していないと意味がありません。残念ながら、既存のオープン・ソースのドライバの多くはマルチ・セクタ転送に未対応です。なお、FatFsモジュールおよびそれ用のサンプル・ドライバはマルチ・セクタ転送に対応しています。</p> <p>フラッシュ・メモリ・メディアの書き込み速度はシングル・セクタ書き込みの時に最も低いものになり、一回のトランザクションで転送されるセクタ数が大きくなるほど書き込み速度は向上します。この効果はバス速度が高速になるほど顕著で、10倍以上の差が現れることも珍しくありません。<a href="../img/rwtest2.png">テスト結果</a>は、マルチ・セクタ書き込み(W:16K, 32 sectors)がシングル・セクタ書き込み(W:100, 1 sector)よりどの程度速いかを明確に示しています。大容量メディアほどシングル・セクタ書き込みが遅くなる点もまた重要です。書き込みトランザクションの回数はまた、メディアの寿命にも影響してきます。このため、アプリケーションはなるべく大きなブロック(クラスタ・サイズまたは2の累乗セクタ境界にアライメントした)で読み書きを行う必要があります。もちろん、アプリケーションからメディアに至る全てのレイヤがマルチ・セクタ転送に対応していないと意味がありません。残念ながら、既存のオープン・ソースのドライバの多くはマルチ・セクタ転送に未対応です。なお、FatFsモジュールおよびサンプル・ドライバはマルチ・セクタ転送に対応しています。</p>
<h4>明示的なメモリ消去</h4> <h4>明示的なメモリ消去</h4>
<p>通常のファイル消去では、記録されたデータに対して何らかの制御が行われるわけではなく、単にFAT上に未使用クラスタとして記録されているだけです。このため、ファイルが消去されたあともそれらは有効なメモリ・ブロックとしてフラッシュ・メモリ上に残ります。そこで、ファイルを消去するとき、占有していたデータ・セクタを明示的に消去(つまり未使用ブロックにする)することにより、メディア内の空きブロックを増やすことができます。これにより、次にそのブロックに書き込むときの消去動作が無くなり、書き込み性能が向上する可能性があります。また、ウェアレベリングに使えるブロックが増え、メディアの耐久性も向上するかも知れません。この機能を有効にするには、構成オプションの<tt>_USE_ERASE</tt>に1を設定します。これはフラッシュ・メモリ・メディアの内部動作に期待した制御なので、効果があるとは限りません。また、ファイル消去の時間が延びることも考慮に入れるべきです。</p> <p>通常のファイル消去では、記録されたデータに対して何らかの制御が行われるわけではなく、単にFAT上に未使用クラスタとして記録されているだけです。このため、ファイルが消去されたあともそれらは有効なメモリ・ブロックとしてフラッシュ・メモリ上に残ります。そこで、ファイルを消去するとき、占有していたデータ・セクタを明示的に消去(つまり未使用ブロックにする)することにより、メディア内の空きブロックを増やすことができます。これにより、次にそのブロックに書き込むときの消去動作が無くなり、書き込み性能が向上する可能性があります。また、ウェアレベリングに使えるブロックが増え、メディアの耐久性も向上するかも知れません。この機能を有効にするには、構成オプションの<tt>_USE_ERASE</tt>に1を設定します。これはフラッシュ・メモリ・メディアの内部動作に期待した制御なので、効果があるとは限りません。また、ファイル消去の時間が延びることも考慮に入れるべきです。</p>
</div> </div>
@ -252,6 +252,7 @@ _FS_LOCK 0 (Disable file lock control)
<li><a href="../img/app2.c">ディレクトリを空にする</a></li> <li><a href="../img/app2.c">ディレクトリを空にする</a></li>
<li><a href="../img/app3.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/app4.c">ディスクI/Oモジュールの機能/互換性チェッカー</a></li>
<li><a href="../img/mkfatimg.zip">FATイメージ作成ツール</a></li>
</ol> </ol>
</div> </div>
@ -259,7 +260,7 @@ _FS_LOCK 0 (Disable file lock control)
<h3>FatFsのライセンスについて</h3> <h3>FatFsのライセンスについて</h3>
<p>ソース・ファイルのヘッダにライセンス条件が記述されているので、利用の際はそれに従うこと。英語を読めない方のために以下に日本語訳を示しておきます。</p> <p>ソース・ファイルのヘッダにライセンス条件が記述されているので、利用の際はそれに従うこと。英語を読めない方のために以下に日本語訳を示しておきます。</p>
<pre>/*----------------------------------------------------------------------------/ <pre>/*----------------------------------------------------------------------------/
/ FatFs - FAT file system module R0.10a (C)ChaN, 2014 / FatFs - FAT file system module R0.10b (C)ChaN, 2014
/-----------------------------------------------------------------------------/ /-----------------------------------------------------------------------------/
/ FatFsモジュールは、小規模な組み込みシステム向けの汎用FATファイルシステム・ / FatFsモジュールは、小規模な組み込みシステム向けの汎用FATファイルシステム・
/ モジュールです。これはフリー・ソフトウェアとして、教育・研究・開発のために / モジュールです。これはフリー・ソフトウェアとして、教育・研究・開発のために

View File

@ -13,7 +13,7 @@
<div class="para func"> <div class="para func">
<h2>disk_ioctl</h2> <h2>disk_ioctl</h2>
<p>一般的なセクタ読み書き以外のストレージ・デバイス自体に対する様々な制御を行います。</p> <p>一般的なデータ読み書き以外のストレージ・デバイス自体に対する様々な制御を行います。</p>
<pre> <pre>
DRESULT disk_ioctl ( DRESULT disk_ioctl (
BYTE <span class="arg">pdrv</span>, <span class="c">/* [IN] 物理ドライブ番号 */</span> BYTE <span class="arg">pdrv</span>, <span class="c">/* [IN] 物理ドライブ番号 */</span>
@ -51,15 +51,36 @@ DRESULT disk_ioctl (
<div class="para desc"> <div class="para desc">
<h4>解説</h4> <h4>解説</h4>
<p>ストレージ・デバイスの種類によりサポートされるコマンドは異なりますが、FatFsモジュール自体は、次の汎用コマンドのみ使用し、特定のデバイスに依存した制御は行いません。アプリケーション上でこれ以外の制御が必要なときは、必要に応じてユーザ定義コマンドを追加してください。</p> <p>ストレージ・デバイスの種類によりサポートされるコマンドは異なりますが、FatFsモジュール自体は、次の汎用コマンドのみ使用し、特定のデバイスに依存した制御は行いません。</p>
<table class="lst"> <table class="lst">
<caption>標準ioctlコマンド</caption>
<tr><th>コマンド</th><th>解説</th></tr> <tr><th>コマンド</th><th>解説</th></tr>
<tr><td>CTRL_SYNC</td><td>ストレージ・デバイスのデータ書き込み処理を完了させます。ライト・バック・キャッシュなどが存在する場合は、書き込まれていないデータを即時書き込みます。メディア上への書き込みがそれぞれ<tt>disk_write</tt>関数内で完了する場合は、このコマンドに対してすることはありません。</td></tr> <tr><td>CTRL_SYNC</td><td>ストレージ・デバイスのデータ書き込み処理を完了させます。ライト・バック・キャッシュなどが存在する場合は、書き込まれていないデータを即時書き込みます。メディア上への書き込みがそれぞれ<tt>disk_write()</tt>内で完了する場合は、このコマンドに対してすることはありません。</td></tr>
<tr><td>GET_SECTOR_COUNT</td><td><tt class="arg">buff</tt>の指す<tt>DWORD</tt>型変数にドライブ上の総セクタ数を返します。<tt>f_mkfs()</tt>内で呼び出され、作成するボリュームのサイズを決定するために使用されます。</td></tr> <tr><td>GET_SECTOR_COUNT</td><td><tt class="arg">buff</tt>の指す<tt>DWORD</tt>型変数にドライブ上の総セクタ数を返します。<tt>f_mkfs()</tt>および<tt>f_fdisk()</tt>内から呼び出され、作成するボリュームのサイズを決定するために使用されます。</td></tr>
<tr><td>GET_SECTOR_SIZE</td><td><tt class="arg">buff</tt>の指す<tt>WORD</tt>型変数にドライブのセクタ・サイズを返します。有効値は512、1024、2048または4096です。セクタ・サイズ固定構成(<tt>_MAX_SS ==_MIN_SS</tt>)のときはこのコマンドは使われることはなく、常にそのセクタ・サイズで動作しなければなりません。</td></tr> <tr><td>GET_SECTOR_SIZE</td><td><tt class="arg">buff</tt>の指す<tt>WORD</tt>型変数にドライブのセクタ・サイズを返します。有効値は512、1024、2048または4096です。セクタ・サイズ固定構成(<tt>_MAX_SS ==_MIN_SS</tt>)のときはこのコマンドは使われることはなく、常にそのセクタ・サイズで動作しなければなりません。</td></tr>
<tr><td>GET_BLOCK_SIZE</td><td><tt class="arg">buff</tt>の指す<tt>DWORD</tt>型変数にフラッシュ・メモリの消去ブロック・サイズ(セクタ単位)を返します。1から32768の範囲で2の累乗の値でなければなりません。不明な場合またはフラッシュ・メモリ以外のメディアでは1を返します。<tt>f_mkfs()</tt>内でのみ使用され、ボリュームのデータ領域はこの境界にアライメントされます。</td></tr> <tr><td>GET_BLOCK_SIZE</td><td><tt class="arg">buff</tt>の指す<tt>DWORD</tt>型変数にフラッシュ・メモリの消去ブロック・サイズ(セクタ単位)を返します。1から32768の範囲で2の累乗の値でなければなりません。不明な場合またはフラッシュ・メモリ以外のメディアでは1を返します。<tt>f_mkfs()</tt>内でのみ使用され、ボリュームのデータ領域はこの境界にアライメントされます。</td></tr>
<tr><td>CTRL_ERASE_SECTOR</td><td>フラッシュ・メモリ上の領域の明示的消去。<tt class="arg">buff</tt>の指す<tt>DWORD</tt>型配列には消去する領域 {開始セクタ,終了セクタ} を指定して呼び出されます。<tt>_USE_ERASE</tt>が1のとき、クラスタが解放されるときに呼び出されます。これは、ATAコマンド・セットのTrimコマンドと等価で、この機能をサポートしない場合は何もする必要はありません。また、戻り値はチェックされず、消去が完全に行われなかったとしてもFatFsの動作には影響ありません。</td></tr> <tr><td>CTRL_ERASE_SECTOR</td><td>フラッシュ・メモリ上の領域の明示的消去。<tt class="arg">buff</tt>の指す<tt>DWORD</tt>型配列には消去する領域 {開始セクタ,終了セクタ} を指定して呼び出されます。<tt>_USE_ERASE</tt>が1のとき、クラスタが解放されるときに呼び出されます。これは、ATAコマンド・セットのTrimコマンドと等価で、この機能をサポートしない場合は何もする必要はありません。また、戻り値はチェックされず、消去が完全に行われなかったとしてもFatFsの動作には影響ありません。</td></tr>
</table> </table>
<p>FatFs自体はデバイス依存コマンドやユーザ定義コマンドは一切使用しませんが、アプリケーションから何らかのデバイス制御が行えると便利なことがあります。アプリケーション上で標準以外の制御が必要なときは、必要に応じてユーザ定義コマンドを追加して利用するとよいでしょう。次にコマンドの例を示します。</p>
<table class="lst">
<caption>ユーザ定義ioctlコマンドの例</caption>
<tr><th>コマンド</th><th>解説</th></tr>
<tr><td>CTRL_FORMAT</td><td>メディアの物理フォーマットを行います。<tt class="arg">buff</tt>はNULLでないとき、進行表示のためのコールバック関数のアドレスを示します。</td></tr>
<tr><td>CTRL_POWER_IDLE</td><td>デバイスをアイドル状態にします。通常の読み書き要求でアクティブ状態に戻るなら、<tt>STA_NOINIT</tt>フラグをセットする必要はありません。</td></tr>
<tr><td>CTRL_POWER_OFF</td><td>デバイスをシャットダウン状態にします。<tt>STA_NOINIT</tt>はセットされます。デバイスは<tt>disk_initialize()</tt>でアクティブ状態に戻ります。</td></tr>
<tr><td>CTRL_LOCK</td><td>ユーザによるメディアの取り出しを禁止します。</td></tr>
<tr><td>CTRL_UNLOCK</td><td>ユーザによるメディアの取り出しを許可します。</td></tr>
<tr><td>CTRL_EJECT</td><td>メディアを排出します。完了後、<tt>STA_NOINIT</tt><tt>STA_NODISK</tt>フラグはセットされます。</td></tr>
<tr><td>MMC_GET_TYPE</td><td>カード・タイプを示すフラグ(b0:MMCv3, b1:SDv1, b2:SDv2+, b3:LBA)を<tt class="arg">buff</tt>の示す<tt>BYTE</tt>変数に読み出します。(MMC/SDカード専用)</td></tr>
<tr><td>MMC_GET_CSD</td><td>CSDレジスタの内容を<tt class="arg">buff</tt>の示す16バイトのバッファに読み出します。(MMC/SDカード専用)</td></tr>
<tr><td>MMC_GET_CID</td><td>CIDレジスタの内容を<tt class="arg">buff</tt>の示す16バイトのバッファに読み出します。(MMC/SDカード専用)</td></tr>
<tr><td>MMC_GET_OCR</td><td>OCRレジスタの内容を<tt class="arg">buff</tt>の示す4バイトのバッファに読み出します。(MMC/SDカード専用)</td></tr>
<tr><td>MMC_GET_SDSTAT</td><td>SD STATUSレジスタの内容を<tt class="arg">buff</tt>の示す64バイトのバッファに読み出します。(SDカード専用)</td></tr>
<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>
</table>
</div> </div>

View File

@ -13,7 +13,7 @@
<div class="para func"> <div class="para func">
<h2>disk_read</h2> <h2>disk_read</h2>
<p>ストレージ・デバイスからセクタを読み出します。</p> <p>ストレージ・デバイスからデータを読み出します。</p>
<pre> <pre>
DRESULT disk_read ( DRESULT disk_read (
BYTE <span class="arg">pdrv</span>, <span class="c">/* [IN] 物理ドライブ番号 */</span> BYTE <span class="arg">pdrv</span>, <span class="c">/* [IN] 物理ドライブ番号 */</span>

View File

@ -13,7 +13,7 @@
<div class="para func"> <div class="para func">
<h2>disk_status</h2> <h2>disk_status</h2>
<p>ディスク・ドライブの状態を取得します。</p> <p>ストレージ・デバイスの状態を取得します。</p>
<pre> <pre>
DSTATUS disk_status ( DSTATUS disk_status (
BYTE <span class="arg">pdrv</span> <span class="c">/* [IN] 物理ドライブ番号 */</span> BYTE <span class="arg">pdrv</span> <span class="c">/* [IN] 物理ドライブ番号 */</span>
@ -32,10 +32,10 @@ DSTATUS disk_status (
<div class="para ret"> <div class="para ret">
<h4>戻り値</h4> <h4>戻り値</h4>
<p>物理ドライブの状態を次のフラグの組み合わせ値で返します。</p> <p>ストレージ・デバイスの状態を次のフラグの組み合わせ値で返します。</p>
<dl class="ret"> <dl class="ret">
<dt>STA_NOINIT</dt> <dt>STA_NOINIT</dt>
<dd>ドライブが初期化されていないことを示すフラグ。システム・リセットやメディアの取り外し等でセットされ、<tt>disk_initialize()</tt>の正常終了でクリア、失敗でセットされます。メディア交換は非同期に発生するイベントなので、過去にメディア交換があった場合もこのフラグに反映させる必要があります。FatFsモジュールは、このフラグを参照して自動マウント動作を行うかどうかを判断します。</dd> <dd>デバイスが初期化されていないことを示すフラグ。システム・リセットやメディアの取り外し等でセットされ、<tt>disk_initialize()</tt>の正常終了でクリア、失敗でセットされます。メディア交換は非同期に発生するイベントなので、過去にメディア交換があった場合もこのフラグに反映させる必要があります。FatFsモジュールは、このフラグを参照して自動マウント動作を行うかどうかを判断します。</dd>
<dt>STA_NODISK</dt> <dt>STA_NODISK</dt>
<dd>メディアが存在しないことを示すフラグ。メディアが取り外されている間はセットされ、セットされている間はクリアされます。固定ディスクでは常にクリアします。なお、このフラグはFatFsモジュールでは参照されません。</dd> <dd>メディアが存在しないことを示すフラグ。メディアが取り外されている間はセットされ、セットされている間はクリアされます。固定ディスクでは常にクリアします。なお、このフラグはFatFsモジュールでは参照されません。</dd>
<dt>STA_PROTECT</dt> <dt>STA_PROTECT</dt>

View File

@ -13,7 +13,7 @@
<div class="para func"> <div class="para func">
<h2>disk_write</h2> <h2>disk_write</h2>
<p>ストレージ・デバイスのセクタに書き込みます。</p> <p>ストレージ・デバイスにデータを書き込みます。</p>
<pre> <pre>
DRESULT disk_write ( DRESULT disk_write (
BYTE <span class="arg">pdrv</span>, <span class="c">/* [IN] 物理ドライブ番号 */</span> BYTE <span class="arg">pdrv</span>, <span class="c">/* [IN] 物理ドライブ番号 */</span>

View File

@ -22,7 +22,7 @@ DWORD get_fattime (void);
<div class="para ret"> <div class="para ret">
<h4>戻り値</h4> <h4>戻り値</h4>
<p>現在のローカル・タイムを<tt>DWORD</tt>値にパックして返しす。ビット・フィールドは次に示すようになります。</p> <p>現在のローカル・タイムを<tt>DWORD</tt>値にパックして返しす。ビット・フィールドは次に示すようになります。</p>
<dl> <dl>
<dt>bit31:25</dt> <dt>bit31:25</dt>
<dd>1980年を起点とした年を 0..127 でセット。</dd> <dd>1980年を起点とした年を 0..127 でセット。</dd>

View File

@ -13,7 +13,7 @@
<div class="para func"> <div class="para func">
<h2>f_getcwd</h2> <h2>f_getcwd</h2>
<p>カレント・ディレクトリを得ます</p> <p>カレント・ディレクトリを得ます</p>
<pre> <pre>
FRESULT f_getcwd ( FRESULT f_getcwd (
TCHAR* <span class="arg">buff</span>, <span class="c">/* [OUT] バッファ */</span> TCHAR* <span class="arg">buff</span>, <span class="c">/* [OUT] バッファ */</span>
@ -28,7 +28,7 @@ FRESULT f_getcwd (
<dt>buff</dt> <dt>buff</dt>
<dd>カレント・ディレクトリのパス名文字列を格納するバッファ</dd> <dd>カレント・ディレクトリのパス名文字列を格納するバッファ</dd>
<dt>len</dt> <dt>len</dt>
<dd>TCHAR単位のバッファ・サイズ</dd> <dd><tt>TCHAR</tt>単位のバッファ・サイズ</dd>
</dl> </dl>
</div> </div>

View File

@ -13,7 +13,7 @@
<div class="para func"> <div class="para func">
<h2>f_getfree</h2> <h2>f_getfree</h2>
<p>ボリューム上の未使用クラスタ数を取得します。</p> <p>ボリューム上の空き領域のサイズを取得します。</p>
<pre> <pre>
FRESULT f_getfree ( FRESULT f_getfree (
const TCHAR* <span class="arg">path</span>, <span class="c">/* [IN] 対象ドライブを指定します */</span> const TCHAR* <span class="arg">path</span>, <span class="c">/* [IN] 対象ドライブを指定します */</span>
@ -53,7 +53,7 @@ FRESULT f_getfree (
<div class="para desc"> <div class="para desc">
<h4>解説</h4> <h4>解説</h4>
<p>論理ドライブ上の空きクラスタ数を取得します。返されたファイル・システム・オブジェクトの<tt>csize</tt>メンバがクラスタあたりのセクタ数を示しているので、これを元にセクタ単位の空きサイズが計算できます。FAT32ボリュームにおいては、FSINFOの情報が実際の空きクラスタ数と同期していない場合、不正確な値を返す可能性があります。この問題を避けるため、<tt>_FS_NOFSINFO</tt>オプションでFSINFOを無視して初回はフルFATスキャンをするように構成することもできます。</p> <p>論理ドライブ上の空き領域のサイズをクラスタ単位で取得します。返されたファイル・システム・オブジェクトの<tt>csize</tt>メンバがクラスタあたりのセクタ数を示しているので、これを元にセクタ単位の空きサイズが計算できます。FAT32ボリュームにおいては、FSINFOの情報が実際の空きクラスタ数と同期していない場合、不正確な値を返す可能性があります。この問題を避けるため、<tt>_FS_NOFSINFO</tt>オプションでマウント後の初回は必ずフルFATスキャンをするように構成することもできます。</p>
</div> </div>

View File

@ -17,8 +17,8 @@
<pre> <pre>
FRESULT f_getlabel ( FRESULT f_getlabel (
const TCHAR* <span class="arg">path</span>, <span class="c">/* [IN] 対象ドライブ */</span> const TCHAR* <span class="arg">path</span>, <span class="c">/* [IN] 対象ドライブ */</span>
TCHAR* <span class="arg">name</span>, <span class="c">/* [OUT] ボリューム名を格納するバッファ */</span> TCHAR* <span class="arg">label</span>, <span class="c">/* [OUT] ボリューム名を格納するバッファ */</span>
DWORD* <span class="arg">sn</span> <span class="c">/* [OUT] ボリューム・シリアル番号を格納する変数 */</span> DWORD* <span class="arg">vsn</span> <span class="c">/* [OUT] ボリューム・シリアル番号を格納する変数 */</span>
); );
</pre> </pre>
</div> </div>
@ -28,9 +28,9 @@ FRESULT f_getlabel (
<dl class="par"> <dl class="par">
<dt>path</dt> <dt>path</dt>
<dd>対象となる論理ドライブの<a href="filename.html">パス名</a>を示すヌル文字<tt>'\0'</tt>終端の文字列へのポインタを指定します。ヌル文字列の場合は、デフォルト・ドライブを指定したことになります。</dd> <dd>対象となる論理ドライブの<a href="filename.html">パス名</a>を示すヌル文字<tt>'\0'</tt>終端の文字列へのポインタを指定します。ヌル文字列の場合は、デフォルト・ドライブを指定したことになります。</dd>
<dt>name</dt> <dt>label</dt>
<dd>ボリューム名を格納する配列へのポインタを指定します。少なくとも12要素のサイズが必要です。ボリューム名がない場合はヌル文字列が返されます。この情報が不要なときはヌル・ポインタを指定してください。</dd> <dd>ボリューム名を格納する配列へのポインタを指定します。少なくとも12要素のサイズが必要です。ボリューム名がない場合はヌル文字列が返されます。この情報が不要なときはヌル・ポインタを指定してください。</dd>
<dt>sn</dt> <dt>vsn</dt>
<dd>ボリューム・シリアル番号を格納する<tt>DWORD</tt>型変数へのポインタを指定します。この情報が不要なときはヌル・ポインタを指定してください。</dd> <dd>ボリューム・シリアル番号を格納する<tt>DWORD</tt>型変数へのポインタを指定します。この情報が不要なときはヌル・ポインタを指定してください。</dd>
</dl> </dl>
</div> </div>

View File

@ -38,13 +38,13 @@ TCHAR* f_gets (
<div class="para ret"> <div class="para ret">
<h4>戻り値</h4> <h4>戻り値</h4>
<p>関数が成功すると<tt>buff</tt>が返されます。</p> <p>関数が成功すると<tt class="arg">buff</tt>が返されます。</p>
</div> </div>
<div class="para desc"> <div class="para desc">
<h4>解説</h4> <h4>解説</h4>
<p>この関数は<a href="read.html"><tt>f_read()</tt></a>のラッパー関数です。読み出し動作は、最初の<tt>'\n'</tt>を読み込むか、ファイル終端に達するか、<tt>len - 1</tt>文字を読み出すまで続きます。読み込まれた文字列の終端には<tt>'\0'</tt>が付加されます。既にファイル終端で1文字も読み込まれなかったとき、または何らかのエラーが発生したときは関数は失敗しヌル・ポインタを返します。ファイル終端かエラーかは<tt>f_eof()</tt>,<tt>f_error()</tt>マクロで調べられます。</p> <p>この関数は<a href="read.html"><tt>f_read()</tt></a>のラッパー関数です。読み出し動作は、最初の<tt>'\n'</tt>を読み込むか、ファイル終端に達するか、<tt class="arg">len</tt> - 1文字を読み出すまで続きます。読み込まれた文字列の終端には<tt>'\0'</tt>が付加されます。既にファイル終端で1文字も読み込まれなかったとき、または何らかのエラーが発生したときは関数は失敗しヌル・ポインタを返します。ファイル終端かエラーかは<tt>f_eof()</tt>,<tt>f_error()</tt>マクロで調べられます。</p>
<p>Unicode API構成(<tt>_LFN_UNICODE == 1</tt>)が選択されているときは、<tt class="arg">buff</tt>はUTF-16文字列になりますが、ファイル上のエンコードは、<tt>_STRF_ENCODE</tt>オプションで選択できます。それ以外の時は無変換(1バイト/1文字)で読み出します。</p> <p>Unicode API構成(<tt>_LFN_UNICODE == 1</tt>)が選択されているときは、<tt class="arg">buff</tt>はUTF-16文字列になりますが、ファイル上のエンコードは、<tt>_STRF_ENCODE</tt>オプションで選択できます。それ以外の時は無変換(1バイト/1文字)で読み出します。</p>
</div> </div>

View File

@ -31,7 +31,7 @@ FRESULT f_mkfs (
<dt>sfd</dt> <dt>sfd</dt>
<dd>パーテーション形式。(0(FDISK) または 1(SFD))</dd> <dd>パーテーション形式。(0(FDISK) または 1(SFD))</dd>
<dt>au</dt> <dt>au</dt>
<dd>クラスタ・サイズをバイト単位で指定します。対象ドライブのセクタ・サイズのn倍(n = 1128で、2の累乗)でなければなりません。0を指定した場合、ボリュームのサイズに応じたデフォルトのクラスタ・サイズが選択されます。</dd> <dd>クラスタ・サイズをバイト単位で指定します。値は対象ドライブのセクタ・サイズのn倍(n = 1128で、2の累乗)でなければなりません。0などの無効値を指定した場合、ボリュームのサイズに応じたデフォルトのクラスタ・サイズが選択されます。</dd>
</dl> </dl>
</div> </div>

View File

@ -16,7 +16,7 @@
<p>論理ドライブにファイル・システム・オブジェクトを登録・抹消します。</p> <p>論理ドライブにファイル・システム・オブジェクトを登録・抹消します。</p>
<pre> <pre>
FRESULT f_mount ( FRESULT f_mount (
FATFS* <span class="arg">fatfs</span>, <span class="c">/* [IN] ファイル・システム・オブジェクト */</span> FATFS* <span class="arg">fs</span>, <span class="c">/* [IN] ファイル・システム・オブジェクト */</span>
const TCHAR* <span class="arg">path</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>
); );
@ -26,7 +26,7 @@ FRESULT f_mount (
<div class="para arg"> <div class="para arg">
<h4>引数</h4> <h4>引数</h4>
<dl class="par"> <dl class="par">
<dt>fatfs</dt> <dt>fs</dt>
<dd>登録するファイル・システム・オブジェクトへのポインタ。</dd> <dd>登録するファイル・システム・オブジェクトへのポインタ。</dd>
<dt>path</dt> <dt>path</dt>
<dd>対象となる論理ドライブの<a href="filename.html">パス名</a>を示すヌル文字'\0'終端の文字列へのポインタを指定します。ドライブ番号を含まない場合は、デフォルト・ドライブを指定したことになります。</dd> <dd>対象となる論理ドライブの<a href="filename.html">パス名</a>を示すヌル文字'\0'終端の文字列へのポインタを指定します。ドライブ番号を含まない場合は、デフォルト・ドライブを指定したことになります。</dd>
@ -49,11 +49,11 @@ FRESULT f_mount (
<div class="para desc"> <div class="para desc">
<h4>解説</h4> <h4>解説</h4>
<p>FatFsモジュールでは、それぞれの論理ドライブに<em>ファイル・システム・オブジェクト</em>というワーク・エリアが必要です。この関数は論理ドライブにファイル・システム・オブジェクトを登録したり抹消したりします。何らかのファイル関数を使用する前に、この関数でその論理ドライブのファイル・システム・オブジェクトを与えておかなければなりません。<tt class="arg">fatfs</tt>にヌル・ポインタを指定すると、その論理ドライブのファイル・システム・オブジェクトの登録は抹消されるだけです。登録抹消されたファイル・システム・オブジェクトのメモリは解放できます。操作対象の論理ドライブ上に開かれているファイルやディレクトリがあった場合、それらは全て無効になります。この関数の内部処理は次のような順に行われます。</p> <p>FatFsモジュールでは、それぞれの論理ドライブに<em>ファイル・システム・オブジェクト</em>というワーク・エリアが必要です。この関数は論理ドライブにファイル・システム・オブジェクトを登録したり抹消したりします。何らかのファイル関数を使用する前に、この関数でその論理ドライブのファイル・システム・オブジェクトを与えておかなければなりません。<tt class="arg">fs</tt>にヌル・ポインタを指定すると、その論理ドライブのファイル・システム・オブジェクトの登録は抹消されるだけです。登録抹消されたファイル・システム・オブジェクトのメモリは解放できます。操作対象の論理ドライブ上に開かれているファイルやディレクトリがあった場合、それらは全て無効になります。この関数の内部処理は次のような順に行われます。</p>
<ol> <ol>
<li>対象の論理ドライブを<tt class="arg">path</tt>から得る。</li> <li>対象の論理ドライブを<tt class="arg">path</tt>から得る。</li>
<li>既に登録されているファイル・システム・オブジェクトはクリアし、登録を解除する。</li> <li>既に登録されているファイル・システム・オブジェクトはクリアし、登録を解除する。</li>
<li><tt class="arg">fatfs</tt>が有効なポインタのときは、そのファイル・システム・オブジェクトをクリアし登録する。</li> <li><tt class="arg">fs</tt>が有効なポインタのときは、そのファイル・システム・オブジェクトをクリアし登録する。</li>
<li>マウント動作が指定されているときは、それを実行する。</li> <li>マウント動作が指定されているときは、それを実行する。</li>
</ol> </ol>
<p><tt class="arg">opt</tt>に0を指定すると、マウント動作(物理ドライブの初期化、FATボリュームの検索、BPBを解析しファイル・システム・オブジェクトを初期化)は行われず、関数は物理ドライブの状態に関わらず常に成功します。関数内では下位レイヤへのアクセスは発生せず、指定されたファイル・システム・オブジェクトをクリア(無効化)し、そのアドレスを内部配列に登録するだけです。単に登録済みのファイル・システム・オブジェクトをクリアする目的にも使えます。そして、続いてボリュームへのアクセスが行われたとき次のうちいずれかでも真の場合は、実際のマウント動作が行われます。</p> <p><tt class="arg">opt</tt>に0を指定すると、マウント動作(物理ドライブの初期化、FATボリュームの検索、BPBを解析しファイル・システム・オブジェクトを初期化)は行われず、関数は物理ドライブの状態に関わらず常に成功します。関数内では下位レイヤへのアクセスは発生せず、指定されたファイル・システム・オブジェクトをクリア(無効化)し、そのアドレスを内部配列に登録するだけです。単に登録済みのファイル・システム・オブジェクトをクリアする目的にも使えます。そして、続いてボリュームへのアクセスが行われたとき次のうちいずれかでも真の場合は、実際のマウント動作が行われます。</p>

View File

@ -17,7 +17,7 @@
<pre> <pre>
FRESULT f_open ( FRESULT f_open (
FIL* <span class="arg">fp</span>, <span class="c">/* [OUT] 空のファイル・オブジェクト構造体へのポインタ */</span> FIL* <span class="arg">fp</span>, <span class="c">/* [OUT] 空のファイル・オブジェクト構造体へのポインタ */</span>
const TCHAR* <span class="arg">path</span>, <span class="c">/* [IN] ファイルのフルパス名へのポインタ */</span> const TCHAR* <span class="arg">path</span>, <span class="c">/* [IN] ファイル名へのポインタ */</span>
BYTE <span class="arg">mode</span> <span class="c">/* [IN] モードフラグ */</span> BYTE <span class="arg">mode</span> <span class="c">/* [IN] モードフラグ */</span>
); );
</pre> </pre>
@ -29,7 +29,7 @@ FRESULT f_open (
<dt>fp</dt> <dt>fp</dt>
<dd>新しく作成するファイル・オブジェクト構造体へのポインタを指定します。以降、そのファイルを閉じるまでこのファイル・オブジェクトを使用してファイル操作をします。</dd> <dd>新しく作成するファイル・オブジェクト構造体へのポインタを指定します。以降、そのファイルを閉じるまでこのファイル・オブジェクトを使用してファイル操作をします。</dd>
<dt>path</dt> <dt>path</dt>
<dd>開く(または作成する)ファイルの <a href="filename.html">ファイル名</a>を示すヌル文字<tt>'\0'</tt>終端の文字列へのポインタを指定します。</dd> <dd>開くファイルの<a href="filename.html">ファイル名</a>を示すヌル文字<tt>'\0'</tt>終端の文字列へのポインタを指定します。</dd>
<dt>mode</dt> <dt>mode</dt>
<dd>ファイルのアクセス方法やオープン方法を決めるフラグです。このパラメータには次の組み合わせを指定します。<br> <dd>ファイルのアクセス方法やオープン方法を決めるフラグです。このパラメータには次の組み合わせを指定します。<br>
<table class="lst"> <table class="lst">

View File

@ -56,8 +56,8 @@ int f_printf (
<div class="para comp"> <div class="para comp">
<h4>Ήž<EFBFBD>î•ñ</h4> <h4>Ήž<EFBFBD>î•ñ</h4>
<p><tt>_FS_READONLY == 0</tt>で、且つ<tt>_USE_STRFUNC</tt> 1または 2のとき使用可能になります。2の時は、出力に含まれる<tt>'\n'</tt><tt>"\r\n"</tt>に展開されてファイルに書き込まれます。</p> <p><tt>_FS_READONLY == 0</tt>で、且つ<tt>_USE_STRFUNC</tt>が1または2のとき使用可能になります。2の時は、出力に含まれる<tt>'\n'</tt><tt>'\r'+'\n'</tt>に展開されてファイルに書き込まれます。</p>
<p>APIにUnicodeが選択(<tt>_LFN_UNICODE</tt>が1)されているときは、<span class="arg">fmt</span>はUnicode文字列になりますが、ファイル上のエンコードは、<tt>_STRF_ENCODE</tt>オプションで選択できます。それ以外の時は無変換(1バイト/1文字)で書き込みます。</p> <p>APIにUnicodeが選択(<tt>_LFN_UNICODE</tt>が1)されているときは、<tt class="arg">fmt</tt>はUnicode文字列になりますが、ファイル上のエンコードは、<tt>_STRF_ENCODE</tt>オプションで選択できます。それ以外の時は無変換(1バイト/1文字)で書き込みます。</p>
</div> </div>

View File

@ -36,7 +36,7 @@ int f_putc (
<div class="para ret"> <div class="para ret">
<h4>戻り値</h4> <h4>戻り値</h4>
<p>文字が正常に書き込まれると書き込んだ文字数が返されます。ディスクが満杯またはエラーにより書き込まれなかったときは<tt>EOF (-1)</tt>が返されます。</p> <p>文字が正常に書き込まれると書き込んだ文字数が返されます。ディスクが満杯またはエラーにより書き込まれなかったときは<tt>EOF (-1)</tt>が返されます。</p>
<p>APIにUnicodeが選択(<tt>_LFN_UNICODE</tt>が1)されているときは、<span class="arg">chr</span>はUTF-16文字になりますが、ファイル上のエンコードは、<tt>_STRF_ENCODE</tt>オプションで選択できます。それ以外の時は無変換(1バイト/1文字)で書き込みます。</p> <p>APIにUnicodeが選択(<tt>_LFN_UNICODE</tt>が1)されているときは、<tt class="arg">chr</tt>はUTF-16文字になりますが、ファイル上のエンコードは、<tt>_STRF_ENCODE</tt>オプションで選択できます。それ以外の時は無変換(1バイト/1文字)で書き込みます。</p>
</div> </div>
@ -48,7 +48,7 @@ int f_putc (
<div class="para comp"> <div class="para comp">
<h4>対応情報</h4> <h4>対応情報</h4>
<p><tt>_FS_READONLY == 0</tt>で、且つ<tt>_USE_STRFUNC</tt>が 1または 2のとき使用可能です。2を指定すると、<tt>'\n'</tt><tt>"\r\n"</tt>に展開されてファイルに書き込まれます。</p> <p><tt>_FS_READONLY == 0</tt>で、且つ<tt>_USE_STRFUNC</tt>が 1または 2のとき使用可能です。2を指定すると、<tt>'\n'</tt><tt>'\r'+'\n'</tt>に展開されてファイルに書き込まれます。</p>
</div> </div>

View File

@ -36,7 +36,7 @@ int f_puts (
<div class="para ret"> <div class="para ret">
<h4>戻り値</h4> <h4>戻り値</h4>
<p>文字列が正常に書き込まれると、書き込まれた文字数が返されます。ディスクが満杯またはエラーにより書き込みが中断されたときは<tt>EOF (-1)</tt>が返されます。</p> <p>文字列が正常に書き込まれると、書き込まれた文字数が返されます。ディスクが満杯またはエラーにより書き込みが中断されたときは<tt>EOF (-1)</tt>が返されます。</p>
<p>APIにUnicodeが選択(<tt>_LFN_UNICODE</tt>が1)されているときは、<span class="arg">str</span>はUTF-16文字列になりますが、ファイル上のエンコードは、<tt>_STRF_ENCODE</tt>オプションで選択できます。それ以外の時は無変換(1バイト/1文字)で書き込みます。</p> <p>APIにUnicodeが選択(<tt>_LFN_UNICODE</tt>が1)されているときは、<tt class="arg">str</tt>はUTF-16文字列になりますが、ファイル上のエンコードは、<tt>_STRF_ENCODE</tt>オプションで選択できます。それ以外の時は無変換(1バイト/1文字)で書き込みます。</p>
</div> </div>
@ -48,7 +48,7 @@ int f_puts (
<div class="para comp"> <div class="para comp">
<h4>対応情報</h4> <h4>対応情報</h4>
<p><tt>_FS_READONLY == 0</tt>で、且つ<tt>_USE_STRFUNC</tt> 1または 2のとき使用可能です。2を指定すると、文字列に含まれる<tt>'\n'</tt><tt>"\r\n"</tt>に展開されてファイルに書き込まれます。</p> <p><tt>_FS_READONLY == 0</tt>で、且つ<tt>_USE_STRFUNC</tt>が1または2のとき使用可能です。2を指定すると、文字列に含まれる<tt>'\n'</tt><tt>'\r'+'\n'<tt>に展開されてファイルに書き込まれます。</p>
</div> </div>

View File

@ -17,15 +17,14 @@
<dt id="ok">FR_OK (0)</dt> <dt id="ok">FR_OK (0)</dt>
<dd>関数は成功した。</dd> <dd>関数は成功した。</dd>
<dt id="de">FR_DISK_ERR</dt> <dt id="de">FR_DISK_ERR</dt>
<dd>下位レイヤ(<tt>disk_read(), disk_write(), disk_ioctl()</tt>関数)で回復不能なエラーが発生した。</dd> <dd>下位レイヤ(<tt>disk_read(), disk_write(), disk_ioctl()</tt>関数)で回復不能なエラーが発生した。<br>※開かれたファイルの操作においてこのエラーが発生すると、そのファイル・オブジェクトはアボート状態となり、クローズ以外のの操作ができなくなります。</dd>
<dt id="ie">FR_INT_ERR</dt> <dt id="ie">FR_INT_ERR</dt>
<dd>内部処理の健全性に異常が検出された。原因としては次のようなことが考えられます。 <dd>内部処理の健全性に異常が検出された。原因としては次のようなことが考えられます。
<ul> <ul>
<li>ボリューム上のFAT構造にエラーがある。</li> <li>ボリューム上のFAT構造にエラーがある。</li>
<li>スタック不足や他のタスク等によるワーク・エリア(ファイル・システム・オブジェクトやファイル・オブジェクト)の破壊。多くはこれが原因。</li> <li>スタック不足や不正なメモリ操作等によるワーク・エリアの破壊。多くはこれが原因。</li>
<li>そのファイルオブジェクトでは過去に<tt>FR_DISK_ERR</tt>が発生している。</li>
</ul> </ul>
</dd> ※開かれたファイルの操作においてこのエラーが発生すると、そのファイル・オブジェクトはアボート状態となり、クローズ以外の操作ができなくなります。</dd>
<dt id="nr">FR_NOT_READY</dt> <dt id="nr">FR_NOT_READY</dt>
<dd>物理ドライブが動作可能な状態にない。または、ドライブの初期化に失敗した。</dd> <dd>物理ドライブが動作可能な状態にない。または、ドライブの初期化に失敗した。</dd>
<dt id="nf">FR_NO_FILE</dt> <dt id="nf">FR_NO_FILE</dt>
@ -40,20 +39,19 @@
<li>書き込み禁止属性(<tt>AM_RDO</tt>)を持つファイルを書き込みモードで開こうとした。</li> <li>書き込み禁止属性(<tt>AM_RDO</tt>)を持つファイルを書き込みモードで開こうとした。</li>
<li>書き込み禁止属性を持つファイルやディレクトリを削除しようとした。</li> <li>書き込み禁止属性を持つファイルやディレクトリを削除しようとした。</li>
<li>空でないディレクトリまたはカレント・ディレクトリを削除しようとした。</li> <li>空でないディレクトリまたはカレント・ディレクトリを削除しようとした。</li>
<li><tt>FA_READ</tt>を付けずに開いたファイルに対して読み出しを行った。</li> <li><tt>FA_READ</tt>フラグを付けずに開いたファイルに対して読み出しを行った。</li>
<li><tt>FA_WRITE</tt>を付けずに開いたファイルに対して変更操作を行った。</li> <li><tt>FA_WRITE</tt>フラグを付けずに開いたファイルに対して書き込みまたはそれに類する操作を行った。</li>
<li>ディレクトリ・テーブルが満杯でファイルやディレクトリを作成できなかった。</li> <li>ボリュームまたはディレクトリ・テーブルが満杯でファイルやディレクトリを作成できなかった。</li>
<li>ボリュームが満杯でディレクトリを作成できなかった。</li>
</ul> </ul>
</dd> </dd>
<dt id="ex">FR_EXIST</dt> <dt id="ex">FR_EXIST</dt>
<dd>新しく作成しようとしたオブジェクトと同じ名前のオブジェクトが既に存在する。</dd> <dd>新しく作成しようとしたオブジェクトと同じ名前のオブジェクトが既に存在する。</dd>
<dt id="io">FR_INVALID_OBJECT</dt> <dt id="io">FR_INVALID_OBJECT</dt>
<dd>指定されたファイル・オブジェクトやディレクトリ・オブジェクトが無効(オープンされていない、既に閉じられた、破損しているなど)、またはヌル・ポインタが渡された。また、開かれたままのオブジェクトは、そのボリュームのマウント動作により無効となります。</dd> <dd>指定されたファイル・オブジェクトやディレクトリ・オブジェクトが無効(オープンされていない、既に閉じられた、破損しているなど)、またはヌル・ポインタが渡された。また、開かれたままのオブジェクトは、そ属するボリュームのマウント動作により無効となります。</dd>
<dt id="wp">FR_WRITE_PROTECTED</dt> <dt id="wp">FR_WRITE_PROTECTED</dt>
<dd>物理ドライブが書き込み禁止状態のとき、書き込み系の操作を行おうとした。</dd> <dd>物理ドライブが書き込み禁止状態のとき、書き込みを伴う操作を行おうとした。</dd>
<dt id="id">FR_INVALID_DRIVE</dt> <dt id="id">FR_INVALID_DRIVE</dt>
<dd>パス名指定されたドライブ番号が無効、またはパス名にヌル・ポインタが渡された。(関連オプション: <tt>_VOLUMES</tt>)</dd> <dd>パス名中に指定されたドライブ番号が無効、またはパス名にヌル・ポインタが渡された。(関連オプション: <tt>_VOLUMES</tt>)</dd>
<dt id="ne">FR_NOT_ENABLED</dt> <dt id="ne">FR_NOT_ENABLED</dt>
<dd>そのボリュームの操作に必要なワーク・エリア(ファイル・システム・オブジェクト構造体)が与えられていない。</dd> <dd>そのボリュームの操作に必要なワーク・エリア(ファイル・システム・オブジェクト構造体)が与えられていない。</dd>
<dt id="ns">FR_NO_FILESYSTEM</dt> <dt id="ns">FR_NO_FILESYSTEM</dt>
@ -63,13 +61,13 @@
<ul> <ul>
<li>ボリュームが小さすぎる。</li> <li>ボリュームが小さすぎる。</li>
<li>FATタイプの計算に矛盾が見つかった。クラスタ数がFATタイプの境界付近になるときに発生する場合があります。</li> <li>FATタイプの計算に矛盾が見つかった。クラスタ数がFATタイプの境界付近になるときに発生する場合があります。</li>
<li>論理ドライブに対応する区画が見つからなかった。(関連オプション: <tt>_MULTI_PARTITION</tt>)</li> <li>その論理ドライブに対応する区画が見つからなかった。(関連オプション: <tt>_MULTI_PARTITION</tt>)</li>
</ul> </ul>
</dd> </dd>
<dt id="tm">FR_TIMEOUT</dt> <dt id="tm">FR_TIMEOUT</dt>
<dd><a href="appnote.html#reentrant">再入制御</a>による待ち時間が定義された時間を越えたため、関数は実行されなかった。(関連オプション: <tt>_TIMEOUT</tt>)</dd> <dd><a href="appnote.html#reentrant">再入制御</a>による待ち時間が定義された時間を越えたため、関数は実行されなかった。(関連オプション: <tt>_TIMEOUT</tt>)</dd>
<dt id="lo">FR_LOCKED</dt> <dt id="lo">FR_LOCKED</dt>
<dd><a href="appnote.html#dup">多重アクセス排他機能</a>により、そのファイルに対して行おうとしたアクセスが拒否された。(関連オプション: <tt>_FS_LOCK</tt>)</dd> <dd><a href="appnote.html#dup">多重アクセス排他機能</a>により、そのファイルやディレクトリに対して行おうとしたアクセスが拒否された。(関連オプション: <tt>_FS_LOCK</tt>)</dd>
<dt id="nc">FR_NOT_ENOUGH_CORE</dt> <dt id="nc">FR_NOT_ENOUGH_CORE</dt>
<dd>メモリ不足による失敗。原因としては次のようなことが考えられます。 <dd>メモリ不足による失敗。原因としては次のようなことが考えられます。
<ul> <ul>

View File

@ -13,7 +13,7 @@
<div class="para func"> <div class="para func">
<h2>f_readdir</h2> <h2>f_readdir</h2>
<p>ディレクトリ項目を読み出します</p> <p>ディレクトリ項目を読み出します</p>
<pre> <pre>
FRESULT f_readdir ( FRESULT f_readdir (
DIR* <span class="arg">dp</span>, <span class="c">/* [IN] ディレクトリ・ブジェクト構造体へのポインタ */</span> DIR* <span class="arg">dp</span>, <span class="c">/* [IN] ディレクトリ・ブジェクト構造体へのポインタ */</span>
@ -49,8 +49,9 @@ FRESULT f_readdir (
<div class="para desc"> <div class="para desc">
<h4>解説</h4> <h4>解説</h4>
<p>ディレクトリの項目(ファイルとディレクトリ)を順次読み出します。この関数を繰り返し実行することによりそのディレクトリの全ての項目を読み出すことができます。全ての項目が読み出され、読み出す項目がもう無いときは、<tt>fname[]</tt>メンバにヌル文字列が返されます。ドット・エントリ("."、"..")は、相対パスが有効なとき(<tt>_FS_RPATH &gt;= 1</tt>)にのみ現れます。得られるファイル情報の詳細については <tt>FILINFO</tt>構造体を参照してください。<tt class="arg">fno</tt>にヌル・ポインタを指定すると、そのディレクトリのリード・インデックスを先頭に巻き戻します。</p> <p>ディレクトリの項目(ファイルとディレクトリ)を順次読み出します。この関数を繰り返し実行することによりそのディレクトリの全ての項目を読み出すことができます。得られるファイル情報の詳細については <tt>FILINFO</tt>構造体を参照してください。全ての項目が読み出され、読み出す項目がもう無いときは、<tt>fname[]</tt>メンバにヌル文字列が返されます。<tt class="arg">fno</tt>にヌル・ポインタを指定すると、そのディレクトリのリード・インデックスを先頭に巻き戻します。また、この関数は次に示すように関連する構成オプションにより動作が変わります。</p>
<p>LFN機能が有効な時は、<tt>f_readdir()</tt>関数の呼び出しに先立って<tt>FILINFO</tt>構造体の<tt>lfname</tt><tt>lfsize</tt>が有効な値で初期化されていなければなりません。<tt>lfname</tt>はLFNを格納するバッファで、<tt>lfsize</tt>はそのバッファの要素数です。LFNを読み出す必要がないときは、<tt>lfname</tt>にヌル・ポインタをセットしてください。次の条件に一つでも該当する場合は、LFN格納バッファにヌル文字列が返されます。</p> <p>ドット・エントリ("."、"..")は、相対パスが有効なとき(<tt>_FS_RPATH &gt;= 1</tt>)にのみ出力に現れます。</p>
<p>LFN機能が有効な時は、この関数の呼び出しに先立って<tt>FILINFO</tt>構造体の<tt>lfname</tt><tt>lfsize</tt>が有効な値で初期化されていなければなりません。<tt>lfname</tt>はLFNを格納するバッファで、<tt>lfsize</tt>はそのバッファの要素数です。LFNを読み出す必要がないときは、<tt>lfname</tt>にヌル・ポインタをセットしてください。次の条件に一つでも該当する場合は、LFN格納バッファにヌル文字列が返されます。</p>
<ul> <ul>
<li>ディレクトリ項目にLFN情報が存在しない。</li> <li>ディレクトリ項目にLFN情報が存在しない。</li>
<li>LFNの長さに対してLFN格納バッファまたはLFN操作バッファのサイズが不十分。</li> <li>LFNの長さに対してLFN格納バッファまたはLFN操作バッファのサイズが不十分。</li>

View File

@ -13,7 +13,7 @@
<div class="para func"> <div class="para func">
<h2>f_rename</h2> <h2>f_rename</h2>
<p>ファイルまたはサブ・ディレクトリの名前の変更または移動。</p> <p>ファイルまたはサブ・ディレクトリの名前の変更または移動します</p>
<pre> <pre>
FRESULT f_rename ( FRESULT f_rename (
const TCHAR* <span class="arg">old_name</span>, <span class="c">/* [IN] 古いオブジェクト名 */</span> const TCHAR* <span class="arg">old_name</span>, <span class="c">/* [IN] 古いオブジェクト名 */</span>

View File

@ -28,8 +28,8 @@
UINT lockid; <span class="c">/* ロックID */</span> UINT lockid; <span class="c">/* ロックID */</span>
<span class="k">#endif</span> <span class="k">#endif</span>
<span class="k">#if</span> _USE_LFN <span class="k">#if</span> _USE_LFN
WCHAR* lfn; <span class="c">/* LFNバッファへのポインタ */</span> WCHAR* lfn; <span class="c">/* LFNバッファへのポインタ (in/out) */</span>
WORD lfn_idx; <span class="c">/* 最後にマッチしたLFNエントリの先頭インデックス (0xFFFF:無効) */</span> WORD lfn_idx; <span class="c">/* LFNエントリの先頭インデックス (0xFFFF:無効) */</span>
<span class="k">#endif</span> <span class="k">#endif</span>
} DIR; } DIR;
</pre> </pre>

View File

@ -13,10 +13,10 @@
<div class="para func"> <div class="para func">
<h2>f_setlabel</h2> <h2>f_setlabel</h2>
<p>ボリューム・ラベルを書き込みます。</p> <p>ボリュームにボリューム・ラベルを設定します。</p>
<pre> <pre>
FRESULT f_setlabel ( FRESULT f_setlabel (
const TCHAR* <span class="arg">name</span> <span class="c">/* [IN] 設定するボリュームへのポインタ */</span> const TCHAR* <span class="arg">label</span> <span class="c">/* [IN] 設定するボリューム・ラベルへのポインタ */</span>
); );
</pre> </pre>
</div> </div>
@ -24,8 +24,8 @@ FRESULT f_setlabel (
<div class="para arg"> <div class="para arg">
<h4>引数</h4> <h4>引数</h4>
<dl class="par"> <dl class="par">
<dt>name</dt> <dt>label</dt>
<dd>設定するボリュームを示すヌル文字<tt>'\0'</tt>終端の文字列へのポインタを指定します。</dd> <dd>設定するボリューム・ラベルを示すヌル文字<tt>'\0'</tt>終端の文字列へのポインタを指定します。</dd>
</dl> </dl>
</div> </div>
@ -49,11 +49,11 @@ FRESULT f_setlabel (
<div class="para desc"> <div class="para desc">
<h4>解説</h4> <h4>解説</h4>
<p>文字列の先頭にドライブ番号を含む場合は、その論理ドライブに設定されます。含まない場合は、デフォルト・ドライブに設定されます。ボリューム名を削除するときは、ヌル文字列を指定します。名前のフォーマットは、短いファイル名とほぼ同じですが、次の点が異なります。</p> <p>文字列の先頭にドライブ番号を含む場合は、その論理ドライブに対して設定されます。含まない場合は、デフォルト・ドライブに設定されます。ボリューム・ラベルを削除するときは、ヌル文字列を指定します。ボリューム・ラベルのフォーマットは、ファイル名(SFN)とほぼ同じですが、次の点が異なります。</p>
<ul> <ul>
<li>ローカル・コード換算で11バイト以下</li> <li>ローカル文字コード換算で11バイト以下。LFN拡張は適用されません</li>
<li>ピリオドを含むことはできない。</li> <li>ピリオドを含むことはできない。</li>
<li>任意の位置にスペースを置くことができる。ただし、最後尾スペースは除去される。</li> <li>任意の位置にスペースを置くことができる。ただし、最後尾となるスペースは除去される。</li>
</ul> </ul>
</div> </div>
@ -66,13 +66,13 @@ FRESULT f_setlabel (
<div class="para use"> <div class="para use">
<h4>使用例</h4> <h4>使用例</h4>
<pre> <pre>
<span class="c">/* デフォルト・ドライブにボリュームを設定 */</span> <span class="c">/* デフォルト・ドライブにボリューム・ラベルを設定 */</span>
f_setlabel("DATA DISK"); f_setlabel("DATA DISK");
<span class="c">/* ドライブ2にボリュームを設定 */</span> <span class="c">/* ドライブ2にボリューム・ラベルを設定 */</span>
f_setlabel("2:DISK 3 OF 4"); f_setlabel("2:DISK 3 OF 4");
<span class="c">/* ドライブ2のボリュームを削除 */</span> <span class="c">/* ドライブ2のボリューム・ラベルを削除 */</span>
f_setlabel("2:"); f_setlabel("2:");
</pre> </pre>
</div> </div>

View File

@ -54,7 +54,7 @@ FRESULT f_stat (
<div class="para desc"> <div class="para desc">
<h4>‰ð<EFBFBD>à</h4> <h4>‰ð<EFBFBD>à</h4>
<p>指定されたファイルまたはサブ・ディレクトリの存在を調べます。存在しない場合は、<tt>FR_NO_FILE</tt>が帰ります。存在する場合は<tt>FR_OK</tt>が帰り、ファイル情報構造体にそれ関する情報(サイズ、タイムスタンプおよび属性)がストアされます。</p> <p>指定されたファイルまたはサブ・ディレクトリの存在を調べます。存在しない場合は、<tt>FR_NO_FILE</tt>が帰ります。存在する場合は<tt>FR_OK</tt>が帰り、ファイル情報構造体にそれ関する情報(サイズ、タイムスタンプ、属性および短いファイル名)がストアされます。</p>
</div> </div>

View File

@ -46,7 +46,7 @@ FRESULT f_sync (
<div class="para desc"> <div class="para desc">
<h4>解説</h4> <h4>解説</h4>
<p>この関数は<tt>f_close()</tt>と同じ処理を実行しますが、ファイルは引き続き開かれたままになり、読み書きを続行できます。ロギングなど、書き込みモードで長時間ファイルが開かれているアプリケーションにおいて、定期的または区切りの良いところでこの関数を使用することにより、不意の電源断やメディアの取り外しにより失われるデータを最小にすることができます。この背景については、<a href="appnote.html#critical">アプリケーション・ノート</a>も参照してください。</p> <p>この関数は<tt>f_close()</tt>と同じ処理を実行しますが、ファイルは引き続き開かれたままになり、読み書きを続行できます。ロギングなど、書き込みモードで長時間ファイルが開かれているアプリケーションにおいて、定期的または区切りの良いところでこの関数を使用することにより、不意の電源断やメディアの取り外しにより失われるデータを最小にすることができます。この背景については、<a href="appnote.html#critical">アプリケーション・ノート</a>も参照してください。</p>
<p>実際のところ、<tt>f_close()</tt>内ではこの関数を呼び出した後ファイル・オブジェクトを無効化しているだけなので、<tt>f_close()</tt>直前<tt>f_sync()</tt>は意味がありません</p> <p>実際のところ、<tt>f_close()</tt>内ではこの関数を呼び出した後ファイル・オブジェクトを無効化しているだけなので、<tt>f_close()</tt>直前<tt>f_sync()</tt>を置くことは無意味です</p>
</div> </div>

View File

@ -54,11 +54,11 @@ FRESULT f_unlink (
<div class="para desc"> <div class="para desc">
<h4>‰ð<EFBFBD>à</h4> <h4>‰ð<EFBFBD>à</h4>
<p>削除対象のオブジェクトが次の条件に当てはまる場合、そのアクセスは拒否(<tt>FR_DENIED</tt>または<tt>FR_LOCKED</tt>)され関数は失敗します。 <p>削除対象のオブジェクトが次の条件に当てはまる場合、そのアクセスは拒否され関数は失敗します。
<ul> <ul>
<li>リード・オンリー属性(<tt>AM_RDO</tt>)を持っている。</li> <li>リード・オンリー属性(<tt>AM_RDO</tt>)を持っている場合は、拒否(<tt>FR_DENIED</tt>)される</li>
<li>空でないサブ・ディレクトリまたはカレント・ディレクトリである。</li> <li>空でないサブ・ディレクトリまたはカレント・ディレクトリである場合は、拒否(<tt>FR_DENIED</tt>)される</li>
<li>開かれているファイルまたはサブ・ディレクトリである<a href="appnote.html#dup">多重アクセス制御</a>が有効なときは安全に拒否されますが、そうでないときは不正な操作となり、<em>FAT構造が破壊される可能性</em>があります。</li> <li>開かれているファイルまたはサブ・ディレクトリである場合は、<a href="appnote.html#dup">多重アクセス制御</a>が有効なら安全に拒否(<tt>FR_LOCKED</tt>)されますが、そうでないときは不正な操作となり、<em>FAT構造が破壊される可能性</em>があります。</li>
</ul> </ul>
</p> </p>
</div> </div>

View File

@ -1,33 +1,37 @@
R0.10a, Jan 15,'14 R0.10b, May 19, 2014
Added arbitrary strings as drive number in the path name. (_STR_VOLUME_ID) Fixed a hard error in the disk I/O layer can collapse the directory entry.
Added a configuration option of minimum sector size. (_MIN_SS) Fixed LFN entry is not deleted on delete/rename an object with its lossy converted SFN.
2nd argument of f_rename() can have a drive number and it will be ignored.
Fixed f_mount() with forced mount fails when drive number is >= 1.
Fixed f_close() invalidates the file object without volume lock.
Fixed f_closedir() returns but the volume lock is left acquired.
Fixed creation of an entry with LFN fails on too many SFN collisions.
R0.10, Oct 02,'13 R0.10a, Jan 15, 2014
Added selection of character encoding on the file. (_STRF_ENCODE) Added arbitrary strings as drive number in the path name. (_STR_VOLUME_ID)
Added an option for minimum sector size. (_MIN_SS)
2nd argument of f_rename() can have a drive number and it will be ignored.
Fixed f_mount() with forced mount fails when drive number is larger than 0.
Fixed f_close() invalidates the file object without volume lock.
Fixed volume lock is left acquired after return from f_closedir().
Fixed creation of a directory entry with LFN fails on too many SFN collisions.
R0.10, Oct 02, 2013
Added an option for character encoding on the file. (_STRF_ENCODE)
Added f_closedir(). Added f_closedir().
Added forced full FAT scan for f_getfree(). (_FS_NOFSINFO) Added forced full FAT scan option for f_getfree(). (_FS_NOFSINFO)
Added forced mount feature with changes of f_mount(). Added forced mount feature with changes of f_mount().
Improved behavior of volume auto detection. Improved behavior of volume auto detection.
Improved write throughput of f_puts() and f_printf(). Improved write throughput of f_puts() and f_printf().
Changed argument of f_chdrive(), f_mkfs(), disk_read() and disk_write(). 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_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 result code on error.
R0.09b, Jan 24, 2013 R0.09b, Jan 24, 2013
Added f_getlabel() and f_setlabel(). (_USE_LABEL = 1) Added f_getlabel() and f_setlabel(). (_USE_LABEL = 1)
R0.09a, Aug 27, 2012 R0.09a, Aug 27, 2012
Fixed assertion failure due to OS/2 EA on FAT12/16. Fixed assertion failure due to OS/2 EA on FAT12/16 volume.
Changed API rejects null object pointer to avoid crash. Changed file functions reject null object pointer to avoid crash.
Changed option name _FS_SHARE to _FS_LOCK. Changed option name _FS_SHARE to _FS_LOCK.
R0.09, Sep 06, 2011 R0.09, Sep 06, 2011
f_mkfs() supports multiple partition to finish the multiple partition feature. f_mkfs() supports multiple partition to complete the multiple partition feature.
Added f_fdisk(). (_MULTI_PARTITION = 2) Added f_fdisk(). (_MULTI_PARTITION = 2)
R0.08b, Jan 15, 2011 R0.08b, Jan 15, 2011

View File

@ -1,4 +1,4 @@
FatFs Module Source Files R0.10a (C)ChaN, 2014 FatFs Module Source Files R0.10b (C)ChaN, 2014
FILES FILES
@ -153,3 +153,6 @@ REVISION HISTORY
Fixed f_close() invalidates the file object without volume lock. Fixed f_close() invalidates the file object without volume lock.
Fixed f_closedir() returns but the volume lock is left acquired. Fixed f_closedir() returns but the volume lock is left acquired.
Fixed creation of an entry with LFN fails on too many SFN collisions. Fixed creation of an entry with LFN fails on too many SFN collisions.
Mar 19,'14 R0.10b Fixed a hard error in the disk I/O layer can collapse the directory entry.
Fixed LFN entry is not deleted on delete/rename an object with lossy converted SFN.

View File

@ -1,10 +1,10 @@
/*-----------------------------------------------------------------------*/ /*-----------------------------------------------------------------------*/
/* Low level disk I/O module skeleton for FatFs (C)ChaN, 2013 */ /* Low level disk I/O module skeleton for FatFs (C)ChaN, 2014 */
/*-----------------------------------------------------------------------*/ /*-----------------------------------------------------------------------*/
/* If a working storage control module is available, it should be */ /* If a working storage control module is available, it should be */
/* attached to the FatFs via a glue function rather than modifying it. */ /* attached to the FatFs via a glue function rather than modifying it. */
/* This is an example of glue functions to attach various exsisting */ /* This is an example of glue functions to attach various exsisting */
/* storage control module to the FatFs module with a defined API. */ /* storage control modules to the FatFs module with a defined API. */
/*-----------------------------------------------------------------------*/ /*-----------------------------------------------------------------------*/
#include "diskio.h" /* FatFs lower layer API */ #include "diskio.h" /* FatFs lower layer API */
@ -12,56 +12,18 @@
#include "atadrive.h" /* Example: ATA drive control */ #include "atadrive.h" /* Example: ATA drive control */
#include "sdcard.h" /* Example: MMC/SDC contorl */ #include "sdcard.h" /* Example: MMC/SDC contorl */
/* Definitions of physical drive number for each media */ /* Definitions of physical drive number for each drive */
#define ATA 0 #define ATA 0 /* Example: Map ATA drive to drive number 0 */
#define MMC 1 #define MMC 1 /* Example: Map MMC/SD card to drive number 1 */
#define USB 2 #define USB 2 /* Example: Map USB drive to drive number 2 */
/*-----------------------------------------------------------------------*/ /*-----------------------------------------------------------------------*/
/* Inidialize a Drive */ /* Get Drive Status */
/*-----------------------------------------------------------------------*/
DSTATUS disk_initialize (
BYTE pdrv /* Physical drive nmuber (0..) */
)
{
DSTATUS stat;
int result;
switch (pdrv) {
case ATA :
result = ATA_disk_initialize();
// translate the reslut code here
return stat;
case MMC :
result = MMC_disk_initialize();
// translate the reslut code here
return stat;
case USB :
result = USB_disk_initialize();
// translate the reslut code here
return stat;
}
return STA_NOINIT;
}
/*-----------------------------------------------------------------------*/
/* Get Disk Status */
/*-----------------------------------------------------------------------*/ /*-----------------------------------------------------------------------*/
DSTATUS disk_status ( DSTATUS disk_status (
BYTE pdrv /* Physical drive nmuber (0..) */ BYTE pdrv /* Physical drive nmuber to identify the drive */
) )
{ {
DSTATUS stat; DSTATUS stat;
@ -94,15 +56,53 @@ DSTATUS disk_status (
/*-----------------------------------------------------------------------*/
/* Inidialize a Drive */
/*-----------------------------------------------------------------------*/
DSTATUS disk_initialize (
BYTE pdrv /* Physical drive nmuber to identify the drive */
)
{
DSTATUS stat;
int result;
switch (pdrv) {
case ATA :
result = ATA_disk_initialize();
// translate the reslut code here
return stat;
case MMC :
result = MMC_disk_initialize();
// translate the reslut code here
return stat;
case USB :
result = USB_disk_initialize();
// translate the reslut code here
return stat;
}
return STA_NOINIT;
}
/*-----------------------------------------------------------------------*/ /*-----------------------------------------------------------------------*/
/* Read Sector(s) */ /* Read Sector(s) */
/*-----------------------------------------------------------------------*/ /*-----------------------------------------------------------------------*/
DRESULT disk_read ( DRESULT disk_read (
BYTE pdrv, /* Physical drive nmuber (0..) */ BYTE pdrv, /* Physical drive nmuber to identify the drive */
BYTE *buff, /* Data buffer to store read data */ BYTE *buff, /* Data buffer to store read data */
DWORD sector, /* Sector address (LBA) */ DWORD sector, /* Sector address in LBA */
UINT count /* Number of sectors to read (1..128) */ UINT count /* Number of sectors to read */
) )
{ {
DRESULT res; DRESULT res;
@ -136,6 +136,7 @@ DRESULT disk_read (
return res; return res;
} }
return RES_PARERR; return RES_PARERR;
} }
@ -147,10 +148,10 @@ DRESULT disk_read (
#if _USE_WRITE #if _USE_WRITE
DRESULT disk_write ( DRESULT disk_write (
BYTE pdrv, /* Physical drive nmuber (0..) */ BYTE pdrv, /* Physical drive nmuber to identify the drive */
const BYTE *buff, /* Data to be written */ const BYTE *buff, /* Data to be written */
DWORD sector, /* Sector address (LBA) */ DWORD sector, /* Sector address in LBA */
UINT count /* Number of sectors to write (1..128) */ UINT count /* Number of sectors to write */
) )
{ {
DRESULT res; DRESULT res;
@ -184,6 +185,7 @@ DRESULT disk_write (
return res; return res;
} }
return RES_PARERR; return RES_PARERR;
} }
#endif #endif
@ -205,32 +207,24 @@ DRESULT disk_ioctl (
switch (pdrv) { switch (pdrv) {
case ATA : case ATA :
// pre-process here
result = ATA_disk_ioctl(cmd, buff); // Process of the command for the ATA drive
// post-process here
return res; return res;
case MMC : case MMC :
// pre-process here
result = MMC_disk_ioctl(cmd, buff); // Process of the command for the MMC/SD card
// post-process here
return res; return res;
case USB : case USB :
// pre-process here
result = USB_disk_ioctl(cmd, buff); // Process of the command the USB drive
// post-process here
return res; return res;
} }
return RES_PARERR; return RES_PARERR;
} }
#endif #endif

View File

@ -1,5 +1,5 @@
/*----------------------------------------------------------------------------/ /*----------------------------------------------------------------------------/
/ FatFs - FAT file system module R0.10a (C)ChaN, 2014 / FatFs - FAT file system module R0.10b (C)ChaN, 2014
/-----------------------------------------------------------------------------/ /-----------------------------------------------------------------------------/
/ FatFs module is a generic FAT file system module for small embedded systems. / FatFs module is a generic FAT file system module for small embedded systems.
/ This is a free software that opened for education, research and commercial / This is a free software that opened for education, research and commercial
@ -111,6 +111,8 @@
/ Fixed f_close() invalidates the file object without volume lock. / Fixed f_close() invalidates the file object without volume lock.
/ Fixed f_closedir() returns but the volume lock is left acquired. / Fixed f_closedir() returns but the volume lock is left acquired.
/ Fixed creation of an entry with LFN fails on too many SFN collisions. / Fixed creation of an entry with LFN fails on too many SFN collisions.
/ May 19,'14 R0.10b Fixed a hard error in the disk I/O layer can collapse the directory entry.
/ Fixed LFN entry is not deleted on delete/rename an object with lossy converted SFN.
/---------------------------------------------------------------------------*/ /---------------------------------------------------------------------------*/
#include "ff.h" /* Declarations of FatFs API */ #include "ff.h" /* Declarations of FatFs API */
@ -125,7 +127,7 @@
---------------------------------------------------------------------------*/ ---------------------------------------------------------------------------*/
#if _FATFS != 29000 /* Revision ID */ #if _FATFS != 8051 /* Revision ID */
#error Wrong include file (ff.h). #error Wrong include file (ff.h).
#endif #endif
@ -150,7 +152,7 @@
#error Wrong sector size configuration. #error Wrong sector size configuration.
#endif #endif
#if _MAX_SS == _MIN_SS #if _MAX_SS == _MIN_SS
#define SS(fs) ((UINT)_MIN_SS) /* Fixed sector size */ #define SS(fs) ((UINT)_MAX_SS) /* Fixed sector size */
#else #else
#define SS(fs) ((fs)->ssize) /* Variable sector size */ #define SS(fs) ((fs)->ssize) /* Variable sector size */
#endif #endif
@ -163,7 +165,7 @@
#endif #endif
typedef struct { typedef struct {
FATFS *fs; /* Object ID 1, volume (NULL:blank entry) */ FATFS *fs; /* Object ID 1, volume (NULL:blank entry) */
DWORD clu; /* Object ID 2, directory */ DWORD clu; /* Object ID 2, directory (0:root) */
WORD idx; /* Object ID 3, directory index */ WORD idx; /* Object ID 3, directory index */
WORD ctr; /* Object open counter, 0:none, 0x01..0xFF:read mode open count, 0x100:write mode */ WORD ctr; /* Object open counter, 0:none, 0x01..0xFF:read mode open count, 0x100:write mode */
} FILESEM; } FILESEM;
@ -450,7 +452,7 @@ typedef struct {
#define FSI_Nxt_Free 492 /* FSI: Last allocated cluster (4) */ #define FSI_Nxt_Free 492 /* FSI: Last allocated cluster (4) */
#define MBR_Table 446 /* MBR: Partition table offset (2) */ #define MBR_Table 446 /* MBR: Partition table offset (2) */
#define SZ_PTE 16 /* MBR: Size of a partition table entry */ #define SZ_PTE 16 /* MBR: Size of a partition table entry */
#define BS_55AA 510 /* Boot sector signature (2) */ #define BS_55AA 510 /* Signature word (2) */
#define DIR_Name 0 /* Short file name (11) */ #define DIR_Name 0 /* Short file name (11) */
#define DIR_Attr 11 /* Attribute (1) */ #define DIR_Attr 11 /* Attribute (1) */
@ -482,7 +484,7 @@ typedef struct {
/*------------------------------------------------------------*/ /*------------------------------------------------------------*/
/* Note that uninitialized variables with static duration are /* Note that uninitialized variables with static duration are
/ guaranteed zero/null as initial value. If not, either the / guaranteed zero/null as initial value. If not, either the
/ compiler or start-up routine is out of ANSI-C standard. / linker or start-up routine is out of ANSI-C standard.
*/ */
#if _VOLUMES >= 1 || _VOLUMES <= 10 #if _VOLUMES >= 1 || _VOLUMES <= 10
@ -641,7 +643,7 @@ void unlock_fs (
static static
FRESULT chk_lock ( /* Check if the file can be accessed */ FRESULT chk_lock ( /* Check if the file can be accessed */
DIR* dp, /* Directory object pointing the file to be checked */ DIR* dp, /* Directory object pointing the file to be checked */
int acc /* Desired access (0:Read, 1:Write, 2:Delete/Rename) */ int acc /* Desired access type (0:Read, 1:Write, 2:Delete/Rename) */
) )
{ {
UINT i, be; UINT i, be;
@ -1499,7 +1501,7 @@ FRESULT dir_find (
if (res != FR_OK) return res; if (res != FR_OK) return res;
#if _USE_LFN #if _USE_LFN
ord = sum = 0xFF; ord = sum = 0xFF; dp->lfn_idx = 0xFFFF; /* Reset LFN sequence */
#endif #endif
do { do {
res = move_window(dp->fs, dp->sect); res = move_window(dp->fs, dp->sect);
@ -1510,22 +1512,22 @@ FRESULT dir_find (
#if _USE_LFN /* LFN configuration */ #if _USE_LFN /* LFN configuration */
a = dir[DIR_Attr] & AM_MASK; a = dir[DIR_Attr] & AM_MASK;
if (c == DDE || ((a & AM_VOL) && a != AM_LFN)) { /* An entry without valid data */ if (c == DDE || ((a & AM_VOL) && a != AM_LFN)) { /* An entry without valid data */
ord = 0xFF; ord = 0xFF; dp->lfn_idx = 0xFFFF; /* Reset LFN sequence */
} else { } else {
if (a == AM_LFN) { /* An LFN entry is found */ if (a == AM_LFN) { /* An LFN entry is found */
if (dp->lfn) { if (dp->lfn) {
if (c & LLE) { /* Is it start of LFN sequence? */ if (c & LLE) { /* Is it start of LFN sequence? */
sum = dir[LDIR_Chksum]; sum = dir[LDIR_Chksum];
c &= ~LLE; ord = c; /* LFN start order */ c &= ~LLE; ord = c; /* LFN start order */
dp->lfn_idx = dp->index; dp->lfn_idx = dp->index; /* Start index of LFN */
} }
/* Check validity of the LFN entry and compare it with given name */ /* Check validity of the LFN entry and compare it with given name */
ord = (c == ord && sum == dir[LDIR_Chksum] && cmp_lfn(dp->lfn, dir)) ? ord - 1 : 0xFF; ord = (c == ord && sum == dir[LDIR_Chksum] && cmp_lfn(dp->lfn, dir)) ? ord - 1 : 0xFF;
} }
} else { /* An SFN entry is found */ } else { /* An SFN entry is found */
if (!ord && sum == sum_sfn(dir)) break; /* LFN matched? */ if (!ord && sum == sum_sfn(dir)) break; /* LFN matched? */
ord = 0xFF; dp->lfn_idx = 0xFFFF; /* Reset LFN sequence */
if (!(dp->fn[NS] & NS_LOSS) && !mem_cmp(dir, dp->fn, 11)) break; /* SFN matched? */ if (!(dp->fn[NS] & NS_LOSS) && !mem_cmp(dir, dp->fn, 11)) break; /* SFN matched? */
ord = 0xFF; dp->lfn_idx = 0xFFFF; /* Reset LFN sequence */
} }
} }
#else /* Non LFN configuration */ #else /* Non LFN configuration */
@ -2678,7 +2680,7 @@ FRESULT f_write (
if (fp->fptr == 0) { /* On the top of the file? */ if (fp->fptr == 0) { /* On the top of the file? */
clst = fp->sclust; /* Follow from the origin */ clst = fp->sclust; /* Follow from the origin */
if (clst == 0) /* When no cluster is allocated, */ if (clst == 0) /* When no cluster is allocated, */
fp->sclust = clst = create_chain(fp->fs, 0); /* Create a new cluster chain */ clst = create_chain(fp->fs, 0); /* Create a new cluster chain */
} else { /* Middle or end of the file */ } else { /* Middle or end of the file */
#if _USE_FASTSEEK #if _USE_FASTSEEK
if (fp->cltbl) if (fp->cltbl)
@ -2691,6 +2693,7 @@ FRESULT f_write (
if (clst == 1) ABORT(fp->fs, FR_INT_ERR); if (clst == 1) ABORT(fp->fs, FR_INT_ERR);
if (clst == 0xFFFFFFFF) ABORT(fp->fs, FR_DISK_ERR); if (clst == 0xFFFFFFFF) ABORT(fp->fs, FR_DISK_ERR);
fp->clust = clst; /* Update current cluster */ fp->clust = clst; /* Update current cluster */
if (fp->sclust == 0) fp->sclust = clst; /* Set start cluster if the first write */
} }
#if _FS_TINY #if _FS_TINY
if (fp->fs->winsect == fp->dsect && sync_window(fp->fs)) /* Write-back sector cache */ if (fp->fs->winsect == fp->dsect && sync_window(fp->fs)) /* Write-back sector cache */
@ -3750,7 +3753,7 @@ FRESULT f_rename (
FRESULT f_getlabel ( FRESULT f_getlabel (
const TCHAR* path, /* Path name of the logical drive number */ const TCHAR* path, /* Path name of the logical drive number */
TCHAR* label, /* Pointer to a buffer to return the volume label */ TCHAR* label, /* Pointer to a buffer to return the volume label */
DWORD* sn /* Pointer to a variable to return the volume serial number */ DWORD* vsn /* Pointer to a variable to return the volume serial number */
) )
{ {
FRESULT res; FRESULT res;
@ -3794,11 +3797,11 @@ FRESULT f_getlabel (
} }
/* Get volume serial number */ /* Get volume serial number */
if (res == FR_OK && sn) { if (res == FR_OK && vsn) {
res = move_window(dj.fs, dj.fs->volbase); res = move_window(dj.fs, dj.fs->volbase);
if (res == FR_OK) { if (res == FR_OK) {
i = dj.fs->fs_type == FS_FAT32 ? BS_VolID32 : BS_VolID; i = dj.fs->fs_type == FS_FAT32 ? BS_VolID32 : BS_VolID;
*sn = LD_DWORD(&dj.fs->win[i]); *vsn = LD_DWORD(&dj.fs->win[i]);
} }
} }

View File

@ -1,5 +1,5 @@
/*---------------------------------------------------------------------------/ /*---------------------------------------------------------------------------/
/ FatFs - FAT file system module include file R0.10a (C)ChaN, 2014 / FatFs - FAT file system module include file R0.10b (C)ChaN, 2014
/----------------------------------------------------------------------------/ /----------------------------------------------------------------------------/
/ FatFs module is a generic FAT file system module for small embedded systems. / FatFs module is a generic FAT file system module for small embedded systems.
/ This is a free software that opened for education, research and commercial / This is a free software that opened for education, research and commercial
@ -15,7 +15,7 @@
/----------------------------------------------------------------------------*/ /----------------------------------------------------------------------------*/
#ifndef _FATFS #ifndef _FATFS
#define _FATFS 29000 /* Revision ID */ #define _FATFS 8051 /* Revision ID */
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
@ -53,7 +53,7 @@ extern PARTITION VolToPart[]; /* Volume - Partition resolution table */
#if _LFN_UNICODE /* Unicode string */ #if _LFN_UNICODE /* Unicode string */
#if !_USE_LFN #if !_USE_LFN
#error _LFN_UNICODE must be 0 in non-LFN cfg. #error _LFN_UNICODE must be 0 at non-LFN cfg.
#endif #endif
#ifndef _INC_TCHAR #ifndef _INC_TCHAR
typedef WCHAR TCHAR; typedef WCHAR TCHAR;
@ -96,7 +96,7 @@ typedef struct {
#if _FS_RPATH #if _FS_RPATH
DWORD cdir; /* Current directory start cluster (0:root) */ DWORD cdir; /* Current directory start cluster (0:root) */
#endif #endif
DWORD n_fatent; /* Number of FAT entries (= number of clusters + 2) */ DWORD n_fatent; /* Number of FAT entries, = number of clusters + 2 */
DWORD fsize; /* Sectors per FAT */ DWORD fsize; /* Sectors per FAT */
DWORD volbase; /* Volume start sector */ DWORD volbase; /* Volume start sector */
DWORD fatbase; /* FAT start sector */ DWORD fatbase; /* FAT start sector */
@ -113,25 +113,25 @@ typedef struct {
typedef struct { typedef struct {
FATFS* fs; /* Pointer to the related file system object (**do not change order**) */ FATFS* fs; /* Pointer to the related file system object (**do not change order**) */
WORD id; /* Owner file system mount ID (**do not change order**) */ WORD id; /* Owner file system mount ID (**do not change order**) */
BYTE flag; /* File status flags */ BYTE flag; /* Status flags */
BYTE err; /* Abort flag (error code) */ BYTE err; /* Abort flag (error code) */
DWORD fptr; /* File read/write pointer (Zeroed on file open) */ DWORD fptr; /* File read/write pointer (Zeroed on file open) */
DWORD fsize; /* File size */ DWORD fsize; /* File size */
DWORD sclust; /* File data start cluster (0:no data cluster, always 0 when fsize is 0) */ DWORD sclust; /* File start cluster (0:no cluster chain, always 0 when fsize is 0) */
DWORD clust; /* Current cluster of fpter */ DWORD clust; /* Current cluster of fpter (not valid when fprt is 0) */
DWORD dsect; /* Current data sector of fpter */ DWORD dsect; /* Sector number appearing in buf[] (0:invalid) */
#if !_FS_READONLY #if !_FS_READONLY
DWORD dir_sect; /* Sector containing the directory entry */ DWORD dir_sect; /* Sector number containing the directory entry */
BYTE* dir_ptr; /* Pointer to the directory entry in the window */ BYTE* dir_ptr; /* Pointer to the directory entry in the win[] */
#endif #endif
#if _USE_FASTSEEK #if _USE_FASTSEEK
DWORD* cltbl; /* Pointer to the cluster link map table (Nulled on file open) */ DWORD* cltbl; /* Pointer to the cluster link map table (Nulled on file open) */
#endif #endif
#if _FS_LOCK #if _FS_LOCK
UINT lockid; /* File lock ID (index of file semaphore table Files[]) */ UINT lockid; /* File lock ID origin from 1 (index of file semaphore table Files[]) */
#endif #endif
#if !_FS_TINY #if !_FS_TINY
BYTE buf[_MAX_SS]; /* File data read/write buffer */ BYTE buf[_MAX_SS]; /* File private data read/write window */
#endif #endif
} FIL; } FIL;
@ -226,7 +226,7 @@ FRESULT f_chdir (const TCHAR* path); /* Change current directory */
FRESULT f_chdrive (const TCHAR* path); /* Change current drive */ FRESULT f_chdrive (const TCHAR* path); /* Change current drive */
FRESULT f_getcwd (TCHAR* buff, UINT len); /* Get current directory */ 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_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* sn); /* Get volume label */ FRESULT f_getlabel (const TCHAR* path, TCHAR* label, DWORD* vsn); /* Get volume label */
FRESULT f_setlabel (const TCHAR* label); /* Set volume label */ FRESULT f_setlabel (const TCHAR* label); /* Set volume label */
FRESULT f_mount (FATFS* fs, const TCHAR* path, BYTE opt); /* Mount/Unmount a logical drive */ 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_mkfs (const TCHAR* path, BYTE sfd, UINT au); /* Create a file system on the volume */

View File

@ -1,9 +1,9 @@
/*---------------------------------------------------------------------------/ /*---------------------------------------------------------------------------/
/ FatFs - FAT file system module configuration file R0.10a (C)ChaN, 2014 / FatFs - FAT file system module configuration file R0.10b (C)ChaN, 2014
/---------------------------------------------------------------------------*/ /---------------------------------------------------------------------------*/
#ifndef _FFCONF #ifndef _FFCONF
#define _FFCONF 29000 /* Revision ID */ #define _FFCONF 8051 /* Revision ID */
/*---------------------------------------------------------------------------/ /*---------------------------------------------------------------------------/
@ -61,7 +61,7 @@
/* The _CODE_PAGE specifies the OEM code page to be used on the target system. /* The _CODE_PAGE specifies the OEM code page to be used on the target system.
/ Incorrect setting of the code page can cause a file open failure. / Incorrect setting of the code page can cause a file open failure.
/ /
/ 932 - Japanese Shift-JIS (DBCS, OEM, Windows) / 932 - Japanese Shift_JIS (DBCS, OEM, Windows)
/ 936 - Simplified Chinese GBK (DBCS, OEM, Windows) / 936 - Simplified Chinese GBK (DBCS, OEM, Windows)
/ 949 - Korean (DBCS, OEM, Windows) / 949 - Korean (DBCS, OEM, Windows)
/ 950 - Traditional Chinese Big5 (DBCS, OEM, Windows) / 950 - Traditional Chinese Big5 (DBCS, OEM, Windows)
@ -86,14 +86,14 @@
/ 857 - Turkish (OEM) / 857 - Turkish (OEM)
/ 862 - Hebrew (OEM) / 862 - Hebrew (OEM)
/ 874 - Thai (OEM, Windows) / 874 - Thai (OEM, Windows)
/ 1 - ASCII (Valid for only non-LFN cfg.) */ / 1 - ASCII (Valid for only non-LFN configuration) */
#define _USE_LFN 0 /* 0 to 3 */ #define _USE_LFN 0 /* 0 to 3 */
#define _MAX_LFN 255 /* Maximum LFN length to handle (12 to 255) */ #define _MAX_LFN 255 /* Maximum LFN length to handle (12 to 255) */
/* The _USE_LFN option switches the LFN feature. /* The _USE_LFN option switches the LFN feature.
/ /
/ 0: Disable LFN feature. _MAX_LFN and _LFN_UNICODE have no effect. / 0: Disable LFN feature. _MAX_LFN has no effect.
/ 1: Enable LFN with static working buffer on the BSS. Always NOT thread-safe. / 1: Enable LFN with static working buffer on the BSS. Always NOT thread-safe.
/ 2: Enable LFN with dynamic working buffer on the STACK. / 2: Enable LFN with dynamic working buffer on the STACK.
/ 3: Enable LFN with dynamic working buffer on the HEAP. / 3: Enable LFN with dynamic working buffer on the HEAP.
@ -109,13 +109,14 @@
#define _LFN_UNICODE 0 /* 0:ANSI/OEM or 1:Unicode */ #define _LFN_UNICODE 0 /* 0:ANSI/OEM or 1:Unicode */
/* To switch the character encoding on the FatFs API (TCHAR) to Unicode, enable LFN /* To switch the character encoding on the FatFs API (TCHAR) to Unicode, enable LFN
/ feature and set _LFN_UNICODE to 1. This option affects behavior of string I/O / feature and set _LFN_UNICODE to 1. This option affects behavior of string I/O
/ functions. */ / functions. This option must be 0 when LFN feature is not enabled. */
#define _STRF_ENCODE 3 /* 0:ANSI/OEM, 1:UTF-16LE, 2:UTF-16BE, 3:UTF-8 */ #define _STRF_ENCODE 3 /* 0:ANSI/OEM, 1:UTF-16LE, 2:UTF-16BE, 3:UTF-8 */
/* When Unicode API is enabled by _LFN_UNICODE option, this option selects the character /* When Unicode API is enabled by _LFN_UNICODE option, this option selects the character
/ encoding on the file to be read/written via string I/O functions, f_gets(), f_putc(), / encoding on the file to be read/written via string I/O functions, f_gets(), f_putc(),
/ f_puts and f_printf(). This option has no effect when Unicode API is not enabled. */ / f_puts and f_printf(). This option has no effect when _LFN_UNICODE == 0. Note that
/ FatFs supports only BMP. */
#define _FS_RPATH 0 /* 0 to 2 */ #define _FS_RPATH 0 /* 0 to 2 */
@ -138,10 +139,10 @@
#define _STR_VOLUME_ID 0 /* 0:Use only 0-9 for drive ID, 1:Use strings for drive ID */ #define _STR_VOLUME_ID 0 /* 0:Use only 0-9 for drive ID, 1:Use strings for drive ID */
#define _VOLUME_STRS "RAM","NAND","CF","SD1","SD2","USB1","USB2","USB3" #define _VOLUME_STRS "RAM","NAND","CF","SD1","SD2","USB1","USB2","USB3"
/* When _STR_VOLUME_ID is set to 1, also pre-defined string can be used as drive number /* When _STR_VOLUME_ID is set to 1, also pre-defined strings can be used as drive
/ in the path name. _VOLUME_STRS defines the drive ID strings for each logical drives. / number in the path name. _VOLUME_STRS defines the drive ID strings for each logical
/ Number of items must be equal to _VOLUMES. Valid characters for the drive ID strings / drives. Number of items must be equal to _VOLUMES. Valid characters for the drive ID
/ are: 0-9 and A-Z. */ / strings are: 0-9 and A-Z. */
#define _MULTI_PARTITION 0 /* 0:Single partition, 1:Enable multiple partition */ #define _MULTI_PARTITION 0 /* 0:Single partition, 1:Enable multiple partition */
@ -153,10 +154,10 @@
#define _MIN_SS 512 #define _MIN_SS 512
#define _MAX_SS 512 #define _MAX_SS 512
/* These options configure the sector size to be supported. (512, 1024, 2048 or 4096) /* These options configure the range of sector size to be supported. (512, 1024, 2048 or
/ Always set both 512 for most systems, all memory card and hard disk. But a larger / 4096) Always set both 512 for most systems, all memory card and harddisk. But a larger
/ value may be required for on-board flash memory and some type of optical media. / value may be required for on-board flash memory and some type of optical media.
/ When _MIN_SS != _MAX_SS, FatFs is configured to multiple sector size and / When _MAX_SS is larger than _MIN_SS, FatFs is configured to variable sector size and
/ GET_SECTOR_SIZE command must be implemented to the disk_ioctl() function. */ / GET_SECTOR_SIZE command must be implemented to the disk_ioctl() function. */
@ -166,9 +167,9 @@
#define _FS_NOFSINFO 0 /* 0 to 3 */ #define _FS_NOFSINFO 0 /* 0 to 3 */
/* If you need to know correct free space on the FAT32 volume, set bit 0 of this /* If you need to know correct free space on the FAT32 volume, set bit 0 of this option
/ option and f_getfree() function at first time after volume mount will force / and f_getfree() function at first time after volume mount will force a full FAT scan.
/ a full FAT scan. Bit 1 controls the last allocated cluster number as bit 0. / Bit 1 controls the last allocated cluster number as bit 0.
/ /
/ bit0=0: Use free cluster count in the FSINFO if available. / bit0=0: Use free cluster count in the FSINFO if available.
/ bit0=1: Do not trust free cluster count in the FSINFO. / bit0=1: Do not trust free cluster count in the FSINFO.
@ -182,35 +183,16 @@
/ System Configurations / System Configurations
/---------------------------------------------------------------------------*/ /---------------------------------------------------------------------------*/
#define _WORD_ACCESS 0 /* 0 or 1 */
/* The _WORD_ACCESS option is an only platform dependent option. It defines
/ which access method is used to the word data on the FAT volume.
/
/ 0: Byte-by-byte access. Always compatible with all platforms.
/ 1: Word access. Do not choose this unless under both the following conditions.
/
/ * Address misaligned memory access is always allowed for all instructions.
/ * Byte order on the memory is little-endian.
/
/ If it is the case, _WORD_ACCESS can also be set to 1 to improve performance
/ and reduce code size.
*/
#define _FS_LOCK 0 /* 0:Disable or >=1:Enable */ #define _FS_LOCK 0 /* 0:Disable or >=1:Enable */
/* To enable file lock control feature, set _FS_LOCK to 1 or greater. /* To enable file lock control feature, set _FS_LOCK to non-zero value.
/ The value defines how many files/sub-directories can be opened simultaneously. / The value defines how many files/sub-directories can be opened simultaneously
/ This feature consumes _FS_LOCK * 12 bytes of bss area. */ / with file lock control. This feature uses bss _FS_LOCK * 12 bytes. */
#define _FS_REENTRANT 0 /* 0:Disable or 1:Enable */ #define _FS_REENTRANT 0 /* 0:Disable or 1:Enable */
#define _FS_TIMEOUT 1000 /* Timeout period in unit of time ticks */ #define _FS_TIMEOUT 1000 /* Timeout period in unit of time tick */
#define _SYNC_t HANDLE /* O/S dependent sync object type. e.g. HANDLE, OS_EVENT*, ID and etc.. */ #define _SYNC_t HANDLE /* O/S dependent sync object type. e.g. HANDLE, OS_EVENT*, ID, SemaphoreHandle_t and etc.. */
/*#include <windows.h>*/ /* The _FS_REENTRANT option switches the re-entrancy (thread safe) of the FatFs module.
/* A header file that defines sync object types on the O/S, such as windows.h,
/ ucos_ii.h and semphr.h, should be included here when enable this option.
/ The _FS_REENTRANT option switches the re-entrancy (thread safe) of the FatFs module.
/ /
/ 0: Disable re-entrancy. _FS_TIMEOUT and _SYNC_t have no effect. / 0: Disable re-entrancy. _FS_TIMEOUT and _SYNC_t have no effect.
/ 1: Enable re-entrancy. Also user provided synchronization handlers, / 1: Enable re-entrancy. Also user provided synchronization handlers,
@ -219,4 +201,28 @@
*/ */
#endif /* _FFCONFIG */ #define _WORD_ACCESS 0 /* 0 or 1 */
/* The _WORD_ACCESS option is an only platform dependent option. It defines
/ which access method is used to the word data on the FAT volume.
/
/ 0: Byte-by-byte access. Always compatible with all platforms.
/ 1: Word access. Do not choose this unless under both the following conditions.
/
/ * Address misaligned memory access is always allowed for ALL instructions.
/ * Byte order on the memory is little-endian.
/
/ If it is the case, _WORD_ACCESS can also be set to 1 to improve performance and
/ reduce code size. Following table shows an example of some processor types.
/
/ ARM7TDMI 0 ColdFire 0 V850E 0
/ Cortex-M3 0 Z80 0/1 V850ES 0/1
/ Cortex-M0 0 RX600(LE) 0/1 TLCS-870 0/1
/ AVR 0/1 RX600(BE) 0 TLCS-900 0/1
/ AVR32 0 RL78 0 R32C 0
/ PIC18 0/1 SH-2 0 M16C 0/1
/ PIC24 0 H8S 0 MSP430 0
/ PIC32 0 H8/300H 0 x86 0/1
*/
#endif /* _FFCONF */

View File

@ -2,15 +2,15 @@
#if _USE_LFN != 0 #if _USE_LFN != 0
#if _CODE_PAGE == 932 #if _CODE_PAGE == 932 /* Japanese Shift_JIS */
#include "cc932.c" #include "cc932.c"
#elif _CODE_PAGE == 936 #elif _CODE_PAGE == 936 /* Simplified Chinese GBK */
#include "cc936.c" #include "cc936.c"
#elif _CODE_PAGE == 949 #elif _CODE_PAGE == 949 /* Korean */
#include "cc949.c" #include "cc949.c"
#elif _CODE_PAGE == 950 #elif _CODE_PAGE == 950 /* Traditional Chinese Big5 */
#include "cc950.c" #include "cc950.c"
#else #else /* Small character-set */
#include "ccsbcs.c" #include "ccsbcs.c"
#endif #endif