fatfs v0.09b Jan 23,2013:

- Added f_getlabel() and f_setlabel(). (_USE_LABEL == 1)
This commit is contained in:
savelij13 2025-09-11 09:51:27 +03:00
parent 030f12c942
commit 750225eb33
112 changed files with 1847 additions and 1043 deletions

View File

@ -3,14 +3,16 @@
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta http-equiv="Content-Style-Type" content="text/css">
<meta name="description" content="Open souece 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="stylesheet" href="css_e.css" type="text/css" media="screen" title="ELM Default">
<title>ELM - FatFs Generic FAT File System Module</title>
<title>FatFs - Generic FAT File System Module</title>
</head>
<body>
<h1>FatFs Generic FAT File System Module</h1>
<h1>FatFs - Generic FAT File System Module</h1>
<hr>
<div class="abst">
@ -60,6 +62,8 @@
<li><a href="en/chdir.html">f_chdir</a> - Change current directory</li>
<li><a href="en/chdrive.html">f_chdrive</a> - Change current drive</li>
<li><a href="en/getcwd.html">f_getcwd</a> - Retrieve the current directory</li>
<li><a href="en/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/forward.html">f_forward</a> - Forward file data to the stream directly</li>
<li><a href="en/mkfs.html">f_mkfs</a> - Create a file system on the drive</li>
<li><a href="en/fdisk.html">f_fdisk</a> - Divide a physical drive</li>
@ -77,7 +81,7 @@
<div class="para">
<h3>Disk I/O Interface</h3>
<p>Since the FatFs module is completely separated from disk I/O layer, it requires following functions at least to access the physical media. 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 drivers are also available in the resources.</p>
<p>Since the FatFs module is completely separated from disk I/O layer, it requires following functions at least to access the physical media. 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 drivers are also available in the resources.</p>
<ul>
<li><a href="en/dinit.html">disk_initialize</a> - Initialize disk drive</li>
<li><a href="en/dstat.html">disk_status</a> - Get disk status</li>
@ -94,16 +98,10 @@
<p>The FatFs module is a free software opened for education, research and development. You can use, modify and/or redistribute it for personal projects or commercial products without any restriction under your responsibility. For further information, refer to the application note.</p>
<ul>
<li><a href="http://elm-chan.org/fsw/ff/bd/"><em>FatFs User Forum</em></a></li>
<li>Read first: <a href="en/appnote.html">FatFs module application note</a> <span class="mfd">August 27, 2012</span></li>
<li><a href="http://nemuisan.blog.bai.ne.jp/">Nemuisan's Blog</a> (Well written implementations for STM32F/SDIO and LPC2300/MCI)</li>
<li><a href="http://www.siwawi.arubi.uni-kl.de/avr_projects/arm_projects/arm_memcards/index.html">ARM-Projects by Martin THOMAS</a> (examples for LPC2000, AT91SAM and STM32)</li>
<li><a href="http://www.microsoft.com/whdc/system/platform/firmware/fatgen.mspx">FAT32 Specification by Microsoft</a> (The reference document on FAT file system)</li>
<li><a href="http://elm-chan.org/docs/mmc/mmc_e.html">How to Use MMC/SDC</a></li>
<li><a href="img/rwtest.png">Benchmark 1</a> (ATmega64/9.2MHz with MMC via SPI, HDD/CFC via GPIO)</li>
<li><a href="img/rwtest2.png">Benchmark 2</a> (LPC2368/72MHz with MMC via MCI)</li>
<li><a href="http://members.jcom.home.ne.jp/felm/fd.mp4">Demo movie of an application</a> (this project is in ffsample.zip/lpc23xx)</li>
<li>Read first: <a href="en/appnote.html">FatFs module application note</a> <span class="mfd">April 20, 2013</span></li>
</ul>
</div>
</body>
</html>

View File

@ -3,7 +3,9 @@
<head>
<meta http-equiv="Content-Type" content="text/html; charset=Shift_JIS">
<meta http-equiv="Content-Style-Type" content="text/css">
<meta name="description" content="組み込みシステム向けFATファイル・システム">
<meta name="description" content="組み込みシステム向け汎用FATファイル・システム">
<link rel="start" title="Site Top" href="../../index_j.html">
<link rel="up" title="Freewares" href="../../fsw.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">
<title>ELM - FatFs 汎用FATファイルシステム・モジュール</title>
@ -37,7 +39,7 @@
<div class="para">
<h3>上位レイヤ・インターフェース</h3>
<p>FatFsモジュールは、次のファイル操作関数(API)を提供します。つまり、このリストはFatFsにできることをシンプルに示しています。</p>
<p>FatFsモジュールは、アプリケーション・レイヤに対し、次のファイル操作関数(API)を提供します。つまり、このリストはFatFsにできることをシンプルに示しています。</p>
<ul>
<li><a href="ja/mount.html">f_mount</a> - ワークエリアの登録・削除</li>
<li><a href="ja/open.html">f_open</a> - ファイルのオープン・作成</li>
@ -59,6 +61,8 @@
<li><a href="ja/chdir.html">f_chdir</a> - カレント・ディレクトリの変更</li>
<li><a href="ja/chdrive.html">f_chdrive</a> - カレント・ドライブの変更</li>
<li><a href="ja/getcwd.html">f_getcwd</a> - カレント・ディレクトリの取得</li>
<li><a href="ja/getlabel.html">f_getlabel</a> - ボリューム・ラベルの取得</li>
<li><a href="ja/setlabel.html">f_setlabel</a> - ボリューム・ラベルの設定</li>
<li><a href="ja/forward.html">f_forward</a> - ファイル・データをストリーム関数に転送</li>
<li><a href="ja/mkfs.html">f_mkfs</a> - 論理ドライブのフォーマット</li>
<li><a href="ja/fdisk.html">f_fdisk</a> - 物理ドライブの分割</li>
@ -76,7 +80,7 @@
<div class="para">
<h3>下位レイヤ・インターフェース</h3>
<p>FatFsモジュールは、物理ドライブ等へのアクセスのため、下位レイヤに少なくとも次のインターフェースを要求します。使用する記録メディアに対応したディスクI/Oモジュールは、ユーザによって用意される必要があります。OS関連機能を有効にしたときは、加えてプロセス・メモリ関連関数も必要になります。資料にドライバを含むサンプル・プロジェクトあり</p>
<p>FatFsモジュールは、単なるファイル・システム・レイヤなので、メディア制御レイヤは含まれません。使用するメディアに対応した制御関数は、ユーザによって提供される必要があります。FatFsモジュールは、下位レイヤに対し少なくとも次のインターフェースを要求します。OS関連機能を有効にしたときは、加えてプロセス/メモリ関連関数も必要になります。サンプル・プロジェクトに下位レイヤの実装例を示します</p>
<ul>
<li><a href="ja/dinit.html">disk_initialize</a> - ドライブの初期化</li>
<li><a href="ja/dstat.html">disk_status</a> - ドライブの状態取得</li>
@ -93,16 +97,10 @@
<p>FatFsモジュールはフリー・ソフトウェアとして教育・研究・開発用に公開しています。どのような利用目的個人利用から商用まででも使用・改変・配布について一切の制限はありませんが、全て利用者の責任の下での利用とします。詳しくはアプリケーション・ートを参照してください。</p>
<ul>
<li><a href="http://elm-chan.org/fsw/ff/bd/"><em>FatFsユーザ・フォーラム</em></a></li>
<li>最初に読め: <a href="ja/appnote.html">FatFsモジュール・アプリケーション・ート</a> <span class="mfd">2012. 8. 27</span></li>
<li><a href="http://nemuisan.blog.bai.ne.jp/">ねむいさんのぶろぐ</a> (Well written implementations for STM32F/SDIO and LPC2300/MCI)</li>
<li><a href="http://www.siwawi.arubi.uni-kl.de/avr_projects/arm_projects/arm_memcards/index.html">ARM-Projects by Martin THOMAS</a> (examples for LPC2000, AT91SAM and STM32)</li>
<li><a href="http://www.microsoft.com/whdc/system/platform/firmware/fatgen.mspx">FATファイル・システム仕様書 by Microsoft</a> (FATの理解・実装に必要な唯一のリファレンス)</li>
<li><a href="http://elm-chan.org/docs/fat.html">FATファイル・システム概要</a> (↑を読むためのガイド)</li>
<li><a href="http://elm-chan.org/docs/mmc/mmc.html">MMCの使いかた</a></li>
<li><a href="img/rwtest.png">パフォーマンス・テスト1</a> (ATmega64/9.2MHz with MMC via SPI, HDD/CFC via GPIO)</li>
<li><a href="img/rwtest2.png">パフォーマンス・テスト2</a> (LPC2368/72MHz with MMC via MCI)</li>
<li>最初に読め: <a href="ja/appnote.html">FatFsモジュール・アプリケーション・ート</a> <span class="mfd">2013. 4. 20</span></li>
</ul>
</div>
</body>
</html>

View File

@ -8,23 +8,24 @@ abbr {border-width: 1px;}
p {margin: 0 0 0.3em 1em;}
em {font-style: normal; font-weight: bold; margin: 0 0.1em;}
pre em {font-style: italic; font-weight: normal;}
strong {}
pre {border: 1px dashed gray; margin: 0.5em 1em; padding: 0.5em; line-height: 1.2em; font-family: 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;}
pre span.c {color: green;}
pre span.k {color: blue;}
tt {margin: 0 0.2em; font-family: monospace; }
ol {margin: 0 2.5em;}
ul {margin: 0 2em;}
dl {margin: 0 1em;}
dt {font-family: monospace;}
dl.par dt {margin: 0.5em 0 0 0 ; font-style: italic; }
dl.ret dt {margin: 0.5em 0 0 0 ; font-weight: bold;}
pre span.arg {font-style: italic;}
tt {margin: 0 0.2em; font-size: 0.85em; font-family: "Consolas", "Courier New", monospace; }
tt.arg {font-style: italic;}
ol {margin: 0.5em 2.5em;}
ul {margin: 0.5em 2em;}
dl {margin: 0.5em 1em;}
dd {margin: 0 2em;}
dt {font-size: 0.85em; font-family: "Consolas", "Courier New", monospace;}
dl.par dt {margin: 0.5em 0 0 0 ; font-style: italic; }
dl.ret dt {margin: 0.5em 0 0 0 ; font-size: 0.85em; font-family: "Consolas", "Courier New", monospace;}
hr {border-width: 1px; margin: 1em;}
div.abst {font-family: sans-serif;}
div.para {clear: both; font-family: serif;}
div.ret a {font-family: monospace; }
div.ret a {font-size: 0.85em; font-family: "Consolas", "Courier New", monospace; }
.equ {text-indent: 0; margin: 1em 2em 1em;}
.indent {margin-left: 2em;}
.rset {float: right; margin: 0 0 0.5em 0.5em;}
@ -40,7 +41,7 @@ h1 {line-height: 1em; font-size: 2em; font-family: sans-serif; padding: 0.3em 0
p.hdd {float: right; text-align: right; margin-top: 0.5em;}
hr.hds {clear: both; margin-bottom: 1em;}
h2 {font-size: 1.6em; font-family: sans-serif; background-color: #d8d8FF; padding: 0.2em 0.5em; margin: 0 0 0.5em;}
h2 {font-size: 2em; font-family: sans-serif; background-color: #d8d8FF; padding: 0.5em 0.5em; margin: 0 0 0.5em;}
h3 {font-size: 1.5em; font-family: sans-serif; margin: 1.5em 0 0.5em;}
h4 {font-size: 1.2em; font-family: sans-serif; margin: 1em 0 0.2em;}
h5 {font-size: 1em; font-family: sans-serif; margin: 0.5em 0 0em;}
@ -51,8 +52,8 @@ small {font-size: 80%;}
table {margin: 0.5em 1em; border-collapse: collapse; border: 2px solid black; }
th {background-color: white; border-style: solid; border-width: 1px 1px 2px; border-color: black; padding: 0 3px; vertical-align: top; white-space: nowrap;}
td {background-color: white; border: 1px solid black; padding: 0 3px; vertical-align: top; line-height: 1.3em;}
table.lst td:first-child {font-family: monospace;}
table.lst2 td {font-family: monospace;}
table.lst td:first-child {font-size: 0.85em; font-family: "Consolas", "Courier New", monospace;}
table.lst2 td {font-size: 0.85em; font-family: "Consolas", "Courier New", monospace;}
table caption {font-family: sans-serif; font-weight: bold;}
tr.lst3 td { border-width: 2px 1px 1px; }

View File

@ -11,23 +11,24 @@ abbr {border-width: 1px;}
p {text-indent: 1em; margin: 0 0 0.3em 0.5em;}
em {font-style: normal; font-weight: bold; margin: 0 0.1em;}
pre em {font-style: italic; font-weight: normal;}
strong {}
pre {border: 1px dashed gray; margin: 0.5em 1em; padding: 0.5em; line-height: 1.2em; letter-spacing: 0; font-family: 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", " ゴシック", monospace; background-color: white;}
pre span.c {color: green;}
pre span.k {color: blue;}
tt {margin: 0 0.2em; letter-spacing: 0; font-family: monospace; }
ol {margin: 0 2.5em;}
ul {margin: 0 2em;}
dl {margin: 0 1em;}
dt {font-family: monospace;}
pre span.arg {font-style: italic;}
tt {margin: 0 0.2em; letter-spacing: 0; font-size: 0.85em; font-family: "Consolas", "Courier New", " ゴシック", monospace;}
tt.arg {font-style: italic;}
ol {margin: 0.5em 2.5em;}
ul {margin: 0.5em 2em;}
dl {margin: 0.5em 1em;}
dd {margin: 0em 2em;}
dt {font-size: 0.85em; font-family: "Consolas", "Courier New", " ゴシック", monospace;}
dl.par dt {margin: 0.5em 0 0 0 ; font-style: italic; letter-spacing: 0;}
dl.ret dt {margin: 0.5em 0 0 0 ; font-family: monospace; letter-spacing: 0; font-weight: bold;}
dd {margin: 0 2em;}
dl.ret dt {margin: 0.5em 0 0 0 ; font-size: 0.85em; font-family: "Consolas", "Courier New", " ゴシック", monospace; letter-spacing: 0; }
hr {border-width: 1px; margin: 1em;}
div.abst {font-family: " Pゴシック",sans-serif;}
div.para {clear: both; font-family: " P明朝",serif;}
div.ret a {font-family: monospace; }
div.ret a {font-size: 0.85em; font-family: "Consolas", "Courier New", monospace; }
.equ {text-indent: 0; margin: 1em 2em 1em;}
.indent {margin-left: 2em;}
.rset {float: right; margin: 0 0 0.5em 0.5em;}
@ -43,7 +44,7 @@ h1 {line-height: 1em; font-size: 2em; font-family: sans-serif; padding: 0.3em 0
p.hdd {float: right; text-align: right; margin-top: 0.5em;}
hr.hds {clear: both; margin-bottom: 1em;}
h2 {font-size: 1.6em; font-family: "lr oƒSƒVƒbƒN",sans-serif; background-color: #d8d8FF; padding: 0.2em 0.5em; margin: 0 0 0.5em;}
h2 {font-size: 2em; font-family: " Pゴシック",sans-serif; background-color: #d8d8FF; padding: 0.5em 0.5em; margin: 0 0 0.5em;}
h3 {font-size: 1.5em; font-family: " Pゴシック",sans-serif; margin: 1.5em 0 0.5em;}
h4 {font-size: 1.2em; font-family: " Pゴシック",sans-serif; margin: 1em 0 0.2em;}
h5 {font-size: 1em; font-family: " Pゴシック",sans-serif; margin: 0.5em 0 0em;}
@ -54,8 +55,8 @@ small {font-size: 80%;}
table {margin: 0.5em 1em; border-collapse: collapse; border: 2px solid black; letter-spacing: 0;}
th {background-color: white; border-style: solid; border-width: 1px 1px 2px; border-color: black; padding: 0 3px; vertical-align: top;}
td {background-color: white; border: 1px solid black; padding: 0 3px; vertical-align: top; line-height: 1.3em;}
table.lst td:first-child {font-family: monospace; white-space: nowrap;}
table.lst2 td {font-family: monospace; white-space: nowrap;}
table.lst td:first-child {font-size: 0.85em; font-family: "Consolas", "Courier New", monospace; white-space: nowrap;}
table.lst2 td {font-size: 0.85em; font-family: "Consolas", "Courier New", monospace; white-space: nowrap;}
table caption {font-family: sans-serif; font-weight: bold;}
tr.lst3 td {border-width: 2px 1px 1px; }

View File

@ -23,6 +23,7 @@
<li><a href="#fs1">Performance Effective File Access</a></li>
<li><a href="#fs2">Considerations on Flash Memory Media</a></li>
<li><a href="#critical">Critical Section</a></li>
<li><a href="#fs3">Extended Use of APIs</a></li>
<li><a href="#license">About FatFs License</a></li>
</ol>
<hr>
@ -34,9 +35,9 @@
<p>The FatFs module is assuming following conditions on portability.</p>
<ul>
<li>ANSI C<br>
The FatFs module is a middleware which is written in ANSI C (C89). There is no platform dependence, so long as the compiler is in compliance with ANSI C.</li>
The FatFs module is a middleware written in ANSI C (C89). There is no platform dependence, so long as the compiler is in compliance with ANSI C.</li>
<li>Size of integer types<br>
The FatFs module assumes that size of char/short/long are 8/16/32 bit and int is 16 or 32 bit. These correspondence are defined in integer.h. This will not be a problem on most compilers. When any conflict with existing definitions is occured, you must resolve it with care.</li>
The FatFs module assumes that size of char/short/long are 8/16/32 bit and int is 16 or 32 bit. These correspondence are defined in <tt>integer.h</tt>. This will not be a problem on most compilers. When any conflict with existing definitions is occured, you must resolve it with care.</li>
</ul>
<h4>System organizations</h4>
@ -44,7 +45,7 @@ The FatFs module assumes that size of char/short/long are 8/16/32 bit and int is
<p><img src="../img/modules.png" width="507" height="224" alt="dependency diagram"></p>
<h4>Which function is required?</h4>
<p>You need to provide only low level disk I/O functions that required by FatFs module and nothing else. If a working disk module for the target is already existing, you need to write only glue functions to attach it to the FatFs module. If not, you need to port any other disk module or write it from scratch. All defined functions are not that always required. For example, disk write function is not required in read-only configuration. Following table shows which function is required depends on configuration options.</p>
<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>
<table class="lst2">
<tr><th>Function</th><th>Required when:</th><th>Note</th></tr>
<tr><td>disk_initialize<br>disk_status<br>disk_read</td><td>Always</td><td rowspan="5">Disk I/O functions.<br>Samples available in ffsample.zip.<br>There are many implementations on the web.</td></tr>
@ -72,21 +73,23 @@ The FatFs module assumes that size of char/short/long are 8/16/32 bit and int is
</div>
<div class="para" id="memory">
<h3>Memory Usage (R0.09a)</h3>
<h3>Memory Usage</h3>
<table class="lst2">
<tr><th></th><th>ARM7<small><br>32bit</small></th><th>ARM7<small><br>Thumb</small></th><th>CM3<small><br>Thumb-2</small></th><th>AVR</th><th>H8/300H</th><th>PIC24</th><th>RL78</th><th>V850ES</th><th>SH-2A</th><th>RX600</th><th>IA-32</th></tr>
<tr><td>Compiler</td><td>GCC</td><td>GCC</td><td>GCC</td><td>GCC</td><td>CH38</td><td>C30</td><td>CC78K0R</td><td>CA850</td><td>SHC</td><td>RXC</td><td>VC6</td></tr>
<tr><td>_WORD_ACCESS</td><td>0</td><td>0</td><td>0</td><td>1</td><td>0</td><td>0</td><td>0</td><td>1</td><td>0</td><td>1</td><td>1</td></tr>
<tr class="lst3"><td>text (Full, R/W)</td><td>10375</td><td>7019</td><td>6561</td><td>13267</td><td>10525</td><td>11205</td><td>12812</td><td>7783</td><td>8715</td><td>5782</td><td>7615</td></tr>
<tr> <td>text (Min, R/W)</td> <td>6487</td><td>4727</td><td>4283</td> <td>8521</td> <td>6967</td> <td>7398</td> <td>8800</td><td>5019</td><td>5635</td><td>3784</td><td>5003</td></tr>
<tr> <td>text (Full, R/O)</td> <td>4551</td><td>3125</td><td>2895</td> <td>6219</td> <td>4895</td> <td>5268</td> <td>6123</td><td>3629</td><td>3843</td><td>2699</td><td>3527</td></tr>
<tr> <td>text (Min, R/O)</td> <td>3321</td><td>2457</td><td>2197</td> <td>4527</td> <td>3797</td> <td>3999</td> <td>4663</td><td>2773</td><td>2999</td><td>2064</td><td>2736</td></tr>
<tr> <td>bss</td><td>D*4 + 2</td><td>D*4 + 2</td><td>D*4 + 2</td><td>D*2 + 2</td><td>D*4 + 2</td><td>D*2 + 2</td><td>D*2 + 2</td><td>D*4 + 2</td><td>D*4 + 2</td><td>D*4 + 2</td><td>D*4 + 2</td></tr>
<tr> <td>Work area<br>(_FS_TINY == 0)</td><td>V*560 +<br>F*550</td><td>V*560 +<br>F*550</td><td>V*560 +<br>F*550</td><td>V*560 +<br>F*544</td><td>V*560 +<br>F*550</td><td>V*560 +<br>F*544</td><td>V*560 +<br>F*544</td><td>V*560 +<br>F*544</td><td>V*560 +<br>F*550</td><td>V*560 +<br>F*550</td><td>V*560 +<br>F*550</td></tr>
<tr><td>Work area<br>(_FS_TINY == 1)</td><td>V*560 +<br>F*36</td><td>V*560 +<br>F*36</td><td>V*560 +<br>F*36</td><td>V*560 +<br>F*32</td><td>V*560 +<br>F*36</td><td>V*560 +<br>F*32</td><td>V*560 +<br>F*32</td><td>V*560 +<br>F*36</td><td>V*560 +<br>F*36</td><td>V*560 +<br>F*36</td><td>V*560 +<br>F*36</td></tr>
<!-- *ARM *Thumb *CM3 *AVR *H8 *PIC24 RL78 *V850ES *SH-2A *RX600 *IA-32 -->
<tr class="lst3"><td>text (Full, R/W)</td><td>10395</td><td>7037</td><td>6555</td><td>13362</td><td>10609</td><td>11364</td><td>12884</td><td>7814</td><td>8783</td><td>5826</td><td>7659</td></tr>
<tr> <td>text (Min, R/W)</td> <td>6519</td><td>4747</td><td>4315</td> <td>8608</td> <td>7043</td> <td>7539</td> <td>8860</td><td>5070</td><td>5723</td><td>3821</td><td>5038</td></tr>
<tr> <td>text (Full, R/O)</td> <td>4563</td><td>3147</td><td>2911</td> <td>6174</td> <td>4925</td> <td>5340</td> <td>6136</td><td>3628</td><td>3863</td><td>2721</td><td>3534</td></tr>
<tr> <td>text (Min, R/O)</td> <td>3311</td><td>2463</td><td>2209</td> <td>4610</td> <td>3817</td> <td>4029</td> <td>4641</td><td>2762</td><td>3003</td><td>2068</td><td>2722</td></tr>
<tr> <td>bss</td><td>V*4 + 2</td><td>V*4 + 2</td><td>V*4 + 2</td><td>V*2 + 2</td><td>V*4 + 2</td><td>V*2 + 2</td><td>V*2 + 2</td><td>V*4 + 2</td><td>V*4 + 2</td><td>V*4 + 2</td><td>V*4 + 2</td></tr>
<tr> <td>Work area<br>(_FS_TINY == 0)</td><td>V*564 +<br>F*550</td><td>V*564 +<br>F*550</td><td>V*564 +<br>F*550</td><td>V*564 +<br>F*544</td><td>V*564 +<br>F*550</td><td>V*564 +<br>F*544</td><td>V*564 +<br>F*544</td><td>V*564 +<br>F*544</td><td>V*564 +<br>F*550</td><td>V*564 +<br>F*550</td><td>V*564 +<br>F*550</td></tr>
<tr><td>Work area<br>(_FS_TINY == 1)</td><td>V*564 +<br>F*36</td><td>V*564 +<br>F*36</td><td>V*564 +<br>F*36</td><td>V*564 +<br>F*32</td><td>V*564 +<br>F*36</td><td>V*564 +<br>F*32</td><td>V*564 +<br>F*32</td><td>V*564 +<br>F*36</td><td>V*564 +<br>F*36</td><td>V*564 +<br>F*36</td><td>V*564 +<br>F*36</td></tr>
</table>
<p>These are the memory usage on some target systems with following condition. The memory sizes are in unit of byte, <em>V</em> means number of mounted volumes and <em>F</em> means number of open files. All samples are optimezed in code size.</p>
<p>These are the memory usage on some target systems with following condition. The memory sizes are in unit of byte, <em>V</em> denotes number of volumes and <em>F</em> denotes number of open files. All samples are optimezed in code size.</p>
<pre>
FatFs R0.09b options:
_FS_READONLY 0 (R/W), 1 (R/O)
_FS_MINIMIZE 0 (Full function), 3 (Minimized function)
_USE_STRFUNC 0 (Disable string functions)
@ -96,8 +99,9 @@ _USE_FASTSEEK 0 (Disable fast seek feature)
_CODE_PAGE 932 (Japanese Shift-JIS)
_USE_LFN 0 (Disable LFN)
_MAX_SS 512 (Fixed sector size)
_FS_RPATH 0 (Disable relative path)
_VOLUMES D (Number of logical drives to be used)
_FS_RPATH 0 (Disable relative path feature)
_FS_LABEL 0 (Disable volume label functions)
_VOLUMES V (Number of logical drives to be used)
_MULTI_PARTITION 0 (Single partition per drive)
_FS_REENTRANT 0 (Disable reentrancy)
_FS_LOCK 0 (Disable shareing control)
@ -108,41 +112,43 @@ _FS_LOCK 0 (Disable shareing control)
<h3>Module Size Reduction</h3>
<p>Follwing table shows which API function is removed by configuration options for the module size reduction.</p>
<table class="lst2">
<tr><td rowspan="2">Function</td><td colspan="4">_FS_MINIMIZE</td><td colspan="2">_FS_READONLY</td><td colspan="2">_USE_STRFUNC</td><td colspan="3">_FS_RPATH</td><td colspan="2">_USE_MKFS</td><td colspan="2">_USE_FORWARD</td><td colspan="2">_MULTI_PARTITION</td></tr>
<tr><td>0</td><td>1</td><td>2</td><td>3</td><td>0</td><td>1</td><td>0&nbsp;&nbsp;</td><td>1/2</td><td>0</td><td>1</td><td>2</td><td>0</td><td>1</td><td>0</td><td>1</td><td>0/1</td><td>2</td></tr>
<tr class="lst3"><td>f_mount</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr>
<tr><td>f_open</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr>
<tr><td>f_close</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr>
<tr><td>f_read</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr>
<tr><td>f_write</td><td></td><td></td><td></td><td></td><td></td><td>x</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr>
<tr><td>f_sync</td><td></td><td></td><td></td><td></td><td></td><td>x</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr>
<tr><td>f_lseek</td><td></td><td></td><td></td><td>x</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr>
<tr><td>f_opendir</td><td></td><td></td><td>x</td><td>x</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr>
<tr><td>f_readdir</td><td></td><td></td><td>x</td><td>x</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr>
<tr><td>f_stat</td><td></td><td>x</td><td>x</td><td>x</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr>
<tr><td>f_getfree</td><td></td><td>x</td><td>x</td><td>x</td><td></td><td>x</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr>
<tr><td>f_truncate</td><td></td><td>x</td><td>x</td><td>x</td><td></td><td>x</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr>
<tr><td>f_unlink</td><td></td><td>x</td><td>x</td><td>x</td><td></td><td>x</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr>
<tr><td>f_mkdir</td><td></td><td>x</td><td>x</td><td>x</td><td></td><td>x</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr>
<tr><td>f_chmod</td><td></td><td>x</td><td>x</td><td>x</td><td></td><td>x</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr>
<tr><td>f_utime</td><td></td><td>x</td><td>x</td><td>x</td><td></td><td>x</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr>
<tr><td>f_rename</td><td></td><td>x</td><td>x</td><td>x</td><td></td><td>x</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr>
<tr><td>f_chdir</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td>x</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr>
<tr><td>f_chdrive</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td>x</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr>
<tr><td>f_getcwd</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td>x</td><td>x</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr>
<tr><td>f_mkfs</td><td></td><td></td><td></td><td></td><td></td><td>x</td><td></td><td></td><td></td><td></td><td></td><td>x</td><td></td><td></td><td></td><td></td><td></td></tr>
<tr><td>f_fdisk</td><td></td><td></td><td></td><td></td><td></td><td>x</td><td></td><td></td><td></td><td></td><td></td><td>x</td><td></td><td></td><td></td><td>x</td><td></td></tr>
<tr><td>f_forward</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td>x</td><td></td><td></td><td></td></tr>
<tr><td>f_putc</td><td></td><td></td><td></td><td></td><td></td><td>x</td><td>x</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr>
<tr><td>f_puts</td><td></td><td></td><td></td><td></td><td></td><td>x</td><td>x</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr>
<tr><td>f_printf</td><td></td><td></td><td></td><td></td><td></td><td>x</td><td>x</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr>
<tr><td>f_gets</td><td></td><td></td><td></td><td></td><td></td><td></td><td>x</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr>
<tr><td rowspan="2">Function</td><td colspan="4">_FS_MINIMIZE</td><td colspan="2">_FS_READONLY</td><td colspan="2">_USE_STRFUNC</td><td colspan="3">_FS_RPATH</td><td colspan="2">_FS_LABEL</td><td colspan="2">_USE_MKFS</td><td colspan="2">_USE_FORWARD</td><td colspan="2">_MULTI_PARTITION</td></tr>
<tr><td>0</td><td>1</td><td>2</td><td>3</td><td>0</td><td>1</td><td>0&nbsp;&nbsp;</td><td>1/2</td><td>0</td><td>1</td><td>2</td><td>0</td><td>1</td><td>0</td><td>1</td><td>0</td><td>1</td><td>0</td><td>1</td></tr>
<tr class="lst3"><td>f_mount</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr>
<tr><td>f_open</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr>
<tr><td>f_close</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr>
<tr><td>f_read</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr>
<tr><td>f_write</td><td></td><td></td><td></td><td></td><td></td><td>x</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr>
<tr><td>f_sync</td><td></td><td></td><td></td><td></td><td></td><td>x</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr>
<tr><td>f_lseek</td><td></td><td></td><td></td><td>x</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr>
<tr><td>f_opendir</td><td></td><td></td><td>x</td><td>x</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr>
<tr><td>f_readdir</td><td></td><td></td><td>x</td><td>x</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr>
<tr><td>f_stat</td><td></td><td>x</td><td>x</td><td>x</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr>
<tr><td>f_getfree</td><td></td><td>x</td><td>x</td><td>x</td><td></td><td>x</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr>
<tr><td>f_truncate</td><td></td><td>x</td><td>x</td><td>x</td><td></td><td>x</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr>
<tr><td>f_unlink</td><td></td><td>x</td><td>x</td><td>x</td><td></td><td>x</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr>
<tr><td>f_mkdir</td><td></td><td>x</td><td>x</td><td>x</td><td></td><td>x</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr>
<tr><td>f_chmod</td><td></td><td>x</td><td>x</td><td>x</td><td></td><td>x</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr>
<tr><td>f_utime</td><td></td><td>x</td><td>x</td><td>x</td><td></td><td>x</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr>
<tr><td>f_rename</td><td></td><td>x</td><td>x</td><td>x</td><td></td><td>x</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr>
<tr><td>f_chdir</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td>x</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr>
<tr><td>f_chdrive</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td>x</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr>
<tr><td>f_getcwd</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td>x</td><td>x</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr>
<tr><td>f_getlabel</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td>x</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr>
<tr><td>f_setlabel</td><td></td><td></td><td></td><td></td><td></td><td>x</td><td></td><td></td><td></td><td></td><td></td><td>x</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr>
<tr><td>f_forward</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td>x</td><td></td><td></td><td></td></tr>
<tr><td>f_mkfs</td><td></td><td></td><td></td><td></td><td></td><td>x</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td>x</td><td></td><td></td><td></td><td></td><td></td></tr>
<tr><td>f_fdisk</td><td></td><td></td><td></td><td></td><td></td><td>x</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td>x</td><td></td><td></td><td></td><td>x</td><td></td></tr>
<tr><td>f_putc</td><td></td><td></td><td></td><td></td><td></td><td>x</td><td>x</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr>
<tr><td>f_puts</td><td></td><td></td><td></td><td></td><td></td><td>x</td><td>x</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr>
<tr><td>f_printf</td><td></td><td></td><td></td><td></td><td></td><td>x</td><td>x</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr>
<tr><td>f_gets</td><td></td><td></td><td></td><td></td><td></td><td></td><td>x</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr>
</table>
</div>
<div class="para" id="lfn">
<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>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>
<table class="lst2 rset">
<caption>LFN cfg on ARM7</caption>
<tr><th>Code page</th><th>Program size</th></tr>
@ -152,32 +158,32 @@ _FS_LOCK 0 (Disable shareing control)
<tr><td>949(Korean)</td><td>+139K</td></tr>
<tr><td>950(Big5)</td><td>+111K</td></tr>
</table>
<p>When the LFN feature is enabled, the module size will be increased depends on the selected code page. Right table shows how many bytes increased when LFN feature is enabled with some code pages. We are the East-Asians have tens of thousands of characters. Unfortunately, it requires a huge OEM-Unicode bidirectional conversion table and the module size will be drastically increased that shown in the table. As the result, the FatFs with LFN feature with DBCS will not able to be implemented to most 8-bit microcontrollers. <small>This is the reason why I had not been interested in implementing the LFN feature for a long time :-)</small></p>
<p>Note that the LFN feature on the FAT file system is a patent of Microsoft Corporation. This is not the case on FAT32 but most FAT32 drivers include the LFN feature. FatFs can swich the LFN feature by configuration option. When enable LFN feature on the commercial products, a license from Microsoft may be required depends on the final destination.</p>
<p>When the LFN feature is enabled, the module size will be increased depends on the selected code page. Right table shows how many bytes increased when LFN feature is enabled with some code pages. Especially, in the CJK region, tens of thousands of characters are being used. Unfortunately, it requires a huge OEM-Unicode bidirectional conversion table and the module size will be drastically increased that shown in the table. As the result, the FatFs with LFN feature with those code pages will not able to be implemented to most 8-bit microcontrollers.</p>
<p>Note that the LFN feature on the FAT file system is a patent of Microsoft Corporation. This is not the case on FAT32 but most FAT32 drivers come with the LFN feature. FatFs can swich the LFN feature off by configuration option. When enable LFN feature on the commercial products, a license from Microsoft may be required depends on the final destination.</p>
</div>
<div class="para" id="unicode">
<h3>Unicode API</h3>
<p>FatFs supports ANSI/OEM code set on the API in default but FatFs can also switch the code set to Unicode. For more information, refer to the description in the <a href="filename.html">file name</a>.</p>
<p>In default, FatFs supports ANSI/OEM code set on the API but FatFs can also switch the code set to Unicode. 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>
</div>
<div class="para" id="reentrant">
<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, ff_cre_syncobj, ff_del_syncobj, ff_req_grant and ff_rel_grant must be added to the project.</p>
<p>The file operations to the different volume is always re-entrant and can work simultaneously. The file operations to the same volume is not re-entrant but it can also be configured to thread-safe with <tt>_FS_REENTRANT</tt> option. In this case, also the OS dependent synchronization object control functions, <tt>ff_cre_syncobj(), ff_del_syncobj(), ff_req_grant() and ff_rel_grant()</tt> must be added to the project.</p>
<p>When a file function is called while the volume is in use by any other task, the file function is suspended until that task leaves file function. If wait time exceeded a period defined by <tt>_TIMEOUT</tt>, the file function will abort with <tt>FR_TIMEOUT</tt>. The timeout feature might not be supported on some RTOS.</p>
<p>There is an exception on f_mount and f_mkfs function. These functions are not re-entrant to the same volume. When use these functions, all other task must close the corresponding file on the volume and avoid to access the volume.</p>
<p>There is an exception on <tt>f_mount()</tt> and <tt>f_mkfs()</tt> function. These functions are not re-entrant to the same volume. When use these functions, all other task must close the corresponding file on the volume and avoid to access the volume.</p>
<p>Note that this section describes on the re-entrancy of the FatFs module itself but also the low level disk I/O layer must be re-entrant.</p>
</div>
<div class="para" id="dup">
<h3>Duplicated File Access</h3>
<p>FatFs module does not support the shareing controls of duplicated file access in default. It is permitted when open method to a file is only read mode. The duplicated open in write mode to a file is always prohibited and open file must not be renamed, deleted, or the FAT structure on the volume can be collapted.</p>
<p>The file shareing control can also be available when <tt>_FS_LOCK</tt> is set to 1 or grater. The value specifies the number of files 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 gets larger than <tt>_FS_LOCK</tt>, the f_open function will fail with <tt>FR_TOO_MANY_OPEN_FILES</tt>.</p>
<p>The file shareing control can also be available when <tt>_FS_LOCK</tt> is set to 1 or grater. The value specifies the number of files 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 gets larger than <tt>_FS_LOCK</tt>, the <tt>f_open()</tt> function will fail with <tt>FR_TOO_MANY_OPEN_FILES</tt>.</p>
</div>
<div class="para" id="fs1">
<h3>Performance Effective File Access</h3>
<p>For good performance on reading/writing files on the small embedded system, application programmer should consider what process is done in the FatFs module. The file data on the disk is transferred in following sequence by f_read function.</p>
<p>For good performance on reading/writing files on the small embedded system, application programmer should consider what process is done in the FatFs module. The file data on the volume is transferred in following sequence by <tt>f_read()</tt> function.</p>
<p>Figure 1. Sector miss-aligned read (short)<br>
<img src="../img/f1.png" width="490" height="110" alt="">
</p>
@ -187,8 +193,8 @@ _FS_LOCK 0 (Disable shareing control)
<p>Figure 3. Sector aligned read<br>
<img src="../img/f3.png" width="490" height="119" alt="">
</p>
<p>The file I/O buffer means 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 on 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 on 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 partial sector data 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 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 disk_read function at a time but the multi sector transfer never across the cluster boundary even if it is contiguous.</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 on 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 on 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 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 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>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 on the tiny configuration so that it can achieve same performance as non-tiny configuration with small memory footprint.</p>
</div>
@ -202,12 +208,12 @@ Figure 6. Comparison between Multiple/Single Sector Write<br>
</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>
<h4>Forcing Memory Erase</h4>
<p>When remove a file with f_remove function, the data clusters occupied by the file are marked 'free' on the FAT. But the data sectors containing the file data are not that applied any process, so that the file data left occupies a part of the flash memory array as live blocks. If the file data is forced erased on removing the file, the number of free blocks on the flash memory will be increased. This may skip internal block erase operation to the data block on next write. As the result the write performance might be improved. To enable this feature, set <tt>_USE_ERASE</tt> to 1. Note that this is a feature with expectation of internal process of the flash memory media. It may not always effective and f_remove function will take a time on removing a large file.</p>
<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>
</div>
<div class="para" id="critical">
<h3>Critical Section</h3>
<p>If a write operation to the FAT file system is interrupted due to any accidental failure, such as sudden blackout, incorrect disk removal and unrecoverable disk error, the FAT structure can be collapted. Following images shows the critical section on the FatFs application.</p>
<p>If a write operation to the FAT volume is interrupted due to any accidental failure, such as sudden blackout, incorrect disk removal and unrecoverable disk error, the FAT structure on the volume can be collapted. Following images shows the critical section of the FatFs module.</p>
<div class="lset">
Figure 4. Long critical section<br>
<img src="../img/f4.png" width="320" height="436" alt="fig.4">
@ -217,28 +223,38 @@ Figure 5. Minimized critical section<br>
<img src="../img/f5.png" width="320" height="436" alt="fig.5">
</div>
<br class="clr">
<p>An interruption in the red section can cause a cross link; as a result, the object being changed may be lost. There is one or more possibility listed below when an interruption in the yellow section is occured.</p>
<p>An interruption in the red section can cause a cross link; as a result, the object being changed can be lost. If an interruption in the yellow section is occured, there is one or more possibility listed below.</p>
<ul>
<li>File data being rewrited is collapted.</li>
<li>A file being appended returns initial state.</li>
<li>A file created as new is gone.</li>
<li>A file created as new or in overwritten remains with no content.</li>
<li>The file data being rewrited is collapted.</li>
<li>The file being appended returns initial state.</li>
<li>The file created as new is gone.</li>
<li>The file created as new or overwritten remains but no content.</li>
<li>Efficiency of disk use gets worse due to lost clusters.</li>
</ul>
<p>Each case does not affect the files that not in write mode open. To minimize risk of data loss, the critical section can be minimized like shown in Figure 5 by minimizing the time that file is opened in write mode or using f_sync function properly.</p>
<p>Each case does not affect the files that not opened in write mode. To minimize risk of data loss, the critical section can be minimized like shown in Figure 5 by minimizing the time that file is opened in write mode or using <tt>f_sync()</tt> function properly.</p>
</div>
<div class="para" id="fs3">
<h3>Extended Use of APIs</h3>
<p>These are examples of extended use of FatFs APIs. New item will be added whenever a useful code is found.</p>
<ol>
<li><a href="../img/app1.c">Open or create a file for append</a></li>
<li><a href="../img/app2.c">Empty a directory</a></li>
<li><a href="../img/app3.c">Allocate contiguous area to the file</a></li>
</ol>
</div>
<div class="para" id="license">
<h3>About FatFs License</h3>
<p>This is a copy of the FatFs license document that included in the source codes.</p>
<pre>/*----------------------------------------------------------------------------/
/ FatFs - FAT file system module R0.09 (C)ChaN, 2011
/ FatFs - FAT file system module R0.09b (C)ChaN, 2013
/-----------------------------------------------------------------------------/
/ 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
/ developments under license policy of following trems.
/
/ Copyright (C) 2011, ChaN, all right reserved.
/ Copyright (C) 2013, ChaN, all right reserved.
/
/ * The FatFs module is a free software and there is NO WARRANTY.
/ * No restriction on use. You can use, modify and redistribute it for
@ -246,7 +262,7 @@ Figure 5. Minimized critical section<br>
/ * Redistributions of source code must retain the above copyright notice.
/
/-----------------------------------------------------------------------------/</pre>
<p>Therefore FatFs license is one of the BSD-style license but there is a big difference. Because FatFs is for embedded projects, the conditions for redistributions in binary form, such as embedded code, hex file and binary library, are not specified to increase its usability. The documentation of the distributions need not include about FatFs and its license document, and it may also. Of course FatFs is compatible with the projects under GNU GPL. When redistribute it 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 license but there is a big difference. Because FatFs is for embedded projects, the conditions for redistributions in binary form, such as embedded code, hex file and binary library, is not specified to increase its usability. The documentation of the distributions need not include about FatFs and its license document, and it may also. Of course FatFs is compatible with the projects under GNU GPL. When redistribute it with any modification, the license can also be changed to GNU GPL or BSD-style license.</p>
</div>
<p class="foot"><a href="../00index_e.html">Return</a></p>

View File

@ -16,7 +16,7 @@
<p>The f_chdir function changes the current directory of a drive.</p>
<pre>
FRESULT f_chdir (
const TCHAR* <em>Path</em> <span class="c">/* Pointer to the path name */</span>
const TCHAR* <span class="arg">path</span> <span class="c">/* [IN] Path name */</span>
);
</pre>
</div>
@ -24,7 +24,7 @@ FRESULT f_chdir (
<div class="para arg">
<h4>Parameters</h4>
<dl class="par">
<dt>Path</dt>
<dt>path</dt>
<dd>Pointer to the null-terminated string that specifies a <a href="filename.html">directory</a> to go.</dd>
</dl>
</div>
@ -50,7 +50,7 @@ FRESULT f_chdir (
<div class="para desc">
<h4>Description</h4>
<p>The f_chdir function changes the current directory of the logical drive. The current directory of a drive is initialized to the root directory when the drive is auto-mounted. Note that the current directory is retained in the each file system object so that it also affects other tasks that using the drive.</p>
<p>The <tt>f_chdir()</tt> function changes the current directory of the logical drive. The current directory of a drive is initialized to the root directory when the drive is auto-mounted. Note that the current directory is retained in the each file system object so that it also affects other tasks that using the volume.</p>
</div>

View File

@ -16,7 +16,7 @@
<p>The f_chdrive function changes the current drive.</p>
<pre>
FRESULT f_chdrive (
BYTE <em>Drive</em> <span class="c">/* Logical drive number */</span>
BYTE <span class="arg">vol</span> <span class="c">/* [IN] Logical drive number */</span>
);
</pre>
</div>
@ -24,7 +24,7 @@ FRESULT f_chdrive (
<div class="para arg">
<h4>Parameters</h4>
<dl class="par">
<dt>Drive</dt>
<dt>vol</dt>
<dd>Specifies the <a href="filename.html">logical drive number</a> to be set as the current drive.</dd>
</dl>
</div>
@ -41,7 +41,7 @@ FRESULT f_chdrive (
<div class="para desc">
<h4>Description</h4>
<p>The f_chdrive function changes the current drive. The initial value of the current drive number is 0. Note that the current drive is retained in a static variable so that it also affects other tasks that using the file functions.</p>
<p>The <tt>f_chdrive()</tt> function changes the current drive. The initial value of the current drive number is 0. Note that the current drive is retained in a static variable so that it also affects other tasks that using the file functions.</p>
</div>
<div class="para comp">

View File

@ -16,9 +16,9 @@
<p>The f_chmod function changes the attribute of a file or directory.</p>
<pre>
FRESULT f_chmod (
const TCHAR* <em>FileName</em>, <span class="c">/* Pointer to the file or directory */</span>
BYTE <em>Attribute</em>, <span class="c">/* Attribute flags */</span>
BYTE <em>AttributeMask</em> <span class="c">/* Attribute masks */</span>
const TCHAR* <span class="arg">path</span>, <span class="c">/* [IN] Object name */</span>
BYTE <span class="arg">attr</span>, <span class="c">/* [IN] Attribute flags */</span>
BYTE <span class="arg">mask</span> <span class="c">/* [IN] Attribute masks */</span>
);
</pre>
</div>
@ -26,9 +26,9 @@ FRESULT f_chmod (
<div class="para arg">
<h4>Parameters</h4>
<dl class="par">
<dt>FileName</dt>
<dt>path</dt>
<dd>Pointer to the null-terminated string that specifies a <a href="filename.html">file or directory</a> to be changed</dd>
<dt>Attribute</dt>
<dt>attr</dt>
<dd>Attribute flags to be set in one or more combination of the following flags. The specified flags are set and others are cleard.<br>
<table class="lst">
<tr><th>Attribute</th><th>Description</th></tr>
@ -38,7 +38,7 @@ FRESULT f_chmod (
<tr><td>AM_HID</td><td>Hidden</td></tr>
</table>
</dd>
<dt>AttributeMask</dt>
<dt>mask</dt>
<dd>Attribute mask that specifies which attribute is changed. The specified aattributes are set or cleard.</dd>
</dl>
</div>
@ -66,7 +66,7 @@ FRESULT f_chmod (
<div class="para desc">
<h4>Description</h4>
<p>The f_chmod function changes the attribute of a file or directory.</p>
<p>The <tt>f_chmod()</tt> function changes the attribute of a file or directory.</p>
</div>

View File

@ -16,7 +16,7 @@
<p>The f_close function closes an open file.</p>
<pre>
FRESULT f_close (
FIL* <em>FileObject</em> <span class="c">/* Pointer to the file object structure */</span>
FIL* <span class="arg">fp</span> <span class="c">/* [IN] Pointer to the file object */</span>
);
</pre>
</div>
@ -24,7 +24,7 @@ FRESULT f_close (
<div class="para arg">
<h4>Parameter</h4>
<dl class="par">
<dt>FileObject</dt>
<dt>fp</dt>
<dd>Pointer to the open file object structure to be closed.</dd>
</dl>
</div>
@ -45,7 +45,7 @@ FRESULT f_close (
<div class="para desc">
<h4>Description</h4>
<p>The f_close 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 disk. 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 disk. After the function succeeded, the file object is no longer valid and it can be discarded.</p>
</div>

View File

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

View File

@ -13,12 +13,12 @@
<div class="para func">
<h2>disk_ioctl</h2>
<p>The disk_ioctl function cntrols device specified features and miscellaneous functions other than disk read/write.</p>
<p>The disk_ioctl function cntrols device specific features and miscellaneous functions other than generic read/write.</p>
<pre>
DRESULT disk_ioctl (
BYTE <em>Drive</em>, <span class="c">/* Drive number */</span>
BYTE <em>Command</em>, <span class="c">/* Control command code */</span>
void* <em>Buffer</em> <span class="c">/* Parameter and data buffer */</span>
BYTE <span class="arg">pdrv</span>, <span class="c">/* [IN] Drive number */</span>
BYTE <span class="arg">cmd</span>, <span class="c">/* [IN] Control command code */</span>
void* <span class="arg">buff</span> <span class="c">/* [I/O] Parameter and data buffer */</span>
);
</pre>
</div>
@ -26,12 +26,12 @@ DRESULT disk_ioctl (
<div class="para arg">
<h4>Parameters</h4>
<dl class="par">
<dt>Drive</dt>
<dt>pdrv</dt>
<dd>Specifies the drive number (0-9).</dd>
<dt>Command</dt>
<dt>cmd</dt>
<dd>Specifies the command code.</dd>
<dt>Buffer</dt>
<dd>Pointer to the parameter buffer depends on the command code. When it is not used, specify a NULL pointer.</dd>
<dt>buff</dt>
<dd>Pointer to the parameter buffer depends on the command code. Set NULL if not used.</dd>
</dl>
</div>
@ -44,7 +44,7 @@ DRESULT disk_ioctl (
<dt>RES_ERROR</dt>
<dd>Any error occured.</dd>
<dt>RES_PARERR</dt>
<dd>Invalid command code.</dd>
<dd>Invalid command code or parameter.</dd>
<dt>RES_NOTRDY</dt>
<dd>The disk drive has not been initialized.</dd>
</dl>
@ -57,10 +57,10 @@ DRESULT disk_ioctl (
<table class="lst">
<tr><th>Command</th><th>Description</th></tr>
<tr><td>CTRL_SYNC</td><td>Make sure that the disk drive has finished pending write process. When the disk I/O module has a write back cache, flush the dirty sector immediately. This command is not used in read-only configuration.</td></tr>
<tr><td>GET_SECTOR_SIZE</td><td>Returns sector size of the drive into the WORD variable pointed by <tt>Buffer</tt>. This command is not used in fixed sector size configuration, <tt>_MAX_SS</tt> is 512.</td></tr>
<tr><td>GET_SECTOR_COUNT</td><td>Returns number of available sectors on the drive into the DWORD variable pointed by <tt>Buffer</tt>. This command is used by only f_mkfs function to determine the volume size to be created.</td></tr>
<tr><td>GET_BLOCK_SIZE</td><td>Returns erase block size of the flash memory in unit of sector into the DWORD variable pointed by <tt>Buffer</tt>. The allowable value is 1 to 32768 in power of 2. Return 1 if the erase block size is unknown or disk devices. This command is used by only f_mkfs function and it attempts to align data area to the erase block boundary.</td></tr>
<tr><td>CTRL_ERASE_SECTOR</td><td>Erases a part of the flash memory specified by a DWORD array {&lt;start sector&gt;, &lt;end sector&gt;} pointed by <tt>Buffer</tt>. When this feature is not supported or not a flash memory media, this command has no effect. The FatFs does not check the result code and the file function is not affected even if the sectors are not erased well. This command is called on removing a cluster chain when <tt>_USE_ERASE</tt> is 1.</td></tr>
<tr><td>GET_SECTOR_SIZE</td><td>Returns sector size of the drive into the <tt>WORD</tt> variable pointed by <tt class="arg">buff</tt>. This command is not used in fixed sector size configuration, <tt>_MAX_SS</tt> is 512.</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> function to determine the volume size to be created.</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 1 to 32768 in power of 2. Return 1 if the erase block size is unknown or disk devices. 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>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 command set. When this feature is not supported or not a flash memory media, this command has no effect. The FatFs does not check the result code and the file function is not affected even if the sectors are not erased well. This command is called on removing a cluster chain when <tt>_USE_ERASE</tt> is 1.</td></tr>
</table>
</div>

View File

@ -16,10 +16,10 @@
<p>The disk_read function reads sector(s) from the disk drive.</p>
<pre>
DRESULT disk_read (
BYTE <em>Drive</em>, <span class="c">/* Physical drive number */</span>
BYTE* <em>Buffer</em>, <span class="c">/* Pointer to the read data buffer */</span>
DWORD <em>SectorNumber</em>, <span class="c">/* Start sector number */</span>
BYTE <em>SectorCount</em> <span class="c">/* Number of sectros to read */</span>
BYTE <span class="arg">pdrv</span>, <span class="c">/* [IN] Physical drive number */</span>
BYTE* <span class="arg">buff</span>, <span class="c">/* [OUT] Pointer to the read data buffer */</span>
DWORD <span class="arg">sector</span>, <span class="c">/* [IN] Start sector number */</span>
BYTE <span class="arg">count</span> <span class="c">/* [IN] Number of sectros to read */</span>
);
</pre>
</div>
@ -27,13 +27,13 @@ DRESULT disk_read (
<div class="para arg">
<h4>Parameters</h4>
<dl class="par">
<dt>Drive</dt>
<dt>pdrv</dt>
<dd>Specifies the physical drive number.</dd>
<dt>Buffer</dt>
<dt>buff</dt>
<dd>Pointer to the <em>byte array</em> to store the read data. The size of buffer must be in sector size * sector count.</dd>
<dt>SectorNumber</dt>
<dt>sector</dt>
<dd>Specifies the start sector number in logical block address (LBA).</dd>
<dt>SectorCount</dt>
<dt>count</dt>
<dd>Specifies number of sectors to read. The value can be 1 to 128. Generally, a multiple sector transfer request must not be split into single sector transactions to the device, or you may not get good read performance.</dd>
</dl>
</div>
@ -56,11 +56,11 @@ DRESULT disk_read (
<div class="para desc">
<h4>Description</h4>
<p>The specified memory address is not that always aligned to word boundary because the type of pointer is defined as BYTE. The misaligned read/write request can occure at <a href="appnote.html#fs1">direct transfer</a>. If the bus architecture, especially DMA controller, does not allow misaligned memory access, it should be solved in this function. There are some workarounds below to avoid this problem.</p>
<p>The memory address specified by <tt class="arg">buff</tt> is not that always aligned to word boundary because the type of argument is defined as <tt>BYTE*</tt>. The misaligned read/write request can occure at <a href="appnote.html#fs1">direct transfer</a>. If the bus architecture, especially DMA controller, does not allow misaligned memory access, it should be solved in this function. There are some workarounds described below to avoid this issue.</p>
<ul>
<li>In this function, convert word transfer to byte transfer. - Recommended.</li>
<li>On f_read(), avoid long read request that includes a whole of sector. - Direct transfer will never occure.</li>
<li>On f_read(), make sure that the lower two bits of start address is equal to the lower two bits of file read/write pointer. - Word aligned direct transfer is guaranteed.</li>
<li>Convert word transfer to byte transfer in this function. - Recommended.</li>
<li>For <tt>f_read()</tt>, avoid long read request that includes a whole of sector. - Direct transfer will never occure.</li>
<li>For <tt>f_read(fp, buff, btr, &amp;br)</tt>, make sure that <tt>(((UINT)buff &amp; 3) == (f_tell(fp) &amp; 3))</tt> is true. - Word aligned direct transfer is guaranteed.</li>
</ul>
</div>

View File

@ -16,7 +16,7 @@
<p>The disk_status function returns the current disk status.</p>
<pre>
DSTATUS disk_status (
BYTE <em>Drive</em> <span class="c">/* Physical drive number */</span>
BYTE <span class="arg">pdrv</span> <span class="c">/* [IN] Physical drive number */</span>
);
</pre>
</div>
@ -24,7 +24,7 @@ DSTATUS disk_status (
<div class="para arg">
<h4>Parameter</h4>
<dl class="par">
<dt>Drive</dt>
<dt>pdrv</dt>
<dd>Specifies the physical drive number to be confirmed.</dd>
</dl>
</div>
@ -35,11 +35,11 @@ DSTATUS disk_status (
<p>The disk status is returned in combination of following flags. FatFs refers only <tt>STA_NOINIT</tt> and <tt>STA_PROTECTED</tt>.</p>
<dl class="ret">
<dt>STA_NOINIT</dt>
<dd>Indicates that the disk drive is not initialized. This flag is set on system reset, media removal, media change and disk_initialize function failed. The flag is cleared on disk_initialize function succeeded. Media change that occurs asynchronously must be captured and reflect it to the status flags, or auto-mount feature will not work correctly. When media change detection is not supported, application program should clear the file system object with f_mount function after the media change.</dd>
<dd>Indicates that the disk drive is not initialized. This flag is set on system reset, media removal or failure of <tt>disk_initialize()</tt> function. It is cleared on <tt>disk_initialize()</tt> function succeeded. Media change that occurs asynchronously must be captured and reflect it to the status flags, or auto-mount feature will not work correctly. When media change detection feature is not supported, application program needs to de-initialize the file system object with <tt>f_mount()</tt> function after the media change.</dd>
<dt>STA_NODISK</dt>
<dd>Indicates that no medium in the drive. This is always cleared on fixed disk drive.</dd>
<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_PROTECTED</dt>
<dd>Indicates that the medium is write protected. This is always cleared on the drive that does not support write protect notch. Not valid while <tt>STA_NODISK</tt> is set.</dd>
<dd>Indicates that the medium is write protected. This is always cleared on the drive that does not support write protect notch. Not valid while no medium in the drive.</dd>
</dl>
</div>

View File

@ -16,10 +16,10 @@
<p>The disk_write writes sector(s) to the disk.</p>
<pre>
DRESULT disk_write (
BYTE <em>Drive</em>, <span class="c">/* Physical drive number */</span>
const BYTE* <em>Buffer</em>, <span class="c">/* Pointer to the write data (may be non aligned) */</span>
DWORD <em>SectorNumber</em>, <span class="c">/* Sector number to write */</span>
BYTE <em>SectorCount</em> <span class="c">/* Number of sectors to write */</span>
BYTE <span class="arg">drv</span>, <span class="c">/* [IN] Physical drive number */</span>
const BYTE* <span class="arg">buff</span>, <span class="c">/* [IN] Write data (may be non aligned) */</span>
DWORD <span class="arg">sector</span>, <span class="c">/* [IN] Sector number to write */</span>
BYTE <span class="arg">count</span> <span class="c">/* [IN] Number of sectors to write */</span>
);
</pre>
</div>
@ -27,13 +27,13 @@ DRESULT disk_write (
<div class="para arg">
<h4>Parameters</h4>
<dl class="par">
<dt>Drive</dt>
<dt>pdrv</dt>
<dd>Specifies the physical drive number.</dd>
<dt>Buffer</dt>
<dt>buff</dt>
<dd>Pointer to the <em>byte array</em> to be written.</dd>
<dt>SectorNumber</dt>
<dt>sector</dt>
<dd>Specifies the start sector number in logical block address (LBA).</dd>
<dt>SectorCount</dt>
<dt>count</dt>
<dd>Specifies the number of sectors to write. The value can be 1 to 128. Generally, a multiple sector transfer request must not be split into single sector transactions to the device, or you will never get good write performance.</dd>
</dl>
</div>
@ -58,7 +58,8 @@ DRESULT disk_write (
<div class="para desc">
<h4>Description</h4>
<p>This function is not required in read only configuration. The specified memory address is not that always aligned to word boundary because the type of pointer is defined as BYTE. For more information, read <a href="dread.html">description in disk_read function</a>.</p>
<p>This function is not required in read only configuration. 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, read <a href="dread.html">description in disk_read function</a>.</p>
<p><em>Application program MUST NOT call this function while FatFs is in use, or FAT structure on the volume can be corrapted.</em></p>
</div>

View File

@ -16,7 +16,7 @@
<p>The f_eof function tests for end-of-file on a file.</p>
<pre>
int f_eof (
FIL* <em>FileObject</em> <span class="c">/* File object */</span>
FIL* <span class="arg">fp</span> <span class="c">/* [IN] File object */</span>
);
</pre>
</div>
@ -25,7 +25,7 @@ int f_eof (
<div class="para arg">
<h4>Parameters</h4>
<dl class="par">
<dt>FileObject</dt>
<dt>fp</dt>
<dd>Pointer to the open file object structure.</dd>
</dl>
</div>
@ -33,13 +33,13 @@ int f_eof (
<div class="para ret">
<h4>Return Values</h4>
<p>The f_eof function returns a non-zero value if the read/write pointer has reached end of the file; otherwise it returns a zero.</p>
<p>The <tt>f_eof()</tt> function returns a non-zero value if the read/write pointer has reached end of the file; otherwise it returns a zero.</p>
</div>
<div class="para desc">
<h4>Description</h4>
<p>In this revision, the f_eof function is implemented as a macro.</p>
<p>In this revision, this function is implemented as a macro.</p>
<pre>
<span class="k">#define</span> f_eof(fp) (((fp)->fptr) == ((fp)->fsize) ? 1 : 0)
</pre>

View File

@ -16,7 +16,7 @@
<p>The f_error tests for an error on a file.</p>
<pre>
int f_error (
FIL* <em>FileObject</em> <span class="c">/* File object */</span>
FIL* <span class="arg">fp</span> <span class="c">/* [IN] File object */</span>
);
</pre>
</div>
@ -25,7 +25,7 @@ int f_error (
<div class="para arg">
<h4>Parameters</h4>
<dl class="par">
<dt>FileObject</dt>
<dt>fp</dt>
<dd>Pointer to the open file object structure.</dd>
</dl>
</div>
@ -39,7 +39,7 @@ int f_error (
<div class="para desc">
<h4>Description</h4>
<p>In this revision, the f_error function is implemented as a macro.</p>
<p>In this revision, this function is implemented as a macro.</p>
<pre>
<span class="k">#define</span> f_error(fp) (((fp)->flag & FA__ERROR) ? 1 : 0)
</pre>

View File

@ -22,7 +22,7 @@ DWORD get_fattime (void);
<div class="para ret">
<h4>Return Value</h4>
<p>Currnet time is returned with packed into a DWORD value. The bit field is as follows:</p>
<p>Currnet time is returned with packed into a <tt>DWORD</tt> value. The bit field is as follows:</p>
<dl class="ret">
<dt>bit31:25</dt>
<dd>Year from 1980 (0..127)</dd>
@ -42,7 +42,7 @@ DWORD get_fattime (void);
<div class="para desc">
<h4>Description</h4>
<p>The get_fattime function must return any valid time even if the system does not support a real time clock. If a zero is returned, the file will not have a valid time. This fucntion is not required in read only configuration.</p>
<p>The <tt>get_fattime()</tt> function must return any valid time even if the system does not support a real time clock. If a zero is returned, the file will not have a valid time. This fucntion is not required in read only configuration.</p>
</div>

View File

@ -16,9 +16,9 @@
<p>The f_fdisk fucntion divides a physical drive.</p>
<pre>
FRESULT f_fdisk (
BYTE <em>Drive</em>, <span class="c">/* Physical drive number */</span>
const DWORD <em>Partitions[]</em>, <span class="c">/* Partition size */</span>
void* <em>Work</em> <span class="c">/* Work area */</span>
BYTE <span class="arg">pdrv</span>, <span class="c">/* [IN] Physical drive number */</span>
const DWORD <em>part[]</em>, <span class="c">/* [IN] Partition size */</span>
void* <span class="arg">work</span> <span class="c">/* [IN] Work area */</span>
);
</pre>
</div>
@ -26,12 +26,12 @@ FRESULT f_fdisk (
<div class="para arg">
<h4>Parameters</h4>
<dl class="par">
<dt>Drive</dt>
<dt>pdrv</dt>
<dd>Specifies the <em>physical drive</em> to be divided.</dd>
<dt>Partitions[]</dt>
<dt>part[]</dt>
<dd>Partition map table. It must have four items.</dd>
<dt>Work</dt>
<dd>Pointer to the function work area. The size must be at least _MAX_SS bytes.</dd>
<dt>work</dt>
<dd>Pointer to the function work area. The size must be at least <tt>_MAX_SS</tt> bytes.</dd>
</dl>
</div>
@ -48,18 +48,18 @@ FRESULT f_fdisk (
<div class="para desc">
<h4>Description</h4>
<p>The f_fdisk function creates a partition table into the MBR of the physical drive. The partitioning rule is in generic FDISK format so that it can create upto four primary partitions. Extended partition is not supported. The Partitions[] specifies how to divide the physical drive. The first item specifies the size of first primary partition and fourth item specifies the fourth primary partition. If the value is less than or equal to 100, it means percentage of the partition in the entire disk space. If it is larger than 100, it means partition size in unit of sector.</p>
<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>
</div>
<div class="para comp">
<h4>QuickInfo</h4>
<p>Available when <tt>_FS_READOLNY == 0</tt>, <tt>_USE_MKFS == 1</tt> and <tt>_MULTI_PARTITION == 2</tt>.</p>
<p>Available when <tt>_FS_READOLNY == 0</tt>, <tt>_USE_MKFS == 1</tt> and <tt>_MULTI_PARTITION == 1</tt>.</p>
</div>
<div class="para use">
<h4>Example</h4>
<pre>
<span class="c">/* Volume management table defined by user (required when _MULTI_PARTITION != 0) */</span>
<span class="c">/* Volume management table defined by user (required when _MULTI_PARTITION == 1) */</span>
PARTITION VolToPart[] = {
{0, 1}, <span class="c">/* Logical drive 0 ==> Physical drive 0, 1st partition */</span>
@ -89,7 +89,7 @@ FRESULT f_fdisk (
<div class="para ref">
<h4>See Also</h4>
<p><tt><a href="filename.html#vol">Volume management</a>, <a href="mkfs.html">f_mkfs</a></tt></p>
<p><a href="filename.html#vol">Volume management</a>, <a href="mkfs.html"><tt>f_mkfs</tt></a></p>
</div>
<p class="foot"><a href="../00index_e.html">Return</a></p>

View File

@ -14,12 +14,12 @@
<div class="para" id="nam">
<h3>Format of the path names</h3>
<p>The path name format on the FatFs module is similer to the filename specs of DOS/Windos as follows:</p>
<p><tt>"[drive#:][/]directory/file"</tt></p>
<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 default drive (0 or current drive).</p>
<p>Control characters (\0 to \x1F) are recognized as end of the path name. Leading/embedded spaces in the path name are valid as a part of the name on LFN configuration but they are recognized as end of the path name on 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>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>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>
<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>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 on LFN configuration but they are recognized as end of the path name on 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>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>
<table class="lst2">
<tr><td>Path name</td><td>_FS_RPATH == 0</td><td>_FS_RPATH == 1</td></tr>
<tr class="lst3"><td>file.txt</td><td>A file in the root directory of the drive 0</td><td>A file in the current directory of the current drive</td></tr>
@ -40,11 +40,11 @@
<p><br></p>
<div class="para" id="uni">
<h3>Unicode API</h3>
<p>The path names are input/output in either ANSI/OEM code (SBCS/DBCS) or Unicode depends on the configuration options. The type of arguments that specifies the file names are defined as <tt>TCHAR</tt> which is an alias of <tt>char</tt> in default. The code set of the file name string is the ANSI/OEM code set specifid by <tt>_CODE_PAGE</tt>. When <tt>_LFN_UNICODE</tt> is set to 1 under LFN configuration, the type of the <tt>TCHAR</tt> is switched to <tt>unsigned short</tt> (UCS-2 character) to support Unicode. In this case, the LFN feature is fully supported and the Unicode specific characters, such as ✝☪✡☸☭, can also be used for the path name. It also affects data types and encoding of the string I/O functions. To define literal strings, <tt>_T(s)</tt> and <tt>_TEXT(s)</tt> macro are available to select either ANSI/OEM or Unicode automatically. The code shown below is an example to define the literal strings.</p>
<p>The path names are input/output in either ANSI/OEM code (SBCS/DBCS) or Unicode depends on the configuration options. The type of arguments that specifies the file names are defined as <tt>TCHAR</tt> which is an alias of <tt>char</tt> in default. The code set of the file name string is the ANSI/OEM code set specifid by <tt>_CODE_PAGE</tt>. When <tt>_LFN_UNICODE</tt> is set to 1, the type of the <tt>TCHAR</tt> is switched to <tt>WCHAR, unsigned short</tt> (UCS-2 character) to support Unicode. In this case, the LFN feature is fully supported and the Unicode specific characters, such as ✝☪✡☸☭, can also be used for the path name. It also affects data types and encoding of the string I/O functions. To define literal strings, <tt>_T(s)</tt> and <tt>_TEXT(s)</tt> macro are available to select either ANSI/OEM or Unicode automatically. The code shown below is an example to define the literal strings.</p>
<pre>
f_open(fp, "filename.txt", FA_READ); <span class="c">/* ANSI/OEM only */</span>
f_open(fp, L"filename.txt", FA_READ); <span class="c">/* Unicode only */</span>
f_open(fp, _T("filename.txt"), FA_READ); <span class="c">/* Changed automatically */</span>
f_open(fp, _T("filename.txt"), FA_READ); <span class="c">/* Changed by configuration */</span>
</pre>
</div>
@ -63,6 +63,7 @@ PARTITION VolToPart[] = {
{1, 0} <span class="c">/* Logical drive 3 ==> Physical drive 1 (auto detection) */</span>
};
</pre>
<img src="../img/f7.png" width="828" height="288" alt="relationship between logical drive and physical drive">
<p>There are some considerations when use <tt>_MULTI_PARTITION</tt> configuration.</p>
<ul>
<li>Only four pri-partitions can be mounted. Extended partition is not supported.</li>

View File

@ -16,10 +16,10 @@
<p>The f_forward function reads the file data and forward it to the data streaming device.</p>
<pre>
FRESULT f_forward (
FIL* <em>FileObject</em>, <span class="c">/* File object */</span>
UINT (*<em>Func</em>)(const BYTE*,UINT), <span class="c">/* Data streaming function */</span>
UINT <em>ByteToFwd</em>, <span class="c">/* Number of bytes to forward */</span>
UINT* <em>ByteFwd</em> <span class="c">/* Number of bytes forwarded */</span>
FIL* <span class="arg">fp</span>, <span class="c">/* [IN] File object */</span>
UINT (*<span class="arg">func</span>)(const BYTE*,UINT), <span class="c">/* [IN] Data streaming function */</span>
UINT <span class="arg">btf</span>, <span class="c">/* [IN] Number of bytes to forward */</span>
UINT* <span class="arg">bf</span> <span class="c">/* [OUT] Number of bytes forwarded */</span>
);
</pre>
</div>
@ -27,14 +27,14 @@ FRESULT f_forward (
<div class="para arg">
<h4>Parameters</h4>
<dl class="par">
<dt>FileObject</dt>
<dt>fp</dt>
<dd>Pointer to the open file object.</dd>
<dt>Func</dt>
<dt>func</dt>
<dd>Pointer to the user-defined data streaming function. For details, refer to the sample code.</dd>
<dt>ByteToFwd</dt>
<dd>Number of bytes to forward in range of UINT.</dd>
<dt>ByteFwd</dt>
<dd>Pointer to the UINT variable to return number of bytes forwarded.</dd>
<dt>btf</dt>
<dd>Number of bytes to forward in range of <tt>UINT</tt>.</dd>
<dt>bf</dt>
<dd>Pointer to the <tt>UINT</tt> variable to return number of bytes forwarded.</dd>
</dl>
</div>
@ -54,7 +54,7 @@ FRESULT f_forward (
<div class="para desc">
<h4>Description</h4>
<p>The f_forward function reads the data from the file and forward it to the outgoing stream without data buffer. This is suitable for small memory system because it does not require any data buffer at application module. The file pointer of the file object increases in number of bytes forwarded. In case of <tt>*ByteFwd &lt; ByteToFwd</tt> without error, it means the requested bytes could not be transferred due to end of file or stream goes busy during data transfer.</p>
<p>The <tt>f_forward()</tt> function reads the data from the file and forward it to the outgoing stream without data buffer. This is suitable for small memory system because it does not require any data buffer at application module. The file pointer of the file object increases in number of bytes forwarded. In case of <tt class="arg">*bf</tt> is less than <tt class="arg">btf</tt> without error, it means the requested bytes could not be transferred due to end of file or stream goes busy during data transfer.</p>
</div>

View File

@ -16,8 +16,8 @@
<p>The f_getcwd function retrieves the current directory.</p>
<pre>
FRESULT f_getcwd (
TCHAR* <em>Buffer</em>, <span class="c">/* Pointer to the buffer */</span>
UINT <em>BufferLen</em> <span class="c">/* The length of the buffer */</span>
TCHAR* <span class="arg">buff</span>, <span class="c">/* [OUT] Buffer to return path name */</span>
UINT <span class="arg">len</span> <span class="c">/* [IN] The length of the buffer */</span>
);
</pre>
</div>
@ -25,9 +25,9 @@ FRESULT f_getcwd (
<div class="para arg">
<h4>Parameters</h4>
<dl class="par">
<dt>Buffer</dt>
<dt>buff</dt>
<dd>Pointer to the buffer to receive the current directory string.</dd>
<dt>BufferLen</dt>
<dt>len</dt>
<dd>Size of the buffer in unit of TCHAR.</dd>
</dl>
</div>
@ -50,7 +50,7 @@ FRESULT f_getcwd (
<div class="para desc">
<h4>Description</h4>
<p>The f_getcwd function retrieves the current directory of the current drive in full path string including drive number.</p>
<p>The <tt>f_getcwd()</tt> function retrieves the current directory of the current drive in full path string including drive number.</p>
</div>

View File

@ -16,9 +16,9 @@
<p>The f_getfree function gets number of the free clusters.</p>
<pre>
FRESULT f_getfree (
const TCHAR* <em>Path</em>, <span class="c">/* Logical drive number */</span>
DWORD* <em>Clusters</em>, <span class="c">/* Pointer to the variable to store number of free clusters */</span>
FATFS** <em>FileSystemObject</em> <span class="c">/* Pointer to pointer to file system object */</span>
const TCHAR* <span class="arg">path</span>, <span class="c">/* [IN] Logical drive number */</span>
DWORD* <span class="arg">nclst</span>, <span class="c">/* [OUT] Number of free clusters */</span>
FATFS** <span class="arg">fatfs</span> <span class="c">/* [OUT] Corresponding file system object */</span>
);
</pre>
</div>
@ -26,11 +26,11 @@ FRESULT f_getfree (
<div class="para arg">
<h4>Parameters</h4>
<dl class="par">
<dt>Path</dt>
<dd>Pinter to the null-terminated string that specifies the <a href="filename.html">logical drive</a>.</dd>
<dt>Clusters</dt>
<dd>Pointer to the DWORD variable to store number of free clusters.</dd>
<dt>FileSystemObject</dt>
<dt>path</dt>
<dd>Pinter to the null-terminated string that specifies the <a href="filename.html">logical drive</a>. A null-string means the current drive.</dd>
<dt>nclst</dt>
<dd>Pointer to the <tt>DWORD</tt> variable to store number of free clusters.</dd>
<dt>fatfs</dt>
<dd>Pointer to pointer that to store a pointer to the corresponding file system object.</dd>
</dl>
</div>
@ -53,7 +53,7 @@ FRESULT f_getfree (
<div class="para desc">
<h4>Descriptions</h4>
<p>The f_getfree function gets number of free clusters on the drive. The member <tt>csize</tt> in the file system object is refrecting number of sectors per cluster, so that the free space in unit of sector can be calcurated with this. When FSInfo structure on FAT32 volume is not in sync, this function can return an incorrect free cluster count.</p>
<p>The <tt>f_getfree()</tt> function gets number of free clusters on the drive. The member <tt>csize</tt> in the file system object is refrecting number of sectors per cluster, so that the free space in unit of sector can be calcurated with this. When FSInfo structure on FAT32 volume is not in sync, this function can return an incorrect free cluster count.</p>
</div>
@ -78,10 +78,9 @@ FRESULT f_getfree (
tot_sect = (fs->n_fatent - 2) * fs->csize;
fre_sect = fre_clust * fs->csize;
<span class="c">/* Print free space in unit of KB (assuming 512 bytes/sector) */</span>
printf("%lu KB total drive space.\n"
"%lu KB available.\n",
fre_sect / 2, tot_sect / 2);
<span class="c">/* Print free space in unit of KiB (assuming 512 bytes/sector) */</span>
printf("%lu KB total drive space.\n%lu KB available.\n",
tot_sect / 2, fre_sect / 2);
</pre>
</div>

82
doc/en/getlabel.html Normal file
View File

@ -0,0 +1,82 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<meta http-equiv="Content-Style-Type" content="text/css">
<link rel="up" title="FatFs" href="../00index_e.html">
<link rel="alternate" hreflang="ja" title="Japanese" href="../ja/getlabel.html">
<link rel="stylesheet" href="../css_e.css" type="text/css" media="screen" title="ELM Default">
<title>FatFs - f_getlabel</title>
</head>
<body>
<div class="para func">
<h2>f_getlabel</h2>
<p>The f_getlabel function returns volume label and volume serial number of a drive.</p>
<pre>
FRESULT f_getlabel (
const TCHAR* <span class="arg">path</span>, <span class="c">/* [IN] Path name */</span>
TCHAR* <span class="arg">buff</span>, <span class="c">/* [OUT] Volume label */</span>
DWORD* <span class="arg">sn</span> <span class="c">/* [OUT] Volume serial number */</span>
);
</pre>
</div>
<div class="para arg">
<h4>Parameters</h4>
<dl class="par">
<dt>path</dt>
<dd>Pointer to the nul-terminated string specifying the logical drive. Null-string specifies the default drive.</dd>
<dt>buff</dt>
<dd>Pointer to the buffer to store the volume label. The buffer size must be at least 12 items. If no volume label, a nul-string will be returned. Set null pointer if this information is not needed.</dd>
<dt>sn</dt>
<dd>Pointer to the <tt>DWORD</tt> variable to store the volume serial number. Set null pointer if this information is not needed.</dd>
</dl>
</div>
<div class="para ret">
<h4>Return Values</h4>
<p>
<a href="rc.html#ok">FR_OK</a>,
<a href="rc.html#de">FR_DISK_ERR</a>,
<a href="rc.html#ie">FR_INT_ERR</a>,
<a href="rc.html#nr">FR_NOT_READY</a>,
<a href="rc.html#id">FR_INVALID_DRIVE</a>,
<a href="rc.html#ne">FR_NOT_ENABLED</a>,
<a href="rc.html#ns">FR_NO_FILESYSTEM</a>,
<a href="rc.html#tm">FR_TIMEOUT</a>
</p>
</div>
<div class="para comp">
<h4>QuickInfo</h4>
<p>Available when <tt>_USE_LABEL == 1</tt>.</p>
</div>
<div class="para use">
<h4>Example</h4>
<pre>
char str[12];
<span class="c">/* Get volume label of the default drive */</span>
f_getlabel("", str, 0);
<span class="c">/* Get volume label of the drive 2 */</span>
f_getlabel("2:", str, 0);
</pre>
</div>
<div class="para ref">
<h4>See Also</h4>
<tt><a href="setlabel.html">f_setlabel</a></tt>
</div>
<p class="foot"><a href="../00index_e.html">Return</a></p>
</body>
</html>

View File

@ -16,9 +16,9 @@
<p>The f_gets reads a string from the file.</p>
<pre>
TCHAR* f_gets (
TCHAR* <em>Str</em>, <span class="c">/* Read buffer */</span>
int <em>Size</em>, <span class="c">/* Size of the read buffer */</span>
FIL* <em>FileObject</em> <span class="c">/* File object */</span>
TCHAR* <span class="arg">buff</span>, <span class="c">/* [OUT] Read buffer */</span>
int <span class="arg">len</span>, <span class="c">/* [IN] Size of the read buffer */</span>
FIL* <span class="arg">fp</span> <span class="c">/* [IN] File object */</span>
);
</pre>
</div>
@ -26,11 +26,11 @@ TCHAR* f_gets (
<div class="para arg">
<h4>Parameters</h4>
<dl class="par">
<dt>Str</dt>
<dt>buff</dt>
<dd>Pointer to read buffer to store the read string.</dd>
<dt>Size</dt>
<dt>len</dt>
<dd>Size of the read buffer in unit of character.</dd>
<dt>FileObject</dt>
<dt>fp</dt>
<dd>Pointer to the open file object structure.</dd>
</dl>
</div>
@ -38,14 +38,14 @@ TCHAR* f_gets (
<div class="para ret">
<h4>Return Values</h4>
<p>When the function succeeded, <tt>Str</tt> will be returuned.</p>
<p>When the function succeeded, <tt class="arg">buff</tt> will be returuned.</p>
</div>
<div class="para desc">
<h4>Description</h4>
<p>The f_gets() is a wrapper function of <a href="read.html">f_read()</a>. The read operation continues until a <tt>'\n'</tt> is stored, reached end of the file or the buffer is filled with <tt>Size - 1</tt> characters. The read string is terminated with a <tt>'\0'</tt>. When no character to read or any error occured during read operation, f_gets() returns a null pointer. The end of file and error status can be examined with <tt>f_eof()</tt> and <tt>f_error()</tt> macros.</p>
<p>When the FatFs is configured to Unicode API (<tt>_LFN_UNICODE == 1</tt>), the file is read in UTF-8 encoding and stored it to the buffer in UCS-2. If not the case, the file will be read in one byte per character without any code conversion.</p>
<p>The <tt>f_gets()</tt> function is a wrapper function of <a href="read.html">f_read()</a> function. The read operation continues until a <tt>'\n'</tt> is stored, reached end of the file or the buffer is filled with <tt>len - 1</tt> characters. The read string is terminated with a <tt>'\0'</tt>. When no character to read or any error occured during read operation, it returns a null pointer. The status of eof and error can be examined with <tt>f_eof()</tt> and <tt>f_error()</tt> macros.</p>
<p>When the FatFs is configured to Unicode API (<tt>_LFN_UNICODE == 1</tt>), the file is read in assumption of UTF-8 encoding and stored it to the buffer in UCS-2. If not the case, the file will be read in one byte per character without any code conversion.</p>
</div>

View File

@ -17,8 +17,8 @@
<pre>
FRESULT f_lseek (
FIL* <em>FileObject</em>, <span class="c">/* Pointer to the file object structure */</span>
DWORD <em>Offset</em> <span class="c">/* File offset in unit of byte */</span>
FIL* <span class="arg">fp</span>, <span class="c">/* [IN] File object */</span>
DWORD <span class="arg">ofs</span> <span class="c">/* [IN] File read/write pointer */</span>
);
</pre>
</div>
@ -26,10 +26,10 @@ FRESULT f_lseek (
<div class="para arg">
<h4>Parameters</h4>
<dl class="par">
<dt>FileObject</dt>
<dt>fp</dt>
<dd>Pointer to the open file object.</dd>
<dt>Offset</dt>
<dd>Number of bytes where from start of the file</dd>
<dt>ofs</dt>
<dd>Byte offset from top of the file.</dd>
</dl>
</div>
@ -49,13 +49,13 @@ FRESULT f_lseek (
<div class="para desc">
<h4>Description</h4>
<p>The f_lseek function moves the file read/write pointer of an open file. The offset can be specified in only origin from top of the file. When an offset above the file size is specified in write mode, the file size is increased to the offset and the data in the expanded area is undefined. This is suitable to create a large file quickly, for fast write operation. After the f_lseek function succeeded, 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 above the file size is specified in write mode, the file size is increased to the offset and the data in the expanded area is undefined. This is suitable to create a large file quickly, for fast write operation. After the <tt>f_lseek()</tt> function succeeded, the current read/write pointer should be checked in order to make sure the read/write pointer was moved correctry. In case of the current read/write pointer is not the expected value, either of followings has been occured.</p>
<ul>
<li>End of file. The specified Offset was clipped at end of the file because the file has been opened in read-only mode.</li>
<li>Disk full. There is insufficient free space on the volume to expand the file size.</li>
<li>End of file. The specified <tt class="arg">ofs</tt> was clipped at end of the file because the file is in read-only mode.</li>
<li>Disk full. There is insufficient free space on the volume to expand the file.</li>
</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 cluster link map table (CLMT) stored in the user defined table. It is also applied to f_read/f_write functions. In this mode, the file size cannot be increased by f_write/f_lseek functions.</p>
<p>The CLMT must be created in the user defined DWORD array prior to use fast seek feature. To create the CLMT, set pointer to the DWORD array to the member <tt>cltbl</tt> in the file object, set the array size in unit of items into the first item and call the f_lseek function with <tt>Offset = CREATE_LINKMAP</tt>. After the function succeeded and CLMT is created, no FAT access is occured in subsequent f_read/f_write/f_lseek functions to the file. If the function failed with <tt>FR_NOT_ENOUGH_CORE</tt>, the given array size is insufficient for the file and the required items is returned into the first item of the array. The required array size is (number of fragments + 1) * 2 items. For example, when the file is fragmented in 5, 12 items will be required for the CLMT. </p>
<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 cluster link map table (CLMT). It is also applied to <tt>f_read()/f_write()</tt> functions. In this mode, the file cannot be expanded by <tt>f_write()/f_lseek()</tt> functions.</p>
<p>The CLMT must be created in the user defined <tt>DWORD</tt> array prior to use fast seek feature. To create the CLMT, set pointer to 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> functions to the file. If the function failed with <tt>FR_NOT_ENOUGH_CORE</tt>, the given array size is insufficient for the file and 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>
@ -69,53 +69,52 @@ FRESULT f_lseek (
<h4>Example</h4>
<pre>
<span class="c">/* Open file */</span>
file = malloc(sizeof (FIL));
if (!file) ...
res = f_open(file, "file.dat", FA_READ|FA_WRITE);
fp = malloc(sizeof (FIL));
res = f_open(fp, "file.dat", FA_READ|FA_WRITE);
if (res) ...
<span class="c">/* Move to offset of 5000 from top of the file */</span>
res = f_lseek(file, 5000);
res = f_lseek(fp, 5000);
<span class="c">/* Move to end of the file to append data */</span>
res = f_lseek(file, f_size(file));
res = f_lseek(fp, f_size(fp));
<span class="c">/* Forward 3000 bytes */</span>
res = f_lseek(file, f_tell(file) + 3000);
res = f_lseek(fp, f_tell(fp) + 3000);
<span class="c">/* Rewind 2000 bytes (take care on overflow) */</span>
res = f_lseek(file, f_tell(file) - 2000);
res = f_lseek(fp, f_tell(fp) - 2000);
</pre>
<pre>
<span class="c">/* Cluster pre-allocation (to prevent buffer overrun on streaming write) */</span>
res = f_open(file, recfile, FA_CREATE_NEW | FA_WRITE); <span class="c">/* Create a file */</span>
res = f_open(fp, recfile, FA_CREATE_NEW | FA_WRITE); <span class="c">/* Create a file */</span>
res = f_lseek(file, PRE_SIZE); <span class="c">/* Expand file size (cluster pre-allocation) */</span>
if (res || f_tell(file) != PRE_SIZE) ... <span class="c">/* Check if the file has been expanded */</span>
res = f_lseek(fp, PRE_SIZE); <span class="c">/* Expand file size (cluster pre-allocation) */</span>
if (res || f_tell(fp) != PRE_SIZE) ... <span class="c">/* Check if the file has been expanded */</span>
res = f_lseek(file, DATA_START); <span class="c">/* Record data stream WITHOUT cluster allocation delay */</span>
res = f_lseek(fp, DATA_START); <span class="c">/* Record data stream WITHOUT cluster allocation delay */</span>
... <span class="c">/* DATA_START and write block size should be aligned to sector boundary */</span>
res = f_truncate(file); <span class="c">/* Truncate unused area */</span>
res = f_lseek(file, 0); <span class="c">/* Put file header */</span>
res = f_truncate(fp); <span class="c">/* Truncate unused area */</span>
res = f_lseek(fp, 0); <span class="c">/* Put file header */</span>
...
res = f_close(file);
res = f_close(fp);
</pre>
<pre>
<span class="c">/* Using fast seek feature */</span>
DWORD lktbl[SZ_TBL]; <span class="c">/* Link map table buffer */</span>
res = f_lseek(file, ofs1); <span class="c">/* This is normal seek (file.cltbl is nulled on file open) */</span>
res = f_lseek(fp, ofs1); <span class="c">/* This is normal seek (cltbl member is nulled on file open) */</span>
file.cltbl = lktbl; <span class="c">/* Enable fast seek feature */</span>
fp-&gt;cltbl = lktbl; <span class="c">/* Enable fast seek feature (cltbl != NULL) */</span>
lktbl[0] = SZ_TBL; <span class="c">/* Set table size */</span>
res = f_lseek(file, CREATE_LINKMAP); <span class="c">/* Create CLMT */</span>
res = f_lseek(fp, CREATE_LINKMAP); <span class="c">/* Create CLMT */</span>
...
res = f_lseek(file, ofs2); <span class="c">/* This is fast seek (file.cltbl != NULL) */</span>
res = f_lseek(fp, ofs2); <span class="c">/* This is fast seek */</span>
</pre>
</div>

View File

@ -16,7 +16,7 @@
<p>The f_mkdir function creates a new directory.</p>
<pre>
FRESULT f_mkdir (
const TCHAR* <em>DirName</em> <span class="c">/* Pointer to the directory name */</span>
const TCHAR* <span class="arg">path</span> <span class="c">/* [IN] Directory name */</span>
);
</pre>
</div>
@ -24,7 +24,7 @@ FRESULT f_mkdir (
<div class="para arg">
<h4>Parameter</h4>
<dl class="par">
<dt>DirName</dt>
<dt>path</dt>
<dd>Pointer to the null-terminated string that specifies the <a href="filename.html">directory name</a> to create. </dd>
</dl>
</div>
@ -53,7 +53,7 @@ FRESULT f_mkdir (
<div class="para desc">
<h4>Description</h4>
<p>The f_mkdir function creates a new directory.</p>
<p>This function creates a new directory.</p>
</div>

View File

@ -16,9 +16,9 @@
<p>The f_mkfs fucntion creates an FAT file system on the logical drive.</p>
<pre>
FRESULT f_mkfs (
BYTE <em>Drive</em>, <span class="c">/* Logical drive number */</span>
BYTE <em>PartitioningRule</em>, <span class="c">/* Partitioning rule */</span>
UINT <em>AllocSize</em> <span class="c">/* Size of the allocation unit */</span>
BYTE <span class="arg">vol</span>, <span class="c">/* [IN] Logical drive number */</span>
BYTE <span class="arg">sfd</span>, <span class="c">/* [IN] Partitioning rule */</span>
UINT <span class="arg">au</span> <span class="c">/* [IN] Size of the allocation unit */</span>
);
</pre>
</div>
@ -26,12 +26,12 @@ FRESULT f_mkfs (
<div class="para arg">
<h4>Parameters</h4>
<dl class="par">
<dt>Drive</dt>
<dd>Logical drive number (0-9) to be formatted.</dd>
<dt>PartitioningRule</dt>
<dd>Specifies partitioning rule, FDISK(0) or SFD(1). This argument is ignored on some case.</dd>
<dt>AllocSize</dt>
<dd>Force the allocation unit (cluter) size in unit of byte. The value must be power of 2 and between the sector size and 128 * sector size. When a zero is given, the cluster size is determined depends on the volume size.</dd>
<dt>vol</dt>
<dd>Logical drive number to be formatted. (0 to <tt>_VOLUMES - 1</tt>)</dd>
<dt>sfd</dt>
<dd>Specifies partitioning rule (FDISK(0) or SFD(1)). This argument is ignored on some case.</dd>
<dt>au</dt>
<dd>Force the size of allocation unit (cluter) in unit of byte. The value must be sector size * n (n = 1 to 128 and power of 2). When a zero is given, the cluster size is determined depends on the volume size.</dd>
</dl>
</div>
@ -51,11 +51,11 @@ FRESULT f_mkfs (
<div class="para desc">
<h4>Description</h4>
<p>The f_mkfs function creates an FAT volume on the logical drive. When FDISK is specified, a primary partition occupies the entire disk space is created and then an FAT volume is created on the partition. When SFD is specified, the FAT volume starts from the first sector of the physical drive.</p>
<p>If the logical drive is being bound to any partition (1-4) by multiple partition feature <tt>(_MULTI_PARTITION)</tt>, the FAT volume is created into the specified partition. In this case, the second argument is ignored. The physical drive must be partitioned with f_fdisk function or any other partitioning tool prior to use this function.</p>
<p>Note that there are two partitioning rules, FDISK and SFD. The FDISK format is usually used for harddisk, MMC, SDC and CFC. It can divide a physical drive into one or more partitions with a partition table on the MBR. The SFD format is non-partitioned method. The FAT volume starts from the first sector on the physical drive without partition table. It is used for floppy disk, Microdrive, optical disk and super-floppy media.</p>
<p>The <tt>f_mkfs()</tt> function creates an FAT volume on the logical drive. When FDISK format is specified, a primary partition occupies the entire disk space is created and then an FAT volume is created on the partition. When SFD format is specified, the FAT volume starts from the first sector of the physical drive.</p>
<p>If the logical drive is being bound to any partition (1-4) by multiple partition feature (<tt>_MULTI_PARTITION</tt>), the FAT volume is created into the specified partition. In this case, the second argument <tt class="arg">sfd</tt> is ignored. The physical drive must have been partitioned with f_fdisk function or any other partitioning tool prior to use this function.</p>
<p>Note that there are two partitioning rules, FDISK and SFD. The FDISK partitioning is usually used for harddisk, MMC, SDC and CFC. It can divide a physical drive into one or more partitions with a partition table on the MBR. However Windows does not support multiple partition on the removable media. The SFD is non-partitioned method. The FAT volume starts from the first sector on the physical drive without partition table. It is used for floppy disk, Microdrive, optical disk and super-floppy media.</p>
<p>The FAT sub-type, FAT12/FAT16/FAT32, is determined by number of clusters on the volume and nothing else, according to the FAT specification issued by Microsoft. Thus which FAT sub-type is selected, is depends on the volume size and the specified cluster size. The cluster size affects performance of the file system and large cluster increases the performance.</p>
<p>When the number of clusters gets near the FAT sub-type boundaries, the function can fail with FR_MKFS_ABORTED.</p>
<p>When the number of clusters gets near the FAT sub-type boundaries, the function can fail with <tt>FR_MKFS_ABORTED</tt>.</p>
</div>
<div class="para comp">

View File

@ -13,11 +13,11 @@
<div class="para func">
<h2>f_mount</h2>
<p>The f_mount fucntion registers/unregisters a work area to the FatFs module.</p>
<p>The f_mount fucntion registers/unregisters file system object (work area) to the FatFs module.</p>
<pre>
FRESULT f_mount (
BYTE <em>Drive</em>, <span class="c">/* Logical drive number */</span>
FATFS* <em>FileSystemObject</em> <span class="c">/* Pointer to the work area */</span>
BYTE <span class="arg">vol</span>, <span class="c">/* [IN] Logical drive number */</span>
FATFS* <span class="arg">fatfs</span> <span class="c">/* [IN] File system object */</span>
);
</pre>
</div>
@ -25,10 +25,10 @@ FRESULT f_mount (
<div class="para arg">
<h4>Parameters</h4>
<dl class="par">
<dt>Drive</dt>
<dd>Logical drive number (0-9) to register/unregister the work area.</dd>
<dt>FileSystemObject</dt>
<dd>Pointer to the work area (file system object) to be registered.</dd>
<dt>vol</dt>
<dd>Logical drive number to register/unregister file system object. (0 to <tt>_VOLUMES - 1</tt>)</dd>
<dt>fatfs</dt>
<dd>Pointer to the file system object to be registered. Null pointer unregisters the registered file system object.</dd>
</dl>
</div>
@ -43,8 +43,13 @@ FRESULT f_mount (
<div class="para desc">
<h4>Description</h4>
<p>The f_mount function registers/unregisters a work area to the FatFs module. The work area must be given to the each volume with this function prior to use any other file function. To unregister a work area, specify a NULL to the <em>FileSystemObject</em>, and then the work area can be discarded.</p>
<p>This function always succeeds regardless of the drive status. No media access is occured in this function. It only clears the given work area and registers its address to the internal table. The volume mount process is performed on first file access after f_mount function or media change.</p>
<p>The <tt>f_mount()</tt> function registers/unregisters a file system object to the FatFs module. 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>This function always succeeds regardless of the physical drive status. No media access is occured in this function. It only de-initializes the given work area and registers its address to the internal table. It can also be used to force de-initialized the registered work area of a logical drive. The volume mount process, initialize the corresponding physical drive, find the FAT volume in it and initialize the work area, is performed when either or both of following condition is true:</p>
<ul>
<li>File system object is not initialized. (by <tt>f_mount()</tt>)</li>
<li>Physical drive is not initialized. (by system reset or media removal)</li>
</ul>
<p>If the disk I/O layer does not detect media change, application program needs to perform <tt>f_mount()</tt> every media change.</p>
</div>

View File

@ -16,9 +16,9 @@
<p>The f_open function creates a <em>file object</em> to be used to access the file.</p>
<pre>
FRESULT f_open (
FIL* <em>FileObject</em>, <span class="c">/* Pointer to the blank file object structure */</span>
const TCHAR* <em>FileName</em>, <span class="c">/* Pointer to the file neme */</span>
BYTE <em>ModeFlags</em> <span class="c">/* Mode flags */</span>
FIL* <span class="arg">fp</span>, <span class="c">/* [OUT] File object structure */</span>
const TCHAR* <span class="arg">path</span>, <span class="c">/* [IN] File name */</span>
BYTE <span class="arg">mode</span> <span class="c">/* [IN] Mode flags */</span>
);
</pre>
</div>
@ -26,11 +26,11 @@ FRESULT f_open (
<div class="para arg">
<h4>Parameters</h4>
<dl class="par">
<dt>FileObject</dt>
<dt>fp</dt>
<dd>Pointer to the file object structure to be created.</dd>
<dt>FileName</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>
<dt>ModeFlags</dt>
<dt>mode</dt>
<dd>Specifies the type of access and open method for the file. It is specified by a combination of following flags.<br>
<table class="lst">
<tr><th>Value</th><th>Description</th></tr>
@ -38,7 +38,7 @@ FRESULT f_open (
<tr><td>FA_WRITE</td><td>Specifies write access to the object. Data can be written to the file. Combine with <tt>FA_READ</tt> for read-write access.</td></tr>
<tr><td>FA_OPEN_EXISTING</td><td>Opens the file. The function fails if the file is not existing. (Default)</td></tr>
<tr><td>FA_OPEN_ALWAYS</td><td>Opens the file if it is existing. If not, a new file is created.<br>
To append data to the file, use <a href="lseek.html">f_lseek</a> function after file open in this method.</td></tr>
To append data to the file, use <a href="lseek.html"><tt>f_lseek()</tt></a> function after file open in this method.</td></tr>
<tr><td>FA_CREATE_NEW</td><td>Creates a new file. The function fails with <tt>FR_EXIST</tt> if the file is existing.</td></tr>
<tr><td>FA_CREATE_ALWAYS</td><td>Creates a new file. If the file is existing, it is truncated and overwritten.</td></tr>
</table>
@ -59,6 +59,7 @@ To append data to the file, use <a href="lseek.html">f_lseek</a> function after
<a href="rc.html#in">FR_INVALID_NAME</a>,
<a href="rc.html#de">FR_DENIED</a>,
<a href="rc.html#ex">FR_EXIST</a>,
<a href="rc.html#io">FR_INVALID_OBJECT</a>,
<a href="rc.html#wp">FR_WRITE_PROTECTED</a>,
<a href="rc.html#id">FR_INVALID_DRIVE</a>,
<a href="rc.html#ne">FR_NOT_ENABLED</a>,
@ -73,9 +74,9 @@ To append data to the file, use <a href="lseek.html">f_lseek</a> function after
<div class="para desc">
<h4>Description</h4>
<p>After f_open function succeeded, the file object is valid. The file object is used for subsequent read/write functions to identify the file. When close an open file object, use <a href="close.html">f_close</a> function. If the modified file is not closed, the file data can be collapsed.</p>
<p>If duplicated file open is needed, read <a href="appnote.html#dup">here</a> carefully. However duplicated open of a file with write mode flags is always prohibited.</p>
<p>Before using any file function, a work area (file system object) must be registered to the logical drive with <a href="mount.html">f_mount</a> function. All API functions except for <a href="fdisk.html">f_fdisk</a> function can work after this procedure.</p>
<p>After <tt>f_open()</tt> function succeeded, the file object is valid. The file object is used for subsequent read/write functions to identify the file. To close an open file, use <a href="close.html"><tt>f_close()</tt></a> function. If the file is modified and not closed properly, the file data will be collapted.</p>
<p>If duplicated file open is needed, read <a href="appnote.html#dup">here</a> carefully. However duplicated open of a file with write mode flag is always prohibited.</p>
<p>Before using any file function, a work area (file system object) must be registered to the logical drive with <a href="mount.html"><tt>f_mount()</tt></a> function. All API functions except for <a href="fdisk.html"><tt>f_fdisk()</tt></a> function can work after this procedure.</p>
</div>

View File

@ -16,8 +16,8 @@
<p>The f_opendir function opens a directory.</p>
<pre>
FRESULT f_opendir (
DIR* <em>DirObject</em>, <span class="c">/* Pointer to the blank directory object structure */</span>
const TCHAR* <em>DirName</em> <span class="c">/* Pointer to the directory name */</span>
DIR* <span class="arg">dj</span>, <span class="c">/* [OUT] Blank directory object */</span>
const TCHAR* <span class="arg">path</span> <span class="c">/* [IN] Directory name */</span>
);
</pre>
</div>
@ -25,9 +25,9 @@ FRESULT f_opendir (
<div class="para arg">
<h4>Parameters</h4>
<dl class="par">
<dt>DirObject</dt>
<dt>dj</dt>
<dd>Pointer to the blank directory object to be created.</dd>
<dt>DirName</dt>
<dt>path</dt>
<dd>Pinter to the null-terminated string that specifies the <a href="filename.html">directory name</a> to be opened.</dd>
</dl>
</div>
@ -53,7 +53,7 @@ FRESULT f_opendir (
<div class="para desc">
<h4>Description</h4>
<p>The f_opendir function opens an exsisting directory and creates the directory object for subsequent calls. The directory object structure can be discarded at any time without any procedure.</p>
<p>The <tt>f_opendir()</tt> function opens an exsisting directory and creates the directory object for subsequent calls. The directory object structure can be discarded at any time without any procedure.</p>
</div>

View File

@ -16,8 +16,8 @@
<p>The f_printf function writes formatted string to the file.</p>
<pre>
int f_printf (
FIL* <em>FileObject</em>, <span class="c">/* File object */</span>
const TCHAR* <em>Foramt</em>, <span class="c">/* Format stirng */</span>
FIL* <span class="arg">fp</span>, <span class="c">/* [IN] File object */</span>
const TCHAR* <span class="arg">fmt</span>, <span class="c">/* [IN] Format stirng */</span>
...
);
</pre>
@ -26,9 +26,9 @@ int f_printf (
<div class="para arg">
<h4>Parameters</h4>
<dl class="par">
<dt>FileObject</dt>
<dt>fp</dt>
<dd>Pointer to the open file object structure.</dd>
<dt>Format</dt>
<dt>fmt</dt>
<dd>Pointer to the null terminated format string.</dd>
<dt>...</dt>
<dd>Optional arguments.</dd>
@ -45,7 +45,7 @@ int f_printf (
<div class="para desc">
<h4>Description</h4>
<p>The f_printf() is a wrapper function of <a href="putc.html">f_putc()</a> and <a href="puts.html">f_puts()</a>. The format control directive is a sub-set of standard library shown as follos:</p>
<p>The <tt>f_printf()</tt> is a wrapper function of <a href="putc.html"><tt>f_putc()</tt></a> and <a href="puts.html"><tt>f_puts()</tt></a>. The format control directive is a sub-set of standard library shown as follos:</p>
<ul>
<li>Type: <tt>c C s S d D u U x X b B</tt></li>
<li>Size: <tt>l L</tt></li>
@ -57,7 +57,7 @@ int f_printf (
<div class="para comp">
<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>When the FatFs is configured to Unicode API (<tt>_LFN_UNICODE == 1</tt>), the generated UCS-2 characters are written to the file in UTF-8 encoding. If not the case, the byte characters will be written directly.</p>
<p>When the FatFs is configured to Unicode API (<tt>_LFN_UNICODE == 1</tt>), the generated UCS-2 string is written to the file in UTF-8 encoding. If not the case, the byte characters will be written directly.</p>
</div>

View File

@ -16,8 +16,8 @@
<p>The f_putc funciton puts a character to the file.</p>
<pre>
int f_putc (
TCHAR <em>Chr</em>, <span class="c">/* A character to put */</span>
FIL* <em>FileObject</em> <span class="c">/* File object */</span>
TCHAR <span class="arg">chr</span>, <span class="c">/* [IN] A character to put */</span>
FIL* <span class="arg">fp</span> <span class="c">/* [IN] File object */</span>
);
</pre>
</div>
@ -25,9 +25,9 @@ int f_putc (
<div class="para arg">
<h4>Parameters</h4>
<dl class="par">
<dt>Chr</dt>
<dt>chr</dt>
<dd>A character to be put.</dd>
<dt>FileObject</dt>
<dt>fp</dt>
<dd>Pointer to the open file object structuer.</dd>
</dl>
</div>
@ -36,13 +36,13 @@ int f_putc (
<div class="para ret">
<h4>Return Values</h4>
<p>When the character was written successfuly, the function returns 1. When the function failed due to disk full or any error, an <tt>EOF (-1)</tt> will be returned.</p>
<p>When the FatFs is configured to Unicode API (<tt>_LFN_UNICODE == 1</tt>), the UTF-16 character is written to the file in UTF-8 encoding. If not the case, the byte will be written directly.</p>
<p>When the FatFs is configured to Unicode API (<tt>_LFN_UNICODE == 1</tt>), the UCS-2 character is written to the file in UTF-8 encoding. If not the case, the byte will be written directly.</p>
</div>
<div class="para desc">
<h4>Description</h4>
<p>The f_putc() is a wrapper function of <a href="write.html">f_write()</a>.</p>
<p>The <tt>f_putc()</tt> function is a wrapper function of <a href="write.html"><tt>f_write()</tt></a> function.</p>
</div>

View File

@ -16,8 +16,8 @@
<p>The f_puts function writes a string to the file.</p>
<pre>
int f_puts (
const TCHAR* <em>Str</em>, <span class="c">/* String */</span>
FIL* <em>FileObject</em> <span class="c">/* File object */</span>
const TCHAR* <span class="arg">str</span>, <span class="c">/* [IN] String */</span>
FIL* <span class="arg">fp</span> <span class="c">/* [IN] File object */</span>
);
</pre>
</div>
@ -25,9 +25,9 @@ int f_puts (
<div class="para arg">
<h4>Parameters</h4>
<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>
<dt>FileObject</dt>
<dt>fp</dt>
<dd>Pointer to the open file object structure.</dd>
</dl>
</div>
@ -36,13 +36,13 @@ int f_puts (
<div class="para ret">
<h4>Return Value</h4>
<p>When the function succeeded, number of characters written that is not minus value is returned. When the write operation is aborted due to disk full or any error, an <tt>EOF (-1)</tt> will be returned.</p>
<p>When the FatFs is configured to Unicode API (<tt>_LFN_UNICODE == 1</tt>), the UTF-16 string is written to the file in UTF-8 encoding. If not the case, the byte stream will be written directly.</p>
<p>When the FatFs is configured to Unicode API (<tt>_LFN_UNICODE == 1</tt>), the UCS-2 string is written to the file in UTF-8 encoding. If not the case, the byte stream will be written directly.</p>
</div>
<div class="para desc">
<h4>Description</h4>
<p>The f_puts() is a wrapper function of <a href="putc.html">f_putc()</a>.</p>
<p>The <tt>f_puts()</tt> function is a wrapper function of <a href="putc.html"><tt>f_putc()</tt></a> function.</p>
</div>

View File

@ -11,13 +11,13 @@
<body>
<h1>Return Code of the File Functions</h1>
<p>On the FatFs API, most of file functions return common result code as enum type. When a function succeeded, it returns zero, otherwise returns non-zero value that indicates type of error.</p>
<p>On the FatFs API, most of file functions return common result code as enum type <tt>FRESULT</tt>. When a function succeeded, it returns zero, otherwise returns non-zero value that indicates type of error.</p>
<dl class="ret">
<dt id="ok">FR_OK (0)</dt>
<dd>The function succeeded.</dd>
<dt id="de">FR_DISK_ERR</dt>
<dd>An unrecoverable error occured in the lower layer (disk I/O functions).</dd>
<dd>An unrecoverable error occured in the lower layer, <tt>disk_read()</tt>, <tt>disk_write()</tt> or <tt>disk_ioctl()</tt> function.</dd>
<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.
<ul>
@ -27,7 +27,7 @@
</ul>
</dd>
<dt id="nr">FR_NOT_READY</dt>
<dd>The disk drive cannot work due to incorrect medium removal or disk_initialize function failed.</dd>
<dd>The disk drive cannot work due to incorrect medium removal or <tt>disk_initialize()</tt> function failed.</dd>
<dt id="nf">FR_NO_FILE</dt>
<dd>Could not find the file.</dd>
<dt id="np">FR_NO_PATH</dt>
@ -37,47 +37,48 @@
<dt id="dn">FR_DENIED</dt>
<dd>The required access was denied due to one of the following reasons:
<ul>
<li>Write mode open against the file with read-only attribute.</li>
<li>Deleting the file or directory with read-only attribute.</li>
<li>Write mode open against the read-only file.</li>
<li>Deleting the read-only file or directory.</li>
<li>Deleting the non-empty directory or current directory.</li>
<li>Reading the file opened without FA_READ flag.</li>
<li>Any modification to the file opened without FA_WRITE flag.</li>
<li>Reading the file opened without <tt>FA_READ</tt> flag.</li>
<li>Any modification to the file opened without <tt>FA_WRITE</tt> flag.</li>
<li>Could not create the file or directory due to the directory table is full.</li>
<li>Could not create the directory due to the volume is full.</li>
</ul>
</dd>
<dt id="ex">FR_EXIST</dt>
<dd>Any object that has the same name is already existing.</dd>
<dd>Any file or directory that has the same name is already existing.</dd>
<dt id="io">FR_INVALID_OBJECT</dt>
<dd>The given file/directory object structure is invalid.</dd>
<dd>The file/directory object is invalid or a null pointer is given.</dd>
<dt id="wp">FR_WRITE_PROTECTED</dt>
<dd>Any write mode action against write-protected media.</dd>
<dd>Any write mode action against the write-protected media.</dd>
<dt id="id">FR_INVALID_DRIVE</dt>
<dd>Invalid drive number is specified. (Related option: _VOLUMES)</dd>
<dd>Invalid drive number is specified. (Related option: <tt>_VOLUMES</tt>)</dd>
<dt id="ne">FR_NOT_ENABLED</dt>
<dd>Work area for the logical drive has not been registered by f_mount function.</dd>
<dd>Work area for the logical drive has not been registered by <tt>f_mount()</tt> function.</dd>
<dt id="ns">FR_NO_FILESYSTEM</dt>
<dd>There is no valid FAT volume on the drive.</dd>
<dt id="ma">FR_MKFS_ABORTED</dt>
<dd>The f_mkfs function aborted before start in format due to a reason as follows:
<dd>The <tt>f_mkfs()</tt> function aborted before start in format due to a reason as follows:
<ul>
<li>The disk size is too small.</li>
<li>Not allowable cluster size for this disk. This can occure when number of clusters gets near the 0xFF7 and 0xFFF7.</li>
<li>There is no partition related to the logical drive. (Related option: <tt>_MULTI_PARTITION</tt>)</li>
</ul>
</dd>
<dt id="tm">FR_TIMEOUT</dt>
<dd>The function canceled due to a timeout of <a href="appnote.html#reentrant">thread-safe control</a>. (Related option: _TIMEOUT)</dd>
<dd>The function 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>
<dd>The file access is rejected by <a href="appnote.html#dup">file sharing control</a>. (Related option: _FS_LOCK)</dd>
<dd>The file access is 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>
<dd>Not enough memory for the operation. There is one of the following reasons:
<ul>
<li>Could not allocate a memory for LFN working buffer. (Related option: _USE_LFN)</li>
<li>Given table size is insufficient for the required size.</li>
<li>Could not allocate a memory for LFN working buffer. (Related option: <tt>_USE_LFN</tt>)</li>
<li>Given CLMT is insufficient size for the required size.</li>
</ul>
</dd>
<dt id="tf">FR_TOO_MANY_OPEN_FILES</dt>
<dd>Number of open files has been reached maximum value and no more file can be opened. (Related option: _FS_LOCK)</dd>
<dd>Number of open files has been reached maximum value and no more file can be opened. (Related option: <tt>_FS_LOCK</tt>)</dd>
<dt id="ip">FR_INVALID_PARAMETER</dt>
<dd>The given parameter is invalid or there is any inconsistent.</dd>
</dl>

View File

@ -16,10 +16,10 @@
<p>The f_read function reads data from a file.</p>
<pre>
FRESULT f_read (
FIL* <em>FileObject</em>, <span class="c">/* Pointer to the file object structure */</span>
void* <em>Buffer</em>, <span class="c">/* Pointer to the buffer to store read data */</span>
UINT <em>ByteToRead</em>, <span class="c">/* Number of bytes to read */</span>
UINT* <em>ByteRead</em> <span class="c">/* Pointer to the variable to return number of bytes read */</span>
FIL* <span class="arg">fp</span>, <span class="c">/* [IN] File object */</span>
void* <span class="arg">buff</span>, <span class="c">/* [OUT] Buffer to store read data */</span>
UINT <span class="arg">btr</span>, <span class="c">/* [IN] Number of bytes to read */</span>
UINT* <span class="arg">br</span> <span class="c">/* [OUT] Number of bytes read */</span>
);
</pre>
</div>
@ -27,14 +27,14 @@ FRESULT f_read (
<div class="para arg">
<h4>Parameters</h4>
<dl class="par">
<dt>FileObject</dt>
<dt>fp</dt>
<dd>Pointer to the open file object.</dd>
<dt>Buffer</dt>
<dt>buff</dt>
<dd>Pointer to the buffer to store read data</dd>
<dt>ByteToRead</dt>
<dd>Number of bytes to read in range of UINT.</dd>
<dt>ByteRead</dt>
<dd>Pointer to the UINT variable to return number of bytes read. The value is always valid after the function call regardless of the result.</dd>
<dt>btr</dt>
<dd>Number of bytes to read in range of <tt>UINT</tt> type.</dd>
<dt>br</dt>
<dd>Pointer to the <tt>UINT</tt> variable to return number of bytes read. The value is always valid after the function call regardless of the result.</dd>
</dl>
</div>
@ -54,7 +54,7 @@ FRESULT f_read (
<div class="para desc">
<h4>Description</h4>
<p>The file read/write pointer of the file object advances number of bytes read. After the function succeeded, <tt>*ByteRead</tt> should be checked to detect the end of file. In case of <tt>*ByteRead &lt; ByteToRead</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 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>
</div>

View File

@ -16,8 +16,8 @@
<p>The f_readdir function reads directory entries.</p>
<pre>
FRESULT f_readdir (
DIR* <em>DirObject</em>, <span class="c">/* Pointer to the open directory object */</span>
FILINFO* <em>FileInfo</em> <span class="c">/* Pointer to the file information structure */</span>
DIR* <span class="arg">dj</span>, <span class="c">/* [IN] Directory object */</span>
FILINFO* <span class="arg">fno</span> <span class="c">/* [OUT] File information structure */</span>
);
</pre>
</div>
@ -25,9 +25,9 @@ FRESULT f_readdir (
<div class="para arg">
<h4>Parameters</h4>
<dl class="par">
<dt>DirObject</dt>
<dt>dj</dt>
<dd>Pointer to the open directory object.</dd>
<dt>FileInfo</dt>
<dt>fno</dt>
<dd>Pointer to the file information structure to store the read item.</dd>
</dl>
</div>
@ -49,9 +49,9 @@ FRESULT f_readdir (
<div class="para desc">
<h4>Description</h4>
<p>The f_readdir function reads directory entries in sequence. All items in the directory can be read by calling f_readdir function repeatedly. When all directory entries have been read and no item to read, the function returns a null string into <tt>f_name[]</tt> member without any error. When a null pointer is given to the <tt>FileInfo</tt>, the read index of the directory object will be rewinded.</p>
<p>When LFN feature is enabled, <tt>lfname</tt> and <tt>lfsize</tt> in the file information structure must be initialized with valid value prior to use the f_readdir function. The <tt>lfname</tt> is a pointer to the string buffer to return the long file name. The <tt>lfsize</tt> is the size of the string buffer in unit of TCHAR. If either the size of read buffer or LFN working buffer is insufficient for the LFN or the object has no LFN, a null string will be returned to the LFN read buffer. If the LFN contains any charactrer that cannot be converted to OEM code, a null string will be returned but this is not the case on Unicode API configuration. When <tt>lfname</tt> is a NULL, nothing of the LFN is returned. When the object has no LFN, some small capitals can be contained in the SFN.</p>
<p>When relative path feature is enabled <tt>(_FS_RPATH == 1)</tt>, "." and ".." entries are not filtered out and it will appear in the read entries.</p>
<p>The <tt>f_readdir()</tt> function reads directory items, file and directory, in sequence. All items in the directory can be read by calling <tt>f_readdir()</tt> function repeatedly. When all directory items have been read and no item to read, the function returns a null string into <tt>fname[]</tt> member without any error. When a null pointer is given to the <tt class="arg">fno</tt>, the read index of the directory object will be rewinded.</p>
<p>When LFN feature is enabled, <tt>lfname</tt> and <tt>lfsize</tt> in the file information structure must be initialized with valid value prior to use it. The <tt>lfname</tt> is a pointer to the string buffer to return the long file name. The <tt>lfsize</tt> is the size of the string buffer in unit of <tt>TCHAR</tt>. If either the size of read buffer or LFN working buffer is insufficient for the LFN or the object has no LFN, a null string will be returned to the LFN read buffer. If the LFN contains any charactrer that cannot be converted to OEM code, a null string will be returned but this is not the case on Unicode API configuration. When <tt>lfname</tt> is a null, nothing of the LFN is returned. When the object has no LFN, some small capitals can be contained in the SFN in the <tt>fname[]</tt>.</p>
<p>When relative path feature is enabled (<tt>_FS_RPATH == 1</tt>), dot entries ("." and "..") are not filtered out and they will appear in the read items.</p>
</div>
@ -74,7 +74,7 @@ FRESULT scan_files (
int i;
char *fn; <span class="c">/* This function is assuming non-Unicode cfg. */</span>
<span class="k">#if</span> _USE_LFN
static char lfn[_MAX_LFN + 1];
static char lfn[_MAX_LFN + 1]; <span class="c">/* Buffer to store the LFN */</span>
fno.lfname = lfn;
fno.lfsize = sizeof lfn;
<span class="k">#endif</span>

View File

@ -16,8 +16,8 @@
<p>Renames an object.</p>
<pre>
FRESULT f_rename (
const TCHAR* <em>OldName</em>, <span class="c">/* Pointer to old object name */</span>
const TCHAR* <em>NewName</em> <span class="c">/* Pointer to new object name */</span>
const TCHAR* <span class="arg">old_name</span>, <span class="c">/* [IN] Old object name */</span>
const TCHAR* <span class="arg">new_name</span> <span class="c">/* [IN] New object name */</span>
);
</pre>
</div>
@ -25,9 +25,9 @@ FRESULT f_rename (
<div class="para arg">
<h4>Parameters</h4>
<dl class="par">
<dt>OldName</dt>
<dt>old_name</dt>
<dd>Pointer to a null-terminated string specifies the old <a href="filename.html">object name</a> to be renamed.</dd>
<dt>NewName</dt>
<dt>new_name</dt>
<dd>Pointer to a null-terminated string specifies the new object name without drive number.</dd>
</dl>
</div>
@ -58,7 +58,7 @@ FRESULT f_rename (
<div class="para desc">
<h4>Description</h4>
<p>Renames an object (file or directory) and can also move it to other directory. The logical drive number is determined by old name, new name must not contain a logical drive number. <em>Do not rename open objects</em>.</p>
<p>Renames an object (file or directory) and can also move it to other directory. The logical drive number is determined by old name, new name must not contain a logical drive number. <em>Do not rename open objects</em> or directry table can be collapted.</p>
</div>
@ -79,6 +79,7 @@ FRESULT f_rename (
</pre>
</div>
<p class="foot"><a href="../00index_e.html">Return</a></p>
</body>
</html>

View File

@ -13,7 +13,7 @@
<div class="para">
<h2>DIR</h2>
<p>The <tt>DIR</tt> structure is used for the work area to read a directory by f_oepndir, f_readdir function. There is no member that can be changed by application program.</p>
<p>The <tt>DIR</tt> structure is used for the work area to read a directory by <tt>f_oepndir()/f_readdir()</tt> function. Application program must not modify any member in this structure.</p>
<pre>
<span class="k">typedef</span> <span class="k">struct</span> {
FATFS* fs; <span class="c">/* Pointer to the owner file system object */</span>

89
doc/en/setlabel.html Normal file
View File

@ -0,0 +1,89 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<meta http-equiv="Content-Style-Type" content="text/css">
<link rel="up" title="FatFs" href="../00index_e.html">
<link rel="alternate" hreflang="ja" title="Japanese" href="../ja/setlabel.html">
<link rel="stylesheet" href="../css_e.css" type="text/css" media="screen" title="ELM Default">
<title>FatFs - f_setlabel</title>
</head>
<body>
<div class="para func">
<h2>f_setlabel</h2>
<p>The f_setlabel function sets/removes the label of a volume.</p>
<pre>
FRESULT f_setlabel (
const TCHAR* <span class="arg">name</span> <span class="c">/* [IN] Volume label to be set */</span>
);
</pre>
</div>
<div class="para arg">
<h4>Parameters</h4>
<dl class="par">
<dt>name</dt>
<dd>Pointer to the nul-terminated string specifying the volume label to be set.</dd>
</dl>
</div>
<div class="para ret">
<h4>Return Values</h4>
<p>
<a href="rc.html#ok">FR_OK</a>,
<a href="rc.html#de">FR_DISK_ERR</a>,
<a href="rc.html#ie">FR_INT_ERR</a>,
<a href="rc.html#nr">FR_NOT_READY</a>,
<a href="rc.html#in">FR_INVALID_NAME</a>,
<a href="rc.html#wp">FR_WRITE_PROTECTED</a>,
<a href="rc.html#id">FR_INVALID_DRIVE</a>,
<a href="rc.html#ne">FR_NOT_ENABLED</a>,
<a href="rc.html#ns">FR_NO_FILESYSTEM</a>,
<a href="rc.html#tm">FR_TIMEOUT</a>
</p>
</div>
<div class="para desc">
<h4>Description</h4>
<p>When the string has a drive number, the volume label will be set to the volume specified by the drive number. If 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 difference shown below:</p>
<ul>
<li>11 bytes or less in length as local character code.</li>
<li>Cannot contain period.</li>
<li>Can contain spaces anywhere in the name.</li>
</ul>
</div>
<div class="para comp">
<h4>QuickInfo</h4>
<p>Available when <tt>_FS_READONLY == 0</tt> and <tt>_USE_LABEL == 1</tt>.</p>
</div>
<div class="para use">
<h4>Example</h4>
<pre>
<span class="c">/* Set volume label to the default drive */</span>
f_setlabel("DATA DISK");
<span class="c">/* Set volume label to the drive 2 */</span>
f_setlabel("2:DISK 3 OF 4");
<span class="c">/* Remove volume label of the drive 2 */</span>
f_setlabel("2:");
</pre>
</div>
<div class="para ref">
<h4>See Also</h4>
<tt><a href="getlabel.html">f_getlabel</a></tt>
</div>
<p class="foot"><a href="../00index_e.html">Return</a></p>
</body>
</html>

View File

@ -13,7 +13,7 @@
<div class="para">
<h2>FATFS</h2>
<p>The <tt>FATFS</tt> structure (file system object) holds dynamic work area of individual logical drives. It is given by application program and registerd/unregisterd to the FatFs module with f_mount function. Initialization is done on first file access after f_mount or media change. There is no member that can be changed from the application program.</p>
<p>The <tt>FATFS</tt> structure (file system object) holds dynamic work area of individual logical drives. It is given by application program and registerd/unregisterd to the FatFs module with <tt>f_mount()</tt> function. Initialization is done on first API call after <tt>f_mount()</tt> function or media change. Application program must not modify any member in this structure.</p>
<pre>
<span class="k">typedef</span> <span class="k">struct</span> {
BYTE fs_type; <span class="c">/* FAT sub-type (0:Not mounted) */</span>
@ -40,6 +40,7 @@
<span class="k">#endif</span>
DWORD n_fatent; <span class="c">/* Number of FAT entries (== Number of clusters + 2) */</span>
DWORD fsize; <span class="c">/* Sectors per FAT */</span>
DWORD volbase; <span class="c">/* Volume start sector */</span>
DWORD fatbase; <span class="c">/* FAT area start sector */</span>
DWORD dirbase; <span class="c">/* Root directory area start sector (FAT32: Cluster#) */</span>
DWORD database; <span class="c">/* Data area start sector */</span>

View File

@ -13,7 +13,7 @@
<div class="para">
<h2>FIL</h2>
<p>The FIL structure (file object) holds state of an open file. It is created by f_open function and discarded by f_close function. There is no member that can be changed by the application program except for <tt>cltbl</tt>. Note that a sector buffer is defined in this structure under non-tiny configuration so that the FIL structures should not be defined as auto variable.</p>
<p>The <tt>FIL</tt> structure (file object) holds state of an open file. It is created by <tt>f_open()</tt> function and discarded by <tt>f_close()</tt> function. Application program must not modify any member in this structure except for <tt>cltbl</tt>. Note that a sector buffer is defined in this structure under non-tiny configuration, so that the <tt>FIL</tt> structures should not be defined as auto variable.</p>
<pre>
<span class="k">typedef</span> <span class="k">struct</span> {

View File

@ -13,7 +13,7 @@
<div class="para">
<h2>FILINFO</h2>
<p>The <tt>FILINFO</tt> structure holds a file information returned by f_stat and f_readdir function.</p>
<p>The <tt>FILINFO</tt> structure holds a file information returned by <tt>f_readdir()</tt> and <tt>f_stat()</tt> function.</p>
<pre>
<span class="k">typedef struct</span> {
DWORD fsize; <span class="c">/* File size */</span>

View File

@ -16,7 +16,7 @@
<p>The f_size function gets the size of a file.</p>
<pre>
DWORD f_size (
FIL* <em>FileObject</em> <span class="c">/* File object */</span>
FIL* <span class="arg">fp</span> <span class="c">/* [IN] File object */</span>
);
</pre>
</div>
@ -25,7 +25,7 @@ DWORD f_size (
<div class="para arg">
<h4>Parameters</h4>
<dl class="par">
<dt>FileObject</dt>
<dt>fp</dt>
<dd>Pointer to the open file object structure.</dd>
</dl>
</div>
@ -39,7 +39,7 @@ DWORD f_size (
<div class="para desc">
<h4>Description</h4>
<p>In this revision, the f_size function is implemented as a macro.</p>
<p>In this revision, the <tt>f_size()</tt> function is implemented as a macro.</p>
<pre>
<span class="k">#define</span> f_size(fp) ((fp)->fsize)
</pre>

View File

@ -16,8 +16,8 @@
<p>The f_stat gets the file status.</p>
<pre>
FRESULT f_stat (
const TCHAR* <em>FileName</em>, <span class="c">/* Pointer to the file or directory name */</span>
FILINFO* <em>FileInfo</em> <span class="c">/* Pointer to the FILINFO structure */</span>
const TCHAR* <span class="arg">path</span>, <span class="c">/* [IN] Object name */</span>
FILINFO* <span class="arg">fno</span> <span class="c">/* [OUT] FILINFO structure */</span>
);
</pre>
</div>
@ -25,9 +25,9 @@ FRESULT f_stat (
<div class="para arg">
<h4>Parameters</h4>
<dl class="par">
<dt>FileName</dt>
<dt>path</dt>
<dd>Pointer to the null-terminated string that specifies the <a href="filename.html">file or directory</a> to get its information.</dd>
<dt>FileInfo</dt>
<dt>fno</dt>
<dd>Pointer to the blank <tt>FILINFO</tt> structure to store the information.</dd>
</dl>
</div>
@ -54,7 +54,13 @@ FRESULT f_stat (
<div class="para desc">
<h4>Description</h4>
<p>The f_stat gets the size, timestamp and attribute of a file or directory. For details of the infomation, refer to the <tt>FILINFO</tt> structure and <a href="readdir.html">f_readdir</a> function. This function is not supported in minimization level of &gt;= 1.</p>
<p>The <tt>f_stat()</tt> function gets the size, timestamp and attribute of a file or directory. For details of the infomation, refer to the <tt>FILINFO</tt> structure and <a href="readdir.html"><tt>f_readdir()</tt></a> function.</p>
</div>
<div class="para comp">
<h4>QuickInfo</h4>
<p>Available when <tt>_FS_MINIMIZE == 0</tt>.</p>
</div>

View File

@ -16,7 +16,7 @@
<p>The f_sync function flushes the cached information of a writing file.</p>
<pre>
FRESULT f_sync (
FIL* <em>FileObject</em> <span class="c">/* Pointer to the file object */</span>
FIL* <span class="arg">fp</span> <span class="c">/* [IN] File object */</span>
);
</pre>
</div>
@ -24,7 +24,7 @@ FRESULT f_sync (
<div class="para arg">
<h4>Parameter</h4>
<dl class="par">
<dt>FileObject</dt>
<dt>fp</dt>
<dd>Pointer to the open file object to be flushed.</dd>
</dl>
</div>
@ -45,7 +45,7 @@ FRESULT f_sync (
<div class="para desc">
<h4>Description</h4>
<p>The f_sync function performs the same process as f_close function but the file is left opened and can continue read/write/seek operations to the file. This is suitable for the applications that open files for a long time in write mode, such as data logger. Performing f_sync of periodic or immediataly after f_write can minimize the risk of data loss due to a sudden blackout or an unintentional media removal. However f_sync immediataly before f_close has no advantage because f_close performs f_sync in it. In other words, the differnce between those functions is that the file object is invalidated or not. </p>
<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. 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>
</div>

View File

@ -16,7 +16,7 @@
<p>The f_tell function gets the current read/write pointer of a file.</p>
<pre>
DWORD f_tell (
FIL* <em>FileObject</em> <span class="c">/* File object */</span>
FIL* <span class="arg">fp</span> <span class="c">/* [IN] File object */</span>
);
</pre>
</div>
@ -25,7 +25,7 @@ DWORD f_tell (
<div class="para arg">
<h4>Parameters</h4>
<dl class="par">
<dt>FileObject</dt>
<dt>fp</dt>
<dd>Pointer to the open file object structure.</dd>
</dl>
</div>
@ -39,7 +39,7 @@ DWORD f_tell (
<div class="para desc">
<h4>Description</h4>
<p>In this revision, the f_tell function is implemented as a macro.</p>
<p>In this revision, the <tt>f_tell()</tt> function is implemented as a macro.</p>
<pre>
<span class="k">#define</span> f_tell(fp) ((fp)->fptr)
</pre>

View File

@ -16,7 +16,7 @@
<p>The f_truncate function truncates the file size.</p>
<pre>
FRESULT f_truncate (
FIL* <em>FileObject</em> <span class="c">/* Pointer to the file object */</span>
FIL* <span class="arg">fp</span> <span class="c">/* [IN] File object */</span>
);
</pre>
</div>
@ -24,7 +24,7 @@ FRESULT f_truncate (
<div class="para arg">
<h4>Parameter</h4>
<dl class="par">
<dt>FileObject</dt>
<dt>fp</dt>
<dd>Pointer to the open file object to be truncated.</dd>
</dl>
</div>
@ -45,7 +45,7 @@ FRESULT f_truncate (
<div class="para desc">
<h4>Description</h4>
<p>The f_truncate function truncates the file size to the current file read/write point. This function has no effect if the file read/write pointer is already pointing end of the file.</p>
<p>The <tt>f_truncate()</tt> function truncates the file size to the current file read/write pointer. This function has no effect if the file read/write pointer is already pointing end of the file.</p>
</div>

View File

@ -16,7 +16,7 @@
<p>The f_unlink function removes a file or directory.</p>
<pre>
FRESULT f_unlink (
const TCHAR* <em>FileName</em> <span class="c">/* Pointer to the object name */</span>
const TCHAR* <span class="arg">path</span> <span class="c">/* [IN] Object name */</span>
);
</pre>
</div>
@ -24,7 +24,7 @@ FRESULT f_unlink (
<div class="para arg">
<h4>Parameter</h4>
<dl class="par">
<dt>FileName</dt>
<dt>path</dt>
<dd>Pointer to the null-terminated string that specifies an <a href="filename.html">object</a> to be removed.</dd>
</dl>
</div>
@ -56,9 +56,8 @@ FRESULT f_unlink (
<div class="para desc">
<h4>Description</h4>
<p>
If condition of the object to be removed is applicable to the following terms, the function will fail with error.
<ul>
<li>The object must not have read-only attribute (AM_RDO) or the function will be rejected with <tt>FR_DENIED</tt>.</li>
If condition of the object to be removed is applicable to the following terms, the function will fail with error.<ul>
<li>The object must not have read-only attribute (<tt>AM_RDO</tt>) or the function will be rejected with <tt>FR_DENIED</tt>.</li>
<li>The directory must be empty and must not be current directory or the function will be rejected with <tt>FR_DENIED</tt>.</li>
<li>The file must not have been opened or the <em>FAT volume can be collapted</em>. It will able to be rejected with <tt>FR_LOCKED</tt> when <a href="appnote.html#dup">file shareing control</a> is enabled.</li>
</ul>

View File

@ -16,8 +16,8 @@
<p>The f_utime function changes the timestamp of a file or directory.</p>
<pre>
FRESULT f_utime (
const TCHAR* <em>FileName</em>, <span class="c">/* Pointer to the file or directory path */</span>
const FILINFO* <em>TimeDate</em> <span class="c">/* Time and data to be set */</span>
const TCHAR* <span class="arg">path</span>, <span class="c">/* [IN] Object name */</span>
const FILINFO* <span class="arg">fno</span> <span class="c">/* [IN] Time and data to be set */</span>
);
</pre>
</div>
@ -25,9 +25,9 @@ FRESULT f_utime (
<div class="para arg">
<h4>Parameters</h4>
<dl class="par">
<dt>FileName</dt>
<dt>path</dt>
<dd>Pointer to the null-terminated string that specifies a <a href="filename.html">file or directory</a> to be changed.</dd>
<dt>TimeDate</dt>
<dt>fno</dt>
<dd>Pointer to the file information structure that has a timestamp to be set in member fdate and ftime. Do not care any other members.</dd>
</dl>
</div>
@ -55,7 +55,7 @@ FRESULT f_utime (
<div class="para desc">
<h4>Description</h4>
<p>The f_utime function changes the timestamp of a file or directory</p>
<p>The <tt>f_utime()</tt> function changes the timestamp of a file or directory</p>
</div>

View File

@ -16,10 +16,10 @@
<p>The f_write writes data to a file.</p>
<pre>
FRESULT f_write (
FIL* <em>FileObject</em>, <span class="c">/* Pointer to the file object structure */</span>
const void* <em>Buffer</em>, <span class="c">/* Pointer to the data to be written */</span>
UINT <em>ByteToWrite</em>, <span class="c">/* Number of bytes to write */</span>
UINT* <em>ByteWritten</em> <span class="c">/* Pointer to the variable to return number of bytes written */</span>
FIL* <span class="arg">fp</span>, <span class="c">/* [IN] Pointer to the file object structure */</span>
const void* <span class="arg">buff</span>, <span class="c">/* [IN] Pointer to the data to be written */</span>
UINT <span class="arg">btw</span>, <span class="c">/* [IN] Number of bytes to write */</span>
UINT* <span class="arg">bw</span> <span class="c">/* [OUT] Pointer to the variable to return number of bytes written */</span>
);
</pre>
</div>
@ -27,14 +27,14 @@ FRESULT f_write (
<div class="para arg">
<h4>Parameters</h4>
<dl class="par">
<dt>FileObject</dt>
<dt>fp</dt>
<dd>Pointer to the open file object structure.</dd>
<dt>Buffer</dt>
<dt>buff</dt>
<dd>Pointer to the data to be written.</dd>
<dt>ByteToWrite</dt>
<dd>Specifies number of bytes to write in range of UINT.</dd>
<dt>ByteWritten</dt>
<dd>Pointer to the UINT variable to return the number of bytes written. The value is always valid after the function call regardless of the result.</dd>
<dt>btw</dt>
<dd>Specifies number of bytes to write in range of <tt>UINT</tt> type.</dd>
<dt>bw</dt>
<dd>Pointer to the <tt>UINT</tt> variable to return the number of bytes written. The value is always valid after the function call regardless of the result.</dd>
</dl>
</div>
@ -54,7 +54,7 @@ FRESULT f_write (
<div class="para desc">
<h4>Description</h4>
<p>The read/write pointer of the file object advances number of bytes written. After the function succeeded, <tt>*ByteWritten</tt> should be checked to detect the disk full. In case of <tt>*ByteWritten &lt; ByteToWrite</tt>, it means the volume got full during the write operation. The function can take a time when the volume is full or close to full.</p>
<p>The read/write pointer of the file object advances number of bytes written. After the function succeeded, <tt class="arg">*bw</tt> should be checked to detect the disk full. In case of <tt class="arg">*bw</tt> is less than <tt class="arg">btw</tt>, it means the volume got full during the write operation. The function can take a time when the volume is full or close to full.</p>
</div>

44
doc/img/app1.c Normal file
View File

@ -0,0 +1,44 @@
/*------------------------------------------------------------/
/ Open or create a file in append mode
/------------------------------------------------------------*/
FRESULT open_append (
FIL* fp, /* [OUT] File object to create */
const char* path /* [IN] File name to be opened */
)
{
FRESULT fr;
/* Opens an existing file. If not exist, creates a new file. */
fr = f_open(fp, path, FA_WRITE | FA_OPEN_ALWAYS);
if (fr == FR_OK) {
/* Seek to end of the file to append data */
fr = f_lseek(fp, f_size(fp));
if (fr != FR_OK)
f_close(fp);
}
return fr;
}
int main (void)
{
FRESULT fr;
FIL fil;
f_mount(0, &Fatfs);
/* Open or create a log file and ready to append */
fr = open_append(&fil, "logfile.txt");
if (fr != FR_OK) return 1;
/* Append a line */
f_printf(&fil, "%02u/%02u/%u, %2u:%02u\n", Mday, Mon, Year, Hour, Min);
/* Close the file */
f_close(&fil);
return 0;
}

67
doc/img/app2.c Normal file
View File

@ -0,0 +1,67 @@
/*------------------------------------------------------------/
/ Remove all contents of a directory
/ This function works regardless of _FS_RPATH.
/------------------------------------------------------------*/
FRESULT empty_directory (
char* path /* Working buffer filled with start directory */
)
{
UINT i, j;
FRESULT fr;
DIR dir;
FILINFO fno;
#if _USE_LFN
fno.lfname = 0; /* Set null pointer because LFN is not needed */
#endif
fr = f_opendir(&dir, path);
if (fr == FR_OK) {
for (i = 0; path[i]; i++) ;
path[i++] = '/';
for (;;) {
fr = f_readdir(&dir, &fno);
if (fr != FR_OK || !fno.fname[0]) break;
if (fno.fname[0] == '.') continue;
j = 0;
do
path[i+j] = fno.fname[j];
while (fno.fname[j++]);
if (fno.fattrib & AM_DIR) {
fr = empty_directory(path);
if (fr != FR_OK) break;
}
fr = f_unlink(path);
if (fr != FR_OK) break;
}
path[--i] = '\0';
}
return fr;
}
int main (void)
{
FRESULT fr;
char buff[64]; /* Working buffer */
f_mount(0, &Fatfs);
strcpy(buff, "/"); /* Directory to be emptied */
fr = empty_directory(buff);
if (fr) {
printf("Function failed. (%u)\n", fr);
return 1;
} else {
printf("All contents in the %s are successfully removed.\n", buff);
return 0;
}
}

98
doc/img/app3.c Normal file
View File

@ -0,0 +1,98 @@
/*------------------------------------------------------------/
/ Allocate a contiguous area to the file
/------------------------------------------------------------*/
/* Declarations of FatFs internal functions accessible from applications.
/ This is intended to be used by disk checking/fixing or dirty hacks :-) */
DWORD clust2sect (FATFS *fs, DWORD clst);
DWORD get_fat (FATFS *fs, DWORD clst);
FRESULT put_fat (FATFS *fs, DWORD clst, DWORD val);
DWORD allocate_contiguous_clusters ( /* Returns file start sector number */
FIL* fp, /* Pointer to the open file object */
DWORD len /* Number of bytes to allocate */
)
{
DWORD csz, tcl, ncl, ccl, cl;
#if _FATFS != 82786 /* Check if R0.09b */
#error This function may not be compatible with this revision of FatFs module.
#endif
if (f_lseek(fp, 0) || !len) /* Check if the given parameters are valid */
return 0;
csz = 512UL * fp->fs->csize; /* Cluster size in unit of byte (assuming 512 bytes/sector) */
tcl = (len + csz - 1) / csz; /* Total number of clusters required */
len = tcl * csz; /* Round-up file size to the cluster boundary */
/* Check if the existing cluster chain is contiguous */
if (len == fp->fsize) {
ncl = 0; ccl = fp->sclust;
do {
cl = get_fat(fp->fs, ccl); /* Get the cluster status */
if (cl + 1 < 3) return 0; /* Hard error? */
if (cl != ccl + 1 &&; cl < fp->fs->n_fatent) break; /* Not contiguous? */
ccl = cl;
} while (++ncl < tcl);
if (ncl == tcl) /* Is the file contiguous? */
return clust2sect(fp->fs, fp->sclust); /* Return file start sector */
}
if (f_truncate(fp)) return 0; /* Remove the existing chain */
/* Find a free contiguous area */
ccl = cl = 2; ncl = 0;
do {
if (cl >= fp->fs->n_fatent) return 0; /* No contiguous area is found. */
if (get_fat(fp->fs, cl)) { /* Encounterd a cluster in use */
do { /* Skip the block of used clusters */
cl++;
if (cl >= fp->fs->n_fatent) return 0; /* No contiguous area is found. */
} while (get_fat(fp->fs, cl));
ccl = cl; ncl = 0;
}
cl++; ncl++;
} while (ncl < tcl);
/* Create a contiguous cluster chain */
fp->fs->last_clust = ccl - 1;
if (f_lseek(fp, len)) return 0;
return clust2sect(fp->fs, fp->sclust); /* Return file start sector */
}
int main (void)
{
FRESULT fr;
DRESULT dr;
FIL fil;
DWORD org;
f_mount(0, &Fatfs);
/* Open or create a file */
fr = f_open(&fil, "pagefile.dat", FA_READ | FA_WRITE | FA_OPEN_ALWAYS);
if (fr) return 1;
/* Check if the file is 64MB in size and occupies a contiguous area.
/ If not, a contiguous area is re-allocated to the file. */
org = allocate_contiguous_clusters(&fil, 0x4000000);
if (!org) {
printf("Function failed due to any error or insufficient contiguous area.\n");
f_close(&fil);
return 1;
}
/* Now you can read/write the file with disk functions bypassing the file system layer.
/ Note that 4th argument of the disk read/write function is BYTE, so that you may need
/ to bypass the disk functions for large number of multiple sector transfer. */
dr = disk_write(fil.fs->drv, Buff, org, 128); /* Write 64K bytes from top of the file */
...
f_close(&fil);
return 0;
}

BIN
doc/img/f7.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.1 KiB

After

Width:  |  Height:  |  Size: 4.5 KiB

View File

@ -24,6 +24,7 @@
<li><a href="#fs1">効率的なファイル・アクセス</a></li>
<li><a href="#fs2">フラッシュ・メモリの特性への配慮</a></li>
<li><a href="#critical">クリチカル・セクション</a></li>
<li><a href="#fs3">APIの拡張的使用例</a></li>
<li><a href="#license">FatFsのライセンスについて</a></li>
</ol>
<hr>
@ -35,9 +36,9 @@
<p>FatFsモジュールは移植性に関して次の点を前提としています。</p>
<ul>
<li>処理系はANSI C準拠であること。<br>
FatFsモジュールはANSI C(C89)準拠で記述されているので、ANSI Cに準拠したまともなコンパイラなら特に処理系依存になる点はありません。</li>
FatFsモジュールはANSI C(C89)準拠で記述されているので、普通のCコンパイラなら特に処理系依存になる点はありません。</li>
<li>char/short/longのサイズは、それぞれ8/16/32ビットで、intは16または32ビットであること。<br>
サイズを明示する整数型が integer.h 内で定義されています。整数の型とサイズに関しては、まっとうな処理系なら問題ないはずですが、既存の定義と衝突した場合はユーザによって解決されなければなりません。</li>
これについても、まっとうな処理系なら問題ないはずです。FatFsモジュールで使用されるサイズを明示する整数型が integer.h 内で定義されていますが、既存の定義と衝突した場合はユーザによって解決されなければなりません。</li>
</ul>
<h4>システム構成</h4>
@ -45,7 +46,7 @@ FatFsモジュールはANSI C(C89)準拠で記述されているので、ANSI C
<p><img src="../img/modules.png" width="507" height="224" alt="システム構成図"></p>
<h4>ユーザの作成する関数</h4>
<p>必要なのは FatFsモジュールの要求するディスク関数を用意することだけで、それ以外にすることはありません。既に動作しているディスク関数があるならその APIを FatFsに合わせるだけで済みますが、無い場合はほかから移植するか最初から書くかする必要があります。定義されている全ての関数が常に必要なわけではありません。例えば、リード・オンリー構成では書き込み系関数は必要ありません。次の表に構成オプションと要求される関数の対応を示します。</p>
<p>必要なのは FatFsモジュールの要求するディスク関数を用意することだけで、それ以外にすることはありません。既に動作しているディスク関数があるならその APIを FatFsに合わせるかグルー関数でつなぐだけで済みますが、無い場合はほかから移植するか最初から書くかする必要があります。定義されている全ての関数が常に必要なわけではありません。例えば、リード・オンリー構成では書き込み系関数は必要ありません。次の表に構成オプションと要求される関数の対応を示します。</p>
<table class="lst2">
<tr><th>ユーザ作成関数</th><th>必要となる条件</th><th>備考</th></tr>
<tr><td>disk_initialize<br>disk_status<br>disk_read</td><td>常時</td><td rowspan="5">ffsample.zip (サンプル)<br>その他web上に多数</td></tr>
@ -74,21 +75,22 @@ FatFsモジュールはANSI C(C89)準拠で記述されているので、ANSI C
<div class="para" id="memory">
<h3>メモリ使用量</h3>
<p>次の表にいくつかのターゲットにおけるメモリ使用量の例を示します。テスト時の構成オプションはその下の通りです。数値の単位はバイトで、<em>V</em>同時マウント・ボリューム数、<em>F</em>は同時オープン・ファイル数を示します。コンパイラの最適化オプションはコード・サイズとしています。</p>
<p>次の表にいくつかのターゲットにおけるメモリ使用量の例を示します。テスト時の構成オプションはその下の通りです。数値の単位はバイトで、<em>V</em>はボリューム数、<em>F</em>は同時オープン・ファイル数を示します。コンパイラの最適化オプションはコード・サイズとしています。</p>
<table class="lst2">
<tr><th></th><th>ARM7<small><br>32bit</small></th><th>ARM7<small><br>Thumb</small></th><th>CM3<small><br>Thumb-2</small></th><th>AVR</th><th>H8/300H</th><th>PIC24</th><th>RL78</th><th>V850ES</th><th>SH-2A</th><th>RX600</th><th>IA-32</th></tr>
<tr><td>Compiler</td><td>GCC</td><td>GCC</td><td>GCC</td><td>GCC</td><td>CH38</td><td>C30</td><td>CC78K0R</td><td>CA850</td><td>SHC</td><td>RXC</td><td>VC6</td></tr>
<tr><td>_WORD_ACCESS</td><td>0</td><td>0</td><td>0</td><td>1</td><td>0</td><td>0</td><td>0</td><td>1</td><td>0</td><td>1</td><td>1</td></tr>
<tr class="lst3"><td>text (Full, R/W)</td><td>10375</td><td>7019</td><td>6561</td><td>13267</td><td>10525</td><td>11205</td><td>12812</td><td>7783</td><td>8715</td><td>5782</td><td>7615</td></tr>
<tr> <td>text (Min, R/W)</td> <td>6487</td><td>4727</td><td>4283</td> <td>8521</td> <td>6967</td> <td>7398</td> <td>8800</td><td>5019</td><td>5635</td><td>3784</td><td>5003</td></tr>
<tr> <td>text (Full, R/O)</td> <td>4551</td><td>3125</td><td>2895</td> <td>6219</td> <td>4895</td> <td>5268</td> <td>6123</td><td>3629</td><td>3843</td><td>2699</td><td>3527</td></tr>
<tr> <td>text (Min, R/O)</td> <td>3321</td><td>2457</td><td>2197</td> <td>4527</td> <td>3797</td> <td>3999</td> <td>4663</td><td>2773</td><td>2999</td><td>2064</td><td>2736</td></tr>
<tr> <td>bss</td><td>D*4 + 2</td><td>D*4 + 2</td><td>D*4 + 2</td><td>D*2 + 2</td><td>D*4 + 2</td><td>D*2 + 2</td><td>D*2 + 2</td><td>D*4 + 2</td><td>D*4 + 2</td><td>D*4 + 2</td><td>D*4 + 2</td></tr>
<tr> <td>Work area<br>(_FS_TINY == 0)</td><td>V*560 +<br>F*550</td><td>V*560 +<br>F*550</td><td>V*560 +<br>F*550</td><td>V*560 +<br>F*544</td><td>V*560 +<br>F*550</td><td>V*560 +<br>F*544</td><td>V*560 +<br>F*544</td><td>V*560 +<br>F*544</td><td>V*560 +<br>F*550</td><td>V*560 +<br>F*550</td><td>V*560 +<br>F*550</td></tr>
<tr><td>Work area<br>(_FS_TINY == 1)</td><td>V*560 +<br>F*36</td><td>V*560 +<br>F*36</td><td>V*560 +<br>F*36</td><td>V*560 +<br>F*32</td><td>V*560 +<br>F*36</td><td>V*560 +<br>F*32</td><td>V*560 +<br>F*32</td><td>V*560 +<br>F*36</td><td>V*560 +<br>F*36</td><td>V*560 +<br>F*36</td><td>V*560 +<br>F*36</td></tr>
<!-- *ARM *Thumb *CM3 *AVR *H8 *PIC24 RL78 *V850ES *SH-2A *RX600 *IA-32 -->
<tr class="lst3"><td>text (Full, R/W)</td><td>10395</td><td>7037</td><td>6555</td><td>13362</td><td>10609</td><td>11364</td><td>12884</td><td>7814</td><td>8783</td><td>5826</td><td>7659</td></tr>
<tr> <td>text (Min, R/W)</td> <td>6519</td><td>4747</td><td>4315</td> <td>8608</td> <td>7043</td> <td>7539</td> <td>8860</td><td>5070</td><td>5723</td><td>3821</td><td>5038</td></tr>
<tr> <td>text (Full, R/O)</td> <td>4563</td><td>3147</td><td>2911</td> <td>6174</td> <td>4925</td> <td>5340</td> <td>6136</td><td>3628</td><td>3863</td><td>2721</td><td>3534</td></tr>
<tr> <td>text (Min, R/O)</td> <td>3311</td><td>2463</td><td>2209</td> <td>4610</td> <td>3817</td> <td>4029</td> <td>4641</td><td>2762</td><td>3003</td><td>2068</td><td>2722</td></tr>
<tr> <td>bss</td><td>V*4 + 2</td><td>V*4 + 2</td><td>V*4 + 2</td><td>V*2 + 2</td><td>V*4 + 2</td><td>V*2 + 2</td><td>V*2 + 2</td><td>V*4 + 2</td><td>V*4 + 2</td><td>V*4 + 2</td><td>V*4 + 2</td></tr>
<tr> <td>Work area<br>(_FS_TINY == 0)</td><td>V*564 +<br>F*550</td><td>V*564 +<br>F*550</td><td>V*564 +<br>F*550</td><td>V*564 +<br>F*544</td><td>V*564 +<br>F*550</td><td>V*564 +<br>F*544</td><td>V*564 +<br>F*544</td><td>V*564 +<br>F*544</td><td>V*564 +<br>F*550</td><td>V*564 +<br>F*550</td><td>V*564 +<br>F*550</td></tr>
<tr><td>Work area<br>(_FS_TINY == 1)</td><td>V*564 +<br>F*36</td><td>V*564 +<br>F*36</td><td>V*564 +<br>F*36</td><td>V*564 +<br>F*32</td><td>V*564 +<br>F*36</td><td>V*564 +<br>F*32</td><td>V*564 +<br>F*32</td><td>V*564 +<br>F*36</td><td>V*564 +<br>F*36</td><td>V*564 +<br>F*36</td><td>V*564 +<br>F*36</td></tr>
</table>
<pre>
FatFs R0.09a options:
FatFs R0.09b options:
_FS_READONLY 0 (R/W), 1 (R/O)
_FS_MINIMIZE 0 (Full function), 3 (Minimized function)
_USE_STRFUNC 0 (Disable string functions)
@ -98,8 +100,9 @@ _USE_FASTSEEK 0 (Disable fast seek feature)
_CODE_PAGE 932 (Japanese Shift-JIS)
_USE_LFN 0 (Disable LFN)
_MAX_SS 512 (Fixed sector size)
_FS_RPATH 0 (Disable relative path)
_VOLUMES D (Number of logical drives to be used)
_FS_RPATH 0 (Disable relative path feature)
_FS_LABEL 0 (Disable volume label functions)
_VOLUMES V (Number of logical drives to be used)
_MULTI_PARTITION 0 (Single partition per drive)
_FS_REENTRANT 0 (Disable reentrancy)
_FS_LOCK 0 (Disable file lock control)
@ -110,41 +113,43 @@ _FS_LOCK 0 (Disable file lock control)
<h3>モジュール・サイズの縮小</h3>
<p>次の表は構成オプションの設定値によりどの機能が削除されるかを示します。</p>
<table class="lst2">
<tr><td rowspan="2">Function</td><td colspan="4">_FS_MINIMIZE</td><td colspan="2">_FS_READONLY</td><td colspan="2">_USE_STRFUNC</td><td colspan="3">_FS_RPATH</td><td colspan="2">_USE_MKFS</td><td colspan="2">_USE_FORWARD</td><td colspan="2">_MULTI_PARTITION</td></tr>
<tr><td>0</td><td>1</td><td>2</td><td>3</td><td>0</td><td>1</td><td>0&nbsp;&nbsp;</td><td>1/2</td><td>0</td><td>1</td><td>2</td><td>0</td><td>1</td><td>0</td><td>1</td><td>0/1</td><td>2</td></tr>
<tr class="lst3"><td>f_mount</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr>
<tr><td>f_open</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr>
<tr><td>f_close</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr>
<tr><td>f_read</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr>
<tr><td>f_write</td><td></td><td></td><td></td><td></td><td></td><td>x</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr>
<tr><td>f_sync</td><td></td><td></td><td></td><td></td><td></td><td>x</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr>
<tr><td>f_lseek</td><td></td><td></td><td></td><td>x</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr>
<tr><td>f_opendir</td><td></td><td></td><td>x</td><td>x</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr>
<tr><td>f_readdir</td><td></td><td></td><td>x</td><td>x</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr>
<tr><td>f_stat</td><td></td><td>x</td><td>x</td><td>x</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr>
<tr><td>f_getfree</td><td></td><td>x</td><td>x</td><td>x</td><td></td><td>x</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr>
<tr><td>f_truncate</td><td></td><td>x</td><td>x</td><td>x</td><td></td><td>x</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr>
<tr><td>f_unlink</td><td></td><td>x</td><td>x</td><td>x</td><td></td><td>x</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr>
<tr><td>f_mkdir</td><td></td><td>x</td><td>x</td><td>x</td><td></td><td>x</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr>
<tr><td>f_chmod</td><td></td><td>x</td><td>x</td><td>x</td><td></td><td>x</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr>
<tr><td>f_utime</td><td></td><td>x</td><td>x</td><td>x</td><td></td><td>x</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr>
<tr><td>f_rename</td><td></td><td>x</td><td>x</td><td>x</td><td></td><td>x</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr>
<tr><td>f_chdir</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td>x</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr>
<tr><td>f_chdrive</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td>x</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr>
<tr><td>f_getcwd</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td>x</td><td>x</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr>
<tr><td>f_mkfs</td><td></td><td></td><td></td><td></td><td></td><td>x</td><td></td><td></td><td></td><td></td><td></td><td>x</td><td></td><td></td><td></td><td></td><td></td></tr>
<tr><td>f_fdisk</td><td></td><td></td><td></td><td></td><td></td><td>x</td><td></td><td></td><td></td><td></td><td></td><td>x</td><td></td><td></td><td></td><td>x</td><td></td></tr>
<tr><td>f_forward</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td>x</td><td></td><td></td><td></td></tr>
<tr><td>f_putc</td><td></td><td></td><td></td><td></td><td></td><td>x</td><td>x</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr>
<tr><td>f_puts</td><td></td><td></td><td></td><td></td><td></td><td>x</td><td>x</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr>
<tr><td>f_printf</td><td></td><td></td><td></td><td></td><td></td><td>x</td><td>x</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr>
<tr><td>f_gets</td><td></td><td></td><td></td><td></td><td></td><td></td><td>x</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr>
<tr><td rowspan="2">Function</td><td colspan="4">_FS_MINIMIZE</td><td colspan="2">_FS_READONLY</td><td colspan="2">_USE_STRFUNC</td><td colspan="3">_FS_RPATH</td><td colspan="2">_FS_LABEL</td><td colspan="2">_USE_MKFS</td><td colspan="2">_USE_FORWARD</td><td colspan="2">_MULTI_PARTITION</td></tr>
<tr><td>0</td><td>1</td><td>2</td><td>3</td><td>0</td><td>1</td><td>0&nbsp;&nbsp;</td><td>1/2</td><td>0</td><td>1</td><td>2</td><td>0</td><td>1</td><td>0</td><td>1</td><td>0</td><td>1</td><td>0/1</td><td>2</td></tr>
<tr class="lst3"><td>f_mount</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr>
<tr><td>f_open</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr>
<tr><td>f_close</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr>
<tr><td>f_read</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr>
<tr><td>f_write</td><td></td><td></td><td></td><td></td><td></td><td>x</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr>
<tr><td>f_sync</td><td></td><td></td><td></td><td></td><td></td><td>x</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr>
<tr><td>f_lseek</td><td></td><td></td><td></td><td>x</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr>
<tr><td>f_opendir</td><td></td><td></td><td>x</td><td>x</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr>
<tr><td>f_readdir</td><td></td><td></td><td>x</td><td>x</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr>
<tr><td>f_stat</td><td></td><td>x</td><td>x</td><td>x</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr>
<tr><td>f_getfree</td><td></td><td>x</td><td>x</td><td>x</td><td></td><td>x</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr>
<tr><td>f_truncate</td><td></td><td>x</td><td>x</td><td>x</td><td></td><td>x</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr>
<tr><td>f_unlink</td><td></td><td>x</td><td>x</td><td>x</td><td></td><td>x</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr>
<tr><td>f_mkdir</td><td></td><td>x</td><td>x</td><td>x</td><td></td><td>x</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr>
<tr><td>f_chmod</td><td></td><td>x</td><td>x</td><td>x</td><td></td><td>x</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr>
<tr><td>f_utime</td><td></td><td>x</td><td>x</td><td>x</td><td></td><td>x</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr>
<tr><td>f_rename</td><td></td><td>x</td><td>x</td><td>x</td><td></td><td>x</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr>
<tr><td>f_chdir</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td>x</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr>
<tr><td>f_chdrive</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td>x</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr>
<tr><td>f_getcwd</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td>x</td><td>x</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr>
<tr><td>f_getlabel</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td>x</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr>
<tr><td>f_setlabel</td><td></td><td></td><td></td><td></td><td></td><td>x</td><td></td><td></td><td></td><td></td><td></td><td>x</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr>
<tr><td>f_forward</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td>x</td><td></td><td></td><td></td></tr>
<tr><td>f_mkfs</td><td></td><td></td><td></td><td></td><td></td><td>x</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td>x</td><td></td><td></td><td></td><td></td><td></td></tr>
<tr><td>f_fdisk</td><td></td><td></td><td></td><td></td><td></td><td>x</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td>x</td><td></td><td></td><td></td><td>x</td><td></td></tr>
<tr><td>f_putc</td><td></td><td></td><td></td><td></td><td></td><td>x</td><td>x</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr>
<tr><td>f_puts</td><td></td><td></td><td></td><td></td><td></td><td>x</td><td>x</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr>
<tr><td>f_printf</td><td></td><td></td><td></td><td></td><td></td><td>x</td><td>x</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr>
<tr><td>f_gets</td><td></td><td></td><td></td><td></td><td></td><td></td><td>x</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr>
</table>
</div>
<div class="para" id="lfn">
<h3>長いファイル名</h3>
<p>FatFsモジュールはR0.07から長いファイル名(LFN)をサポートしました。ファイルに付けられた2つの異なる名前(短いファル名と長いファイル名)は、f_readdir関数を除くファイル操作関数において透過です。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モジュールは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>何らかのリエントラント状態の下でLFN機能を使用する場合は、<tt>_USE_LFN</tt>は2または3に設定されなければなりません。この場合、ファイル関数はバッファをスタックやヒープに確保します。バッファ・サイズは、<tt>(_MAX_LFN + 1) * 2</tt>バイトになるので、スタック等のサイズはそれを考慮した十分なサイズでなければなりません。</p>
<table class="lst2 rset">
<caption>LFN cfg on ARM7</caption>
@ -155,7 +160,7 @@ _FS_LOCK 0 (Disable file lock control)
<tr><td>949(Korean)</td><td>+139857</td></tr>
<tr><td>950(Big5)</td><td>+111497</td></tr>
</table>
<p>LFN機能の上手な使い方は、それを使わないということです。実際、組み込み用途ではLFN機能がどうしても必要になるということはほとんど無いはずです。LFNを有効にすると、選択されたコード・ページに応じてモジュール・サイズが増大されます。右の表に各コード・ページにおけるLFNを有効にしたときのモジュール・サイズの違いを示します。私たち日本人、中国人および韓国人は数万の文字を持ちます。不幸なことに、それは巨大なOEMUnicode相互変換テーブルを要求し、モジュール・サイズは劇的に増大されます。その結果、LFNを有効にしたFatFsモジュールは、AVRを含む殆どの8ビット・マイコンにインプリメントされることができません。<small>これは長い間私がLFNをインプリメントすることに興味を持ってこなかった理由です。</small></p>
<p>LFN機能の上手な使い方は、それを使わないということです。実際、組み込み用途ではLFN機能がどうしても必要になるということはほとんど無いはずです。LFNを有効にすると、選択されたコード・ページに応じてモジュール・サイズが増大されます。右の表に各コード・ページにおけるLFNを有効にしたときのモジュール・サイズの違いを示します。特に、CJK地域では数万の文字が使われていますが、不幸なことにそれは巨大なOEMUnicode相互変換テーブルを要求し、モジュール・サイズは劇的に増大されます。その結果、それらのコード・ページにおいてLFNを有効にしたFatFsモジュールは、AVRを含む殆どの8ビット・マイコンにインプリメントされることができません。</p>
<p>注: マイクロソフト社はFATファイル・システムについていくつかの特許を保有しています。いずれもLFNの実装に関するもので、LFN機能に対して$0.25/unitのライセンス料を要求しています。最近のFAT32ドライバの多くはLFN機能を含んでいるため、それらの使用に当たってライセンスが必要になりますが、FatFsではLFN機能の有効・無効を任意に構成できます。このため、商用製品でLFN機能を有効にするときは、最終仕向地によってはライセンスが必要かも知れません。</p>
</div>
@ -166,7 +171,7 @@ _FS_LOCK 0 (Disable file lock control)
<div class="para" id="unicode">
<h3>Unicode入出力への対応</h3>
<p>ファイル関数のファイル名入出力はデフォルトでは ANSI/OEMコードですが、これをUnicodeに切り替えることもできます。Unicodeファイル名に関する詳細は、<a href="filename.html">ファイル名</a>を参照してください。</p>
<p>API上におけるファイル名の入出力はデフォルトではANSI/OEMコードで行われますが、これをUnicodeに切り替えることもできます。つまり、これはFatFsがLFN機能に完全対応していることを意味します。Unicodeファイル名に関する詳細は、<a href="filename.html">ファイル名</a>を参照してください。</p>
</div>
<div class="para" id="reentrant">
@ -185,7 +190,7 @@ _FS_LOCK 0 (Disable file lock control)
<div class="para" id="fs1">
<h3>効率的なファイル・アクセス</h3>
<p>小規模な組込システムでのファイルの読み書きにおける効率の良いアクセスのため、アプリケーション・プログラマはFatFsモジュールの中でどのような処理が行われているか考慮すべきです。ストレージ上のデータはf_read関数により次のシーケンスで転送されます。</p>
<p>小規模な組込システムでのファイルの読み書きにおける効率の良いアクセスのため、アプリケーション・プログラマはFatFsモジュールの中でどのような処理が行われているか考慮すべきです。ストレージ上のデータは<tt>f_read()</tt>により次のシーケンスで転送されます。</p>
<p>図1. セクタ・ミスアラインド・リード (ショート)<br>
<img src="../img/f1.png" width="490" height="110" alt="fig.1">
</p>
@ -196,7 +201,7 @@ _FS_LOCK 0 (Disable file lock control)
<img src="../img/f3.png" width="490" height="119" alt="fig.3">
</p>
<p>ファイルI/Oバッファはセクタの一部のデータを読み書きするためのセクタ・バッファを意味します。セクタ・バッファは、それぞれのファイル・オブジェクト内のプライベート・セクタ・バッファまたはファイル・システム・オブジェクト内の共有セクタ・バッファのどちらかです。バッファ構成オプションの<tt>_FS_TINY</tt>は、データ転送にどちらを使うかを決定します。タイニー・バッファ(1)が選択されるとデータ・メモリの消費はそれぞれのファイル・オブジェクトで512バイト減少されます。この場合、FatFsモジュールはファイル・データの転送とFAT/ディレクトリ・アクセスにファイル・システム・オブジェクト内のセクタ・バッファだけを使用します。タイニー・バッファの欠点は、セクタ・バッファにキャッシュされたFATデータがファイル・データの転送により失われ、クラスタ境界の毎にリロードされなければならないことです。でも、悪くない性能と少ないメモリ消費の視点から多くのアプリケーションに適するでしょう。</p>
<p>図1はセクタの一部のデータがファイルI/Oバッファを経由で転送されることを示します。図2に示される長いデータの転送では、転送データの中間の1セクタまたはそれ以上のセクタにまたがる転送データがアプリケーション・バッファに直接転送されています。図3は転送データ全体がセクタ境界にアライメントされている場合を示しています。この場合、ファイルI/Oバッファは使用されません。直接転送においては最大の範囲のセクタがdisk_read関数で一度に読み込まれますが、クラスタ境界を越えるマルチ・セクタ転送はそれが隣接であっても行われません。</p>
<p>図1はセクタの一部のデータがファイルI/Oバッファを経由で転送されることを示します。図2に示される長いデータの転送では、転送データの中間の1セクタまたはそれ以上のセクタにまたがる転送データがアプリケーション・バッファに直接転送されています。図3は転送データ全体がセクタ境界にアライメントされている場合を示しています。この場合、ファイルI/Oバッファは使用されません。直接転送においては最大の範囲のセクタが<tt>disk_read()</tt>で一度に読み込まれますが、クラスタ境界を越えるマルチ・セクタ転送はそれが隣接であっても行われません。</p>
<p>このように、セクタにアライメントしたファイルの読み書きへの配慮はバッファ経由のデータ転送を避け、読み書き性能は改善されるでしょう。その効果に加え、タイニー構成でキャッシュされたFATデータがファイル・データの転送によりフラッシュされず、非タイニー構成と同じ性能を小さなメモリ・フットプリントで達成できます。</p>
</div>
@ -215,7 +220,7 @@ _FS_LOCK 0 (Disable file lock control)
<div class="para" id="critical">
<h3>クリチカル・セクション</h3>
<p>ストレージ上のFAT構造を操作している途中で、停電、不正なメディアの取り外し、回復不能なデータ・エラー等の障害が発生すると、処理が中途半端な状態で中断され、その結果としてFAT構造が破壊される可能性があります。次にFatFsモジュールにおけるクリチカル・セクションと、その間の障害により起きうるエラーの状態を示します。</p>
<p>ストレージ上のFAT構造を操作している途中で、停電、不正なメディアの取り外し、回復不能なデータ・エラー等の障害が発生すると、処理が中途半端な状態で中断され、その結果としてFATボリュームの構造が破壊される可能性があります。次にFatFsモジュールにおけるクリチカル・セクションと、その間の障害により起きうるエラーの状態を示します。</p>
<div class="lset">
図4. 長いクリチカル・セクション<br>
<img src="../img/f4.png" width="320" height="436" alt="fig.4">
@ -233,20 +238,30 @@ _FS_LOCK 0 (Disable file lock control)
<li>新規または上書きで作成されたファイルの長さがゼロになって残る。</li>
<li>ロストチェーンの発生によりボリュームの利用効率が悪化する。</li>
</ul>
<p>いずれも書き込み中や操作対象でないファイルには影響はありません。これらのクリチカル・セクションは、ファイルを書き込みモードで開いている時間を最小限にするか、f_sync()を適宜使用することで図5のようにリスクを最小化することができます。</p>
<p>いずれも書き込み中や操作の対象でないファイルには影響はありません。これらのクリチカル・セクションは、ファイルを書き込みモードで開いている時間を最小限にするか、<tt>f_sync()</tt>を適宜使用することで図5のようにリスクを最小化することができます。</p>
</div>
<div class="para" id="fs3">
<h3>APIの拡張的使用例</h3>
<p>FatFs APIの拡張的使用例です。有用なコードがあった場合は、随時追加していきます。。</p>
<ol>
<li><a href="../img/app1.c">追記モードでのオープン/新規作成</a></li>
<li><a href="../img/app2.c">ディレクトリを空にする</a></li>
<li><a href="../img/app3.c">ファイルに連続領域を割り当てる</a></li>
</ol>
</div>
<div class="para" id="license">
<h3>FatFsのライセンスについて</h3>
<p>ソース・ファイルのヘッダにライセンス条件が記述されているので、利用の際はそれに従うこと。英語を読めない方のために以下に日本語訳を示しておきます。</p>
<pre>/*----------------------------------------------------------------------------/
/ FatFs - FAT file system module R0.09 (C)ChaN, 2011
/ FatFs - FAT file system module R0.09b (C)ChaN, 2013
/-----------------------------------------------------------------------------/
/ FatFsモジュールは、小規模な組み込みシステム向けの汎用FATファイルシステム・
/ モジュールです。これはフリー・ソフトウェアとして、教育・研究・開発のために
/ 以下のライセンス・ポリシーの下で公開されています。
/
/ Copyright (C) 2011, ChaN, all right reserved.
/ Copyright (C) 2013, ChaN, all right reserved.
/
/ * FatFsモジュールはフリー・ソフトウェアであり、また<em>無保証です</em>
/ * 用途に制限はありません。<em>あなたの責任の下において</em>、個人的・非営利的な

View File

@ -16,7 +16,7 @@
<p>カレント・ディレクトリを変更します。</p>
<pre>
FRESULT f_chdir (
const XCHAR* <em>Path</em> <span class="c">/* ディレクトリ名へのポインタ */</span>
const TCHAR* <span class="arg">path</span> <span class="c">/* [IN] ディレクトリ名へのポインタ */</span>
);
</pre>
</div>
@ -24,8 +24,8 @@ FRESULT f_chdir (
<div class="para arg">
<h4>引数</h4>
<dl class="par">
<dt>Path</dt>
<dd>移動対象のディレクトリの<a href="filename.html">パス名</a>の入った<tt>'\0'</tt>で終わる文字列を指定します。</dd>
<dt>path</dt>
<dd>移動対象のディレクトリの<a href="filename.html">パス名</a>を示すヌル文字<tt>'\0'</tt>終端の文字列を指定します。</dd>
</dl>
</div>
@ -50,7 +50,7 @@ FRESULT f_chdir (
<div class="para desc">
<h4>解説</h4>
<p>f_chdir関数は各ボリュームのカレント・ディレクトリを変更します。カレント・ディレクトリはファイル・システム・オブジェクトの初期化が行われたとき、ルート・ディレクトリに設定されます。カレント・ディレクトリは、ファイル・システム・オブジェクトに記録されるため、そのボリュームを使用する全てのタスクに対して影響を与えます。</p>
<p>各ボリュームのカレント・ディレクトリを変更します。カレント・ディレクトリはファイル・システム・オブジェクトの初期化が行われたとき、ルート・ディレクトリに設定されます。カレント・ディレクトリは、ファイル・システム・オブジェクトに保持されるため、そのボリュームを使用する全てのタスクに対して影響を与えます。</p>
</div>
@ -63,10 +63,10 @@ FRESULT f_chdir (
<div class="para exa">
<h4>使用例</h4>
<pre>
// カレント・ドライブのカレント・ディレクトリを変更 (ルート下のdir1へ)
<span class="c">/* カレント・ドライブのカレント・ディレクトリを変更 (ルート下のdir1へ) */</span>
f_chdir("/dir1");
// ドライブ2のカレント・ディレクトリを変更 (親ディレクトリへ)
<span class="c">/* ドライブ2のカレント・ディレクトリを変更 (親ディレクトリへ) */</span>
f_chdir("2:..");
</pre>
</div>

View File

@ -16,7 +16,7 @@
<p>カレント・ドライブを変更します。</p>
<pre>
FRESULT f_chdrive (
BYTE <em>Drive</em> <span class="c">/* 論理ドライブ番号 */</span>
BYTE <span class="arg">vol</span> <span class="c">/* [IN] 論理ドライブ番号 */</span>
);
</pre>
</div>
@ -24,7 +24,7 @@ FRESULT f_chdrive (
<div class="para arg">
<h4>引数</h4>
<dl class="par">
<dt>Drive</dt>
<dt>vol</dt>
<dd>カレント・ドライブに設定する<a href="filename.html">論理ドライブ番号</a>を指定します。</dd>
</dl>
</div>
@ -41,7 +41,7 @@ FRESULT f_chdrive (
<div class="para desc">
<h4>解説</h4>
<p>f_chdrive関数はカレント・ドライブを変更します。システム起動時の初期値は0です。この設定はFatFsモジュールの静的変数に記録されるため、全てのタスクに対して影響を与えます。</p>
<p>カレント・ドライブを変更します。システム起動時の初期値は0です。この設定はFatFsモジュールの静的変数に記録されるため、全てのタスクに対して影響を与えます。</p>
</div>

View File

@ -16,9 +16,9 @@
<p>ファイルまたはディレクトリの属性を変更します。</p>
<pre>
FRESULT f_chmod (
const TCHAR* <em>FileName</em>, <span class="c">/* ファイルまたはディレクトリ名へのポインタ */</span>
BYTE <em>Attribute</em>, <span class="c">/* 設定値 */</span>
BYTE <em>AttributeMask</em> <span class="c">/* 変更マスク */</span>
const TCHAR* <span class="arg">path</span>, <span class="c">/* [IN] ファイルまたはディレクトリ名へのポインタ */</span>
BYTE <span class="arg">attr</span>, <span class="c">/* [IN] 設定値 */</span>
BYTE <span class="arg">mask</span> <span class="c">/* [IN] 変更マスク */</span>
);
</pre>
</div>
@ -26,9 +26,9 @@ FRESULT f_chmod (
<div class="para arg">
<h4>引数</h4>
<dl class="par">
<dt>FileName</dt>
<dd>属性変更対象のファイルまたはディレクトリ<a href="filename.html">パス名</a>の入った<tt>'\0'</tt>で終わる文字列を指定します。</dd>
<dt>Attribute</dt>
<dt>path</dt>
<dd>属性変更対象のファイルまたはディレクトリ<a href="filename.html">パス名</a>を示すヌル文字<tt>'\0'</tt>終端の文字列を指定します。</dd>
<dt>attr</dt>
<dd>設定する属性。指定可能な属性は次の通りで、これらの組み合わせで指定します。指定されなかった属性は解除されます。<br>
<table class="lst">
<tr><th></th><th>意味</th></tr>
@ -38,8 +38,8 @@ FRESULT f_chmod (
<tr><td>AM_HID</td><td>ヒドゥン</td></tr>
</table>
</dd>
<dt>AttributeMask</dt>
<dd>変更する属性のマスク。指定した属性が設定または解除され、指定されなかった属性は状態が保持されます。<tt>Attribute</tt>と同じ値を使います。</dd>
<dt>mask</dt>
<dd>変更する属性のマスク。指定した属性が設定または解除され、指定されなかった属性は状態が保持されます。<tt class="arg">attr</tt>と同じ値を使います。</dd>
</dl>
</div>

View File

@ -16,7 +16,7 @@
<p>ファイルを閉じます。</p>
<pre>
FRESULT f_close (
FIL* <em>FileObject</em> <span class="c">/* ファイル・オブジェクトへのポインタ */</span>
FIL* <span class="arg">fp</span> <span class="c">/* [IN] ファイル・オブジェクトへのポインタ */</span>
);
</pre>
</div>
@ -24,7 +24,7 @@ FRESULT f_close (
<div class="para arg">
<h4>引数</h4>
<dl class="par">
<dt>FileObject</dt>
<dt>fp</dt>
<dd>閉じようとするファイルのファイル・オブジェクト構造体へのポインタを指定します。</dd>
</dl>
</div>

View File

@ -16,7 +16,7 @@
<p>ディスク・ドライブを初期化します。</p>
<pre>
DSTATUS disk_initialize (
BYTE <em>Drive</em> <span class="c">/* 物理ドライブ番号 */</span>
BYTE <span class="arg">pdrv</span> <span class="c">/* [IN] 物理ドライブ番号 */</span>
);
</pre>
</div>
@ -24,8 +24,8 @@ DSTATUS disk_initialize (
<div class="para arg">
<h4>引数</h4>
<dl class="par">
<dt>Drive</dt>
<dd>初期化する物理ドライブ番号(0-9)を指定します。</dd>
<dt>pdrv</dt>
<dd>初期化する物理ドライブ番号(0-9)が指定されます。</dd>
</dl>
</div>
@ -38,7 +38,7 @@ DSTATUS disk_initialize (
<div class="para desc">
<h4>解説</h4>
<p>ディスク・ドライブを初期化します。関数が成功すると、戻り値の<tt>STA_NOINIT</tt>フラグがクリアされます。</p>
<p><em>アプリケーションからはこの関数を呼び出してはなりません。さもないと、FATボリュームが破壊されます。エラー等により再初期化が必要なときは、<tt>f_mount()</tt>を使用してください。</em>FatFsモジュールは、自動マウント動作により、必要に応じてこの関数を呼び出します。</p>
<p><em>FatFsを使用中はアプリケーションからはこの関数を呼び出してはなりません。さもないと、FATボリュームが破壊されます。エラー等により再初期化が必要なときは、<tt>f_mount()</tt>を使用してください。</em>FatFsモジュールは、自動マウント動作により、必要に応じてこの関数を呼び出します。</p>
</div>
<p class="foot"><a href="../00index_j.html">戻る</a></p>

View File

@ -16,9 +16,9 @@
<p>セクタの読み書き以外のディスク・ドライブ自体に対する様々な制御をします。</p>
<pre>
DRESULT disk_ioctl (
BYTE <em>Drive</em>, <span class="c">/* 物理ドライブ番号 */</span>
BYTE <em>Command</em>, <span class="c">/* 制御コマンド */</span>
void* <em>Buffer</em> <span class="c">/* データ受け渡しバッファ */</span>
BYTE <span class="arg">pdrv</span>, <span class="c">/* [IN] 物理ドライブ番号 */</span>
BYTE <span class="arg">cmd</span>, <span class="c">/* [IN] 制御コマンド */</span>
void* <span class="arg">buff</span> <span class="c">/* [I/O] データ受け渡しバッファ */</span>
);
</pre>
</div>
@ -26,12 +26,12 @@ DRESULT disk_ioctl (
<div class="para arg">
<h4>引数</h4>
<dl class="par">
<dt>Drive</dt>
<dd>物理ドライブ番号(0-9)を指定します。</dd>
<dt>Command</dt>
<dd>制御コマンド・コードを指定します。</dd>
<dt>Buffer</dt>
<dd>制御コマンドに依存したパラメータを授受するバッファを指すポインタを指定します。データの授受のないコマンドの場合は、NULLを指定します</dd>
<dt>pdrv</dt>
<dd>物理ドライブ番号(0-9)が指定されます。</dd>
<dt>cmd</dt>
<dd>制御コマンド・コードが指定されます。</dd>
<dt>buff</dt>
<dd>制御コマンドに依存したパラメータを授受するバッファを指すポインタが指定されます。データの授受のないコマンドの場合は、値に意味はありません</dd>
</dl>
</div>
@ -55,10 +55,10 @@ DRESULT disk_ioctl (
<table class="lst">
<tr><th>コマンド</th><th>解説</th></tr>
<tr><td>CTRL_SYNC</td><td>ドライブがデータの書き込み処理を完了するのを待ちます。また、ライト・バック・キャッシュが存在する場合は、書き込まれていないデータを即時書き戻します。リード・オンリー構成では使用されません。</td></tr>
<tr><td>GET_SECTOR_SIZE</td><td><tt>Buffer</tt>の指すWORD変数にドライブのセクタ・サイズを返します。セクタ・サイズが固定(<tt>_MAX_SS</tt>が512)のときはこのコマンドは使われません。</td></tr>
<tr><td>GET_SECTOR_COUNT</td><td><tt>Buffer</tt>の指すDWORD変数にドライブ上の総セクタ数を返します。f_mkfs関数内で作成するボリュームのサイズを決定するために使用されます。</td></tr>
<tr><td>GET_BLOCK_SIZE</td><td>フラッシュ・メモリの消去ブロック・サイズを<tt>Buffer</tt>の指すDWORD変数にセクタ単位で返します。1から32768でかつ2の累乗の値でなければなりません。不明な場合またはフラッシュ・メモリ以外のメディアでは1を返します。f_mkfs関数内でのみ使用され、ボリュームのデータ領域はこの境界にアライメントされます。</td></tr>
<tr><td>CTRL_ERASE_SECTOR</td><td>フラッシュ・メモリの一部の領域を消去します。<tt>Buffer</tt>の指すDWORD配列には消去する領域 {開始セクタ,終了セクタ} を指定して呼び出します。この機能をサポートしない場合やフラッシュ・メモリ以外のメディアでは何もしません。この機能の戻り値はチェックされず、また、指定領域の消去が完全に行われなかったとしてもファイル・システムの動作には影響ありません。<tt>_USE_ERASE</tt>が1のとき、クラスタが解放されるときに呼び出されます</td></tr>
<tr><td>GET_SECTOR_SIZE</td><td><tt class="arg">buff</tt>の指す<tt>WORD</tt>変数にドライブのセクタ・サイズを返します。セクタ・サイズが固定(<tt>_MAX_SS</tt>が512)のときはこのコマンドは使われません。</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_BLOCK_SIZE</td><td>フラッシュ・メモリの消去ブロック・サイズを<tt class="arg">buff</tt>の指すDWORD変数にセクタ単位で返します。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>配列には消去する領域 {開始セクタ,終了セクタ} を指定して呼び出します。これは、ATAコマンド・セットのTrimコマンドと等価で、<tt>_USE_ERASE</tt>が1のとき、クラスタが解放されるときに呼び出されます。この機能をサポートしない場合やフラッシュ・メモリ以外のメディアでは何もしません。この機能の戻り値はチェックされず、また、指定領域の消去が完全に行われなかったとしてもFatFsの動作には影響ありません</td></tr>
</table>
</div>

View File

@ -16,10 +16,10 @@
<p>ディスクからセクタを読み出します。</p>
<pre>
DRESULT disk_read (
BYTE <em>Drive</em>, <span class="c">/* 物理ドライブ番号 */</span>
BYTE* <em>Buffer</em>, <span class="c">/* 読み出しバッファへのポインタ */</span>
DWORD <em>SectorNumber</em>, <span class="c">/* 読み出し開始セクタ番号 */</span>
BYTE <em>SectorCount</em> <span class="c">/* 読み出しセクタ数 */</span>
BYTE <span class="arg">pdrv</span>, <span class="c">/* [IN] 物理ドライブ番号 */</span>
BYTE* <span class="arg">buff</span>, <span class="c">/* [OUT] 読み出しバッファへのポインタ */</span>
DWORD <span class="arg">sector</span>, <span class="c">/* [IN] 読み出し開始セクタ番号 */</span>
BYTE <span class="arg">count</span> <span class="c">/* [IN] 読み出しセクタ数 */</span>
);
</pre>
</div>
@ -27,14 +27,14 @@ DRESULT disk_read (
<div class="para arg">
<h4>引数</h4>
<dl class="par">
<dt>Drive</dt>
<dd>物理ドライブ番号(0-9)を指定します。</dd>
<dt>Buffer</dt>
<dd>ディスクから読み出したデータを格納する<em>バイト配列</em>で、読み出されるバイト数分のサイズが必要です。指定されるアドレスはワード・アライメントされているとは限りません。</dd>
<dt>SectorNumber</dt>
<dd>読み出しを開始するセクタ番号。LBAで指定ます。</dd>
<dt>SectorCount</dt>
<dd>読み出すセクタ数。 1128の範囲で指定ます。一般的に、複数セクタの転送要求はデバイスに対して可能な限りマルチ・セクタ転送しなければなりません。複数のシングル・セクタ転送に分解した場合、読み出し速度が低下します。</dd>
<dt>pdrv</dt>
<dd>物理ドライブ番号(0-9)が指定されます。</dd>
<dt>buff</dt>
<dd>ディスクから読み出したデータを格納する<em>バイト配列</em>で、読み出されるバイト数分のサイズが必要です。指定されるアドレスは<em>常にワード・アライメントされているとは限りません</em></dd>
<dt>sector</dt>
<dd>読み出しを開始するセクタ番号。LBAで指定されます。</dd>
<dt>count</dt>
<dd>読み出すセクタ数。 1128の範囲で指定されます。一般的に、複数セクタの転送要求はデバイスに対して可能な限りマルチ・セクタ転送しなければなりません。複数のシングル・セクタ読み出しに分解した場合、スループットが低下することがあります。</dd>
</dl>
</div>

View File

@ -16,7 +16,7 @@
<p>ディスク・ドライブの状態を取得します。</p>
<pre>
DSTATUS disk_status (
BYTE <em>Drive</em> <span class="c">/* 物理ドライブ番号 */</span>
BYTE <span class="arg">pdrv</span> <span class="c">/* [IN] 物理ドライブ番号 */</span>
);
</pre>
</div>
@ -24,18 +24,18 @@ DSTATUS disk_status (
<div class="para arg">
<h4>引数</h4>
<dl class="par">
<dt>Drive</dt>
<dd>ステータスを取得する物理ドライブ番号を指定します。</dd>
<dt>pdrv</dt>
<dd>ステータスを取得する物理ドライブ番号が指定されます。</dd>
</dl>
</div>
<div class="para ret">
<h4>戻り値</h4>
<p>物理ドライブの状態が次のフラグの組み合わせの値で返されます。</p>
<p>物理ドライブの状態を次のフラグの組み合わせ値で返します。</p>
<dl class="ret">
<dt>STA_NOINIT</dt>
<dd>ドライブが初期化されていないことを示すフラグ。システム・リセットやメディアの取り外し等でセットされ、disk_initialize() の正常終了でクリア、失敗でセットされます。</dd>
<dd>ドライブが初期化されていないことを示すフラグ。システム・リセットやメディアの取り外し等でセットされ、<tt>disk_initialize()</tt>の正常終了でクリア、失敗でセットされます。</dd>
<dt>STA_NODISK</dt>
<dd>メディアがセットされていないことを示すフラグ。メディアが取り外されている間はセットされ、メディアがセットされている間はクリアされます。固定ディスクでは常にクリアされています。</dd>
<dt>STA_PROTECTED</dt>

View File

@ -16,10 +16,10 @@
<p>ディスクにデータを書き込みます。</p>
<pre>
DRESULT disk_write (
BYTE <em>Drive</em>, <span class="c">/* 物理ドライブ番号 */</span>
const BYTE* <em>Buffer</em>, <span class="c">/* 書き込むデータへのポインタ */</span>
DWORD <em>SectorNumber</em>, <span class="c">/* 書き込み開始セクタ番号 */</span>
BYTE <em>SectorCount</em> <span class="c">/* 書き込みセクタ数 */</span>
BYTE <span class="arg">pdrv</span>, <span class="c">/* [IN] 物理ドライブ番号 */</span>
const BYTE* <span class="arg">buff</span>, <span class="c">/* [IN] 書き込むデータへのポインタ */</span>
DWORD <span class="arg">sector</span>, <span class="c">/* [IN] 書き込み開始セクタ番号 */</span>
BYTE <span class="arg">count</span> <span class="c">/* [IN] 書き込みセクタ数 */</span>
);
</pre>
</div>
@ -27,14 +27,14 @@ DRESULT disk_write (
<div class="para arg">
<h4>引数</h4>
<dl class="par">
<dt>Drive</dt>
<dd>物理ドライブ番号(0-9)を指定します。</dd>
<dt>Buffer</dt>
<dd>ディスクに書き込む<em>バイト配列</em>を指定します。指定されるアドレスはワード・アライメントされているとは限りません。</dd>
<dt>SectorNumber</dt>
<dd>書き込みを開始するセクタ番号。LBAで指定ます。</dd>
<dt>SectorCount</dt>
<dd>書き込むセクタ数。 1128で指定します。一般的に、複数セクタの転送要求はデバイスに対して可能な限りマルチ・セクタ転送しなければなりません。複数のシングル・セクタ転送に分解した場合、書き込み速度は極端に低下します。</dd>
<dt>pdrv</dt>
<dd>物理ドライブ番号(0-9)が指定されます。</dd>
<dt>buff</dt>
<dd>ディスクに書き込む<em>バイト配列</em>が指定されます。<em>アドレスは常にワード・アライメントされているとは限りません</em></dd>
<dt>sector</dt>
<dd>書き込みを開始するセクタ番号。LBAで指定されます。</dd>
<dt>count</dt>
<dd>書き込むセクタ数。 1128の範囲で指定されます。一般的に、複数セクタの転送要求はデバイスに対して可能な限りマルチ・セクタ転送しなければなりません。複数のシングル・セクタ書き込みに分解した場合、スループットが極端に低下することがあります。</dd>
</dl>
</div>
@ -59,6 +59,7 @@ DRESULT disk_write (
<div class="para desc">
<h4>解説</h4>
<p>リード・オンリー構成ではこの関数は必要とされません。</p>
<p><em>FatFsの使用中はアプリケーションからはこの関数を呼び出してはなりません。さもないと、FATボリュームが破壊されます。エラー等により再初期化が必要なときは、<tt>f_mount()</tt>を使用してください。</em>FatFsモジュールは、自動マウント動作により、必要に応じてこの関数を呼び出します。</p>
</div>

View File

@ -16,7 +16,7 @@
<p>リード/ライト・ポインタがファイル終端に達しているかどうか調べます。.</p>
<pre>
int f_eof (
FIL* <em>FileObject</em> <span class="c">/* ファイル・オブジェクト */</span>
FIL* <span class="arg">fp</span> <span class="c">/* [IN] ファイル・オブジェクト */</span>
);
</pre>
</div>
@ -25,7 +25,7 @@ int f_eof (
<div class="para arg">
<h4>引数</h4>
<dl class="par">
<dt>FileObject</dt>
<dt>fp</dt>
<dd>ファイル・オブジェクト構造体へのポインタを指定します。</dd>
</dl>
</div>

View File

@ -16,7 +16,7 @@
<p>エラー発生の有無を調べます。</p>
<pre>
int f_error (
FIL* <em>FileObject</em> <span class="c">/* ファイル・オブジェクト */</span>
FIL* <span class="arg">fp</span> <span class="c">/* [IN] ファイル・オブジェクト */</span>
);
</pre>
</div>
@ -25,7 +25,7 @@ int f_error (
<div class="para arg">
<h4>引数</h4>
<dl class="par">
<dt>FileObject</dt>
<dt>fp</dt>
<dd>ファイル・オブジェクト構造体へのポインタを指定します。</dd>
</dl>
</div>

View File

@ -16,9 +16,9 @@
<p>物理ドライブを分割します。</p>
<pre>
FRESULT f_fdisk (
BYTE <em>Drive</em>, <span class="c">/* 物理ドライブ番号 */</span>
const DWORD <em>Partitions[]</em>, <span class="c">/* 区画マップ・テーブル */</span>
void* <em>Work</em> <span class="c">/* ワークエリア */</span>
BYTE <span class="arg">pdrv</span>, <span class="c">/* [IN] 物理ドライブ番号 */</span>
const DWORD <em>part[]</em>, <span class="c">/* [IN] 区画マップ・テーブル */</span>
void* <span class="arg">work</span> <span class="c">/* [-] ワークエリア */</span>
);
</pre>
</div>
@ -26,11 +26,11 @@ FRESULT f_fdisk (
<div class="para arg">
<h4>引数</h4>
<dl class="par">
<dt>Drive</dt>
<dt>pdrv</dt>
<dd>分割する<em>物理ドライブ</em>を指定します。</dd>
<dt>Partitions[]</dt>
<dt>part[]</dt>
<dd>区画マップ・テーブルへのポインタを指定します。</dd>
<dt>Work</dt>
<dt>work</dt>
<dd>ワークエリアへのポインタを指定します。サイズは<tt>_MAX_SS</tt>バイト必要です。</dd>
</dl>
</div>
@ -48,18 +48,18 @@ FRESULT f_fdisk (
<div class="para desc">
<h4>説明</h4>
<p>f_fdisk関数は、指定された物理ドライブのMBRに区画テーブルを作成します。区画分けは一般的なFDISK形式で行うため、最大4つの基本区画を作成することができます。拡張区画には対応していません。区画マップテーブル Partitions[] にはドライブをどのように分割するか指定して渡します。この配列は4つの項目から成り、先頭の項目が1番目の、最後の項目が4番目の区画のサイズを示します。値が100以下の場合、ドライブの総容量に対する割合をパーセント単位で指定します。100を超える値の場合はセクタ数の直接指定になります。</p>
<p>この関数は、指定された物理ドライブのMBRに区画テーブルを作成します。区画分けは一般的なFDISK形式で行うため、最大4つの基本区画を作成することができます。拡張区画には対応していません。区画マップテーブル<tt class="arg">part[]</tt>にはドライブをどのように分割するか指定して渡します。この配列は4つの項目から成り、先頭の項目が1番目の、最後の項目が4番目の区画のサイズを示します。値が100以下の場合、ドライブの総容量に対する割合をパーセント単位で指定します。100を超える値の場合はセクタ数の直接指定になります。</p>
</div>
<div class="para comp">
<h4>対応情報</h4>
<p><tt>_FS_READOLNY == 0</tt><tt>_USE_MKFS == 1</tt><tt>_MULTI_PARTITION == 2</tt> のとき使用可能です。</p>
<p><tt>_FS_READOLNY == 0</tt><tt>_USE_MKFS == 1</tt><tt>_MULTI_PARTITION == 1</tt> のとき使用可能です。</p>
</div>
<div class="para use">
<h4>使用例</h4>
<pre>
<span class="c">/* ユーザ定義のボリューム管理テーブル (_MULTI_PARTITION != 0 のとき必要) */</span>
<span class="c">/* ユーザ定義のボリューム管理テーブル (_MULTI_PARTITION == 1 のとき必要) */</span>
PARTITION VolToPart[] = {
{0, 1}, <span class="c">/* 論理ドライブ 0 ==> 物理ドライブ 0, 第1区画 */</span>

View File

@ -14,13 +14,13 @@
<div class="para" id="nam">
<h3>ファイル・ディレクトリ名</h3>
<p>FatFsモジュールでのファイル、ディレクトリ、ドライブの指定方法はDOS/Windows APIとほぼ同じです。パス名のフォーマットは次の通りです。</p>
<p><tt>"[論理ドライブ番号:][/]ディレクトリ名/ファイル名"</tt></p>
<p>FatFsモジュールは長いファイル名(LFN)および8.3形式ファイル名(SFN)に対応しています。LFNは、<tt>(_USE_LFN &gt; 0)</tt>のとき使用可能になります。ディレクトリ・セパレータにはDOS/Windows APIと同じく / と \ を使用します。連続したセパレータは無視され1個として扱われます。唯一の違いは、論理ドライブの指定だけです。論理ドライブ番号は、'0''9'の一文字の数字とコロンで指定し、省略した場合はデフォルト・ドライブ(0またはカレント・ドライブ)が選択されます。</p>
<p>Nul文字と制御文字(\0\x1F)は、パス名の終端として認識されます。パス名に先行あるいは中に含まれるスペースは、LFN構成では名前の一部として有効ですが、非LFN構成ではスペースはパス名の終端として認識されます。</p>
<p>標準構成<tt>(_FS_RPATH == 0)</tt>のときは、全てのオブジェクトがルート・ディレクトリから辿る絶対パスで指定されます。OS指向なカレント・ディレクトリという概念は無く、またドット・ディレクトリ(&quot;.&quot;&quot;..&quot;)は使用できません。パス名先頭のセパレータは無視されます。デフォルト・ドライブ番号は常に0になります。</p>
<p>相対パスを有効<tt>(_FS_RPATH == 1)</tt>にしたときは、先行するセパレータの有無によって検索開始ディレクトリが変わり、セパレータがある場合はルート・ディレクトリから、無い場合は<a href="chdir.html">f_chdir関数</a>で設定されるカレント・ディレクトリからになります。またパス名にドット・ディレクトリが使用できます。デフォルト・ドライブ番号は<a href="chdrive.html">f_chdrive関数</a>で設定された値となります。</p>
<pre>"[論理ドライブ番号:][/]ディレクトリ名/ファイル名"</pre>
<p>FatFsモジュールは長いファイル名(LFN)および8.3形式ファイル名(SFN)に対応しています。LFNは、(<tt>_USE_LFN &gt; 0</tt>)のとき使用可能になります。ディレクトリ・セパレータにはDOS/Windows APIと同じく<tt>'/'</tt><tt>'\'</tt>を使用します。連続したセパレータは無視され1個として扱われます。唯一の違いは、論理ドライブの指定だけです。論理ドライブ番号は、<tt>'0'</tt><tt>'9'</tt>の一文字の数字とコロンで指定し、省略した場合は<em>デフォルト・ドライブ</em>(0またはカレント・ドライブ)が選択されます。</p>
<p>ヌル文字と制御文字(<tt>'\0'</tt><tt>'\x1F'</tt>)は、パス名の終端として認識されます。パス名に先行あるいは中に含まれるスペースは、LFN構成では名前の一部として有効ですが、非LFN構成ではスペースはパス名の終端として認識されます。</p>
<p>標準構成(<tt>_FS_RPATH == 0</tt>)のときは、全てのオブジェクトがルート・ディレクトリから辿る絶対パスで指定されます。OS指向なカレント・ディレクトリという概念は無く、またドット・ディレクトリ(&quot;.&quot;&quot;..&quot;)は使用できません。パス名先頭のセパレータは無視されます。デフォルト・ドライブ番号は常に0になります。</p>
<p>相対パスを有効(<tt>_FS_RPATH == 1</tt>)にしたときは、先行するセパレータの有無によって検索開始ディレクトリが変わり、セパレータがある場合はルート・ディレクトリから、無い場合は<a href="chdir.html">f_chdir関数</a>で設定されるカレント・ディレクトリからになります。またパス名にドット・ディレクトリが使用できます。デフォルト・ドライブ番号は<a href="chdrive.html">f_chdrive関数</a>で設定された値となります。</p>
<table class="lst2">
<tr><td>パス名</td><td>_FS_RPATH == 0</td><td>_FS_RPATH == 1</td></tr>
<tr><td>パス名の例</td><td>_FS_RPATH == 0</td><td>_FS_RPATH == 1</td></tr>
<tr class="lst3"><td>file.txt</td><td>ドライブ0のルート・ディレクトリ下のファイル</td><td>カレント・ドライブのカレント・ディレクトリ下のファイル</td></tr>
<tr><td>/file.txt</td><td>ドライブ0のルート・ディレクトリ下のファイル</td><td>カレント・ドライブのルート・ディレクトリ下のファイル</td></tr>
<tr><td></td><td>ドライブ0のルート・ディレクトリ</td><td>カレント・ドライブのカレント・ディレクトリ</td></tr>
@ -38,11 +38,11 @@
<p><br></p>
<div class="para" id="uni">
<h3>Unicode API</h3>
<p>ファイル関数の入出力のうちファイル名やパス名を指定する引数の型は、<tt>TCHAR</tt>で定義されていますが、これは<tt>char</tt>のエリアスになっています。そして、<tt>_CODE_PAGE</tt>で指定される ANSI/OEMコード(SBCSまたはDBCS)の文字列として扱われます。ファイル名入出力をUnicodeとする構成(LFN構成で、かつ<tt>_LFN_UNICODE</tt>を 1)にしたときは、<tt>TCHAR</tt>はワイド文字(<tt>unsigned short</tt>)に切り替わり、パス名にUnicodeを使用するようになります。これにより LFNフル対応となり、ANSI/OEMコードにない文字(たとえば ✝☪✡☸☭など)も使用できます。この設定は文字列入出力関数のデータ型とエンコーディングにも影響を与えます。リテラル文字列を定義するとき、次に示すように<tt>_T(s)</tt>および<tt>_TEXT(s)</tt>マクロを使ってANSI/OEMとUnicodeを自動切り替えすることができます。</p>
<p>ファイル関数の入出力のうちファイル名やパス名を指定する引数の型は、<tt>TCHAR</tt>で定義されていますが、これは通常は<tt>char</tt>のエリアスになっています。そして、<tt>_CODE_PAGE</tt>で指定されるANSI/OEMコード(SBCSまたはDBCS)の文字列として扱われます。ファイル名入出力をUnicodeとする構成(<tt>_LFN_UNICODE == 1</tt>)にしたときは、<tt>TCHAR</tt>はワイド文字(<tt>WCHAR, unsigned short</tt>)に切り替わり、パス名の入出力にUnicodeを使用するようになります。これによりLFN規格に完全対応となり、ANSI/OEMコードにない文字(たとえば ✝☪✡☸☭など)も使用できます。この設定は文字列入出力関数のデータ型とエンコーディングにも影響を与えます。リテラル文字列を定義するとき、次に示すように<tt>_T(s)</tt>および<tt>_TEXT(s)</tt>マクロを使ってANSI/OEMとUnicodeを自動切り替えすることができます。</p>
<pre>
f_open(fp, "filename.txt", FA_READ); <span class="c">/* ANSI/OEM専用コード */</span>
f_open(fp, L"filename.txt", FA_READ); <span class="c">/* Unicode専用コード */</span>
f_open(fp, _T("filename.txt"), FA_READ); <span class="c">/* 両用コード */</span>
f_open(fp, _T("filename.txt"), FA_READ); <span class="c">/* 両用コード(自動切り替え) */</span>
</pre>
</div>
@ -66,6 +66,8 @@ PARTITION VolToPart[] = {
<li>マウント可能な区画は基本区画のみで、拡張区画内には対応しない。</li>
<li>複数の区画を持つ物理ドライブは、非リムーバブルでなければならない。</li>
</ul>
</div>
<img src="../img/f7.png" width="828" height="288" alt="論理ドライブと物理ドライブの関係">
</body>
</html>

View File

@ -16,10 +16,10 @@
<p>ファイルからデータを読み出し、送信ストリームに直接転送します。</p>
<pre>
FRESULT f_forward (
FIL* <em>FileObject</em>, <span class="c">/* ファイル・オブジェクト構造体 */</span>
UINT (*<em>Func</em>)(const BYTE*,UINT), <span class="c">/* データ転送関数 */</span>
UINT <em>ByteToFwd</em>, <span class="c">/* 転送するバイト数 */</span>
UINT* <em>ByteFwd</em> <span class="c">/* 転送されたバイト数 */</span>
FIL* <span class="arg">fp</span>, <span class="c">/* [IN] ファイル・オブジェクト構造体 */</span>
UINT (*<span class="arg">func</span>)(const BYTE*,UINT), <span class="c">/* [IN] データ転送関数 */</span>
UINT <span class="arg">btf</span>, <span class="c">/* [IN] 転送するバイト数 */</span>
UINT* <span class="arg">bf</span> <span class="c">/* [OUT] 転送されたバイト数 */</span>
);
</pre>
</div>
@ -27,13 +27,13 @@ FRESULT f_forward (
<div class="para arg">
<h4>引数</h4>
<dl class="par">
<dt>FileObject</dt>
<dt>fp</dt>
<dd>ファイル・オブジェクト構造体へのポインタを指定します。</dd>
<dt>Func</dt>
<dt>func</dt>
<dd>データを渡すユーザ定義関数へのポインタを指定します。この関数の仕様はサンプルを参照してください。</dd>
<dt>ByteToRead</dt>
<dt>btf</dt>
<dd>転送するバイト数(0UINTの最大値)を指定します。</dd>
<dt>ByteRead</dt>
<dt>bf</dt>
<dd>実際に転送されたバイト数を格納する変数を指すポインタを指定します。</dd>
</dl>
</div>
@ -55,7 +55,7 @@ FRESULT f_forward (
<div class="para desc">
<h4>解説</h4>
<p>ファイルのデータをバッファに読み出さずに送信ストリームに直接転送します。アプリケーション側でデータ・バッファを必要としないので、メモリの限られた環境で有効です。リード/ライト・ポインタは転送されたバイト数だけ進みます。指定されたバイト数の転送中にファイルの終端に達した場合や送信ストリームがビジーになった場合、<tt>*ByteFwd</tt><tt>ByteToFwd</tt>よりも小さくなります。</p>
<p>ファイルのデータをバッファに読み出さずに送信ストリームに直接転送します。アプリケーション側でデータ・バッファを必要としないので、メモリの限られた環境で有効です。リード/ライト・ポインタは転送されたバイト数だけ進みます。指定されたバイト数の転送中にファイルの終端に達した場合や送信ストリームがビジーになった場合、<tt class="arg">*bf</tt><tt class="arg">btf</tt>よりも小さくなります。</p>
</div>

View File

@ -16,8 +16,8 @@
<p>カレント・ディレクトリを得ます</p>
<pre>
FRESULT f_getcwd (
TCHAR* <em>Buffer</em>, <span class="c">/* バッファ */</span>
UINT <em>BufferLen</em> <span class="c">/* バッファ・サイズ */</span>
TCHAR* <span class="arg">buff</span>, <span class="c">/* [OUT] バッファ */</span>
UINT <span class="arg">len</span> <span class="c">/* [IN] バッファ・サイズ */</span>
);
</pre>
</div>
@ -25,9 +25,9 @@ FRESULT f_getcwd (
<div class="para arg">
<h4>引数</h4>
<dl class="par">
<dt>Buffer</dt>
<dt>buff</dt>
<dd>カレント・ディレクトリの文字列を格納するバッファ</dd>
<dt>BufferLen</dt>
<dt>len</dt>
<dd>TCHAR単位のバッファ・サイズ</dd>
</dl>
</div>
@ -50,7 +50,7 @@ FRESULT f_getcwd (
<div class="para desc">
<h4>解説</h4>
<p>f_getcwd関数は、カレント・ドライブのカレント・ディレクトリのパス文字列を取得します。パス文字列は、ドライブ番号を含んだフル・パス名です。</p>
<p>カレント・ドライブのカレント・ディレクトリのパス文字列を取得します。パス文字列は、ドライブ番号を含んだフル・パス名です。</p>
</div>

View File

@ -16,9 +16,9 @@
<p>論理ドライブ上の未使用クラスタ数を得ます。</p>
<pre>
FRESULT f_getfree (
const TCHAR* <em>Path</em>, <span class="c">/* 対象ドライブを指定します */</span>
DWORD* <em>Clusters</em>, <span class="c">/* 空きクラスタ数を格納する変数へのポインタ */</span>
FATFS** <em>FileSystemObject</em> <span class="c">/* ファイル・システム・オブジェクトを指すポインタへのポインタ */</span>
const TCHAR* <span class="arg">path</span>, <span class="c">/* [IN] 対象ドライブを指定します */</span>
DWORD* <span class="arg">nclst</span>, <span class="c">/* [OUT] 空きクラスタ数を格納する変数へのポインタ */</span>
FATFS** <span class="arg">fatfs</span> <span class="c">/* [OUT] ファイル・システム・オブジェクトを指すポインタへのポインタ */</span>
);
</pre>
</div>
@ -26,11 +26,11 @@ FRESULT f_getfree (
<div class="para arg">
<h4>引数</h4>
<dl class="par">
<dt>Path</dt>
<dd>調べる対象の論理ドライブを示す<a href="filename.html">パス名</a>が入った<tt>'\0'</tt>で終わる文字列へのポインタを指定します。</dd>
<dt>Clusters</dt>
<dt>path</dt>
<dd>調べる対象の論理ドライブを示す<a href="filename.html">パス名</a>を示すヌル文字<tt>'\0'</tt>終端の文字列へのポインタを指定します。ヌル文字列はカレント・ドライブを意味します。</dd>
<dt>nclst</dt>
<dd>空きクラスタ数を格納する<tt>DWORD</tt>変数へのポインタを指定します。</dd>
<dt>FileSystemObject</dt>
<dt>fatfs</dt>
<dd>対象ドライブのファイル・システム・オブジェクトを指すポインタが返されます。</dd>
</dl>
</div>
@ -78,10 +78,9 @@ FRESULT f_getfree (
tot_sect = (fs->n_fatent - 2) * fs->csize;
fre_sect = fre_clust * fs->csize;
<span class="c">/* ドライブサイズと空きサイズの表示 (512バイト/セクタと仮定) */</span>
printf("%lu KB total drive space.\n"
"%lu KB available.\n",
fre_sect / 2, tot_sect / 2);
<span class="c">/* ボリュームとと空きのサイズをKiB単位で表示 (512バイト/セクタと仮定) */</span>
printf("%lu KB total drive space.\n%lu KB available.\n",
tot_sect / 2, fre_sect / 2);
</pre>
</div>

82
doc/ja/getlabel.html Normal file
View File

@ -0,0 +1,82 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html lang="ja">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=Shift_JIS">
<meta http-equiv="Content-Style-Type" content="text/css">
<link rel="up" title="FatFs" href="../00index_j.html">
<link rel="alternate" hreflang="en" title="English" href="../en/getlabel.html">
<link rel="stylesheet" href="../css_j.css" type="text/css" media="screen" title="ELM Default">
<title>FatFs - f_getlabel</title>
</head>
<body>
<div class="para func">
<h2>f_getlabel</h2>
<p>ボリューム・ラベルを取得します。</p>
<pre>
FRESULT f_getlabel (
const TCHAR* <span class="arg">path</span>, <span class="c">/* [IN] 対象ドライブ */</span>
TCHAR* <span class="arg">name</span>, <span class="c">/* [OUT] ボリューム名を格納するバッファ */</span>
DWORD* <span class="arg">sn</span> <span class="c">/* [OUT] ボリューム・シリアル番号を格納する変数 */</span>
);
</pre>
</div>
<div class="para arg">
<h4>引数</h4>
<dl class="par">
<dt>path</dt>
<dd>対象となる論理ドライブの<a href="filename.html">パス名</a>を示すヌル文字<tt>'\0'</tt>終端の文字列へのポインタを指定します。ヌル文字列の場合は、デフォルト・ドライブを指定したことになります。</dd>
<dt>name</dt>
<dd>ボリューム名を格納する配列へのポインタを指定します。少なくとも12要素のサイズが必要です。ボリューム名がない場合はヌル文字列が返されます。この情報が不要なときはヌル・ポインタを指定してください。</dd>
<dt>sn</dt>
<dd>ボリューム・シリアル番号を格納する<tt>DWORD</tt>変数へのポインタを指定します。この情報が不要なときはヌル・ポインタを指定してください。</dd>
</dl>
</div>
<div class="para ret">
<h4>戻り値</h4>
<p>
<a href="rc.html#ok">FR_OK</a>,
<a href="rc.html#de">FR_DISK_ERR</a>,
<a href="rc.html#ie">FR_INT_ERR</a>,
<a href="rc.html#nr">FR_NOT_READY</a>,
<a href="rc.html#id">FR_INVALID_DRIVE</a>,
<a href="rc.html#ne">FR_NOT_ENABLED</a>,
<a href="rc.html#ns">FR_NO_FILESYSTEM</a>,
<a href="rc.html#tm">FR_TIMEOUT</a>
</p>
</div>
<div class="para comp">
<h4>対応情報</h4>
<p><tt>_USE_LABEL == 1</tt>のときに使用可能です。</p>
</div>
<div class="para use">
<h4>使用例</h4>
<pre>
char str[12];
<span class="c">/* デフォルト・ドライブのボリューム名を得る */</span>
f_getlabel("", str, 0);
<span class="c">/* ドライブ2のボリューム名を得る */</span>
f_getlabel("2:", str, 0);
</pre>
</div>
<div class="para ref">
<h4>参照</h4>
<tt><a href="setlabel.html">f_setlabel</a></tt>
</div>
<p class="foot"><a href="../00index_j.html">戻る</a></p>
</body>
</html>

View File

@ -16,9 +16,9 @@
<p>ファイルから文字列を読み出します。</p>
<pre>
TCHAR* f_gets (
TCHAR* <em>Str</em>, <span class="c">/* バッファ */</span>
int <em>Size</em>, <span class="c">/* バッファのサイズ */</span>
FIL* <em>FileObject</em> <span class="c">/* ファイル・オブジェクト */</span>
TCHAR* <span class="arg">buff</span>, <span class="c">/* [OUT] バッファ */</span>
int <span class="arg">len</span>, <span class="c">/* [IN] バッファのサイズ */</span>
FIL* <span class="arg">fp</span> <span class="c">/* [IN] ファイル・オブジェクト */</span>
);
</pre>
</div>
@ -26,11 +26,11 @@ TCHAR* f_gets (
<div class="para arg">
<h4>引数</h4>
<dl class="par">
<dt>Str</dt>
<dt>buff</dt>
<dd>文字列を読み出すバッファを指すポインタを指定します。</dd>
<dt>Size</dt>
<dt>len</dt>
<dd>バッファのサイズを要素数で指定します。</dd>
<dt>FileObject</dt>
<dt>fp</dt>
<dd>ファイル・オブジェクト構造体へのポインタを指定します。</dd>
</dl>
</div>
@ -38,13 +38,13 @@ TCHAR* f_gets (
<div class="para ret">
<h4>戻り値</h4>
<p>関数が成功すると<tt>Str</tt>が返されます。</p>
<p>関数が成功すると<tt>buff</tt>が返されます。</p>
</div>
<div class="para desc">
<h4>解説</h4>
<p>この関数は<a href="read.html">f_read()</a>のラッパー関数です。読み出し動作は、最初の<tt>'\n'</tt>を読み込むか、ファイル終端に達するか、<tt>Size - 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>len - 1</tt>文字を読み出すまで続きます。読み込まれた文字列の終端には<tt>'\0'</tt>が付加されます。既にファイル終端で1文字も読み込まれなかったとき、または何らかのエラーが発生したときは関数は失敗しヌル・ポインタを返します。ファイル終端かエラーかは<tt>f_eof()</tt>,<tt>f_error()</tt>マクロで調べられます。</p>
<p>APIにUnicodeが選択されている(<tt>_LFN_UNICODE</tt>が1)ときは、UTF-8エンコードのテキスト・ファイルとしてUCS-2に変換してバッファに読み込みます。それ以外の時は無変換(1文字1バイト)で読み込みます。</p>
</div>

View File

@ -16,8 +16,8 @@
<p>ファイルのリード/ライト・ポインタを移動します。また、高速シーク機能使用時にはCLMT(後述)の作成にも使用します。</p>
<pre>
FRESULT f_lseek (
FIL* <em>FileObject</em>, <span class="c">/* ファイル・オブジェクト構造体へのポインタ */</span>
DWORD <em>Offset</em> <span class="c">/* 移動先オフセット */</span>
FIL* <span class="arg">fp</span>, <span class="c">/* [IN] ファイル・オブジェクト構造体へのポインタ */</span>
DWORD <span class="arg">ofs</span> <span class="c">/* [IN] 移動先オフセット */</span>
);
</pre>
</div>
@ -25,10 +25,10 @@ FRESULT f_lseek (
<div class="para arg">
<h4>引数</h4>
<dl class="par">
<dt>FileObject</dt>
<dt>fp</dt>
<dd>対象となるファイル・オブジェクト構造体へのポインタを指定します。</dd>
<dt>Offset</dt>
<dd>移動先のオフセット(リード/ライト・ポインタ)値。ファイル先頭からのオフセットをバイト単位で指定します。</dd>
<dt>ofs</dt>
<dd>移動先のオフセット(リード/ライト・ポインタ)値。ファイル先頭からのオフセットをバイト単位で指定します。</dd>
</dl>
</div>
@ -49,13 +49,13 @@ FRESULT f_lseek (
<div class="para desc">
<h4>解説</h4>
<p>ファイルのリード/ライト・ポインタ(次に読み出し・書き込みされるバイトのオフセット)を移動します。オフセットの原点はファイル先頭です。書き込みモードでファイル・サイズより大きな値を指定すると、そこまでファイル・サイズが拡張され、拡張された部分のデータは未定義となります。データを遅延無く高速に書き込みたいときは、予めこの関数で必要なサイズまでファイル・サイズを拡張しておくと良いでしょう。f_lseek関数が正常終了したあとは、リード/ライト・ポインタが正しく移動したかチェックするべきです。リード/ライト・ポインタが指定より小さいときは、次の原因が考えられます。</p>
<p>ファイルのリード/ライト・ポインタ(次に読み出し・書き込みされるバイトのオフセット)を移動します。オフセットの原点はファイル先頭です。書き込みモードでファイル・サイズより大きな値を指定すると、そこまでファイル・サイズが拡張され、拡張された部分のデータは未定義となります。データを遅延無く高速に書き込みたいときは、予めこの関数で必要なサイズまでファイル・サイズを拡張しておくと良いでしょう。<tt>f_lseek()</tt>が正常終了したあとは、リード/ライト・ポインタが正しく移動したかチェックするべきです。リード/ライト・ポインタが指定より小さいときは、次の原因が考えられます。</p>
<ul>
<li>非書き込みモードまたは高速シーク・モードのため、ファイル・サイズでクリップされた。</li>
<li>ファイル拡張中にディスクが満杯になった。</li>
</ul>
<p><tt>_USE_FASTSEEK</tt>が1で、且つファイル・オブジェクトの<tt>cltbl</tt>メンバがNULL以外(f_open()でNULLに設定される)のとき、高速シーク・モードになります。これはファイルのクラスタ配置情報(CLMT)をメモリ上に保持しておくことにより、FATにアクセスすることなく後方シークやロング・シークを高速に行う機能です。高速シーク・モードは、f_read/f_wtite関数の動作にも適用されます。高速シーク・モードではf_wtite/f_lseek関数によるファイル・サイズの拡張はできません。</p>
<p>高速シーク動作を行う前に、CLMTを作成しておく必要があります。これを作成するには、まずCLMT格納バッファ(DWORD配列)を準備し、<tt>cltbl</tt>メンバにそのポインタをセットします。そして、配列の先頭要素にその配列のサイズ(要素数)を入れ、f_lseek関数を<tt>Offset</tt><tt>CREATE_LINKMAP</tt>を指定して呼び出します。関数が成功するとCLMTが作成され、以降のf_read/f_write/f_lseek関数ではFATへのアクセスは発生しません。<tt>FR_NOT_ENOUGH_CORE</tt>で失敗したときは配列サイズが不足で、先頭要素には実際に必要となる要素数が返されます。必要な要素数は、(ファイルの分割数 + 1) * 2 です。たとえば、ファイルが5つのフラグメントに分断されているときに必要な要素数は、12となります。</p>
<p><tt>_USE_FASTSEEK</tt>が1で、且つファイル・オブジェクトの<tt>cltbl</tt>メンバがNULL以外(<tt>f_open(</tt>)でNULLに設定される)のとき、高速シーク・モードになります。これはファイルのクラスタ配置情報(CLMT)をメモリ上に保持しておくことにより、FATにアクセスすることなく後方シークやロング・シークを高速に行う機能です。高速シーク・モードは、<tt>f_read()/f_wtite()</tt>の動作にも適用されます。高速シーク・モードでは<tt>f_wtite()/f_lseek()</tt>によるファイル・サイズの拡張はできません。</p>
<p>高速シーク動作を行う前に、CLMTを作成しておく必要があります。これを作成するには、まずCLMT格納バッファ(<tt>DWORD</tt>配列)を準備し、<tt>cltbl</tt>メンバにそのポインタをセットします。そして、配列の先頭要素にその配列のサイズ(要素数)を入れ、<tt>f_lseek()</tt><tt class="arg">ofs</tt><tt>CREATE_LINKMAP</tt>を指定して呼び出します。関数が成功するとCLMTが作成され、以降の<tt>f_read()/f_write()/f_lseek()</tt>ではFATへのアクセスは発生しません。<tt>FR_NOT_ENOUGH_CORE</tt>で失敗したときは配列サイズが不足で、先頭要素には実際に必要となる要素数が返されます。必要な要素数は、(ファイルの分割数 + 1) * 2 です。たとえば、ファイルが5つのフラグメントに分断されているときに必要な要素数は、12となります。</p>
</div>
@ -69,53 +69,52 @@ FRESULT f_lseek (
<h4>使用例</h4>
<pre>
<span class="c">/* ファイルを開く */</span>
file = malloc(sizeof(FIL));
if (!file) ...
res = f_open(file, "file.dat", FA_READ|FA_WRITE);
fp = malloc(sizeof(FIL));
res = f_open(fp, "file.dat", FA_READ|FA_WRITE);
if (res) ...
<span class="c">/* ファイル・オフセット5000へ移動 */</span>
res = f_lseek(file, 5000);
res = f_lseek(fp, 5000);
<span class="c">/* ファイル終端へ移動(ファイル追記の準備) */</span>
res = f_lseek(file, f_size(file));
res = f_lseek(fp, f_size(fp));
<span class="c">/* 3000バイト進める */</span>
res = f_lseek(file, f_tell(file) + 3000);
res = f_lseek(fp, f_tell(fp) + 3000);
<span class="c">/* 2000バイト戻す (オーバーフローに注意) */</span>
res = f_lseek(file, f_tell(file) - 2000);
res = f_lseek(fp, f_tell(fp) - 2000);
</pre>
<pre>
<span class="c">/* クラスタ先行割り当て (ストリーミング・ライト時のバッファ・オーバーラン防止) */</span>
res = f_open(file, "record.wav", FA_CREATE_NEW | FA_WRITE); <span class="c">/* ファイル作成 */</span>
res = f_open(fp, "record.wav", FA_CREATE_NEW | FA_WRITE); <span class="c">/* ファイル作成 */</span>
res = f_lseek(file, MAX_SIZE); <span class="c">/* 十分なクラスタの先行割り当て */</span>
if (res || f_tell(file) != PRE_SIZE) ... <span class="c">/* 正しくファイルが拡張されたかチェック */</span>
res = f_lseek(fp, MAX_SIZE); <span class="c">/* 十分なクラスタの先行割り当て */</span>
if (res || f_tell(fp) != PRE_SIZE) ... <span class="c">/* 正しくファイルが拡張されたかチェック */</span>
res = f_lseek(file, DATA_START); <span class="c">/* データ・ストリームの記録(アロケーションディレイ無し) */</span>
res = f_lseek(fp, DATA_START); <span class="c">/* データ・ストリームの記録(アロケーションディレイ無し) */</span>
...
res = f_truncate(file); <span class="c">/* 不要領域の切り捨て */</span>
res = f_lseek(file, 0); <span class="c">/* ヘッダの記録 */</span>
res = f_truncate(fp); <span class="c">/* 不要領域の切り捨て */</span>
res = f_lseek(fp, 0); <span class="c">/* ヘッダの記録 */</span>
...
res = f_close(file);
res = f_close(fp);
</pre>
<pre>
<span class="c">/* 高速シーク機能を使う */</span>
DWORD lktbl[SZ_TBL]; <span class="c">/* リンク・マップ・テーブル格納バッファ */</span>
res = f_lseek(file, ofs1); <span class="c">/* 通常シーク (オープン時、file.cltbl == NULL) */</span>
res = f_lseek(fp, ofs1); <span class="c">/* 通常シーク (オープン時、cltblはNULLに初期化される) */</span>
file.cltbl = lktbl; <span class="c">/* 高速シーク機能の有効化 */</span>
fp-&gt;cltbl = lktbl; <span class="c">/* 高速シーク機能の有効化 (cltbl != NULL) */</span>
lktbl[0] = SZ_TBL; <span class="c">/* 先頭要素に配列要素数をセット */</span>
res = f_lseek(file, CREATE_LINKMAP); <span class="c">/* CLMTの作成 */</span>
res = f_lseek(fp, CREATE_LINKMAP); <span class="c">/* CLMTの作成 */</span>
...
res = f_lseek(file, ofs2); <span class="c">/* 以降、f_read/f_write/f_lseekでFATアクセスが発生しない */</span>
res = f_lseek(fp, ofs2); <span class="c">/* 以降、f_read/f_write/f_lseekでFATアクセスが発生しない */</span>
</pre>
</div>

View File

@ -16,7 +16,7 @@
<p>ディレクトリを作成します。</p>
<pre>
FRESULT f_mkdir (
const TCHAR* <em>DirName</em> <span class="c">/* 作成するディレクトリ名へのポインタ */</span>
const TCHAR* <span class="arg">path</span> <span class="c">/* [IN] 作成するディレクトリ名へのポインタ */</span>
);
</pre>
</div>
@ -24,8 +24,8 @@ FRESULT f_mkdir (
<div class="para arg">
<h4>引数</h4>
<dl class="par">
<dt>DirName</dt>
<dd>作成するディレクトリの<a href="filename.html">パス名</a>が入った<tt>'\0'</tt>で終わる文字列へのポインタを指定します。</dd>
<dt>path</dt>
<dd>作成するディレクトリの<a href="filename.html">パス名</a>を示すヌル文字<tt>'\0'</tt>終端の文字列へのポインタを指定します。</dd>
</dl>
</div>

View File

@ -16,9 +16,9 @@
<p>論理ドライブ上にFATボリュームを作成(フォーマット)します。</p>
<pre>
FRESULT f_mkfs (
BYTE <em>Drive</em>, <span class="c">/* 論理ドライブ番号 */</span>
BYTE <em>PartitioningRule</em>, <span class="c">/* 区画作成方法 */</span>
UINT <em>AllocSize</em> <span class="c">/* クラス・タサイズ */</span>
BYTE <span class="arg">vol</span>, <span class="c">/* [IN] 論理ドライブ番号 */</span>
BYTE <span class="arg">sfd</span>, <span class="c">/* [IN] 区画作成方法 */</span>
UINT <span class="arg">au</span> <span class="c">/* [IN] クラス・タサイズ */</span>
);
</pre>
</div>
@ -26,12 +26,12 @@ FRESULT f_mkfs (
<div class="para arg">
<h4>引数</h4>
<dl class="par">
<dt>Drive</dt>
<dd>フォーマットする論理ドライブ(0-9)。</dd>
<dt>PartitioningRule</dt>
<dd>パーテーション形式(0(FDISK) または1(SFD))を指定します。</dd>
<dt>AllocSize</dt>
<dd>クラスタ・サイズをバイト単位で指定します。2の累乗、且つセクタ・サイズ以上、且つセクタ・サイズの128倍以下でなければなりません。0を指定した場合、ボリュームのサイズに応じたデフォルトのクラスタ・サイズが選択されます。</dd>
<dt>vol</dt>
<dd>フォーマットする論理ドライブ。(0 <tt>_VOLUMES - 1</tt>)</dd>
<dt>sfd</dt>
<dd>パーテーション形式。(0(FDISK) or 1(SFD))</dd>
<dt>au</dt>
<dd>クラスタ・サイズをバイト単位で指定します。対象ドライブのセクタ・サイズのn倍(n = 1128で、2の累乗)でなければなりません。0を指定した場合、ボリュームのサイズに応じたデフォルトのクラスタ・サイズが選択されます。</dd>
</dl>
</div>
@ -49,11 +49,11 @@ FRESULT f_mkfs (
<div class="para desc">
<h4>説明</h4>
<p>f_mkfs関数は物理ドライブ上にFATボリュームを作成します。第二引数でFDISK形式が指定された場合は、物理ドライブ全体を占める基本区画(パーテーション)が作成され、その中にFATボリュームが作成されます。SFD形式では、FATボリュームは物理ドライブの先頭からベタで作成されます。</p>
<p>マルチパーテーション機能<tt>(_MULTI_PARTITION)</tt>により、指定された論理ドライブが特定の区画(14)に結び付けられている場合、その区画の中にFATボリュームが作成されます。この場合、第二引数は無視され、また対応する物理ドライブはこれに先立ち、f_fdisk関数または他のツールで適切に区画設定されている必要があります。</p>
<p>パーテーション形式には、FDISK形式とSFD形式の二通りありがあります。FDISK形式は、ハードディスク、MMC、SDC、CFCなどで使用されます。FDISK形式では一台の物理ドライブ上に一つまたは複数の区画を作成することができます。管理情報はMBR(物理ドライブの先頭セクタ)に記録されます。SFD形式は単に何の分割も行わない形式で、ボリュームは物理ドライブの先頭セクタから開始します。SFD形式は、フロッピーディスク、マイクロドライブ、光学ディスク、およびその他スーパーフロッピーメディアで使用されています。</p>
<p>物理ドライブ上にFATボリュームを作成します。FDISK形式が指定された場合は、物理ドライブ全体を占める基本区画(パーテーション)が作成され、その中にFATボリュームが作成されます。SFD形式では、FATボリュームは物理ドライブの先頭セクタからベタで作成されます。</p>
<p>マルチパーテーション機能(<tt>_MULTI_PARTITION</tt>)により、指定された論理ドライブが特定の区画(14)に結び付けられている場合、その区画の中にFATボリュームが作成されます。この場合、<tt class="arg">sfd</tt>は無視され、また対応する物理ドライブはこれに先立ち、<tt>f_fdisk()</tt>または他のツールで適切に区画設定されている必要があります。</p>
<p>パーテーション形式には、FDISK形式とSFD形式の二通りあります。FDISK形式は、ハードディスク、MMC、SDC、CFCなどで使用されます。FDISK形式では一台の物理ドライブ上に一つまたは複数の区画を作成することができます。管理情報はMBR(物理ドライブの先頭セクタ)に記録されます。SFD形式は単に何の分割も行わない形式で、ボリュームは物理ドライブの先頭セクタから開始します。SFD形式は、フロッピーディスク、マイクロドライブ、光学ディスク、およびその他スーパーフロッピーメディアで使用されています。</p>
<p>FATタイプ(FAT12/FAT16/FAT32)は、その論理ドライブ上の<em>クラスタ数によってのみ決定</em>される決まり[FAT仕様書より]になっていて、それ以外の要因はありません。したがって、どのFATタイプになるかはドライブ・サイズとクラスタ・サイズに依存します。クラスタ・サイズは大きくするほど性能が上がり、ディスク利用効率は落ちます。</p>
<p>クラスタ数がFATタイプの境界に近くなるときは、FR_MKFS_ABORTEDで関数が失敗する可能性があります。</p>
<p>クラスタ数がFATタイプの境界に近くなるときは、<tt>FR_MKFS_ABORTED</tt>で関数が失敗する可能性があります。</p>
</div>

View File

@ -13,11 +13,11 @@
<div class="para func">
<h2>f_mount</h2>
<p>論理ドライブのワーク・エリアを登録・抹消します。</p>
<p>論理ドライブにファイル・システム・オブジェクトを登録・抹消します。</p>
<pre>
FRESULT f_mount (
BYTE <em>Drive</em>, <span class="c">/* 論理ドライブ番号 */</span>
FATFS* <em>FileSystemObject</em> <span class="c">/* ワーク・エリアへのポインタ */</span>
BYTE <span class="arg">vol</span>, <span class="c">/* [IN] 論理ドライブ番号 */</span>
FATFS* <span class="arg">fatfs</span> <span class="c">/* [IN] ワーク・エリアへのポインタ */</span>
);
</pre>
</div>
@ -25,10 +25,10 @@ FRESULT f_mount (
<div class="para arg">
<h4>ˆø<EFBFBD></h4>
<dl class="par">
<dt>Drive</dt>
<dd>論理ドライブ番号(0-9)。</dd>
<dt>FileSystemObject</dt>
<dd>登録するワーク・エリア(ファイル・システム・オブジェクト)へのポインタ。</dd>
<dt>vol</dt>
<dd>論理ドライブ番号(0 <tt>_VOLUMES - 1</tt>)。</dd>
<dt>fatfs</dt>
<dd>登録するファイル・システム・オブジェクトへのポインタ。</dd>
</dl>
</div>
@ -43,8 +43,13 @@ FRESULT f_mount (
<div class="para desc">
<h4>‰ð<EFBFBD>à</h4>
<p>FatFsモジュールではそれぞれの論理ドライブにファイル・システム・オブジェクトというワーク・エリアが必要です。この関数は論理ドライブにそのワーク・エリアを登録したり抹消したりします。何らかのファイル関数を使用する前にこの関数でその論理ドライブのワーク・エリアを与えておかなければなりません。<tt>FileSystemObject</tt>にヌル・ポインタを指定するとその論理ドライブのワーク・エリアの登録は抹消され、登録されていたワーク・エリアは破棄できます。操作対象のドライブに対して開かれているファイルやディレクトリがあった場合、それらは全て無効になります。</p>
<p>この関数は、ドライブの状態に関わらず常に成功します。関数内では下位レイヤ(物理ドライブ)へのアクセスは発生せず、ワーク・エリアを初期化して内部配列にそのアドレスを登録するだけです。実際のマウント動作は、この関数の実行またはメディア交換発生の後、最初のファイル・アクセスのときに行われます。</p>
<p>FatFsモジュールでは、それぞれの論理ドライブにファイル・システム・オブジェクトというワーク・エリアが必要です。この関数は論理ドライブにそのワーク・エリアを登録したり抹消したりします。何らかのファイル関数を使用する前に、この関数でその論理ドライブのワーク・エリアを与えておかなければなりません。<tt class="arg">fatfs</tt>にヌル・ポインタを指定するとワーク・エリアの登録は抹消され、登録されていたワーク・エリアは破棄できます。操作対象のドライブに対して開かれているファイルやディレクトリがあった場合、それらは全て無効になります。</p>
<p>この関数は、物理ドライブの状態に関わらず常に成功します。関数内では下位レイヤへのアクセスは発生せず、指定されたワーク・エリアをクリア(無効化)し、そのアドレスを内部配列に登録するだけです。単に登録済みのワーク・エリアをクリアする目的にも使えます。ボリュームへのアクセス開始のとき次のうちいずれかまたは両方の条件が真のとき、実際のマウント動作(物理ドライブの初期化、FATボリュームの検索、BPBに従いワーク・エリアを初期化)が行われます。</p>
<ul>
<li>ファイル・システム・オブジェクトが未初期化(<tt>f_mount()</tt>による)</li>
<li>物理ドライブが未初期化(システム・リセットやメディアの取り外しによる)</li>
</ul>
<p>下位レイヤがメディア交換の検出をサポートしないときは、アプリケーションはメディア交換のたびに<tt>f_mount()</tt>を実行する必要があります。</p>
</div>

View File

@ -16,9 +16,9 @@
<p>ファイルをオープンまたは作成します。</p>
<pre>
FRESULT f_open (
FIL* <em>FileObject</em>, <span class="c">/* 空のファイル・オブジェクト構造体へのポインタ */</span>
const TCHAR* <em>FileName</em>, <span class="c">/* ファイルのフルパス名へのポインタ */</span>
BYTE <em>ModeFlags</em> <span class="c">/* モードフラグ */</span>
FIL* <span class="arg">fp</span>, <span class="c">/* [OUT] 空のファイル・オブジェクト構造体へのポインタ */</span>
const TCHAR* <span class="arg">path</span>, <span class="c">/* [IN] ファイルのフルパス名へのポインタ */</span>
BYTE <span class="arg">mode</span> <span class="c">/* [IN] モードフラグ */</span>
);
</pre>
</div>
@ -26,18 +26,18 @@ FRESULT f_open (
<div class="para arg">
<h4>引数</h4>
<dl class="par">
<dt>FileObject</dt>
<dt>fp</dt>
<dd>新しく作成するファイル・オブジェクト構造体へのポインタを指定します。以降、そのファイルを閉じるまでこのファイル・オブジェクトを使用してファイル操作をします。</dd>
<dt>FileName</dt>
<dd>開く(または作成する)ファイルの <a href="filename.html">ファイル名</a>が入った<tt>'\0'</tt>で終わる文字列へのポインタを指定します。</dd>
<dt>ModeFlags</dt>
<dt>path</dt>
<dd>開く(または作成する)ファイルの <a href="filename.html">ファイル名</a>を示すヌル文字<tt>'\0'</tt>終端の文字列へのポインタを指定します。</dd>
<dt>mode</dt>
<dd>ファイルのアクセス方法やオープン方法を決めるフラグです。このパラメータには次の組み合わせを指定します。<br>
<table class="lst">
<tr><th></th><th>意味</th></tr>
<tr><td>FA_READ</td><td>読み出しモードで開きます。読み書きする場合は<tt>FA_WRITE</tt>と共に指定します。</td></tr>
<tr><td>FA_WRITE</td><td>書き込みモードで開きます。読み書きする場合は<tt>FA_READ</tt>と共に指定します。</td></tr>
<tr><td>FA_OPEN_EXISTING</td><td>既存のファイルを開きます。ファイルが無いときはエラーになります。(デフォルト)</td></tr>
<tr><td>FA_OPEN_ALWAYS</td><td>既存のファイルを開きます。ファイルが無いときはファイルを作成します。追記の場合は、この方法でオープンした後、<a href="lseek.html">f_lseek()</a>でファイルの最後尾に移動してください。</td></tr>
<tr><td>FA_OPEN_ALWAYS</td><td>既存のファイルを開きます。ファイルが無いときはファイルを作成します。追記の場合は、この方法でオープンした後、<a href="lseek.html"><tt>f_lseek()</tt></a>でファイルの最後尾に移動してください。</td></tr>
<tr><td>FA_CREATE_NEW</td><td>ファイルを作成します。同名のファイルがある場合は、<tt>FR_EXIST</tt>で失敗します。</td></tr>
<tr><td>FA_CREATE_ALWAYS</td><td>ファイルを作成します。同名のファイルがある場合は、サイズを0にしてから開きます。</td></tr>
</table>
@ -58,6 +58,7 @@ FRESULT f_open (
<a href="rc.html#in">FR_INVALID_NAME</a>,
<a href="rc.html#de">FR_DENIED</a>,
<a href="rc.html#ex">FR_EXIST</a>,
<a href="rc.html#io">FR_INVALID_OBJECT</a>,
<a href="rc.html#wp">FR_WRITE_PROTECTED</a>,
<a href="rc.html#id">FR_INVALID_DRIVE</a>,
<a href="rc.html#ne">FR_NOT_ENABLED</a>,
@ -72,9 +73,9 @@ FRESULT f_open (
<div class="para desc">
<h4>解説</h4>
<p>既存のファイルを開いたり、新しいファイルを作成します。関数が成功するとファイル・オブジェクトが作成され、以降そのファイルに対するアクセスに使用します。ファイルを閉じるときは、<a href="close.html">f_close()</a>を使用します。何らかの変更が行われたファイルがその後正しく閉じられなかった場合、そのファイルが破損する場合があります。</p>
<p>既存のファイルを開いたり、新しいファイルを作成します。関数が成功するとファイル・オブジェクトが作成され、以降そのファイルに対するアクセスに使用します。ファイルを閉じるときは、<a href="close.html"><tt>f_close()</tt></a>を使用します。何らかの変更が行われたファイルがその後正しく閉じられなかった場合、そのファイルが破損する場合があります。</p>
<p>既に開かれているファイルを開く必要がある場合は、<a href="appnote.html#dup">多重アクセス制御</a>を参照してください。しかし、一つのファイルに対する書き込みモードを含む重複オープンは常に禁止です。</p>
<p>ファイル・アクセスを開始する前に、<a href="mount.html">f_mount()</a>を使ってそれぞれの論理ドライブにワーク・エリア(ファイル・システム・オブジェクト)を与える必要があります。この初期化の後、その論理ドライブに対して全てのファイル関数が使えるようになります。</p>
<p>ファイル・アクセスを開始する前に、<a href="mount.html"><tt>f_mount()</tt></a>を使ってそれぞれの論理ドライブにワーク・エリア(ファイル・システム・オブジェクト)を与える必要があります。この初期化の後、その論理ドライブに対して全てのファイル関数が使えるようになります。</p>
</div>

View File

@ -16,8 +16,8 @@
<p>ディレクトリを開きます。</p>
<pre>
FRESULT f_opendir (
DIR* <em>DirObject</em>, <span class="c">/* ディレクトリ・ブジェクト構造体へのポインタ */</span>
const TCHAR* <em>DirName</em> <span class="c">/* ディレクトリ名へのポインタ */</span>
DIR* <span class="arg">dj</span>, <span class="c">/* [OUT] ディレクトリ・ブジェクト構造体へのポインタ */</span>
const TCHAR* <span class="arg">path</span> <span class="c">/* [IN] ディレクトリ名へのポインタ */</span>
);
</pre>
</div>
@ -25,10 +25,10 @@ FRESULT f_opendir (
<div class="para arg">
<h4>引数</h4>
<dl class="par">
<dt>DirObject</dt>
<dt>dj</dt>
<dd>初期化するディレクトリ・オブジェクト構造体へのポインタを指定します。</dd>
<dt>DirName</dt>
<dd>オープンするディレクトリ<a href="filename.html">パス名</a>が入った<tt>'\0'</tt>で終わる文字列へのポインタを指定します。</dd>
<dt>path</dt>
<dd>オープンするディレクトリの<a href="filename.html">パス名</a>を示すヌル文字<tt>'\0'</tt>終端の文字列へのポインタを指定します。</dd>
</dl>
</div>
@ -53,7 +53,7 @@ FRESULT f_opendir (
<div class="para desc">
<h4>解説</h4>
<p>ディレクトリを開きます。正常終了したら、<tt>DirObject</tt>構造体を使ってこのディレクトリの項目を順次読み出せます。<tt>DirObject</tt>構造体は使用後は任意の時点で破棄できます。</p>
<p>ディレクトリを開きます。正常終了したら、作成された<tt>DIR</tt>構造体を使ってこのディレクトリの項目を順次読み出せます。作成されたディレクトリ・オブジェクトは、不要になったら任意の時点で破棄できます。</p>
</div>

View File

@ -16,8 +16,8 @@
<p>ファイルに書式化文字列を書き込みます。</p>
<pre>
int f_printf (
FIL* <em>FileObject</em>, <span class="c">/* ファイル・オブジェクト */</span>
const TCHAR* <em>Foramt</em>, <span class="c">/* 書式制御文字列 */</span>
FIL* <span class="arg">fp</span>, <span class="c">/* [IN] ファイル・オブジェクト */</span>
const TCHAR* <span class="arg">fmt</span>, <span class="c">/* [IN] 書式制御文字列 */</span>
...
);
</pre>
@ -26,10 +26,10 @@ int f_printf (
<div class="para arg">
<h4>引数</h4>
<dl class="par">
<dt>FileObject</dt>
<dt>fp</dt>
<dd>ファイル・オブジェクト構造体へのポインタを指定します。</dd>
<dt>Format</dt>
<dd>'\0'で終わる書式制御文字列を指すポインタを指定します。'\0'は書き込まれません。</dd>
<dt>fmt</dt>
<dd>ヌル文字<tt>'\0'</tt>終端の書式制御文字列を指すポインタを指定します。ヌル文字は書き込まれません。</dd>
<dt>...</dt>
<dd>オプションの引数。</dd>
@ -39,13 +39,13 @@ int f_printf (
<div class="para ret">
<h4>戻り値</h4>
<p>文字列が正常に書き込まれると書き込まれた文字数が返されます。ディスクが満杯またはその他エラーにより正常に書き込まれなかったときは関数は失敗し<tt>EOF (-1)</tt>が返されます。</p>
<p>文字列が正常に書き込まれると書き込まれた文字数が返されます。ディスクが満杯またはその他エラーにより正常に書き込まれなかったときは関数は失敗し<tt>EOF (-1)</tt>が返されます。</p>
</div>
<div class="para desc">
<h4>解説</h4>
<p>この関数は<a href="putc.html">f_putc()</a>および<a href="puts.html">f_puts()</a>のラッパー関数です。書式制御機能はサブセットとなっていて、書式制御文字は次に示すものが使用可能です。</p>
<p>この関数は<a href="putc.html"><tt>f_putc()</tt></a>および<a href="puts.html"><tt>f_puts()</tt></a>のラッパー関数です。書式制御機能はサブセットとなっていて、書式制御文字は次に示すものが使用可能です。</p>
<ul>
<li>タイプ: <tt>c C s S d D u U x X b B</tt></li>
<li>精度指定: <tt>l L</tt></li>

View File

@ -16,8 +16,8 @@
<p>ファイルに文字を書き込みます。</p>
<pre>
int f_putc (
TCHAR <em>Chr</em>, <span class="c">/* 書き込む文字 */</span>
FIL* <em>FileObject</em> <span class="c">/* ファイル・オブジェクト */</span>
TCHAR <span class="arg">chr</span>, <span class="c">/* [IN] 書き込む文字 */</span>
FIL* <span class="arg">fp</span> <span class="c">/* [IN] ファイル・オブジェクト */</span>
);
</pre>
</div>
@ -25,9 +25,9 @@ int f_putc (
<div class="para arg">
<h4>引数</h4>
<dl class="par">
<dt>Chr</dt>
<dt>chr</dt>
<dd>書き込む文字を指定します。</dd>
<dt>FileObject</dt>
<dt>fp</dt>
<dd>ファイル・オブジェクト構造体へのポインタを指定します。</dd>
</dl>
</div>
@ -42,7 +42,7 @@ int f_putc (
<div class="para desc">
<h4>解説</h4>
<p>1文字をファイルに書き込みます。この関数は<a href="write.html">f_write()</a>のラッパー関数です。</p>
<p>1文字をファイルに書き込みます。この関数は<a href="write.html"><tt>f_write()</tt></a>のラッパー関数です。</p>
</div>

View File

@ -16,8 +16,8 @@
<p>ファイルに文字列を書き込みます。</p>
<pre>
int f_puts (
const TCHAR* <em>Str</em>, <span class="c">/* 書き込む文字列 */</span>
FIL* <em>FileObject</em> <span class="c">/* ファイル・オブジェクト */</span>
const TCHAR* <span class="arg">str</span>, <span class="c">/* [IN] 書き込む文字列 */</span>
FIL* <span class="arg">fp</span> <span class="c">/* [IN] ファイル・オブジェクト */</span>
);
</pre>
</div>
@ -25,9 +25,9 @@ int f_puts (
<div class="para arg">
<h4>引数</h4>
<dl class="par">
<dt>Str</dt>
<dd>書き込む'\0'で終わる文字列を指すポインタを指定します。'\0'は書き込まれません。</dd>
<dt>FileObject</dt>
<dt>str</dt>
<dd>書き込むヌル文字<tt>'\0'</tt>終端の文字列を指すポインタを指定します。ヌル文字は書き込まれません。</dd>
<dt>fp</dt>
<dd>ファイル・オブジェクト構造体へのポインタを指定します。</dd>
</dl>
</div>
@ -42,7 +42,7 @@ int f_puts (
<div class="para desc">
<h4>解説</h4>
<p>文字列をファイルに書き込みます。この関数は<a href="putc.html">f_putc()</a>のラッパー関数です。</p>
<p>文字列をファイルに書き込みます。この関数は<a href="putc.html"><tt>f_putc()</tt></a>のラッパー関数です。</p>
</div>

View File

@ -11,13 +11,13 @@
<body>
<h1>ファイル関数の戻り値</h1>
<p>FatFsのAPIでは、一部の関数を除き結果に応じた共通のリザルト・コード(enum型)を返します。関数が成功した場合は0を返します。失敗した場合は0以外の値を返し、値はエラーの種類を示します。</p>
<p>FatFsのAPIでは、一部の関数を除き結果に応じた共通のリザルト・コード(FRESULT型(enum))を返します。関数が成功した場合は0を返します。失敗した場合は0以外の値を返し、値はエラーの種類を示します。</p>
<dl class="ret">
<dt id="ok">FR_OK (0)</dt>
<dd>関数は成功した。</dd>
<dt id="de">FR_DISK_ERR</dt>
<dd>下位レイヤ(ディスクI/O関数)で回復不能なエラーが発生した。</dd>
<dd>下位レイヤ(<tt>disk_read(), disk_write(), disk_ioctl()</tt>関数)で回復不能なエラーが発生した。</dd>
<dt id="ie">FR_INT_ERR</dt>
<dd>内部処理の健全性に異常が検出された。原因としては次のようなことが考えられます。
<ul>
@ -37,11 +37,11 @@
<dt id="dn">FR_DENIED</dt>
<dd>そのオブジェクトに対する操作の拒否。原因としては次のようなことが考えられます。
<ul>
<li>書き込み禁止属性(AM_RDO)を持つファイルを書き込みモードで開こうとした。</li>
<li>書き込み禁止属性(<tt>AM_RDO</tt>)を持つファイルを書き込みモードで開こうとした。</li>
<li>書き込み禁止属性を持つファイルやディレクトリを削除しようとした。</li>
<li>空でないディレクトリまたはカレント・ディレクトリを削除しようとした。</li>
<li>FA_READを付けずに開いたファイルに対して読み出しを行った。</li>
<li>FA_WRITEを付けずに開いたファイルに対して変更操作を行った。</li>
<li><tt>FA_READ</tt>を付けずに開いたファイルに対して読み出しを行った。</li>
<li><tt>FA_WRITE</tt>を付けずに開いたファイルに対して変更操作を行った。</li>
<li>ディレクトリ・テーブルが満杯でファイルやディレクトリを作成できなかった。</li>
<li>ボリュームが満杯でディレクトリを作成できなかった。</li>
</ul>
@ -49,35 +49,36 @@
<dt id="ex">FR_EXIST</dt>
<dd>新しく作成しようとしたオブジェクトと同じ名前のオブジェクトが既に存在する。</dd>
<dt id="io">FR_INVALID_OBJECT</dt>
<dd>指定されたファイル・オブジェクトやディレクトリ・オブジェクトが無効。</dd>
<dd>指定されたファイル・オブジェクトやディレクトリ・オブジェクトが無効(オープンされていない、破損しているなど)、またはヌル・ポインタが渡された</dd>
<dt id="wp">FR_WRITE_PROTECTED</dt>
<dd>物理ドライブが書き込み禁止状態のとき、書き込みを伴う操作を行おうとした。</dd>
<dd>物理ドライブが書き込み禁止状態のとき、書き込み系の操作を行おうとした。</dd>
<dt id="id">FR_INVALID_DRIVE</dt>
<dd>指定されたドライブ番号が無効。(関連オプション: _VOLUMES)</dd>
<dd>指定されたドライブ番号が無効。(関連オプション: <tt>_VOLUMES</tt>)</dd>
<dt id="ne">FR_NOT_ENABLED</dt>
<dd>そのボリュームの操作に必要なワーク・エリア(ファイル・システム・オブジェクト構造体)が与えられていない。</dd>
<dt id="ns">FR_NO_FILESYSTEM</dt>
<dd>物理ドライブ上に有効なFATボリュームが見つからなかった。</dd>
<dt id="ma">FR_MKFS_ABORTED</dt>
<dd>f_mkfs()の処理が開始前に中断された。原因としては次のようなことが考えられます。
<dd><tt>f_mkfs()</tt>の処理が開始前に中断された。原因としては次のようなことが考えられます。
<ul>
<li>ボリュームが小さすぎる。</li>
<li>FATタイプの計算に矛盾が見つかった。クラスタ数がFATタイプの境界付近になるときに発生する場合があります。</li>
<li>論理ドライブに対応する区画が見つからなかった。(関連オプション: <tt>_MULTI_PARTITION</tt>)</li>
</ul>
</dd>
<dt id="tm">FR_TIMEOUT</dt>
<dd><a href="appnote.html#reentrant">再入制御</a>による待ち時間が定義された時間を越えたため、関数は実行されなかった。(関連オプション: _TIMEOUT)</dd>
<dd><a href="appnote.html#reentrant">再入制御</a>による待ち時間が定義された時間を越えたため、関数は実行されなかった。(関連オプション: <tt>_TIMEOUT</tt>)</dd>
<dt id="lo">FR_LOCKED</dt>
<dd><a href="appnote.html#dup">多重アクセス排他機能</a>により、そのファイルに対して行おうとしたアクセスが拒否された。(関連オプション: _FS_SHARE)</dd>
<dd><a href="appnote.html#dup">多重アクセス排他機能</a>により、そのファイルに対して行おうとしたアクセスが拒否された。(関連オプション: <tt>_FS_LOCK</tt>)</dd>
<dt id="nc">FR_NOT_ENOUGH_CORE</dt>
<dd>メモリ不足による失敗。原因としては次のようなことが考えられます。
<ul>
<li>LFN操作バッファの動的確保に失敗した。(関連オプション: _USE_LFN)</li>
<li>LFN操作バッファの動的確保に失敗した。(関連オプション: <tt>_USE_LFN</tt>)</li>
<li>与えられた配列のサイズが実際に必要なサイズに対して不足している。</li>
</ul>
</dd>
<dt id="tf">FR_TOO_MANY_OPEN_FILES</dt>
<dd>同時オープン可能なファイル数を越えてファイルを開こうとした。(関連オプション: _FS_SHARE)</dd>
<dd>同時オープン可能なファイル数を越えてファイルを開こうとした。(関連オプション: <tt>_FS_LOCK</tt>)</dd>
<dt id="ip">FR_INVALID_PARAMETER</dt>
<dd>与えられたパラメータが無効または矛盾している。</dd>
</dl>

View File

@ -16,10 +16,10 @@
<p>ファイルからデータを読み出します。</p>
<pre>
FRESULT f_read (
FIL* <em>FileObject</em>, <span class="c">/* ファイル・オブジェクト構造体 */</span>
void* <em>Buffer</em>, <span class="c">/* 読み出したデータを格納するバッファ */</span>
UINT <em>ByteToRead</em>, <span class="c">/* 読み出すバイト数 */</span>
UINT* <em>ByteRead</em> <span class="c">/* 読み出されたバイト数 */</span>
FIL* <span class="arg">fp</span>, <span class="c">/* [IN] ファイル・オブジェクト構造体 */</span>
void* <span class="arg">buff</span>, <span class="c">/* [OUT] 読み出したデータを格納するバッファ */</span>
UINT <span class="arg">btr</span>, <span class="c">/* [IN] 読み出すバイト数 */</span>
UINT* <span class="arg">br</span> <span class="c">/* [OUT] 読み出されたバイト数 */</span>
);
</pre>
</div>
@ -27,13 +27,13 @@ FRESULT f_read (
<div class="para arg">
<h4>引数</h4>
<dl class="par">
<dt>FileObject</dt>
<dt>fp</dt>
<dd>ファイル・オブジェクト構造体へのポインタを指定します。</dd>
<dt>Buffer</dt>
<dt>buff</dt>
<dd>読み出したデータを格納するバッファを指すポインタを指定します。</dd>
<dt>ByteToRead</dt>
<dd>読み出すバイト数(0UINTの最大値)を指定します。</dd>
<dt>ByteRead</dt>
<dt>btr</dt>
<dd>読み出すバイト数(0<tt>UINT</tt>の最大値)を指定します。</dd>
<dt>br</dt>
<dd>実際に読み出されたバイト数を格納する変数を指すポインタを指定します。戻り値は関数の成否にかかわらず常に有効です。</dd>
</dl>
</div>
@ -55,7 +55,7 @@ FRESULT f_read (
<div class="para desc">
<h4>解説</h4>
<p>読み込み開始位置は、現在のリード/ライト・ポインタからになります。リード/ライト・ポインタは読み込まれたバイト数だけ進みます。関数が正常終了した後は、<tt>*ByteRead</tt>の値をチェックすべきです。<tt>*ByteRead</tt><tt>ByteToRead</tt>よりも小さいときは、読み込み中にファイルの終端に達したことを示しています。</p>
<p>読み込み開始位置は、現在のリード/ライト・ポインタからになります。リード/ライト・ポインタは読み込まれたバイト数だけ進みます。関数が正常終了した後は、<tt class="arg">*br</tt>の値をチェックすべきです。<tt class="arg">*br</tt><tt class="arg">btr</tt>よりも小さいときは、読み込み中にファイルの終端に達したことを示しています。</p>
</div>

View File

@ -16,8 +16,8 @@
<p>ディレクトリ項目を読み出します</p>
<pre>
FRESULT f_readdir (
DIR* <em>DirObject</em>, <span class="c">/* ディレクトリ・ブジェクト構造体へのポインタ */</span>
FILINFO* <em>FileInfo</em> <span class="c">/* ファイル情報構造体へのポインタ */</span>
DIR* <span class="arg">dj</span>, <span class="c">/* [IN] ディレクトリ・ブジェクト構造体へのポインタ */</span>
FILINFO* <span class="arg">fno</span> <span class="c">/* [OUT] ファイル情報構造体へのポインタ */</span>
);
</pre>
</div>
@ -25,9 +25,9 @@ FRESULT f_readdir (
<div class="para arg">
<h4>引数</h4>
<dl class="par">
<dt>DirObject</dt>
<dt>dj</dt>
<dd>有効なディレクトリ・オブジェクト構造体へのポインタを指定します。</dd>
<dt>FileInfo</dt>
<dt>fno</dt>
<dd>読み出したディレクトリ項目を格納するファイル情報構造体へのポインタを指定します。</dd>
</dl>
</div>
@ -49,14 +49,14 @@ FRESULT f_readdir (
<div class="para desc">
<h4>解説</h4>
<p>ディレクトリ項目を順次読み出します。この関数を繰り返し実行することによりディレクトリの全ての項目を読み出すことができます。全ての項目を読み出し、読み出す項目がもう無いときは、<tt>f_name[]</tt>メンバにヌル文字列が返されます。ボリューム・ラベルは読み出すときに棄てられ、現れることはありません。"."、".."は、相対パスが有効なとき(<tt>_FS_RPATH == 1</tt>)にのみ現れます。得られるファイル情報の詳細については <tt>FILINFO</tt>構造体を参照してください。FileInfoにヌル・ポインタを指定すると、そのディレクトリのリード・インデックスを巻き戻します。</p>
<p>LFN機能が有効な時は、f_readdir関数の呼び出しに先立ってFILINFO構造体の<tt>lfname</tt><tt>lfsize</tt>が有効な値で初期化されていなければなりません。<tt>lfname</tt>はLFNを格納するバッファで、<tt>lfsize</tt>はそのバッファ・サイズ(TCHAR)です。次の条件に一つでも該当する場合は、LFN格納バッファにヌル文字列が返されます。</p>
<p>ディレクトリ項目(ファイルとディレクトリ)を順次読み出します。この関数を繰り返し実行することによりそのディレクトリの全ての項目を読み出すことができます。全ての項目を読み出し、読み出す項目がもう無いときは、<tt>fname[]</tt>メンバにヌル文字列が返されます。ドット・エントリ("."、"..")は、相対パスが有効なとき(<tt>_FS_RPATH == 1</tt>)にのみ現れます。得られるファイル情報の詳細については <tt>FILINFO</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格納バッファにヌル文字列が返されます。</p>
<ul>
<li>そのディレクトリ項目にLFNが存在しない。</li>
<li>LFNの長さに対してLFN格納バッファまたはLFN操作バッファのサイズが不十分。</li>
<li>LFNに現在のOEMコードに存在しない文字が含まれている。(Unicode APIではないとき)</li>
</ul>
<p>また、<tt>lfname</tt>にヌル・ポインタを指定した場合は、LFNに関して何も返されません。LFNが存在しないときは、<tt>f_name[]</tt>メンバのSFNにASCII英小文字が含まれる場合があります。</p>
<p>また、<tt>lfname</tt>にヌル・ポインタを指定した場合は、LFNに関して何も返されません。LFNが存在しないときは、<tt>fname[]</tt>メンバのSFNにASCII英小文字が含まれる場合があります。</p>
</div>

View File

@ -16,8 +16,8 @@
<p>オブジェクトの名前の変更または移動。</p>
<pre>
FRESULT f_rename (
const TCHAR* <em>OldName</em>, <span class="c">/* 古いオブジェクト名 */</span>
const TCHAR* <em>NewName</em> <span class="c">/* 新しいオブジェクト名 */</span>
const TCHAR* <span class="arg">old_name</span>, <span class="c">/* [IN] 古いオブジェクト名 */</span>
const TCHAR* <span class="arg">new_name</span> <span class="c">/* [IN] 新しいオブジェクト名 */</span>
);
</pre>
</div>
@ -25,10 +25,10 @@ FRESULT f_rename (
<div class="para arg">
<h4>引数</h4>
<dl class="par">
<dt>OldName</dt>
<dd>変更対象のオブジェクト(ファイルまたはディレクトリ)<a href="filename.html">パス名</a>の入った<tt>'\0'</tt>で終わる文字列へのポインタを指定します。</dd>
<dt>NewName</dt>
<dd>新しいオブジェクトのフルパス名の入った<tt>'\0'</tt>で終わる文字列へのポインタを指定します。既に存在する名前は使えません。また、ドライブ番号は指定できず、<tt>OldName</tt>で指定された論理ドライブ上のオブジェクトとして扱われます。<br>
<dt>old_name</dt>
<dd>変更対象のオブジェクト(ファイルまたはディレクトリ)の<a href="filename.html">パス名</a>を示すヌル文字<tt>'\0'</tt>終端の文字列へのポインタを指定します。</dd>
<dt>new_name</dt>
<dd>新しいオブジェクトのパス名を示すヌル文字<tt>'\0'</tt>終端の文字列へのポインタを指定します。既に存在する名前は使えません。また、ドライブ番号は指定できず、<tt class="arg">old_name</tt>で指定された論理ドライブ上のオブジェクトとして扱われます。<br>
</dl>
</div>
@ -56,7 +56,7 @@ FRESULT f_rename (
<div class="para desc">
<h4>解説</h4>
<p>オブジェクトの名前を変更します。また、別のディレクトリへの移動も可能です。<em>開かれているオブジェクトに対して使用してはなりません</em></p>
<p>オブジェクトの名前を変更します。また、同時に別のディレクトリへの移動も可能です。<em>開かれているオブジェクトに対して使用してはなりません</em></p>
</div>

View File

@ -13,7 +13,7 @@
<div class="para">
<h2>DIR</h2>
<p><tt>DIR</tt>構造体は、f_opendir(), f_readdir()のワーク・エリアとして使用されます。アプリケーションから変更可能なメンバはありません。</p>
<p><tt>DIR</tt>構造体は、<tt>f_opendir(), f_readdir()</tt>のワーク・エリアとして使用されます。アプリケーションは、この構造体のメンバを書き換えてはなりません。</p>
<pre>
<span class="k">typedef</span> <span class="k">struct</span> {
FATFS* fs; <span class="c">/* 親ファイル・システム・オブジェクトへのポインタ */</span>

89
doc/ja/setlabel.html Normal file
View File

@ -0,0 +1,89 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html lang="ja">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=Shift_JIS">
<meta http-equiv="Content-Style-Type" content="text/css">
<link rel="up" title="FatFs" href="../00index_j.html">
<link rel="alternate" hreflang="en" title="English" href="../en/setlabel.html">
<link rel="stylesheet" href="../css_j.css" type="text/css" media="screen" title="ELM Default">
<title>FatFs - f_setlabel</title>
</head>
<body>
<div class="para func">
<h2>f_setlabel</h2>
<p>ボリューム・ラベルを書き込みます。</p>
<pre>
FRESULT f_setlabel (
const TCHAR* <span class="arg">name</span> <span class="c">/* [IN] 設定するボリューム名へのポインタ */</span>
);
</pre>
</div>
<div class="para arg">
<h4>引数</h4>
<dl class="par">
<dt>name</dt>
<dd>設定するボリューム名を示すヌル文字<tt>'\0'</tt>終端の文字列へのポインタを指定します。</dd>
</dl>
</div>
<div class="para ret">
<h4>戻り値</h4>
<p>
<a href="rc.html#ok">FR_OK</a>,
<a href="rc.html#de">FR_DISK_ERR</a>,
<a href="rc.html#ie">FR_INT_ERR</a>,
<a href="rc.html#nr">FR_NOT_READY</a>,
<a href="rc.html#in">FR_INVALID_NAME</a>,
<a href="rc.html#wp">FR_WRITE_PROTECTED</a>,
<a href="rc.html#id">FR_INVALID_DRIVE</a>,
<a href="rc.html#ne">FR_NOT_ENABLED</a>,
<a href="rc.html#ns">FR_NO_FILESYSTEM</a>,
<a href="rc.html#tm">FR_TIMEOUT</a>
</p>
</div>
<div class="para desc">
<h4>解説</h4>
<p>文字列の先頭にドライブ番号を含む場合は、その論理ドライブに設定されます。含まない場合は、デフォルト・ドライブに設定されます。ボリューム名を削除するときは、ヌル文字列を指定します。名前のフォーマットは、短いファイル名とほぼ同じですが、次の点が異なります。</p>
<ul>
<li>ローカル・コード換算で11バイト以下。</li>
<li>ピリオドを含むことはできない。</li>
<li>任意の位置にスペースを置くことができる。ただし、最後尾のスペースは除去される。</li>
</ul>
</div>
<div class="para comp">
<h4>対応情報</h4>
<p><tt>_FS_READONLY == 0</tt>で、且つ<tt>_USE_LABEL == 1</tt>のときに使用可能です。</p>
</div>
<div class="para use">
<h4>使用例</h4>
<pre>
<span class="c">/* デフォルト・ドライブにボリューム名を設定 */</span>
f_setlabel("DATA DISK");
<span class="c">/* ドライブ2にボリューム名を設定 */</span>
f_setlabel("2:DISK 3 OF 4");
<span class="c">/* ドライブ2のボリューム名を削除 */</span>
f_setlabel("2:");
</pre>
</div>
<div class="para ref">
<h4>参照</h4>
<tt><a href="getlabel.html">f_getlabel</a></tt>
</div>
<p class="foot"><a href="../00index_j.html">戻る</a></p>
</body>
</html>

View File

@ -13,7 +13,7 @@
<div class="para">
<h2>FATFS</h2>
<p><tt>FATFS</tt>構造体(ファイル・システム・オブジェクト)は、個々の論理ドライブのダイナミック・ワーク・エリアを保持し、f_mount()でFatFsモジュールに登録されます。初期化が行われるタイミングは、f_mount()またはメディア交換の後の最初のファイル・アクセスの時です。アプリケーションから書き換え可能なメンバはありません。</p>
<p><tt>FATFS</tt>構造体(ファイル・システム・オブジェクト)は、個々の論理ドライブのダイナミック・ワーク・エリアを保持し、<tt>f_mount()</tt>でFatFsモジュールに登録されます。初期化が行われるタイミングは、<tt>f_mount()</tt>またはメディア交換の後の最初のファイル・アクセスの時です。アプリケーションは、この構造体のメンバを書き換えてはなりません。</p>
<pre>
<span class="k">typedef</span> <span class="k">struct</span> {
@ -41,9 +41,10 @@
<span class="k">#endif</span>
DWORD n_fatent; <span class="c">/* FATのエントリ数 (== クラスタ数 + 2) */</span>
DWORD fsize; <span class="c">/* FAT 1個当たりのセクタ数 */</span>
DWORD volbase; <span class="c">/* ボリューム開始セクタ */</span>
DWORD fatbase; <span class="c">/* FAT領域開始セクタ */</span>
DWORD dirbase; <span class="c">/* ルート・ディレクトリ開始セクタ (FAT32: クラスタ番号) */</span>
DWORD database; <span class="c">/* データ領域開始セクタ */</span>
DWORD dirbase; <span class="c">/* ルート・ディレクトリ開始セクタ/クラスタ */</span>
DWORD database; <span class="c">/* データ領域開始セクタ */</span>
DWORD winsect; <span class="c">/* win[]に現れているセクタ番号 */</span>
BYTE win[_MAX_SS]; <span class="c">/* ディスク・アクセス・ウィンドウ */</span>
} FATFS;

View File

@ -13,7 +13,7 @@
<div class="para">
<h2>FIL</h2>
<p><tt>FIL</tt>構造体(ファイル・オブジェクト)は、f_open関数で初期化され、以後そのファイルの状態を保持します。また、f_close関数でファイルが閉じられると無効化されます。アプリケーションからの書き換えが可能なメンバは<tt>cltbl</tt>のみです。非タイニー構成では内部にセクタ・バッファが確保されるので、サイズに注意が必要です。</p>
<p><tt>FIL</tt>構造体(ファイル・オブジェクト)は、<tt>f_open()</tt>で初期化され、以後そのファイルの状態を保持します。また、<tt>f_close()</tt>でファイルが閉じられると無効化されます。アプリケーションは、この構造体のメンバを書き換えてはなりません(<tt>cltbl</tt>は例外)。非タイニー構成では、内部にセクタ・バッファが確保されるので、占有サイズに注意が必要です。</p>
<pre>
<span class="k">typedef</span> <span class="k">struct</span> {
@ -23,7 +23,7 @@
BYTE pad1;
DWORD fptr; <span class="c">/* ファイル読み書きポインタ (ファイル先頭からのバイト・オフセット) */</span>
DWORD fsize; <span class="c">/* ファイル・サイズ(バイト単位) */</span>
DWORD sclust; <span class="c">/* ファイル開始クラスタ番号 (0 on fsize==0) */</span>
DWORD sclust; <span class="c">/* ファイル開始クラスタ番号 (set 0 if fsize==0) */</span>
DWORD clust; <span class="c">/* 現在のクラスタ */</span>
DWORD dsect; <span class="c">/* 現在のデータ・セクタ */</span>
<span class="k">#if</span> _FS_READONLY == 0

View File

@ -16,7 +16,7 @@
<p>ファイルのサイズを取得します。</p>
<pre>
DWORD f_size (
FIL* <em>FileObject</em> <span class="c">/* ファイル・オブジェクト */</span>
FIL* <span class="arg">fp</span> <span class="c">/* [IN] ファイル・オブジェクト */</span>
);
</pre>
</div>
@ -25,7 +25,7 @@ DWORD f_size (
<div class="para arg">
<h4>引数</h4>
<dl class="par">
<dt>FileObject</dt>
<dt>fp</dt>
<dd>ファイル・オブジェクト構造体へのポインタを指定します。</dd>
</dl>
</div>

View File

@ -15,8 +15,8 @@
<h2>f_stat</h2>
<pre>
FRESULT f_stat (
const TCHAR* <em>FileName</em>, <span class="c">/* ファイルまたはディレクトリ名へのポインタ */</span>
FILINFO* <em>FileInfo</em> <span class="c">/* ファイル情報構造体へのポインタ */</span>
const TCHAR* <span class="arg">path</span>, <span class="c">/* [IN] ファイルまたはディレクトリ名へのポインタ */</span>
FILINFO* <span class="arg">fno</span> <span class="c">/* [OUT] ファイル情報構造体へのポインタ */</span>
);
</pre>
</div>
@ -24,9 +24,9 @@ FRESULT f_stat (
<div class="para arg">
<h4>引数</h4>
<dl class="par">
<dt>FileName</dt>
<dd>情報を得るファイルまたはディレクトリ名<tt>'\0'</tt>で終わる文字列を指すポインタを指定します。</dd>
<dt>FileInfo</dt>
<dt>path</dt>
<dd>情報を得るファイルまたはディレクトリ名を示すヌル文字<tt>'\0'</tt>終端の文字列を指すポインタを指定します。</dd>
<dt>fno</dt>
<dd>読み出したファイル情報を格納するファイル情報構造体へのポインタを指定します。</dd>
</dl>
</div>
@ -53,7 +53,7 @@ FRESULT f_stat (
<div class="para desc">
<h4>解説</h4>
<p>指定されたファイルまたはディレクトリに関する情報(サイズ、タイムスタンプおよび属性)を得ます。ディレクトリのサイズ情報は常に0です。</p>
<p>指定されたファイルまたはディレクトリに関する情報(サイズ、タイムスタンプおよび属性)を得ます。ディレクトリのサイズ情報は無効で常に0です。</p>
</div>

View File

@ -16,7 +16,7 @@
<p>書き込み中のファイルのキャッシュされた情報をフラッシュします。</p>
<pre>
FRESULT f_sync (
FIL* <em>FileObject</em> <span class="c">/* ファイル・オブジェクト構造体へのポインタ */</span>
FIL* <span class="arg">fp</span> <span class="c">/* [IN] ファイル・オブジェクト構造体へのポインタ */</span>
);
</pre>
</div>
@ -24,7 +24,7 @@ FRESULT f_sync (
<div class="para arg">
<h4>引数</h4>
<dl class="par">
<dt>FileObject</dt>
<dt>fp</dt>
<dd>syncするファイルのファイル・オブジェクト構造体へのポインタを指定します。</dd>
</dl>
</div>

View File

@ -16,7 +16,7 @@
<p>現在のリード/ライト・ポインタを取得します。</p>
<pre>
DWORD f_tell (
FIL* <em>FileObject</em> <span class="c">/* ファイル・オブジェクト */</span>
FIL* <span class="arg">fp</span> <span class="c">/* [IN] ファイル・オブジェクト */</span>
);
</pre>
</div>
@ -25,7 +25,7 @@ DWORD f_tell (
<div class="para arg">
<h4>引数</h4>
<dl class="par">
<dt>FileObject</dt>
<dt>fp</dt>
<dd>ファイル・オブジェクト構造体へのポインタを指定します。</dd>
</dl>
</div>

View File

@ -16,7 +16,7 @@
<p>ファイル長を切り詰めます。</p>
<pre>
FRESULT f_truncate (
FIL* <em>FileObject</em> <span class="c">/* ファイル・オブジェクトへのポインタ */</span>
FIL* <span class="arg">fp</span> <span class="c">/* [IN] ファイル・オブジェクトへのポインタ */</span>
);
</pre>
</div>
@ -24,7 +24,7 @@ FRESULT f_truncate (
<div class="para arg">
<h4>引数</h4>
<dl class="par">
<dt>FileObject</dt>
<dt>fp</dt>
<dd>切り詰め対象ファイルのファイル・オブジェクトへのポインタ</dd>
</dl>
</div>

View File

@ -16,7 +16,7 @@
<p>ファイルまたはディレクトリを削除します。</p>
<pre>
FRESULT f_unlink (
const TCHAR* <em>FileName</em> <span class="c">/* オブジェクト名へのポインタ */</span>
const TCHAR* <span class="arg">path</span> <span class="c">/* [IN] オブジェクト名へのポインタ */</span>
);
</pre>
</div>
@ -24,8 +24,8 @@ FRESULT f_unlink (
<div class="para arg">
<h4>引数</h4>
<dl class="par">
<dt>FileName</dt>
<dd>削除対象の<a href="filename.html">パス名</a>の入った<tt>'\0'</tt>で終わる文字列へのポインタを指定します。</dd>
<dt>path</dt>
<dd>削除対象の<a href="filename.html">パス名</a>を示すヌル文字<tt>'\0'</tt>終端の文字列へのポインタを指定します。</dd>
</dl>
</div>
@ -56,9 +56,9 @@ FRESULT f_unlink (
<h4>解説</h4>
<p>削除対象のオブジェクが次の条件に当てはまる場合、そのアクセスは拒否され関数は失敗します。
<ul>
<li>リード・オンリー属性 (AM_RDO)を持っている。</li>
<li>リード・オンリー属性(<tt>AM_RDO</tt>)を持っている。</li>
<li>空でないディレクトリまたはカレント・ディレクトリ。</li>
<li>開かれているファイル。この場合、<em>FAT構造が破壊される可能性</em>があります。<a href="appnote.html#dup">多重アクセス制御</a>が有効なときは安全に拒否されます。</li>
<li>開かれているファイル。<a href="appnote.html#dup">多重アクセス制御</a>が有効なときは安全に拒否されますが、そうでないときは不正な操作となり、<em>FAT構造が破壊される可能性</em>があります。</li>
</ul>
</p>
</div>

View File

@ -16,8 +16,8 @@
<p>オブジェクトのタイムスタンプを変更します。</p>
<pre>
FRESULT f_utime (
const TCHAR* <em>FileName</em>, <span class="c">/* オブジェクト名へのポインタ */</span>
const FILINFO* <em>TimeDate</em> <span class="c">/* 設定する日付 */</span>
const TCHAR* <span class="arg">path</span>, <span class="c">/* [IN] オブジェクト名へのポインタ */</span>
const FILINFO* <span class="arg">fno</span> <span class="c">/* [IN] 設定する日付 */</span>
);
</pre>
</div>
@ -25,10 +25,10 @@ FRESULT f_utime (
<div class="para arg">
<h4>引数</h4>
<dl class="par">
<dt>FileName</dt>
<dd>変更対象のファイルまたはディレクトリ<a href="filename.html">パス名</a>の入った<tt>'\0'</tt>で終わる文字列を指定します。</dd>
<dt>TimeDate</dt>
<dd>設定する日付と時間をfdateとftimeメンバに設定されたFILINFO構造体へのポインタ。他のメンバはDon't careです</dd>
<dt>path</dt>
<dd>変更対象のファイルまたはディレクトリの<a href="filename.html">パス名</a>を示すヌル文字<tt>'\0'</tt>終端の文字列を指定します。</dd>
<dt>fno</dt>
<dd>設定する日付と時間を<tt>fdate</tt><tt>ftime</tt>メンバに設定された<tt>FILINFO</tt>構造体へのポインタ。他のメンバはこの関数では意味を持ちません</dd>
</dl>
</div>

View File

@ -16,10 +16,10 @@
<p>ファイルにデータを書き込みます。</p>
<pre>
FRESULT f_write (
FIL* <em>FileObject</em>, <span class="c">/* ファイル・オブジェクト */</span>
const void* <em>Buffer</em>, <span class="c">/* 書き込みデータ */</span>
UINT <em>ByteToWrite</em>, <span class="c">/* 書き込むバイト数 */</span>
UINT* <em>ByteWritten</em> <span class="c">/* 書き込まれたバイト数 */</span>
FIL* <span class="arg">fp</span>, <span class="c">/* [IN] ファイル・オブジェクト */</span>
const void* <span class="arg">buff</span>, <span class="c">/* [IN] 書き込みデータ */</span>
UINT <span class="arg">btw</span>, <span class="c">/* [IN] 書き込むバイト数 */</span>
UINT* <span class="arg">bw</span> <span class="c">/* [OUT] 書き込まれたバイト数 */</span>
);
</pre>
</div>
@ -27,13 +27,13 @@ FRESULT f_write (
<div class="para arg">
<h4>引数</h4>
<dl class="par">
<dt>FileObject</dt>
<dt>fp</dt>
<dd>ファイル・オブジェクト構造体へのポインタを指定します。</dd>
<dt>Buffer</dt>
<dt>buff</dt>
<dd>書き込むデータを格納したバッファを指すポインタを指定します。</dd>
<dt>ByteToWrite</dt>
<dd>書き込むバイト数(0UINTの最大値)を指定します。</dd>
<dt>ByteWritten</dt>
<dt>btw</dt>
<dd>書き込むバイト数(0<tt>UINT</tt>の最大値)を指定します。</dd>
<dt>bw</dt>
<dd>書き込まれたバイト数を格納する変数を指すポインタを指定します。戻り値は関数の成否にかかわらず常に有効です。</dd>
</dl>
</div>
@ -55,7 +55,7 @@ FRESULT f_write (
<div class="para desc">
<h4>解説</h4>
<p>書き込み開始位置は、リード/ライト・ポインタの位置からになります。リード/ライト・ポインタは実際に書き込まれたバイト数だけ進みます。関数が正常終了した後、要求したバイト数が書き込まれたかどうか<tt>*ByteWritten</tt>をチェックすべきです。<tt>*ByteWritten &lt; ByteToWrite</tt>ときは、ディスク・フルを意味します。ディスク・フルが発生しているときまたはそれに近いときは、制御が帰るまで時間がかかる場合があります。</p>
<p>書き込み開始位置は、リード/ライト・ポインタの位置からになります。リード/ライト・ポインタは実際に書き込まれたバイト数だけ進みます。関数が正常終了した後、要求したバイト数が書き込まれたかどうか<tt class="arg">*bw</tt>をチェックすべきです。<tt class="arg">*bw</tt><tt class="arg">btw</tt>より小さいときは、ディスク・フルを意味します。ディスク・フルが発生しているときまたはそれに近いときは、制御が帰るまで時間がかかる場合があります。</p>
</div>

View File

@ -1,3 +1,6 @@
R0.09b, Jan 24, 2013
Added f_getlabel() and f_setlabel(). (_USE_LABEL = 1)
R0.09a, Aug 27, 2012
Fixed assertion failure due to OS/2 EA on FAT12/16.
Changed API rejects null object pointer to avoid crash.

Some files were not shown because too many files have changed in this diff Show More