diff --git a/doc/00index_e.html b/doc/00index_e.html index 335f5ff..dbdf70a 100644 --- a/doc/00index_e.html +++ b/doc/00index_e.html @@ -59,11 +59,12 @@
  • f_chmod - Change attribute
  • f_utime - Change timestamp
  • f_rename - Rename/Move a file or directory
  • -
  • f_mkfs - Create a file system on the drive
  • -
  • f_forward - Forward file data to the stream directly
  • f_chdir - Change current directory
  • f_chdrive - Change current drive
  • f_getcwd - Retrieve the current directory
  • +
  • f_forward - Forward file data to the stream directly
  • +
  • f_mkfs - Create a file system on the drive
  • +
  • f_fdisk - Divide a physical drive
  • f_gets - Read a string
  • f_putc - Write a character
  • f_puts - Write a string
  • @@ -95,17 +96,19 @@

    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.


    -

    FatFs Home Page

    +

    Return

    diff --git a/doc/00index_j.html b/doc/00index_j.html index a6919db..0793a19 100644 --- a/doc/00index_j.html +++ b/doc/00index_j.html @@ -58,11 +58,12 @@
  • f_chmod - ファイル/ディレクトリの属性の変更
  • f_utime - ファイル/ディレクトリのタイムスタンプの変更
  • f_rename - ファイル/ディレクトリの名前変更・移動
  • -
  • f_mkfs - ディスクのフォーマット
  • f_chdir - カレント・ディレクトリの変更
  • f_chdrive - カレント・ドライブの変更
  • f_getcwd - カレント・ディレクトリの取得
  • f_forward - ファイル・データをストリーム関数に転送
  • +
  • f_mkfs - 論理ドライブのフォーマット
  • +
  • f_fdisk - 物理ドライブの分割
  • f_gets - 文字列の読み出し
  • f_putc - 文字の書き込み
  • f_puts - 文字列の書き込み
  • @@ -79,10 +80,10 @@

    下位レイヤ・インターフェース

    FatFsモジュールは、物理ドライブ等へのアクセスのため、下位レイヤに少なくとも次のインターフェースを要求します。使用する記録メディアに対応したディスクI/Oモジュールは、ユーザによって用意される必要があります。OS関連機能を有効にしたときは、加えてプロセス・メモリ関連関数も必要になります。資料にドライバを含むサンプル・プロジェクトあり。

    @@ -94,7 +95,8 @@

    FatFsモジュールはフリー・ソフトウェアとして教育・研究・開発用に公開しています。どのような利用目的(個人利用から商用まで)でも使用・改変・配布について一切の制限はありませんが、全て利用者の責任の下での利用とします。詳しくはアプリケーション・ノートを参照してください。

    +

    System organizations

    +

    The dependency diagram shown below is a typical configuration of the embedded system with FatFs module.

    +dependency diagram +

    Which function is required?

    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.

    @@ -68,15 +72,15 @@ The FatFs module assumes that size of char/short/long are 8/16/32 bit and int is
    -

    Memory Usage (R0.08b)

    +

    Memory Usage (R0.09)

    - + - - - - + + + + @@ -104,34 +108,35 @@ _FS_SHARE 0 (Disable shareing control)

    Module Size Reduction

    Follwing table shows which API function is removed by configuration options for the module size reduction.

    ARM7
    32bit
    ARM7
    Thumb
    Cortex-M3
    Thumb-2
    AVRH8/300HPIC24RL78V850ESSH-2ARX62NIA-32
    ARM7
    32bit
    ARM7
    Thumb
    Cortex-M3
    Thumb-2
    AVRH8/300HPIC24RL78V850ESSH-2ARX600IA-32
    CompilerGCCGCCGCCGCCCH38C30CC78K0RCA850SHCRXCVC6
    _WORD_ACCESS00010001011
    text (Full, R/W)1049572056661126461068611430129677732875257477545
    text (Min, R/W)65234749433583066986741387454938557637464923
    text (Full, R/O)45393183289359604876525060603554380426593450
    text (Min, R/O)33072495219143663770393946042684294020252664
    text (Full, R/W)1045972016623126461068611466129677732875257477545
    text (Min, R/W)65034745429783066986744087454938557637464923
    text (Full, R/O)45353181286959604876528660603554380426593450
    text (Min, R/O)33032493217143663770398446042684294020252664
    bssD*4 + 2D*4 + 2D*4 + 2D*2 + 2D*4 + 2D*2 + 2D*2 + 2D*4 + 2D*4 + 2D*4 + 2D*4 + 2
    Work area
    (_FS_TINY == 0)
    V*560 +
    F*550
    V*560 +
    F*550
    V*560 +
    F*550
    V*560 +
    F*544
    V*560 +
    F*550
    V*560 +
    F*544
    V*560 +
    F*544
    V*560 +
    F*544
    V*560 +
    F*550
    V*560 +
    F*550
    V*560 +
    F*550
    Work area
    (_FS_TINY == 1)
    V*560 +
    F*36
    V*560 +
    F*36
    V*560 +
    F*36
    V*560 +
    F*32
    V*560 +
    F*36
    V*560 +
    F*32
    V*560 +
    F*32
    V*560 +
    F*36
    V*560 +
    F*36
    V*560 +
    F*36
    V*560 +
    F*36
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    Function_FS_MINIMIZE_FS_READONLY_USE_STRFUNC_FS_RPATH_USE_MKFS_USE_FORWARD
    0123010  1/20120101
    f_mount
    f_open
    f_close
    f_read
    f_writex
    f_syncx
    f_lseekx
    f_opendirxx
    f_readdirxx
    f_statxxx
    f_getfreexxxx
    f_truncatexxxx
    f_unlinkxxxx
    f_mkdirxxxx
    f_chmodxxxx
    f_utimexxxx
    f_renamexxxx
    f_chdirx
    f_chdrivex
    f_getcwdxx
    f_mkfsxx
    f_forwardx
    f_putcxx
    f_putsxx
    f_printfxx
    f_getsx
    Function_FS_MINIMIZE_FS_READONLY_USE_STRFUNC_FS_RPATH_USE_MKFS_USE_FORWARD_MULTI_PARTITION
    0123010  1/201201010/12
    f_mount
    f_open
    f_close
    f_read
    f_writex
    f_syncx
    f_lseekx
    f_opendirxx
    f_readdirxx
    f_statxxx
    f_getfreexxxx
    f_truncatexxxx
    f_unlinkxxxx
    f_mkdirxxxx
    f_chmodxxxx
    f_utimexxxx
    f_renamexxxx
    f_chdirx
    f_chdrivex
    f_getcwdxx
    f_mkfsxx
    f_fdiskxxx
    f_forwardx
    f_putcxx
    f_putsxx
    f_printfxx
    f_getsx
    @@ -148,7 +153,7 @@ _FS_SHARE 0 (Disable shareing control) 950(Big5)+111K

    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. This is the reason why I had not been interested in implementing the LFN feature for a long time :-)

    -

    Note that the LFN feature on the FAT file system is a patent of Microsoft Corporation. This is not the case on FAT32. When enable LFN feature on the commercial products, a license from Microsoft may be required depends on the final destination.

    +

    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.

    @@ -158,7 +163,7 @@ _FS_SHARE 0 (Disable shareing control)

    Re-entrancy

    -

    The file operations to the different volume is always re-entrant ant can work simultaneously. The file operations to the same volume is not re-entrant but it can also be configured to thread-safe with _FS_REENTRANT 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.

    +

    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 _FS_REENTRANT 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.

    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 _TIMEOUT, the file function will abort with FR_TIMEOUT. The timeout feature might not be supported on some RTOS.

    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.

    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.

    @@ -174,7 +179,7 @@ _FS_SHARE 0 (Disable shareing control)

    Performance Effective File Access

    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.

    Figure 1. Sector miss-aligned read (short)
    - +

    Figure 2. Sector miss-aligned read (long)
    @@ -195,9 +200,9 @@ _FS_SHARE 0 (Disable shareing control) Figure 6. Comparison between Multiple/Single Sector Write
    fig.6

    -

    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.

    +

    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.

    Forcing Memory Erase

    -

    When remove a file via f_remove function, the data clusters occupied by the file are maeked 'free' on the FAT. But the data sectors containing the file data are not that applied any process so that the file data left occupies a part of the media as live blocks. If the file data is forced erased on removing the file, the number of free blocks on the media will be increased. This may skip internal block erase operation to the data block on next write. As the result the write performance might be improved. To enable this feature, set _USE_ERASE 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.

    +

    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 _USE_ERASE 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.

    @@ -227,7 +232,7 @@ Figure 5. Minimized critical section

    About FatFs License

    This is a copy of the FatFs license document that included in the source codes.

    /*----------------------------------------------------------------------------/
    -/  FatFs - FAT file system module  R0.08b                    (C)ChaN, 2011
    +/  FatFs - FAT file system module  R0.09                     (C)ChaN, 2011
     /-----------------------------------------------------------------------------/
     / FatFs module is a generic FAT file system module for small embedded systems.
     / This is a free software that opened for education, research and commercial
    diff --git a/doc/en/dinit.html b/doc/en/dinit.html
    index 4f8a3f8..f7ac0bd 100644
    --- a/doc/en/dinit.html
    +++ b/doc/en/dinit.html
    @@ -38,7 +38,7 @@ DSTATUS disk_initialize (
     

    Description

    The disk_initialize function initializes a physical drive and put it ready to read/write. When the function succeeded, STA_NOINIT flag in the return value is cleard.

    -

    Application program should not call this function, or FAT structure on the volume can be collapted. To re-initialize the file system, use f_mount function.This function is called on volume mount process in the FatFs module to manage the media change.

    +

    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.This function is called on volume mount process in the FatFs module to manage the media change.

    Return

    diff --git a/doc/en/dstat.html b/doc/en/dstat.html index fa68f4a..759c386 100644 --- a/doc/en/dstat.html +++ b/doc/en/dstat.html @@ -35,11 +35,11 @@ DSTATUS disk_status (

    The disk status is returned in combination of following flags. FatFs refers only STA_NOINIT and STA_PROTECTED.

    STA_NOINIT
    -
    Indicates that the disk drive has not been initialized. This flag is set on: system reset, disk removal and disk_initialize function failed, and cleared on: disk_initialize function succeeded.
    +
    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.
    STA_NODISK
    Indicates that no medium in the drive. This is always cleared on fixed disk drive.
    STA_PROTECTED
    -
    Indicates that the medium is write protected. This is always cleared on the drive that does not support write protect notch. Not valid when STA_NODISK is set.
    +
    Indicates that the medium is write protected. This is always cleared on the drive that does not support write protect notch. Not valid while STA_NODISK is set.
    diff --git a/doc/en/fdisk.html b/doc/en/fdisk.html new file mode 100644 index 0000000..1adf943 --- /dev/null +++ b/doc/en/fdisk.html @@ -0,0 +1,97 @@ + + + + + + + + +FatFs - f_fdisk + + + + +
    +

    f_fdisk

    +

    The f_fdisk fucntion divides a physical drive.

    +
    +FRESULT f_fdisk (
    +  BYTE  Drive,              /* Physical drive number */
    +  const DWORD Partitions[], /* Partition size */
    +  void* Work                /* Work area */
    +);
    +
    +
    + +
    +

    Parameters

    +
    +
    Drive
    +
    Specifies the physical drive to be divided.
    +
    Partitions[]
    +
    Partition map table. It must have four items.
    +
    Work
    +
    Pointer to the function work area. The size must be at least _MAX_SS bytes.
    +
    +
    + +
    +

    Return Values

    +

    +FR_OK, +FR_DISK_ERR, +FR_NOT_READY, +FR_WRITE_PROTECTED, +FR_INVALID_PARAMETER +

    +
    + +
    +

    Description

    +

    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.

    +
    + +
    +

    QuickInfo

    +

    Available when _FS_READOLNY == 0, _USE_MKFS == 1 and _MULTI_PARTITION == 2.

    +
    + +
    +

    Example

    +
    +    /* Volume management table defined by user (required when _MULTI_PARTITION != 0) */
    +
    +    PARTITION VolToPart[] = {
    +        {0, 1},    /* Logical drive 0 ==> Physical drive 0, 1st partition */
    +        {0, 2},    /* Logical drive 1 ==> Physical drive 0, 2nd partition */
    +        {1, 0}     /* Logical drive 2 ==> Physical drive 1, auto detection */
    +    };
    +
    +
    +    /* Initialize a brand-new disk drive mapped to physical drive 0 */
    +
    +    FATFS Fatfs;
    +    DWORD plist[] = {50, 50, 0, 0};  /* Divide drive into two partitions */
    +    BYTE work[_MAX_SS];
    +
    +    f_fdisk(0, plist, work);  /* Divide physical drive 0 */
    +
    +    f_mount(0, &Fatfs);
    +    f_mkfs(0, 0, 0);          /* Create an FAT volume on the logical drive 0. 2nd argument is ignored. */
    +    f_mount(0, 0);
    +
    +    f_mount(1, &Fatfs);
    +    f_mkfs(1, 0, 0);
    +    f_mount(1, 0);
    +
    +
    +
    + +
    +

    See Also

    +

    Volume management, f_mkfs

    +
    + +

    Return

    + + diff --git a/doc/en/filename.html b/doc/en/filename.html index 44acf54..a60bb1c 100644 --- a/doc/en/filename.html +++ b/doc/en/filename.html @@ -12,7 +12,7 @@

    Path Names

    -
    +

    Format of the path names

    The path name format on the FatFs module is similer to the filename specs of DOS/Windos as follows:

    "[drive#:][/]directory/file"

    @@ -38,7 +38,7 @@


    -
    +

    Unicode API

    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 TCHAR which is an alias of char in default. The code set of the file name string is the ANSI/OEM code set specifid by _CODE_PAGE. When _LFN_UNICODE is set to 1 under LFN configuration, the type of the TCHAR is switched to unsigned short (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, _T(s) and _TEXT(s) macro are available to select either ANSI/OEM or Unicode automatically. The code shown below is an example to define the literal strings.

    @@ -49,25 +49,24 @@
     


    -
    +

    Correspondence between logical and physical drives

    -

    The FatFs module has work areas that called file system object for each volume (logical drive). In default, the logical drive is bound to the physical drive that has same drive number, and the first partition is mounted. When _MULTI_PARTITION == 1 is specified in configuration option, each individual logical drive can be bound to any physical drive/partition. In this case, a drive number resolution table must be defined as follows:

    +

    The FatFs module has work areas that called file system object for each volume (logical drive). In default, each logical drive is bound to the physical drive that has same drive number. It attempts to mount a volume as SFD format and first FDISK partition. When _MULTI_PARTITION >= 1 is specified in configuration option, each individual logical drive is bound to any physical drive/partition. In this case, a volume management table must be defined by user. It is used to resolve relationship between logical drives and partitions as follows:

     Example: Logical drive 0-2 are assigned to three pri-partitions on the physical drive 0 (fixed disk)
              Logical drive 3 is assigned to physical drive 1 (removable disk)
     
    -const PARTITION Drives[] = {
    -    {0, 0},     /* Logical drive 0 ==> Physical drive 0, 1st partition */
    -    {0, 1},     /* Logical drive 1 ==> Physical drive 0, 2nd partition */
    -    {0, 2},     /* Logical drive 2 ==> Physical drive 0, 3rd partition */
    -    {1, 0}      /* Logical drive 3 ==> Physical drive 1 */
    +PARTITION VolToPart[] = {
    +    {0, 1},     /* Logical drive 0 ==> Physical drive 0, 1st partition */
    +    {0, 2},     /* Logical drive 1 ==> Physical drive 0, 2nd partition */
    +    {0, 3},     /* Logical drive 2 ==> Physical drive 0, 3rd partition */
    +    {1, 0}      /* Logical drive 3 ==> Physical drive 1 (auto detection) */
     };
     

    There are some considerations when use _MULTI_PARTITION configuration.

      -
    • Only pri-partition (0-3) can be mounted.
    • -
    • When the physical drive has no partition table (SFD format), the partition number is ignored.
    • -
    • The physical drive that has two or more logical drives must be a fixed drive.
    • +
    • Only four pri-partitions can be mounted. Extended partition is not supported.
    • +
    • The physical drive that has two or more partitions must be non-removable class.
    diff --git a/doc/en/lseek.html b/doc/en/lseek.html index 8d5d110..a75f8f4 100644 --- a/doc/en/lseek.html +++ b/doc/en/lseek.html @@ -49,13 +49,13 @@ FRESULT f_lseek (

    Description

    -

    The f_lseek function moves the file read/write pointer of an open file. The offset can be specified in only origin from top of the file. When an offset above the file size is specified in write mode, the file size is increased to the offset and the data in the expanded area is undefined. This is suitable to create a large file quickly, for fast write operation. After the f_lseek function succeeded, member fptr in the file object should be checked in order to make sure the read/write pointer has been moved correctry. In case of fptr is not the expected value, either of followings has been occured.

    +

    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.

      -
    • End of file. The specified Offset was clipped at the file size because the file has been opened in read-only mode.
    • +
    • End of file. The specified Offset was clipped at end of the file because the file has been opened in read-only mode.
    • Disk full. There is insufficient free space on the volume to expand the file size.
    -

    Fast seek mode is enabled when _USE_FASTSEEK is set to 1 and cltbl member in the file object is not NULL. This feature enables fast backward/long seek operations without FAT access by cluster link map table (CLMT) stored in the user defined table. It is also applied to f_read/f_write functions. In this mode, the file size cannot be increased by f_write/f_lseek functions.

    -

    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 cltbl member in the file object, set the array size in unit of items into the first item and call the f_lseek function with Offset = CREATE_LINKMAP. 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 FR_NOT_ENOUGH_CORE, 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.

    +

    Fast seek feature is enabled when _USE_FASTSEEK is set to 1 and the member cltbl 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.

    +

    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 cltbl in the file object, set the array size in unit of items into the first item and call the f_lseek function with Offset = CREATE_LINKMAP. 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 FR_NOT_ENOUGH_CORE, 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.

    @@ -69,7 +69,7 @@ FRESULT f_lseek (

    Example

         /* Open file */
    -    file = malloc(sizeof(FIL));
    +    file = malloc(sizeof (FIL));
         if (!file) ...
         res = f_open(file, "file.dat", FA_READ|FA_WRITE);
         if (res) ...
    @@ -86,15 +86,16 @@ FRESULT f_lseek (
         /* Rewind 2000 bytes (take care on overflow) */
         res = f_lseek(file, f_tell(file) - 2000);
     
    -
        /* Cluster pre-allocation (to prevent buffer overrun on streaming write) */
    +
    +    /* Cluster pre-allocation (to prevent buffer overrun on streaming write) */
     
         res = f_open(file, recfile, FA_CREATE_NEW | FA_WRITE); /* Create a file */
     
    -    res = f_lseek(file, PRE_SIZE);           /* Pre-allocate clusters */
    -    if (res || f_tell(file) != PRE_SIZE) ... /* Check if the file size has been increased correctly */
    +    res = f_lseek(file, PRE_SIZE);           /* Expand file size (cluster pre-allocation) */
    +    if (res || f_tell(file) != PRE_SIZE) ... /* Check if the file has been expanded */
     
    -    res = f_lseek(file, DATA_START);         /* Record data stream without cluster allocation delay */
    -    ...
    +    res = f_lseek(file, DATA_START);         /* Record data stream WITHOUT cluster allocation delay */
    +    ...                                      /* DATA_START and write block size should be aligned to sector boundary */
     
         res = f_truncate(file);                  /* Truncate unused area */
         res = f_lseek(file, 0);                  /* Put file header */
    @@ -102,14 +103,15 @@ FRESULT f_lseek (
     
         res = f_close(file);
     
    -
        /* Using fast seek feature */
    +
    +    /* Using fast seek feature */
     
         DWORD lktbl[SZ_TBL];                   /* Link map table buffer */
     
         res = f_lseek(file, ofs1);             /* This is normal seek (file.cltbl is nulled on file open) */
     
         file.cltbl = lktbl;                    /* Enable fast seek feature */
    -    lktbl[0] = SZ_TBL;                     /* Set table size to the first item */
    +    lktbl[0] = SZ_TBL;                     /* Set table size */
         res = f_lseek(file, CREATE_LINKMAP);   /* Create CLMT */
         ...
     
    diff --git a/doc/en/mkfs.html b/doc/en/mkfs.html
    index 16f4725..86753a2 100644
    --- a/doc/en/mkfs.html
    +++ b/doc/en/mkfs.html
    @@ -13,7 +13,7 @@
     
     

    f_mkfs

    -

    The f_mkfs fucntion creates a file system on the drive.

    +

    The f_mkfs fucntion creates an FAT file system on the logical drive.

     FRESULT f_mkfs (
       BYTE  Drive,            /* Logical drive number */
    @@ -29,9 +29,9 @@ FRESULT f_mkfs (
     
    Drive
    Logical drive number (0-9) to be formatted.
    PartitioningRule
    -
    When 0 is given, a partition table is created into the master boot record and a primary DOS partition is created and then an FAT volume is created on the partition. This is called FDISK format and used for harddisk and memory cards. When 1 is given, the FAT volume starts from the first sector on the drive without partition table. This is called SFD format and used for floppy disk and most optical disk.
    +
    Specifies partitioning rule, FDISK(0) or SFD(1). This argument is ignored on some case.
    AllocSize
    -
    Force the allocation unit (cluter) size in unit of byte. The value must be power of 2 and between the sector size and 128 times sector size. When invalid value is specified, the cluster size is determined depends on the volume size.
    +
    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.
    @@ -44,23 +44,29 @@ FRESULT f_mkfs ( FR_WRITE_PROTECTED, FR_INVALID_DRIVE, FR_NOT_ENABLED, -FR_MKFS_ABORTED +FR_MKFS_ABORTED, +FR_INVALID_PARAMETER

    Description

    -

    The f_mkfs function creates an FAT volume on the drive. There are two partitioning rules, FDISK and SFD, for removable media. The FDISK format is recommended for the most case. This function currently does not support multiple partition, so that existing partitions on the physical dirve will be deleted and re-created a new partition occupies entire disk space.

    +

    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.

    +

    If the logical drive is being bound to any partition (1-4) by multiple partition feature (_MULTI_PARTITION), 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.

    +

    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.

    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.

    When the number of clusters gets near the FAT sub-type boundaries, the function can fail with FR_MKFS_ABORTED.

    -

    QuickInfo

    Available when _FS_READOLNY == 0 and _USE_MKFS == 1.

    +
    +

    See Also

    +

    Volume management, f_fdisk

    +

    Return

    diff --git a/doc/en/mount.html b/doc/en/mount.html index ea3c3a8..18cef8b 100644 --- a/doc/en/mount.html +++ b/doc/en/mount.html @@ -44,7 +44,7 @@ FRESULT f_mount (

    Description

    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 FileSystemObject, and then the work area can be discarded.

    -

    This function always succeeds regardless of the drive status. No media access is occured in this function. It only initializes the given work area and registers its address to the internal table. The volume mount process is performed on first file access after f_mount function or media change.

    +

    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.

    diff --git a/doc/en/open.html b/doc/en/open.html index a632cff..0b14e56 100644 --- a/doc/en/open.html +++ b/doc/en/open.html @@ -34,8 +34,8 @@ FRESULT f_open (
    Specifies the type of access and open method for the file. It is specified by a combination of following flags.
    - - + + @@ -73,9 +73,9 @@ To append data to the file, use f_lseek function after

    Description

    -

    A file object is created when the function succeeded. The file object is used for subsequent read/write functions to refer to the file. When close an open file object, use f_close function. If the modified file is not closed, the file data can be collapsed.

    -

    If duplicated file open is needed, read here carefully.

    -

    Before using any file function, a work area (file system object) must be registered to the logical drive with f_mount function. All file functions can work after this procedure.

    +

    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 f_close function. If the modified file is not closed, the file data can be collapsed.

    +

    If duplicated file open is needed, read here carefully. However duplicated open of a file with write mode flags is always prohibited.

    +

    Before using any file function, a work area (file system object) must be registered to the logical drive with f_mount function. All API functions except for f_fdisk function can work after this procedure.

    @@ -111,7 +111,7 @@ void main (void) /* Copy source to destination */ for (;;) { - res = f_read(&fsrc, buffer, sizeof(buffer), &br); /* Read a chunk of src file */ + res = f_read(&fsrc, buffer, sizeof buffer, &br); /* Read a chunk of src file */ if (res || br == 0) break; /* error or eof */ res = f_write(&fdst, buffer, br, &bw); /* Write it to the dst file */ if (res || bw < br) break; /* error or disk full */ diff --git a/doc/en/putc.html b/doc/en/putc.html index c5de092..4cabcb0 100644 --- a/doc/en/putc.html +++ b/doc/en/putc.html @@ -35,8 +35,8 @@ int f_putc (

    Return Values

    -

    When the character was written successfuly, the function returns the character. When the function failed due to disk full or any error, an EOF (-1) will be returned.

    -

    When the FatFs is configured to Unicode API (_LFN_UNICODE == 1), the UCS-2 character is written to the file in UTF-8 encoding. If not the case, the byte will be written directly.

    +

    When the character was written successfuly, the function returns 1. When the function failed due to disk full or any error, an EOF (-1) will be returned.

    +

    When the FatFs is configured to Unicode API (_LFN_UNICODE == 1), the UTF-16 character is written to the file in UTF-8 encoding. If not the case, the byte will be written directly.

    diff --git a/doc/en/puts.html b/doc/en/puts.html index be76e05..6fa733f 100644 --- a/doc/en/puts.html +++ b/doc/en/puts.html @@ -35,8 +35,8 @@ int f_puts (

    Return Value

    -

    When the function succeeded, number of characters written that is not minus value is returned. When the function failed due to disk full or any error, an EOF (-1) will be returned.

    -

    When the FatFs is configured to Unicode API (_LFN_UNICODE == 1), the UCS-2 string is written to the file in UTF-8 encoding. If not the case, the byte stream will be written directly.

    +

    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 EOF (-1) will be returned.

    +

    When the FatFs is configured to Unicode API (_LFN_UNICODE == 1), the UTF-16 string is written to the file in UTF-8 encoding. If not the case, the byte stream will be written directly.

    diff --git a/doc/en/rc.html b/doc/en/rc.html index cce22ad..7544355 100644 --- a/doc/en/rc.html +++ b/doc/en/rc.html @@ -23,6 +23,7 @@
    • There is any error of the FAT structure on the volume.
    • Work area (file system object, file object or etc...) is broken by stack overflow or any other application. This is the reason in most case.
    • +
    • An FR_DISK_ERR has occured on the file object.
    FR_NOT_READY
    @@ -77,6 +78,8 @@
    FR_TOO_MANY_OPEN_FILES
    Number of open files has been reached maximum value and no more file can be opened. (Related option: _FS_SHARE)
    +
    FR_INVALID_PARAMETER
    +
    The given parameter is invalid or there is any inconsistent.
    diff --git a/doc/en/readdir.html b/doc/en/readdir.html index 267facf..0a5aeb7 100644 --- a/doc/en/readdir.html +++ b/doc/en/readdir.html @@ -76,7 +76,7 @@ FRESULT scan_files ( #if _USE_LFN static char lfn[_MAX_LFN + 1]; fno.lfname = lfn; - fno.lfsize = sizeof(lfn); + fno.lfsize = sizeof lfn; #endif diff --git a/doc/en/sdir.html b/doc/en/sdir.html index a127270..b1e0cd4 100644 --- a/doc/en/sdir.html +++ b/doc/en/sdir.html @@ -13,12 +13,12 @@

    DIR

    -

    The DIR 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.

    +

    The DIR 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.

     typedef struct {
         FATFS*  fs;         /* Pointer to the owner file system object */
         WORD    id;         /* Owner file system mount ID */
    -    WORD    index;      /* Directory index number to be read/write next */
    +    WORD    index;      /* Index of directory entry to start to search next */
         DWORD   sclust;     /* Table start cluster (0:Root dir) */
         DWORD   clust;      /* Current cluster */
         DWORD   sect;       /* Current sector */
    @@ -26,7 +26,7 @@
         BYTE*   fn;         /* Pointer to the SFN (in/out) {file[8],ext[3],status[1]} */
     #if _USE_LFN
         WCHAR*  lfn;        /* Pointer to the LFN working buffer */
    -    WORD    lfn_idx;    /* Last matched LFN index (0xFFFF:No LFN) */
    +    WORD    lfn_idx;    /* Index of last matched LFN entry (0xFFFF:No LFN) */
     #endif
     } DIR;
     
    diff --git a/doc/en/sfatfs.html b/doc/en/sfatfs.html index 81659ae..39eed91 100644 --- a/doc/en/sfatfs.html +++ b/doc/en/sfatfs.html @@ -25,7 +25,7 @@ WORD id; /* File system mount ID */ WORD n_rootdir; /* Number of root directory entries (FAT12/16) */ #if _MAX_SS != 512 - WORD ssize; /* Sector size (512,1024,2048,4096) */ + WORD ssize; /* Sector size (512,1024,2048 or 4096) */ #endif #if _FS_REENTRANT _SYNC_t sobj; /* Identifier of sync object */ @@ -38,13 +38,13 @@ #if _FS_RPATH DWORD cdir; /* Current directory cluster (0:root) */ #endif - DWORD n_fatent; /* Number of FAT entries (= number of clusters + 2) */ + DWORD n_fatent; /* Number of FAT entries (== Number of clusters + 2) */ DWORD fsize; /* Sectors per FAT */ DWORD fatbase; /* FAT area start sector */ - DWORD dirbase; /* Root directory area start sector (FAT32: cluster#) */ + DWORD dirbase; /* Root directory area start sector (FAT32: Cluster#) */ DWORD database; /* Data area start sector */ DWORD winsect; /* Current sector appearing in the win[] */ - BYTE win[_MAX_SS]; /* Disk access window for Directory, FAT (and Data on tiny cfg) */ + BYTE win[_MAX_SS]; /* Disk access window for Directory, FAT (and file data on tiny cfg) */ } FATFS;
    diff --git a/doc/en/stat.html b/doc/en/stat.html index 5b51190..9c7d226 100644 --- a/doc/en/stat.html +++ b/doc/en/stat.html @@ -54,7 +54,7 @@ FRESULT f_stat (

    Description

    -

    The f_stat gets the information of a file or directory. For details of the infomation, refer to the FILINFO structure and f_readdir function. This function is not supported in minimization level of >= 1.

    +

    The f_stat gets the size, timestamp and attribute of a file or directory. For details of the infomation, refer to the FILINFO structure and f_readdir function. This function is not supported in minimization level of >= 1.

    diff --git a/doc/en/sync.html b/doc/en/sync.html index 6af2850..a7594fa 100644 --- a/doc/en/sync.html +++ b/doc/en/sync.html @@ -45,7 +45,7 @@ FRESULT f_sync (

    Description

    -

    The f_sync function performs the same process as f_close function but the file is left opened and can continue read/write/seek operations to the file. This is suitable for the applications that open files for a long time in write mode, such as data logger. Performing f_sync of periodic or immediataly after f_write can minimize the risk of data loss due to a sudden blackout or an unintentional disk removal. However f_sync immediataly before f_close has no advantage because f_close performs f_sync in it. In other words, the differnce between those functions is that the file object is invalidated or not.

    +

    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.

    diff --git a/doc/en/unlink.html b/doc/en/unlink.html index a4e058f..86929dd 100644 --- a/doc/en/unlink.html +++ b/doc/en/unlink.html @@ -58,9 +58,9 @@ FRESULT f_unlink (

    If condition of the object to be removed is applicable to the following terms, the function will fail with error.

      -
    • The object must not have read-only attribute (AM_RDO) or the function will be rejected with FR_DENIED.
    • -
    • The directory must be empty and must not be current directory or the function will be rejected with FR_DENIED.
    • -
    • The file must not being opened or the FAT volume can be collapted. It will able to be rejected with FR_LOCKED when file shareing control is enabled.
    • +
    • The object must not have read-only attribute (AM_RDO) or the function will be rejected with FR_DENIED.
    • +
    • The directory must be empty and must not be current directory or the function will be rejected with FR_DENIED.
    • +
    • The file must not have been opened or the FAT volume can be collapted. It will able to be rejected with FR_LOCKED when file shareing control is enabled.
    diff --git a/doc/img/f1.png b/doc/img/f1.png index 42cc271..5191700 100644 Binary files a/doc/img/f1.png and b/doc/img/f1.png differ diff --git a/doc/img/layers3.png b/doc/img/layers3.png new file mode 100644 index 0000000..ac439b0 Binary files /dev/null and b/doc/img/layers3.png differ diff --git a/doc/img/rwtest3.png b/doc/img/rwtest3.png new file mode 100644 index 0000000..cbaa3d1 Binary files /dev/null and b/doc/img/rwtest3.png differ diff --git a/doc/ja/appnote.html b/doc/ja/appnote.html index 18c0848..5d84f37 100644 --- a/doc/ja/appnote.html +++ b/doc/ja/appnote.html @@ -30,14 +30,20 @@

    繝昴シ繝繧」繝ウ繧ー縺ョ髫帙↓驟肴ョ縺吶∋縺阪%縺ィ

    +

    遘サ讀阪ョ髫帙ョ蜑肴署譚。莉カ

    FatFs繝「繧ク繝・繝シ繝ォ縺ッ遘サ讀肴ァ縺ォ髢「縺励※谺。縺ョ轤ケ繧貞燕謠舌→縺励※縺縺セ縺吶

    • 蜃ヲ逅邉サ縺ッANSI C貅匁侠縺ァ縺ゅk縺薙→縲
      FatFs繝「繧ク繝・繝シ繝ォ縺ッANSI C(C89)貅匁侠縺ァ險倩ソー縺輔l縺ヲ縺繧九ョ縺ァ縲、NSI C縺ォ貅匁侠縺励◆縺セ縺ィ繧ゅ↑繧ウ繝ウ繝代う繝ゥ縺ェ繧臥音縺ォ蜃ヲ逅邉サ萓晏ュ倥↓縺ェ繧狗せ縺ッ縺ゅj縺セ縺帙s縲
    • char/short/long縺ョ繧オ繧、繧コ縺ッ縲√◎繧後◇繧8/16/32繝薙ャ繝医〒縲(nt縺ッ16縺セ縺溘ッ32繝薙ャ繝医〒縺ゅk縺薙→縲
      -繧オ繧、繧コ繧呈守、コ縺吶k謨エ謨ー縺ョ蝙九′ integer.h 蜀縺ァ螳夂セゥ縺輔l縺ヲ縺縺セ縺吶よ紛謨ー縺ョ蝙九→繧オ繧、繧コ縺ォ髢「縺励※縺ッ縲√∪縺」縺ィ縺縺ェ蜃ヲ逅邉サ縺ェ繧牙撫鬘後↑縺縺ッ縺壹〒縺吶′縲∵里蟄倥ョ螳夂セゥ縺ィ陦晉ェ√@縺溷エ蜷医ッ繝ヲ繝シ繧カ縺ォ繧医▲縺ヲ隗」豎コ縺輔l縺ェ縺代l縺ー縺ェ繧翫∪縺帙s縲
    • +繧オ繧、繧コ繧呈守、コ縺吶k謨エ謨ー蝙九′ integer.h 蜀縺ァ螳夂セゥ縺輔l縺ヲ縺縺セ縺吶よ紛謨ー縺ョ蝙九→繧オ繧、繧コ縺ォ髢「縺励※縺ッ縲√∪縺」縺ィ縺縺ェ蜃ヲ逅邉サ縺ェ繧牙撫鬘後↑縺縺ッ縺壹〒縺吶′縲∵里蟄倥ョ螳夂セゥ縺ィ陦晉ェ√@縺溷エ蜷医ッ繝ヲ繝シ繧カ縺ォ繧医▲縺ヲ隗」豎コ縺輔l縺ェ縺代l縺ー縺ェ繧翫∪縺帙s縲
    + +

    繧キ繧ケ繝繝讒区

    +

    荳九↓遉コ縺吩セ晏ュ倬未菫ょ峙縺ッ縲:atFs繝「繧ク繝・繝シ繝ォ蛻ゥ逕ィ縺ョ邨縺ソ霎シ縺ソ繧キ繧ケ繝繝縺ォ縺翫¢繧倶サ」陦ィ逧縺ェ讒区舌r遉コ縺励∪縺吶

    +繧キ繧ケ繝繝讒区仙峙 +

    繝ヲ繝シ繧カ縺ョ菴懈舌☆繧矩未謨ー

    蠢隕√↑縺ョ縺ッ FatFs繝「繧ク繝・繝シ繝ォ縺ョ隕∵アゅ☆繧九ョ繧」繧ケ繧ッ髢「謨ー繧堤畑諢上☆繧九%縺ィ縺縺代〒縲√◎繧御サ・螟悶↓縺吶k縺薙→縺ッ縺ゅj縺セ縺帙s縲よ里縺ォ蜍穂ス懊@縺ヲ縺繧九ョ繧」繧ケ繧ッ髢「謨ー縺後≠繧九↑繧峨◎縺ョ API繧 FatFs縺ォ蜷医o縺帙k縺縺代〒貂医∩縺セ縺吶′縲∫┌縺蝣エ蜷医ッ縺サ縺九°繧臥ァサ讀阪☆繧九°縲∵怙蛻昴°繧画嶌縺上°縺吶k蠢隕√′縺ゅj縺セ縺吶ょョ夂セゥ縺輔l縺ヲ縺繧句ィ縺ヲ縺ョ髢「謨ー縺悟クク縺ォ蠢隕√↑繧上¢縺ァ縺ッ縺ゅj縺セ縺帙s縲ゆセ九∴縺ー縲√Μ繝シ繝峨サ繧ェ繝ウ繝ェ繝シ讒区舌〒縺ッ譖ク縺崎セシ縺ソ邉サ髢「謨ー縺ッ蠢隕√≠繧翫∪縺帙s縲よャ。縺ョ陦ィ縺ォ讒区舌が繝励す繝ァ繝ウ縺ィ隕∵アゅ&繧後k髢「謨ー縺ョ蟇セ蠢懊r遉コ縺励∪縺吶

    ValueDescription
    FA_READSpecifies read access to the object. Data can be read from the file.
    Combine with FA_WRITE for read-write access.
    FA_WRITESpecifies write access to the object. Data can be written to the file.
    Combine with FA_READ for read-write access.
    FA_READSpecifies read access to the object. Data can be read from the file. Combine with FA_WRITE for read-write access.
    FA_WRITESpecifies write access to the object. Data can be written to the file. Combine with FA_READ for read-write access.
    FA_OPEN_EXISTINGOpens the file. The function fails if the file is not existing. (Default)
    FA_OPEN_ALWAYSOpens the file if it is existing. If not, a new file is created.
    To append data to the file, use f_lseek function after file open in this method.
    @@ -67,16 +73,16 @@ FatFs繝「繧ク繝・繝シ繝ォ縺ッANSI C(C89)貅匁侠縺ァ險倩ソー縺輔l縺ヲ縺繧九ョ縺ァ縲、NSI C
    -

    繝。繝「繝ェ菴ソ逕ィ驥 (R0.08b)

    +

    繝。繝「繝ェ菴ソ逕ィ驥 (R0.09)

    谺。縺ョ陦ィ縺ォ縺縺上▽縺九ョ繧ソ繝シ繧イ繝繝医↓縺翫¢繧九Γ繝「繝ェ菴ソ逕ィ驥上ョ萓九r遉コ縺励∪縺吶ゅユ繧ケ繝域凾縺ョ讒区舌が繝励す繝ァ繝ウ縺ッ縺昴ョ荳九ョ騾壹j縺ァ縺吶よ焚蛟、縺ョ蜊倅ス阪ッ繝舌う繝医〒縲V縺ッ蜷梧凾繝槭え繝ウ繝医サ繝懊Μ繝・繝シ繝謨ー縲F縺ッ蜷梧凾繧ェ繝シ繝励Φ繝サ繝輔ぃ繧、繝ォ謨ー繧堤、コ縺励∪縺吶ゅさ繝ウ繝代う繝ゥ縺ョ譛驕ゥ蛹悶が繝励す繝ァ繝ウ縺ッ繧ウ繝シ繝峨サ繧オ繧、繧コ縺ィ縺励※縺縺セ縺吶

    - + - - - - + + + + @@ -103,34 +109,35 @@ _FS_SHARE 0 (Disable shareing control)

    繝「繧ク繝・繝シ繝ォ繝サ繧オ繧、繧コ縺ョ邵ョ蟆

    谺。縺ョ陦ィ縺ッ讒区舌が繝励す繝ァ繝ウ縺ョ險ュ螳壼、縺ォ繧医j縺ゥ縺ョ讖溯ス縺悟炎髯、縺輔l繧九°繧堤、コ縺励∪縺吶

    ARM7
    32bit
    ARM7
    Thumb
    Cortex-M3
    Thumb-2
    AVRH8/300HPIC24RL78V850ESSH-2ARX62NIA-32
    ARM7
    32bit
    ARM7
    Thumb
    Cortex-M3
    Thumb-2
    AVRH8/300HPIC24RL78V850ESSH-2ARX600IA-32
    CompilerGCCGCCGCCGCCCH38C30CC78K0RCA850SHCRXCVC6
    _WORD_ACCESS00010001011
    text (Full, R/W)1049572056661126461068611430129677732875257477545
    text (Min, R/W)65234749433583066986741387454938557637464923
    text (Full, R/O)45393183289359604876525060603554380426593450
    text (Min, R/O)33072495219143663770393946042684294020252664
    text (Full, R/W)1045972016623126461068611466129677732875257477545
    text (Min, R/W)65034745429783066986744087454938557637464923
    text (Full, R/O)45353181286959604876528660603554380426593450
    text (Min, R/O)33032493217143663770398446042684294020252664
    bssD*4 + 2D*4 + 2D*4 + 2D*2 + 2D*4 + 2D*2 + 2D*2 + 2D*4 + 2D*4 + 2D*4 + 2D*4 + 2
    Work area
    (_FS_TINY == 0)
    V*560 +
    F*550
    V*560 +
    F*550
    V*560 +
    F*550
    V*560 +
    F*544
    V*560 +
    F*550
    V*560 +
    F*544
    V*560 +
    F*544
    V*560 +
    F*544
    V*560 +
    F*550
    V*560 +
    F*550
    V*560 +
    F*550
    Work area
    (_FS_TINY == 1)
    V*560 +
    F*36
    V*560 +
    F*36
    V*560 +
    F*36
    V*560 +
    F*32
    V*560 +
    F*36
    V*560 +
    F*32
    V*560 +
    F*32
    V*560 +
    F*36
    V*560 +
    F*36
    V*560 +
    F*36
    V*560 +
    F*36
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    Function_FS_MINIMIZE_FS_READONLY_USE_STRFUNC_FS_RPATH_USE_MKFS_USE_FORWARD
    0123010  1/20120101
    f_mount
    f_open
    f_close
    f_read
    f_writex
    f_syncx
    f_lseekx
    f_opendirxx
    f_readdirxx
    f_statxxx
    f_getfreexxxx
    f_truncatexxxx
    f_unlinkxxxx
    f_mkdirxxxx
    f_chmodxxxx
    f_utimexxxx
    f_renamexxxx
    f_chdirx
    f_chdrivex
    f_getcwdxx
    f_mkfsxx
    f_forwardx
    f_putcxx
    f_putsxx
    f_printfxx
    f_getsx
    Function_FS_MINIMIZE_FS_READONLY_USE_STRFUNC_FS_RPATH_USE_MKFS_USE_FORWARD_MULTI_PARTITION
    0123010  1/201201010/12
    f_mount
    f_open
    f_close
    f_read
    f_writex
    f_syncx
    f_lseekx
    f_opendirxx
    f_readdirxx
    f_statxxx
    f_getfreexxxx
    f_truncatexxxx
    f_unlinkxxxx
    f_mkdirxxxx
    f_chmodxxxx
    f_utimexxxx
    f_renamexxxx
    f_chdirx
    f_chdrivex
    f_getcwdxx
    f_mkfsxx
    f_fdiskxxx
    f_forwardx
    f_putcxx
    f_putsxx
    f_printfxx
    f_getsx
    @@ -148,7 +155,7 @@ _FS_SHARE 0 (Disable shareing control) 950(Big5)+111497

    LFN讖溯ス縺ョ荳頑焔縺ェ菴ソ縺譁ケ縺ッ縲√◎繧後r菴ソ繧上↑縺縺ィ縺縺縺薙→縺ァ縺吶ょョ滄圀縲∫オ縺ソ霎シ縺ソ逕ィ騾斐〒縺ッLFN讖溯ス縺後←縺縺励※繧ょソ隕√↓縺ェ繧九→縺縺縺薙→縺ッ縺サ縺ィ繧薙←辟。縺縺ッ縺壹〒縺吶LFN繧呈怏蜉ケ縺ォ縺吶k縺ィ縲驕ク謚槭&繧後◆繧ウ繝シ繝峨サ繝壹シ繧ク縺ォ蠢懊§縺ヲ繝「繧ク繝・繝シ繝ォ繝サ繧オ繧、繧コ縺悟「怜、ァ縺輔l縺セ縺吶ょ承縺ョ陦ィ縺ォ蜷繧ウ繝シ繝峨サ繝壹シ繧ク縺ォ縺翫¢繧記FN繧呈怏蜉ケ縺ォ縺励◆縺ィ縺阪ョ繝「繧ク繝・繝シ繝ォ繝サ繧オ繧、繧コ縺ョ驕輔>繧堤、コ縺励∪縺吶らァ√◆縺。譌・譛ャ莠コ縲∽クュ蝗ス莠コ縺翫h縺ウ髻灘嵜莠コ縺ッ謨ー荳縺ョ譁蟄励r謖√■縺セ縺吶ゆク榊ケク縺ェ縺薙→縺ォ縲√◎繧後ッ蟾ィ螟ァ縺ェOEMシ攻nicode逶ク莠貞、画鋤繝繝シ繝悶Ν繧定ヲ∵アゅ@縲√Δ繧ク繝・繝シ繝ォ繝サ繧オ繧、繧コ縺ッ蜉逧縺ォ蠅怜、ァ縺輔l縺セ縺吶ゅ◎縺ョ邨先棡縲´FN繧呈怏蜉ケ縺ォ縺励◆FatFs繝「繧ク繝・繝シ繝ォ縺ッ縲、VR繧貞性繧谿縺ゥ縺ョ8繝薙ャ繝医サ繝槭う繧ウ繝ウ縺ォ繧、繝ウ繝励Μ繝。繝ウ繝医&繧後k縺薙→縺後〒縺阪∪縺帙s縲縺薙l縺ッ髟キ縺髢鍋ァ√′LFN繧偵う繝ウ繝励Μ繝。繝ウ繝医☆繧九%縺ィ縺ォ闊亥袖繧呈戟縺」縺ヲ縺薙↑縺九▲縺溽炊逕ア縺ァ縺吶

    -

    豕ィ: 繝槭う繧ッ繝ュ繧ス繝輔ヨ遉セ縺ッFAT繝輔ぃ繧、繝ォ繝サ繧キ繧ケ繝繝縺ォ縺、縺縺ヲ縺縺上▽縺九ョ迚ケ險ア繧剃ソ晄怏縺励※縺縺セ縺吶ゅ>縺壹l繧LFN縺ョ螳溯」縺ォ髢「縺吶k繧ゅョ縺ァ縲´FN讖溯ス縺ォ蟇セ縺励※$0.25/unit縺ョ繝ゥ繧、繧サ繝ウ繧ケ譁吶r隕∵アゅ@縺ヲ縺縺セ縺吶FAT32縺ッ辟。髢「菫ゅ〒縺吶ゅ%縺ョ縺溘a縲∝膚逕ィ陬ス蜩√〒LFN讖溯ス譛牙柑縺ォ縺吶k縺ィ縺阪ッ縲∵怙邨ゆサ募髄蝨ー縺ォ繧医▲縺ヲ縺ッ繝ゥ繧、繧サ繝ウ繧ケ縺悟ソ隕√°繧ら衍繧後∪縺帙s縲

    +

    豕ィ: 繝槭う繧ッ繝ュ繧ス繝輔ヨ遉セ縺ッFAT繝輔ぃ繧、繝ォ繝サ繧キ繧ケ繝繝縺ォ縺、縺縺ヲ縺縺上▽縺九ョ迚ケ險ア繧剃ソ晄怏縺励※縺縺セ縺吶ゅ>縺壹l繧LFN縺ョ螳溯」縺ォ髢「縺吶k繧ゅョ縺ァ縲´FN讖溯ス縺ォ蟇セ縺励※$0.25/unit縺ョ繝ゥ繧、繧サ繝ウ繧ケ譁吶r隕∵アゅ@縺ヲ縺縺セ縺吶よ怙霑代ョFAT32繝峨Λ繧、繝舌ョ螟壹¥縺ッLFN讖溯ス繧貞性繧薙〒縺繧九◆繧√√◎繧後i縺ョ菴ソ逕ィ縺ォ蠖薙◆縺」縺ヲ繝ゥ繧、繧サ繝ウ繧ケ縺悟ソ隕√↓縺ェ繧翫∪縺吶′縲:atFs縺ァ縺ッLFN讖溯ス縺ョ譛牙柑繝サ辟。蜉ケ繧剃ササ諢上↓讒区舌〒縺阪∪縺吶ゅ%縺ョ縺溘a縲∝膚逕ィ陬ス蜩√〒LFN讖溯ス繧呈怏蜉ケ縺ォ縺吶k縺ィ縺阪ッ縲∵怙邨ゆサ募髄蝨ー縺ォ繧医▲縺ヲ縺ッ繝ゥ繧、繧サ繝ウ繧ケ縺悟ソ隕√°繧ら衍繧後∪縺帙s縲

    @@ -179,7 +186,7 @@ _FS_SHARE 0 (Disable shareing control)

    蜉ケ邇逧縺ェ繝輔ぃ繧、繝ォ繝サ繧「繧ッ繧サ繧ケ

    蟆剰ヲ乗ィ。縺ェ邨霎シ繧キ繧ケ繝繝縺ァ縺ョ繝輔ぃ繧、繝ォ縺ョ隱ュ縺ソ譖ク縺阪↓縺翫¢繧句柑邇縺ョ濶ッ縺繧「繧ッ繧サ繧ケ縺ョ縺溘a縲√い繝励Μ繧ア繝シ繧キ繝ァ繝ウ繝サ繝励Ο繧ー繝ゥ繝槭ッFatFs繝「繧ク繝・繝シ繝ォ縺ョ荳ュ縺ァ縺ゥ縺ョ繧医≧縺ェ蜃ヲ逅縺瑚。後o繧後※縺繧九°閠諷ョ縺吶∋縺阪〒縺吶ゅせ繝医Ξ繝シ繧ク荳翫ョ繝繝シ繧ソ縺ッf_read髢「謨ー縺ォ繧医j谺。縺ョ繧キ繝シ繧ア繝ウ繧ケ縺ァ霆「騾√&繧後∪縺吶

    蝗ウ1. 繧サ繧ッ繧ソ繝サ繝溘せ繧「繝ゥ繧、繝ウ繝峨サ繝ェ繝シ繝 (繧キ繝ァ繝シ繝)
    -fig.1 +fig.1

    蝗ウ2. 繧サ繧ッ繧ソ繝サ繝溘せ繧「繝ゥ繧、繝ウ繝峨サ繝ェ繝シ繝 (繝ュ繝ウ繧ー)
    fig.2 @@ -232,7 +239,7 @@ _FS_SHARE 0 (Disable shareing control)

    FatFs縺ョ繝ゥ繧、繧サ繝ウ繧ケ縺ォ縺、縺縺ヲ

    繧ス繝シ繧ケ繝サ繝輔ぃ繧、繝ォ縺ョ繝倥ャ繝縺ォ繝ゥ繧、繧サ繝ウ繧ケ譚。莉カ縺瑚ィ倩ソー縺輔l縺ヲ縺繧九ョ縺ァ縲∝茜逕ィ縺ョ髫帙ッ縺昴l縺ォ蠕薙≧縺薙→縲り恭隱槭r隱ュ繧√↑縺譁ケ縺ョ縺溘a縺ォ莉・荳九↓譌・譛ャ隱櫁ィウ繧堤、コ縺励※縺翫″縺セ縺吶

    /*----------------------------------------------------------------------------/
    -/  FatFs - FAT file system module  R0.08b                   (C)ChaN, 2011
    +/  FatFs - FAT file system module  R0.09                    (C)ChaN, 2011
     /-----------------------------------------------------------------------------/
     / FatFs繝「繧ク繝・繝シ繝ォ縺ッ縲∝ー剰ヲ乗ィ。縺ェ邨縺ソ霎シ縺ソ繧キ繧ケ繝繝蜷代¢縺ョ豎守畑FAT繝輔ぃ繧、繝ォ繧キ繧ケ繝繝繝サ
     / 繝「繧ク繝・繝シ繝ォ縺ァ縺吶ゅ%繧後ッ繝輔Μ繝シ繝サ繧ス繝輔ヨ繧ヲ繧ァ繧「縺ィ縺励※縲∵蕗閧イ繝サ遐皮ゥカ繝サ髢狗匱縺ョ縺溘a縺ォ
    diff --git a/doc/ja/dinit.html b/doc/ja/dinit.html
    index 4f05dd8..5cf3f23 100644
    --- a/doc/ja/dinit.html
    +++ b/doc/ja/dinit.html
    @@ -38,7 +38,7 @@ DSTATUS disk_initialize (
     

    解説

    ディスク・ドライブを初期化します。関数が成功すると、戻り値のSTA_NOINITフラグがクリアされます。

    -

    アプリケーションからこの関数を呼び出すと、FATボリュームが破壊される可能性があります。エラー等により再初期化が必要なときは、f_mount()を使用します。FatFsモジュールは、自動マウント動作により、必要に応じてこの関数を呼び出します。

    +

    アプリケーションからはこの関数を呼び出してはなりません。さもないと、FATボリュームが破壊されます。エラー等により再初期化が必要なときは、f_mount()を使用してください。FatFsモジュールは、自動マウント動作により、必要に応じてこの関数を呼び出します。

    戻る

    diff --git a/doc/ja/fdisk.html b/doc/ja/fdisk.html new file mode 100644 index 0000000..062fa42 --- /dev/null +++ b/doc/ja/fdisk.html @@ -0,0 +1,97 @@ + + + + + + + + +FatFs - f_fdisk + + + + +
    +

    f_fdisk

    +

    物理ドライブを分割します。

    +
    +FRESULT f_fdisk (
    +  BYTE  Drive,              /* 物理ドライブ番号 */
    +  const DWORD Partitions[], /* 区画マップ・テーブル */
    +  void* Work                /* ワークエリア */
    +);
    +
    +
    + +
    +

    引数

    +
    +
    Drive
    +
    分割する物理ドライブを指定します。
    +
    Partitions[]
    +
    区画マップ・テーブルへのポインタを指定します。
    +
    Work
    +
    ワークエリアへのポインタを指定します。サイズは_MAX_SSバイト必要です。
    +
    +
    + + + +
    +

    説明

    +

    f_fdisk関数は、指定された物理ドライブのMBRに区画テーブルを作成します。区画分けは一般的なFDISK形式で行うため、最大4つの基本区画を作成することができます。拡張区画には対応していません。区画マップテーブル Partitions[] にはドライブをどのように分割するか指定して渡します。この配列は4つの項目から成り、先頭の項目が1番目の、最後の項目が4番目の区画のサイズを示します。値が100以下の場合、ドライブの総容量に対する割合をパーセント単位で指定します。100を超える値の場合はセクタ数の直接指定になります。

    +
    + +
    +

    対応情報

    +

    _FS_READOLNY == 0_USE_MKFS == 1_MULTI_PARTITION == 2 のとき使用可能です。

    +
    + +
    +

    使用例

    +
    +    /* ユーザ定義のボリューム管理テーブル (_MULTI_PARTITION != 0 のとき必要) */
    +
    +    PARTITION VolToPart[] = {
    +        {0, 1},    /* 論理ドライブ 0 ==> 物理ドライブ 0, 第1区画 */
    +        {0, 2},    /* 論理ドライブ 1 ==> 物理ドライブ 0, 第2区画 */
    +        {1, 0}     /* 論理ドライブ 2 ==> 物理ドライブ 1, 自動検出 */
    +    };
    +
    +
    +    /* 新しい物理ドライブ(0)の初期化 */
    +
    +    FATFS Fatfs;
    +    DWORD plist[] = {50, 50, 0, 0};  /* 2分割 */
    +    BYTE work[_MAX_SS];
    +
    +    f_fdisk(0, plist, work);  /* 物理ドライブ 0 の分割 */
    +
    +    f_mount(0, &Fatfs);
    +    f_mkfs(0, 0, 0);          /* 論理ドライブ 0 の初期化. 第二引数は無視される.  */
    +    f_mount(0, 0);
    +
    +    f_mount(1, &Fatfs);
    +    f_mkfs(1, 0, 0);
    +    f_mount(1, 0);
    +
    +
    +
    + +
    +

    See Also

    +

    Volume management, f_mkfs

    +
    + +

    Return

    + + diff --git a/doc/ja/filename.html b/doc/ja/filename.html index f82ed4b..888db03 100644 --- a/doc/ja/filename.html +++ b/doc/ja/filename.html @@ -11,12 +11,12 @@

    繝代せ蜷阪ョ繝輔か繝シ繝槭ャ繝

    -
    +

    繝輔ぃ繧、繝ォ繝サ繝繧」繝ャ繧ッ繝医Μ蜷

    FatFs繝「繧ク繝・繝シ繝ォ縺ァ縺ョ繝輔ぃ繧、繝ォ縲√ョ繧」繝ャ繧ッ繝医Μ縲√ラ繝ゥ繧、繝悶ョ謖螳壽婿豕輔ッDOS/Windows API縺ィ縺サ縺シ蜷後§縺ァ縺吶ゅヱ繧ケ蜷阪ョ繝輔か繝シ繝槭ャ繝医ッ谺。縺ョ騾壹j縺ァ縺吶

    "[隲也炊繝峨Λ繧、繝也分蜿キ:][/]繝繧」繝ャ繧ッ繝医Μ蜷/繝輔ぃ繧、繝ォ蜷"

    FatFs繝「繧ク繝・繝シ繝ォ縺ッ髟キ縺繝輔ぃ繧、繝ォ蜷(LFN)縺翫h縺ウ8.3蠖「蠑上ヵ繧。繧、繝ォ蜷(SFN)縺ォ蟇セ蠢懊@縺ヲ縺縺セ縺吶LFN縺ッ縲(_USE_LFN > 0)縺ョ縺ィ縺堺スソ逕ィ蜿ッ閭ス縺ォ縺ェ繧翫∪縺吶ゅョ繧」繝ャ繧ッ繝医Μ繝サ繧サ繝代Ξ繝シ繧ソ縺ォ縺ッDOS/Windows API縺ィ蜷後§縺 / 縺ィ \ 繧剃スソ逕ィ縺励∪縺吶る」邯壹@縺溘そ繝代Ξ繝シ繧ソ縺ッ辟。隕悶&繧1蛟九→縺励※謇ア繧上l縺セ縺吶ょ髪荳縺ョ驕輔>縺ッ縲∬ォ也炊繝峨Λ繧、繝悶ョ謖螳壹□縺代〒縺吶りォ也炊繝峨Λ繧、繝也分蜿キ縺ッ縲'0'ス'9'縺ョ荳譁蟄励ョ謨ー蟄励→繧ウ繝ュ繝ウ縺ァ謖螳壹@縲∫怐逡・縺励◆蝣エ蜷医ッ繝繝輔か繝ォ繝医サ繝峨Λ繧、繝(0縺セ縺溘ッ繧ォ繝ャ繝ウ繝医サ繝峨Λ繧、繝)縺碁∈謚槭&繧後∪縺吶

    -

    Nul譁蟄励→蛻カ蠕。譁蟄(\0ス杤x1F)縺ッ縲√ヱ繧ケ蜷阪ョ邨らォッ縺ィ縺励※隱崎ュ倥&繧後∪縺吶ゅヱ繧ケ蜷阪↓蜈郁。後≠繧九>縺ッ荳ュ縺ォ蜷ォ縺セ繧後k繧ケ繝壹シ繧ケ縺ッ縲´FN讒区舌〒縺ッ蜷榊燕縺ョ荳驛ィ縺ィ縺励※譛牙柑縺ァ縺吶′縲髱朖FN讒区舌〒縺ッ繝代せ蜷阪ョ邨らォッ縺ィ縺励※隱崎ュ倥&繧後∪縺吶

    +

    Nul譁蟄励→蛻カ蠕。譁蟄(\0ス杤x1F)縺ッ縲√ヱ繧ケ蜷阪ョ邨らォッ縺ィ縺励※隱崎ュ倥&繧後∪縺吶ゅヱ繧ケ蜷阪↓蜈郁。後≠繧九>縺ッ荳ュ縺ォ蜷ォ縺セ繧後k繧ケ繝壹シ繧ケ縺ッ縲´FN讒区舌〒縺ッ蜷榊燕縺ョ荳驛ィ縺ィ縺励※譛牙柑縺ァ縺吶′縲髱朖FN讒区舌〒縺ッ繧ケ繝壹シ繧ケ縺ッ繝代せ蜷阪ョ邨らォッ縺ィ縺励※隱崎ュ倥&繧後∪縺吶

    讓呎コ匁ァ区(_FS_RPATH == 0)縺ョ縺ィ縺阪ッ縲∝ィ縺ヲ縺ョ繧ェ繝悶ず繧ァ繧ッ繝医′繝ォ繝シ繝医サ繝繧」繝ャ繧ッ繝医Μ縺九i霎ソ繧狗オカ蟇セ繝代せ縺ァ謖螳壹&繧後∪縺吶0S謖蜷代↑繧ォ繝ャ繝ウ繝医サ繝繧」繝ャ繧ッ繝医Μ縺ィ縺縺讎ょソオ縺ッ辟。縺上√∪縺溘ラ繝繝医サ繝繧」繝ャ繧ッ繝医Μ("."繧"..")縺ッ菴ソ逕ィ縺ァ縺阪∪縺帙s縲ゅヱ繧ケ蜷榊磯ュ縺ョ繧サ繝代Ξ繝シ繧ソ縺ッ辟。隕悶&繧後∪縺吶ゅョ繝輔か繝ォ繝医サ繝峨Λ繧、繝也分蜿キ縺ッ蟶ク縺ォ0縺ォ縺ェ繧翫∪縺吶

    逶ク蟇セ繝代せ繧呈怏蜉ケ(_FS_RPATH == 1)縺ォ縺励◆縺ィ縺阪ッ縲∝郁。後☆繧九そ繝代Ξ繝シ繧ソ縺ョ譛臥┌縺ォ繧医▲縺ヲ讀懃エ「髢句ァ九ョ繧」繝ャ繧ッ繝医Μ縺悟、峨o繧翫√そ繝代Ξ繝シ繧ソ縺後≠繧句エ蜷医ッ繝ォ繝シ繝医サ繝繧」繝ャ繧ッ繝医Μ縺九i縲∫┌縺蝣エ蜷医ッf_chdir髢「謨ー縺ァ險ュ螳壹&繧後k繧ォ繝ャ繝ウ繝医サ繝繧」繝ャ繧ッ繝医Μ縺九i縺ォ縺ェ繧翫∪縺吶ゅ∪縺溘ヱ繧ケ蜷阪↓繝峨ャ繝医サ繝繧」繝ャ繧ッ繝医Μ縺御スソ逕ィ縺ァ縺阪∪縺吶ゅョ繝輔か繝ォ繝医サ繝峨Λ繧、繝也分蜿キ縺ッf_chdrive髢「謨ー縺ァ險ュ螳壹&繧後◆蛟、縺ィ縺ェ繧翫∪縺吶

    @@ -36,7 +36,7 @@


    -
    +

    Unicode API

    繝輔ぃ繧、繝ォ髢「謨ー縺ョ蜈・蜃コ蜉帙ョ縺縺。繝輔ぃ繧、繝ォ蜷阪d繝代せ蜷阪r謖螳壹☆繧句シ墓焚縺ョ蝙九ッ縲TCHAR縺ァ螳夂セゥ縺輔l縺ヲ縺縺セ縺吶′縲√%繧後ッchar縺ョ繧ィ繝ェ繧「繧ケ縺ォ縺ェ縺」縺ヲ縺縺セ縺吶ゅ◎縺励※縲_CODE_PAGE縺ァ謖螳壹&繧後k ANSI/OEM繧ウ繝シ繝(SBCS縺セ縺溘ッDBCS)縺ョ譁蟄怜励→縺励※謇ア繧上l縺セ縺吶ゅヵ繧。繧、繝ォ蜷榊・蜃コ蜉帙rUnicode縺ィ縺吶k讒区(LFN讒区舌〒縲√°縺、_LFN_UNICODE繧 1)縺ォ縺励◆縺ィ縺阪ッ縲TCHAR縺ッ繝ッ繧、繝画枚蟄(unsigned short)縺ォ蛻繧頑崛繧上j縲√ヱ繧ケ蜷阪↓Unicode繧剃スソ逕ィ縺吶k繧医≧縺ォ縺ェ繧翫∪縺吶ゅ%繧後↓繧医j LFN繝輔Ν蟇セ蠢懊→縺ェ繧翫、NSI/OEM繧ウ繝シ繝峨↓縺ェ縺譁蟄(縺溘→縺医ー 笨昶亂笨。笘ク笘ュ縺ェ縺ゥ)繧ゆスソ逕ィ縺ァ縺阪∪縺吶ゅ%縺ョ險ュ螳壹ッ譁蟄怜怜・蜃コ蜉幃未謨ー縺ョ繝繝シ繧ソ蝙九→繧ィ繝ウ繧ウ繝シ繝繧」繝ウ繧ー縺ォ繧ょスア髻ソ繧剃ク弱∴縺セ縺吶ゅΜ繝繝ゥ繝ォ譁蟄怜励r螳夂セゥ縺吶k縺ィ縺阪∵ャ。縺ォ遉コ縺吶h縺縺ォ_T(s)縺翫h縺ウ_TEXT(s)繝槭け繝ュ繧剃スソ縺」縺ヲANSI/OEM縺ィUnicode繧定ェ蜍募繧頑崛縺医☆繧九%縺ィ縺後〒縺阪∪縺吶

    @@ -47,25 +47,24 @@
     


    -
    +

    隲也炊繝峨Λ繧、繝(繝懊Μ繝・繝シ繝)縺ィ迚ゥ逅繝峨Λ繧、繝(繝繧」繧ケ繧ッ陬鄂ョ)縺ョ蟇セ蠢

    -

    繝繝輔か繝ォ繝医ョ讒区舌〒縺ッ縲√◎繧後◇繧後ョ隲也炊繝峨Λ繧、繝悶ッ蜷後§逡ェ蜿キ縺ョ迚ゥ逅繝峨Λ繧、繝悶↓1:1縺ァ邨舌ウ縺、縺代i繧後※縺縺ヲ縲∫黄逅繝峨Λ繧、繝悶ョ蜈磯ュ縺ョ蛹コ逕サ縺ォ縺ゅk繝懊Μ繝・繝シ繝縺後槭え繝ウ繝医&繧後∪縺吶_MULTI_PARTITION縺ォ 1繧呈欠螳壹☆繧九→縲∝九縺ョ隲也炊繝峨Λ繧、繝悶↓蟇セ縺励※蛟句挨縺ォ迚ゥ逅繝峨Λ繧、繝也分蜿キ繝サ蛹コ逕サ繧呈欠螳壹〒縺阪k繧医≧縺ォ縺ェ繧翫∪縺吶ゅ%縺ョ讒区舌〒縺ッ縲∬ォ也炊繝峨Λ繧、繝悶→蛹コ逕サ縺ョ蟇セ蠢懊r隗」豎コ縺吶k縺溘a縺ョ繝繝シ繝悶Ν繧呈ャ。縺ォ遉コ縺吶h縺縺ォ螳夂セゥ縺吶k蠢隕√′縺ゅj縺セ縺吶

    +

    繝繝輔か繝ォ繝医ョ讒区舌〒縺ッ縲√◎繧後◇繧後ョ隲也炊繝峨Λ繧、繝悶ッ蜷後§逡ェ蜿キ縺ョ迚ゥ逅繝峨Λ繧、繝悶↓1:1縺ァ邨舌ウ縺、縺代i繧後※縺縺ヲ縲ヾFD縺ィ縺励※縺セ縺溘ッ隨ャ1蛹コ逕サ縺ョ繝懊Μ繝・繝シ繝縺後槭え繝ウ繝医&繧後∪縺吶_MULTI_PARTITION縺ォ 1莉・荳翫r謖螳壹☆繧九→縲∝九縺ョ隲也炊繝峨Λ繧、繝悶↓蟇セ縺励※蛟句挨縺ォ迚ゥ逅繝峨Λ繧、繝也分蜿キ繝サ蛹コ逕サ繧呈欠螳壹〒縺阪k繧医≧縺ォ縺ェ繧翫∪縺吶ゅ%縺ョ讒区舌〒縺ッ縲∬ォ也炊繝峨Λ繧、繝悶→蛹コ逕サ縺ョ蟇セ蠢懊r隗」豎コ縺吶k縺溘a縺ョ繝繝シ繝悶Ν繧呈ャ。縺ォ遉コ縺吶h縺縺ォ螳夂セゥ縺吶k蠢隕√′縺ゅj縺セ縺吶

     萓:隲也炊繝峨Λ繧、繝0ス2繧堤黄逅繝峨Λ繧、繝0(蝗コ螳壹ョ繧」繧ケ繧ッ)縺ョ3縺、縺ョ蝓コ譛ャ蛹コ逕サ縺ォ蜑イ繧雁ス薙※縲
        隲也炊繝峨Λ繧、繝3繧堤黄逅繝峨Λ繧、繝1(繝ェ繝繝シ繝舌ヶ繝ォ繝サ繝繧」繧ケ繧ッ)縺ォ蜑イ繧雁ス薙※繧句エ蜷医
     
    -const PARTITION Drives[] = {
    -    {0, 0},     /* Logical drive 0 ==> Physical drive 0, 1st partition */
    -    {0, 1},     /* Logical drive 1 ==> Physical drive 0, 2nd partition */
    -    {0, 2},     /* Logical drive 2 ==> Physical drive 0, 3rd partition */
    -    {1, 0}      /* Logical drive 3 ==> Physical drive 1 */
    +PARTITION VolToPart[] = {
    +    {0, 1},     /* 隲也炊繝峨Λ繧、繝 0 ==> 迚ゥ逅繝峨Λ繧、繝 0, 隨ャ1蛹コ逕サ */
    +    {0, 2},     /* 隲也炊繝峨Λ繧、繝 1 ==> 迚ゥ逅繝峨Λ繧、繝 0, 隨ャ2蛹コ逕サ */
    +    {0, 3},     /* 隲也炊繝峨Λ繧、繝 2 ==> 迚ゥ逅繝峨Λ繧、繝 0, 隨ャ3蛹コ逕サ */
    +    {1, 0}      /* 隲也炊繝峨Λ繧、繝 3 ==> 迚ゥ逅繝峨Λ繧、繝 1, 閾ェ蜍墓、懷コ */
     };
     

    隍謨ー蛹コ逕サ謖螳壹r菴ソ逕ィ縺吶k蝣エ蜷医∵ャ。縺ョ轤ケ縺ォ豕ィ諢上@縺ェ縺代l縺ー縺ェ繧翫∪縺帙s縲

      -
    • 謖螳壼庄閭ス縺ェ蛹コ逕サ縺ッ蝓コ譛ャ蛹コ逕サ(0ス3)縺ョ縺ソ縲
    • -
    • 迚ゥ逅繝峨Λ繧、繝悶′SFD蠖「蠑(蛹コ逕サ繝繝シ繝悶Ν辟。縺)縺ョ蝣エ蜷医∝玄逕サ謖螳壹ッ辟。隕悶&繧後k縲
    • -
    • 隍謨ー縺ョ隲也炊繝峨Λ繧、繝悶r謖√▽迚ゥ逅繝峨Λ繧、繝悶ッ縲∝崋螳壹ョ繧」繧ケ繧ッ縺ァ縺ェ縺代l縺ー縺ェ繧峨↑縺縲
    • +
    • 繝槭え繝ウ繝亥庄閭ス縺ェ蛹コ逕サ縺ッ蝓コ譛ャ蛹コ逕サ縺ョ縺ソ縺ァ縲∵僑蠑オ蛹コ逕サ蜀縺ォ縺ッ蟇セ蠢懊@縺ェ縺縲
    • +
    • 隍謨ー縺ョ蛹コ逕サ繧呈戟縺、迚ゥ逅繝峨Λ繧、繝悶ッ縲髱槭Μ繝繝シ繝舌ヶ繝ォ縺ァ縺ェ縺代l縺ー縺ェ繧峨↑縺縲
    diff --git a/doc/ja/lseek.html b/doc/ja/lseek.html index 291397a..5db5cbf 100644 --- a/doc/ja/lseek.html +++ b/doc/ja/lseek.html @@ -54,8 +54,8 @@ FRESULT f_lseek (
  • 非書き込みモードまたは高速シーク・モードのため、ファイル・サイズでクリップされた。
  • ファイル拡張中にディスクが満杯になった。
  • -

    _USE_FASTSEEKに1が指定されていて、且つファイル・オブジェクトのcltblメンバがNULL以外(ファイルを開いたときはNULL)のとき、高速シーク・モードになります。これはファイルのクラスタ配置情報(CLMT)をメモリ上に保持しておくことにより、FATにアクセスすることなく後方シークやロング・シークを高速に行う機能です。高速シーク・モードは、f_read/f_wtite関数にも適用されます。高速シーク・モードではf_wtite/f_lseek関数によるファイル・サイズの拡張はできません。

    -

    高速シーク動作を行う前に、CLMTを作成しておく必要があります。これを作成するには、まずcltblメンバにCLMT格納バッファ(DWORD配列)へのポインタをセットします。そして、配列の先頭要素にその配列の要素数を入れ、f_lseek関数をOffsetCREATE_LINKMAPを指定して実行します。関数が成功するとCLMTが作成され、以降のf_read/f_write/f_lseek関数ではFATへのアクセスは発生しません。FR_NOT_ENOUGH_COREで失敗したときは配列サイズが不足で、先頭要素には実際に必要となる要素数が返されます。必要な要素数は、(ファイルの分割数 + 1) * 2 です。たとえば、ファイルが5つに分断されているときに必要な要素数は、12となります。

    +

    _USE_FASTSEEKが1で、且つファイル・オブジェクトのcltblメンバがNULL以外(f_open()でNULLに設定される)のとき、高速シーク・モードになります。これはファイルのクラスタ配置情報(CLMT)をメモリ上に保持しておくことにより、FATにアクセスすることなく後方シークやロング・シークを高速に行う機能です。高速シーク・モードは、f_read/f_wtite関数の動作にも適用されます。高速シーク・モードではf_wtite/f_lseek関数によるファイル・サイズの拡張はできません。

    +

    高速シーク動作を行う前に、CLMTを作成しておく必要があります。これを作成するには、まずCLMT格納バッファ(DWORD配列)を準備し、cltblメンバにそのポインタをセットします。そして、配列の先頭要素にその配列のサイズ(要素数)を入れ、f_lseek関数をOffsetCREATE_LINKMAPを指定して呼び出します。関数が成功するとCLMTが作成され、以降のf_read/f_write/f_lseek関数ではFATへのアクセスは発生しません。FR_NOT_ENOUGH_COREで失敗したときは配列サイズが不足で、先頭要素には実際に必要となる要素数が返されます。必要な要素数は、(ファイルの分割数 + 1) * 2 です。たとえば、ファイルが5つのフラグメントに分断されているときに必要な要素数は、12となります。

    @@ -75,30 +75,30 @@ FRESULT f_lseek ( if (res) ... /* ファイル・オフセット5000へ移動 */ - res = f_lseek(file, 5000, 0); + res = f_lseek(file, 5000); /* ファイル終端へ移動(ファイル追記の準備) */ - res = f_lseek(file, f_size(file), 0); + res = f_lseek(file, f_size(file)); /* 3000バイト進める */ - res = f_lseek(file, f_tell(file) + 3000, 0); + res = f_lseek(file, f_tell(file) + 3000); /* 2000バイト戻す (オーバーフローに注意) */ - res = f_lseek(file, f_tell(file) - 2000, 0); + res = f_lseek(file, f_tell(file) - 2000);
         /* クラスタ先行割り当て (ストリーミング・ライト時のバッファ・オーバーラン防止) */
     
         res = f_open(file, "record.wav", FA_CREATE_NEW | FA_WRITE);  /* ファイル作成 */
     
    -    res = f_lseek(file, MAX_SIZE, 0);        /* 十分なクラスタの先行割り当て */
    +    res = f_lseek(file, MAX_SIZE);           /* 十分なクラスタの先行割り当て */
         if (res || f_tell(file) != PRE_SIZE) ... /* 正しくファイルが拡張されたかチェック */
     
    -    res = f_lseek(file, DATA_START, 0);      /* データ・ストリームの記録(アロケーションディレイ無し) */
    +    res = f_lseek(file, DATA_START);         /* データ・ストリームの記録(アロケーションディレイ無し) */
         ...
     
         res = f_truncate(file);                  /* 不要領域の切り捨て */
    -    res = f_lseek(file, 0, 0);               /* ヘッダの記録 */
    +    res = f_lseek(file, 0);                  /* ヘッダの記録 */
         ...
     
         res = f_close(file);
    diff --git a/doc/ja/mkfs.html b/doc/ja/mkfs.html
    index f1e437e..a9eb80d 100644
    --- a/doc/ja/mkfs.html
    +++ b/doc/ja/mkfs.html
    @@ -13,7 +13,7 @@
     
     

    f_mkfs

    -

    物理ドライブ上にFATボリュームを作成(フォーマット)します。

    +

    論理ドライブ上にFATボリュームを作成(フォーマット)します。

     FRESULT f_mkfs (
       BYTE  Drive,              /* 論理ドライブ番号 */
    @@ -29,9 +29,9 @@ FRESULT f_mkfs (
     
    Drive
    フォーマットする論理ドライブ(0-9)。
    PartitioningRule
    -
    0を指定すると、ドライブの全領域を占める基本DOS区画を作成したあと、そこにFATボリュームを作成します(FDISKフォーマット)。1を指定すると、区画テーブルを作成せず物理ドライブの先頭セクタから直接ファイル・システムを作成します(super floppy (SFD) フォーマット)。
    +
    パーテーション形式(0(FDISK) または1(SFD))を指定します。
    AllocSize
    -
    クラスタ・サイズをバイト単位で指定します。2の累乗、且つセクタ・サイズ以上、且つセクタ・サイズの128倍以下でなければなりません。無効な値を指定した場合、ドライブ・サイズに応じたデフォルトのクラスタ・サイズが選択されます。特に指定しない場合は、0を指定して自動選択とします。
    +
    クラスタ・サイズをバイト単位で指定します。2の累乗、且つセクタ・サイズ以上、且つセクタ・サイズの128倍以下でなければなりません。0を指定した場合、ボリュームのサイズに応じたデフォルトのクラスタ・サイズが選択されます。
    @@ -42,14 +42,17 @@ FRESULT f_mkfs ( FR_DISK_ERR, FR_NOT_READY, FR_NOT_ENABLED, -FR_MKFS_ABORTED +FR_MKFS_ABORTED, +FR_INVALID_PARAMETER

    説明

    -

    f_mkfs関数は物理ドライブ上にFATボリュームを作成します。リムーバブル・メディアのパーテーショニング・ルールとしてはFDISK形式とSFD形式があり、メモリ・カードではFDISK形式が普通です。この関数は複数区画には対応していないので、その物理ドライブの既存の区画は全て削除され、全体が一つの区画になります。

    -

    FATタイプ(FAT12/FAT16/FAT32)は、その論理ドライブ上のクラスタ数によってのみ決定される決まり[FAT仕様書より]になっていて、それ以外の要因はありません。したがって、どのFATタイプになるかはドライブ・サイズとクラスタ・サイズに依存します。クラスタ・サイズは大きくするほど性能が上がり、逆にディスク利用効率は落ちます。

    +

    f_mkfs関数は物理ドライブ上にFATボリュームを作成します。第二引数でFDISK形式が指定された場合は、物理ドライブ全体を占める基本区画(パーテーション)が作成され、その中にFATボリュームが作成されます。SFD形式では、FATボリュームは物理ドライブの先頭からベタで作成されます。

    +

    マルチパーテーション機能(_MULTI_PARTITION)により、指定された論理ドライブが特定の区画(1〜4)に結び付けられている場合、その区画の中にFATボリュームが作成されます。この場合、第二引数は無視され、また対応する物理ドライブはこれに先立ち、f_fdisk関数または他のツールで適切に区画設定されている必要があります。

    +

    パーテーション形式には、FDISK形式とSFD形式の二通りありがあります。FDISK形式は、ハードディスク、MMC、SDC、CFCなどで使用されます。FDISK形式では一台の物理ドライブ上に一つまたは複数の区画を作成することができます。管理情報はMBR(物理ドライブの先頭セクタ)に記録されます。SFD形式は単に何の分割も行わない形式で、ボリュームは物理ドライブの先頭セクタから開始します。SFD形式は、フロッピーディスク、マイクロドライブ、光学ディスク、およびその他スーパーフロッピーメディアで使用されています。

    +

    FATタイプ(FAT12/FAT16/FAT32)は、その論理ドライブ上のクラスタ数によってのみ決定される決まり[FAT仕様書より]になっていて、それ以外の要因はありません。したがって、どのFATタイプになるかはドライブ・サイズとクラスタ・サイズに依存します。クラスタ・サイズは大きくするほど性能が上がり、ディスク利用効率は落ちます。

    クラスタ数がFATタイプの境界に近くなるときは、FR_MKFS_ABORTEDで関数が失敗する可能性があります。

    @@ -60,6 +63,11 @@ FRESULT f_mkfs (
    -

    Return

    + + +

    戻る

    diff --git a/doc/ja/open.html b/doc/ja/open.html index 6fc30bd..7cfe243 100644 --- a/doc/ja/open.html +++ b/doc/ja/open.html @@ -73,7 +73,7 @@ FRESULT f_open (

    解説

    既存のファイルを開いたり、新しいファイルを作成します。関数が成功するとファイル・オブジェクトが作成され、以降そのファイルに対するアクセスに使用します。ファイルを閉じるときは、f_close()を使用します。何らかの変更が行われたファイルがその後正しく閉じられなかった場合、そのファイルが破損する場合があります。

    -

    もしも既に開かれているファイルを開く必要がある場合は、多重アクセス制御を参照してください。

    +

    既に開かれているファイルを開く必要がある場合は、多重アクセス制御を参照してください。しかし、一つのファイルに対する書き込みモードを含む重複オープンは常に禁止です。

    ファイル・アクセスを開始する前に、f_mount()を使ってそれぞれの論理ドライブにワーク・エリア(ファイル・システム・オブジェクト)を与える必要があります。この初期化の後、その論理ドライブに対して全てのファイル関数が使えるようになります。

    @@ -109,7 +109,7 @@ void main (void) /* ソースからデスティネーションにコピーする */ for (;;) { - res = f_read(&fsrc, buffer, sizeof(buffer), &br); + res = f_read(&fsrc, buffer, sizeof buffer, &br); if (res || br == 0) break; /* エラーかファイル終端 */ res = f_write(&fdst, buffer, br, &bw); if (res || bw < br) break; /* エラーかディスク満杯 */ diff --git a/doc/ja/putc.html b/doc/ja/putc.html index 005fe0c..074e17d 100644 --- a/doc/ja/putc.html +++ b/doc/ja/putc.html @@ -35,7 +35,7 @@ int f_putc (

    戻り値

    -

    文字が正常に書き込まれると書き込んだ文字が返されます。ディスクが満杯またはエラーにより書き込まれなかったときはEOF (-1)が返されます。

    +

    文字が正常に書き込まれると書き込んだ文字数(1)が返されます。ディスクが満杯またはエラーにより書き込まれなかったときはEOF (-1)が返されます。

    APIにUnicodeが選択されている(_LFN_UNICODEが1)ときは、UTF-8エンコードでファイルに書き込みます。それ以外の時は無変換(1文字1バイト)で書き込みます。

    diff --git a/doc/ja/puts.html b/doc/ja/puts.html index 226cef4..4ac82a9 100644 --- a/doc/ja/puts.html +++ b/doc/ja/puts.html @@ -16,7 +16,7 @@

    ファイルに文字列を書き込みます。

     int f_puts (
    -  const TCHAR* Str,  /* 文字列 */
    +  const TCHAR* Str,  /* 書き込む文字列 */
       FIL* FileObject    /* ファイル・オブジェクト */
     );
     
    @@ -35,7 +35,7 @@ int f_puts (

    戻り値

    -

    文字列が正常に書き込まれると、書き込まれた文字数が返されます。ディスクが満杯またはエラーにより正常に書き込まれなかったときはEOF (-1)が返されます。

    +

    文字列が正常に書き込まれると、書き込まれた文字数が返されます。ディスクが満杯またはエラーにより書き込みが中断されたときはEOF (-1)が返されます。

    APIにUnicodeが選択されている(_LFN_UNICODEが1)ときは、UTF-8エンコードでファイルに書き込みます。それ以外の時は無変換(1文字1バイト)で書き込みます。

    diff --git a/doc/ja/rc.html b/doc/ja/rc.html index cb27aea..3c03cce 100644 --- a/doc/ja/rc.html +++ b/doc/ja/rc.html @@ -23,6 +23,7 @@
    • 繝懊Μ繝・繝シ繝荳翫ョFAT讒矩縺ォ繧ィ繝ゥ繝シ縺後≠繧九
    • 繧ケ繧ソ繝繧ッ荳崎カウ繧莉悶ョ繧ソ繧ケ繧ッ遲峨↓繧医k繝ッ繝シ繧ッ繝サ繧ィ繝ェ繧「(繝輔ぃ繧、繝ォ繝サ繧キ繧ケ繝繝繝サ繧ェ繝悶ず繧ァ繧ッ繝医d繝輔ぃ繧、繝ォ繝サ繧ェ繝悶ず繧ァ繧ッ繝)縺ョ遐エ螢翫ょ、壹¥縺ッ縺薙l縺悟次蝗縲
    • +
    • 縺昴ョ繝輔ぃ繧、繝ォ繧ェ繝悶ず繧ァ繧ッ繝医〒縺ッ驕主悉縺ォFR_DISK_ERR縺檎匱逕溘@縺ヲ縺繧九
    FR_NOT_READY
    @@ -77,6 +78,8 @@
    FR_TOO_MANY_OPEN_FILES
    蜷梧凾繧ェ繝シ繝励Φ蜿ッ閭ス縺ェ繝輔ぃ繧、繝ォ謨ー繧定カ翫∴縺ヲ繝輔ぃ繧、繝ォ繧帝幕縺薙≧縺ィ縺励◆縲(髢「騾」繧ェ繝励す繝ァ繝ウ: _FS_SHARE)
    +
    FR_INVALID_PARAMETER
    +
    荳弱∴繧峨l縺溘ヱ繝ゥ繝。繝シ繧ソ縺檎┌蜉ケ縺セ縺溘ッ遏帷崟縺励※縺繧九
    diff --git a/doc/ja/readdir.html b/doc/ja/readdir.html index 95d4e0a..f1297b2 100644 --- a/doc/ja/readdir.html +++ b/doc/ja/readdir.html @@ -81,7 +81,7 @@ FRESULT scan_files ( #if _USE_LFN static char lfn[_MAX_LFN + 1]; fno.lfname = lfn; - fno.lfsize = sizeof(lfn); + fno.lfsize = sizeof lfn; #endif diff --git a/doc/ja/sfatfs.html b/doc/ja/sfatfs.html index bd3997e..5156860 100644 --- a/doc/ja/sfatfs.html +++ b/doc/ja/sfatfs.html @@ -26,10 +26,10 @@ WORD id; /* ファイル・システム・マウントID */ WORD n_rootdir; /* ルート・ディレクトリのエントリ数 (FAT12/16) */#if _MAX_SS != 512 - WORD ssize; /* セクタ・サイズ (可変セクタ長のみ) */ + WORD ssize; /* セクタ・サイズ (512, 1024, 2048 or 4096) */#endif#if _FS_REENTRANT - HANDLE h_mutex; /* 同期オブジェクトID */ + _SYNC_t sobj; /* 同期オブジェクトID */#endif#if !_FS_READONLY DWORD last_clust; /* 最後に割り当てられたクラスタ番号 */ @@ -39,7 +39,7 @@ #if _FS_RPATH DWORD cdir; /* カレント・ディレクトリのクラスタ (0:ルート) */#endif - DWORD n_fatent; /* FATのエントリ数 (= クラスタ数 + 2) */ + DWORD n_fatent; /* FATのエントリ数 (== クラスタ数 + 2) */ DWORD fsize; /* FAT 1個当たりのセクタ数 */ DWORD fatbase; /* FAT領域開始セクタ */ DWORD dirbase; /* ルート・ディレクトリ開始セクタ (FAT32: クラスタ番号) */ diff --git a/doc/ja/stat.html b/doc/ja/stat.html index 22e33ec..e9e0083 100644 --- a/doc/ja/stat.html +++ b/doc/ja/stat.html @@ -53,7 +53,7 @@ FRESULT f_stat (

    解説

    -

    ファイルまたはディレクトリに関する情報を得ます。得られるファイル情報の詳細については FILINFO構造体を参照してください。

    +

    指定されたファイルまたはディレクトリに関する情報(サイズ、タイムスタンプおよび属性)を得ます。ディレクトリのサイズ情報は常に0です。

    diff --git a/doc/updates.txt b/doc/updates.txt index af69c5b..a592ff2 100644 --- a/doc/updates.txt +++ b/doc/updates.txt @@ -1,3 +1,7 @@ +R0.09, Sep 6, 2011 + f_mkfs() supports multiple partition to finish the multiple partition feature. + Added f_fdisk(). (_MULTI_PARTITION = 2) + R0.08b, Jan 15, 2011 Fast seek feature is also applied to f_read() and f_write(). f_lseek() reports required table size on creating CLMP. diff --git a/src/00readme.txt b/src/00readme.txt index c78da31..cfcdd4a 100644 --- a/src/00readme.txt +++ b/src/00readme.txt @@ -1,4 +1,4 @@ -FatFs Module Source Files R0.08b (C)ChaN, 2011 +FatFs Module Source Files R0.09 (C)ChaN, 2011 FILES @@ -125,3 +125,6 @@ REVISION HISTORY f_lseek() reports required table size on creating CLMP. Extended format syntax of f_printf function. Ignores duplicated directory separators in given path names. + + Sep 06,'11 R0.09 f_mkfs() supports multiple partition to finish the multiple partition feature. + Added f_fdisk(). (_MULTI_PARTITION = 2) diff --git a/src/ff.c b/src/ff.c index 4f76915..bc79e2f 100644 --- a/src/ff.c +++ b/src/ff.c @@ -1,5 +1,5 @@ /*----------------------------------------------------------------------------/ -/ FatFs - FAT file system module R0.08b (C)ChaN, 2011 +/ FatFs - FAT file system module R0.09 (C)ChaN, 2011 /-----------------------------------------------------------------------------/ / FatFs module is a generic FAT file system module for small embedded systems. / This is a free software that opened for education, research and commercial @@ -87,6 +87,9 @@ / f_lseek() reports required table size on creating CLMP. / Extended format syntax of f_printf function. / Ignores duplicated directory separators in given path names. +/ +/ Sep 06,'11 R0.09 f_mkfs() supports multiple partition to finish the multiple partition feature. +/ Added f_fdisk(). (_MULTI_PARTITION = 2) /---------------------------------------------------------------------------*/ #include "ff.h" /* FatFs configurations and declarations */ @@ -99,7 +102,7 @@ ---------------------------------------------------------------------------*/ -#if _FATFS != 8237 +#if _FATFS != 6502 /* Revision ID */ #error Wrong include file (ff.h). #endif @@ -109,7 +112,7 @@ #error Wrong sector size. #endif #if _MAX_SS != 512 -#define SS(fs) ((fs)->ssize) /* Multiple sector size */ +#define SS(fs) ((fs)->ssize) /* Variable sector size */ #else #define SS(fs) 512U /* Fixed sector size */ #endif @@ -453,13 +456,18 @@ typedef struct { /*------------------------------------------------------------*/ -/* Work area */ +/* Module private work area */ +/*------------------------------------------------------------*/ +/* Note that uninitialized variables with static duration are +/ zeroed/nulled at start-up. If not, the compiler or start-up +/ routine is out of ANSI-C standard. +*/ #if _VOLUMES static FATFS *FatFs[_VOLUMES]; /* Pointer to the file system objects (logical drives) */ #else -#error Number of drives must not be 0. +#error Number of volumes must not be 0. #endif static @@ -475,23 +483,23 @@ static FILESEM Files[_FS_SHARE]; /* File lock semaphores */ #endif -#if _USE_LFN == 0 /* No LFN */ +#if _USE_LFN == 0 /* No LFN feature */ #define DEF_NAMEBUF BYTE sfn[12] #define INIT_BUF(dobj) (dobj).fn = sfn #define FREE_BUF() -#elif _USE_LFN == 1 /* LFN with static LFN working buffer */ +#elif _USE_LFN == 1 /* LFN feature with static working buffer */ static WCHAR LfnBuf[_MAX_LFN+1]; #define DEF_NAMEBUF BYTE sfn[12] #define INIT_BUF(dobj) { (dobj).fn = sfn; (dobj).lfn = LfnBuf; } #define FREE_BUF() -#elif _USE_LFN == 2 /* LFN with dynamic LFN working buffer on the stack */ +#elif _USE_LFN == 2 /* LFN feature with dynamic working buffer on the stack */ #define DEF_NAMEBUF BYTE sfn[12]; WCHAR lbuf[_MAX_LFN+1] #define INIT_BUF(dobj) { (dobj).fn = sfn; (dobj).lfn = lbuf; } #define FREE_BUF() -#elif _USE_LFN == 3 /* LFN with dynamic LFN working buffer on the heap */ +#elif _USE_LFN == 3 /* LFN feature with dynamic working buffer on the heap */ #define DEF_NAMEBUF BYTE sfn[12]; WCHAR *lfn #define INIT_BUF(dobj) { lfn = ff_memalloc((_MAX_LFN + 1) * 2); \ if (!lfn) LEAVE_FF((dobj).fs, FR_NOT_ENOUGH_CORE); \ @@ -624,9 +632,7 @@ FRESULT chk_lock ( /* Check if the file can be accessed */ static -int enq_lock ( /* Check if an entry is available for a new file */ - FATFS* fs /* File system object */ -) +int enq_lock (void) /* Check if an entry is available for a new file */ { UINT i; @@ -776,7 +782,7 @@ FRESULT sync ( /* FR_OK: successful, FR_DISK_ERR: failed */ fs->fsi_flag = 0; } /* Make sure that no pending write process in the physical drive */ - if (disk_ioctl(fs->drv, CTRL_SYNC, (void*)0) != RES_OK) + if (disk_ioctl(fs->drv, CTRL_SYNC, 0) != RES_OK) res = FR_DISK_ERR; } @@ -1113,6 +1119,7 @@ FRESULT dir_next ( /* FR_OK:Succeeded, FR_NO_FILE:End of table, FR_DENIED:EOT an WORD i; + stretch = stretch; /* To suppress warning on read-only cfg. */ i = dj->index + 1; if (!i || !dj->sect) /* Report EOT when index has reached 65535 */ return FR_NO_FILE; @@ -1968,11 +1975,11 @@ FRESULT follow_path ( /* FR_OK(0): successful, !=0: error code */ /*-----------------------------------------------------------------------*/ -/* Load boot record and check if it is an FAT boot record */ +/* Load a sector and check if it is an FAT Volume Boot Record */ /*-----------------------------------------------------------------------*/ static -BYTE check_fs ( /* 0:The FAT BR, 1:Valid BR but not an FAT, 2:Not a BR, 3:Disk error */ +BYTE check_fs ( /* 0:FAT-VBR, 1:Valid BR but not FAT, 2:Not a BR, 3:Disk error */ FATFS *fs, /* File system object */ DWORD sect /* Sector# (lba) to check if it is an FAT boot record or not */ ) @@ -2004,7 +2011,7 @@ FRESULT chk_mounted ( /* FR_OK(0): successful, !=0: any error occurred */ BYTE chk_wp /* !=0: Check media write protection for write access */ ) { - BYTE fmt, b, *tbl; + BYTE fmt, b, pi, *tbl; UINT vol; DSTATUS stat; DWORD bsect, fasize, tsect, sysect, nclst, szbfat; @@ -2024,7 +2031,7 @@ FRESULT chk_mounted ( /* FR_OK(0): successful, !=0: any error occurred */ #endif } - /* Check if the logical drive is valid or not */ + /* Check if the file system object is valid or not */ if (vol >= _VOLUMES) /* Is the drive number valid? */ return FR_INVALID_DRIVE; *rfs = fs = FatFs[vol]; /* Return pointer to the corresponding file system object */ @@ -2035,44 +2042,43 @@ FRESULT chk_mounted ( /* FR_OK(0): successful, !=0: any error occurred */ if (fs->fs_type) { /* If the logical drive has been mounted */ stat = disk_status(fs->drv); if (!(stat & STA_NOINIT)) { /* and the physical drive is kept initialized (has not been changed), */ -#if !_FS_READONLY - if (chk_wp && (stat & STA_PROTECT)) /* Check write protection if needed */ + if (!_FS_READONLY && chk_wp && (stat & STA_PROTECT)) /* Check write protection if needed */ return FR_WRITE_PROTECTED; -#endif return FR_OK; /* The file system object is valid */ } } - /* The logical drive must be mounted. */ - /* Following code attempts to mount a volume. (analyze BPB and initialize the fs object) */ + /* The file system object is not valid. */ + /* Following code attempts to mount the volume. (analyze BPB and initialize the fs object) */ fs->fs_type = 0; /* Clear the file system object */ - fs->drv = (BYTE)LD2PD(vol); /* Bind the logical drive and a physical drive */ + fs->drv = LD2PD(vol); /* Bind the logical drive and a physical drive */ stat = disk_initialize(fs->drv); /* Initialize low level disk I/O layer */ if (stat & STA_NOINIT) /* Check if the initialization succeeded */ return FR_NOT_READY; /* Failed to initialize due to no media or hard error */ + if (!_FS_READONLY && chk_wp && (stat & STA_PROTECT)) /* Check disk write protection if needed */ + return FR_WRITE_PROTECTED; #if _MAX_SS != 512 /* Get disk sector size (variable sector size cfg only) */ if (disk_ioctl(fs->drv, GET_SECTOR_SIZE, &fs->ssize) != RES_OK) return FR_DISK_ERR; -#endif -#if !_FS_READONLY - if (chk_wp && (stat & STA_PROTECT)) /* Check disk write protection if needed */ - return FR_WRITE_PROTECTED; #endif /* Search FAT partition on the drive. Supports only generic partitionings, FDISK and SFD. */ - fmt = check_fs(fs, bsect = 0); /* Check sector 0 if it is a VBR */ - if (fmt == 1) { /* Not an FAT-VBR, the disk may be partitioned */ - /* Check the partition listed in top of the partition table */ - tbl = &fs->win[MBR_Table + LD2PT(vol) * SZ_PTE];/* Partition table */ - if (tbl[4]) { /* Is the partition existing? */ - bsect = LD_DWORD(&tbl[8]); /* Partition offset in LBA */ - fmt = check_fs(fs, bsect); /* Check the partition */ + fmt = check_fs(fs, bsect = 0); /* Load sector 0 and check if it is an FAT-VBR (in SFD) */ + if (LD2PT(vol) && !fmt) fmt = 1; /* Force non-SFD if the volume is forced partition */ + if (fmt == 1) { /* Not an FAT-VBR, the physical drive can be partitioned */ + /* Check the partition listed in the partition table */ + pi = LD2PT(vol); + if (pi) pi--; + tbl = &fs->win[MBR_Table + pi * SZ_PTE];/* Partition table */ + if (tbl[4]) { /* Is the partition existing? */ + bsect = LD_DWORD(&tbl[8]); /* Partition offset in LBA */ + fmt = check_fs(fs, bsect); /* Check the partition */ } } if (fmt == 3) return FR_DISK_ERR; - if (fmt) return FR_NO_FILESYSTEM; /* No FAT volume is found */ + if (fmt) return FR_NO_FILESYSTEM; /* No FAT volume is found */ - /* Following code initializes the file system object */ + /* An FAT volume is found. Following code initializes the file system object */ if (LD_WORD(fs->win+BPB_BytsPerSec) != SS(fs)) /* (BPB_BytsPerSec must be equal to the physical sector size) */ return FR_NO_FILESYSTEM; @@ -2202,27 +2208,27 @@ FRESULT f_mount ( FATFS *rfs; - if (vol >= _VOLUMES) /* Check if the drive number is valid */ + if (vol >= _VOLUMES) /* Check if the drive number is valid */ return FR_INVALID_DRIVE; - rfs = FatFs[vol]; /* Get current fs object */ + rfs = FatFs[vol]; /* Get current fs object */ if (rfs) { #if _FS_SHARE clear_lock(rfs); #endif -#if _FS_REENTRANT /* Discard sync object of the current volume */ +#if _FS_REENTRANT /* Discard sync object of the current volume */ if (!ff_del_syncobj(rfs->sobj)) return FR_INT_ERR; #endif - rfs->fs_type = 0; /* Clear old fs object */ + rfs->fs_type = 0; /* Clear old fs object */ } if (fs) { - fs->fs_type = 0; /* Clear new fs object */ -#if _FS_REENTRANT /* Create sync object for the new volume */ + fs->fs_type = 0; /* Clear new fs object */ +#if _FS_REENTRANT /* Create sync object for the new volume */ if (!ff_cre_syncobj(vol, &fs->sobj)) return FR_INT_ERR; #endif } - FatFs[vol] = fs; /* Register new fs object */ + FatFs[vol] = fs; /* Register new fs object */ return FR_OK; } @@ -2276,7 +2282,7 @@ FRESULT f_open ( if (res != FR_OK) { /* No file, create new */ if (res == FR_NO_FILE) /* There is no file to open, create a new entry */ #if _FS_SHARE - res = enq_lock(dj.fs) ? dir_register(&dj) : FR_TOO_MANY_OPEN_FILES; + res = enq_lock() ? dir_register(&dj) : FR_TOO_MANY_OPEN_FILES; #else res = dir_register(&dj); #endif @@ -3555,10 +3561,10 @@ FRESULT f_mkfs ( { static const WORD vst[] = { 1024, 512, 256, 128, 64, 32, 16, 8, 4, 2, 0}; static const WORD cst[] = {32768, 16384, 8192, 4096, 2048, 16384, 8192, 4096, 2048, 1024, 512}; - BYTE fmt, md, *tbl; + BYTE fmt, md, sys, *tbl, pdrv, part; DWORD n_clst, vs, n, wsect; UINT i; - DWORD b_vol, b_fat, b_dir, b_data; /* Offset (LBA) */ + DWORD b_vol, b_fat, b_dir, b_data; /* LBA */ DWORD n_vol, n_rsv, n_fat, n_dir; /* Size */ FATFS *fs; DSTATUS stat; @@ -3566,25 +3572,39 @@ FRESULT f_mkfs ( /* Check mounted drive and clear work area */ if (drv >= _VOLUMES) return FR_INVALID_DRIVE; + if (sfd > 1) return FR_INVALID_PARAMETER; + if (au & (au - 1)) return FR_INVALID_PARAMETER; fs = FatFs[drv]; if (!fs) return FR_NOT_ENABLED; fs->fs_type = 0; - drv = LD2PD(drv); + pdrv = LD2PD(drv); /* Physical drive */ + part = LD2PT(drv); /* Partition (0:auto detect, 1-4:get from partition table)*/ /* Get disk statics */ - stat = disk_initialize(drv); + stat = disk_initialize(pdrv); if (stat & STA_NOINIT) return FR_NOT_READY; if (stat & STA_PROTECT) return FR_WRITE_PROTECTED; #if _MAX_SS != 512 /* Get disk sector size */ - if (disk_ioctl(drv, GET_SECTOR_SIZE, &SS(fs)) != RES_OK) + if (disk_ioctl(pdrv, GET_SECTOR_SIZE, &SS(fs)) != RES_OK || SS(fs) > _MAX_SS) return FR_DISK_ERR; #endif - if (disk_ioctl(drv, GET_SECTOR_COUNT, &n_vol) != RES_OK || n_vol < 128) - return FR_DISK_ERR; - b_vol = (sfd) ? 0 : 63; /* Volume start sector */ - n_vol -= b_vol; - if (au & (au - 1)) au = 0; /* Check validity of the AU size */ - if (!au) { /* AU auto selection */ + if (_MULTI_PARTITION && part) { + /* Get partition information from partition table in the MBR */ + if (disk_read(pdrv, fs->win, 0, 1) != RES_OK) return FR_DISK_ERR; + if (LD_WORD(fs->win+BS_55AA) != 0xAA55) return FR_MKFS_ABORTED; + tbl = &fs->win[MBR_Table + (part - 1) * SZ_PTE]; + if (!tbl[4]) return FR_MKFS_ABORTED; /* No partition? */ + b_vol = LD_DWORD(tbl+8); /* Volume start sector */ + n_vol = LD_DWORD(tbl+12); /* Volume size */ + } else { + /* Create a partition in this function */ + if (disk_ioctl(pdrv, GET_SECTOR_COUNT, &n_vol) != RES_OK || n_vol < 128) + return FR_DISK_ERR; + b_vol = (sfd) ? 0 : 63; /* Volume start sector */ + n_vol -= b_vol; /* Volume size */ + } + + if (!au) { /* AU auto selection */ vs = n_vol / (2000 / (SS(fs) / 512)); for (i = 0; vs < vst[i]; i++) ; au = cst[i]; @@ -3613,10 +3633,10 @@ FRESULT f_mkfs ( b_fat = b_vol + n_rsv; /* FAT area start sector */ b_dir = b_fat + n_fat * N_FATS; /* Directory area start sector */ b_data = b_dir + n_dir; /* Data area start sector */ - if (n_vol < b_data + au) return FR_MKFS_ABORTED; /* Too small volume */ + if (n_vol < b_data + au - b_vol) return FR_MKFS_ABORTED; /* Too small volume */ /* Align data start sector to erase block boundary (for flash memory media) */ - if (disk_ioctl(drv, GET_BLOCK_SIZE, &n) != RES_OK || !n || n > 32768) n = 1; + if (disk_ioctl(pdrv, GET_BLOCK_SIZE, &n) != RES_OK || !n || n > 32768) n = 1; n = (b_data + n - 1) & ~(n - 1); /* Next nearest erase block from current data start */ n = (n - b_data) / N_FATS; if (fmt == FS_FAT32) { /* FAT32: Move FAT offset */ @@ -3632,36 +3652,42 @@ FRESULT f_mkfs ( || (fmt == FS_FAT32 && n_clst < MIN_FAT32)) return FR_MKFS_ABORTED; - /* Create partition table if required */ - if (sfd) { /* No patition table (SFD) */ - md = 0xF0; - } else { /* With patition table (FDISK) */ - DWORD n_disk = b_vol + n_vol; - - mem_set(fs->win, 0, SS(fs)); - tbl = fs->win+MBR_Table; - ST_DWORD(tbl, 0x00010180); /* Partition start in CHS */ - if (n_disk < 63UL * 255 * 1024) { /* Partition end in CHS */ - n_disk = n_disk / 63 / 255; - tbl[7] = (BYTE)n_disk; - tbl[6] = (BYTE)((n_disk >> 2) | 63); - } else { - ST_WORD(&tbl[6], 0xFFFF); /* CHS saturated */ - } - tbl[5] = 254; - if (fmt != FS_FAT32) /* System ID */ - tbl[4] = (n_vol < 0x10000) ? 0x04 : 0x06; - else - tbl[4] = 0x0c; - ST_DWORD(tbl+8, 63); /* Partition start in LBA */ - ST_DWORD(tbl+12, n_vol); /* Partition size in LBA */ - ST_WORD(fs->win+BS_55AA, 0xAA55); /* MBR signature */ - if (disk_write(drv, fs->win, 0, 1) != RES_OK) /* Put the MBR into first physical sector */ - return FR_DISK_ERR; - md = 0xF8; + switch (fmt) { /* Determine system ID for partition table */ + case FS_FAT12: sys = 0x01; break; + case FS_FAT16: sys = (n_vol < 0x10000) ? 0x04 : 0x06; break; + default: sys = 0x0C; } - /* Create volume boot record */ + if (_MULTI_PARTITION && part) { + /* Update system ID in the partition table */ + tbl = &fs->win[MBR_Table + (part - 1) * SZ_PTE]; + tbl[4] = sys; + if (disk_write(pdrv, fs->win, 0, 1) != RES_OK) return FR_DISK_ERR; + md = 0xF8; + } else { + if (sfd) { /* No patition table (SFD) */ + md = 0xF0; + } else { /* Create partition table (FDISK) */ + mem_set(fs->win, 0, SS(fs)); + tbl = fs->win+MBR_Table; /* Create partiton table for single partition in the drive */ + tbl[1] = 1; /* Partition start head */ + tbl[2] = 1; /* Partition start sector */ + tbl[3] = 0; /* Partition start cylinder */ + tbl[4] = sys; /* System type */ + tbl[5] = 254; /* Partition end head */ + n = (b_vol + n_vol) / 63 / 255; + tbl[6] = (BYTE)((n >> 2) | 63); /* Partiiton end sector */ + tbl[7] = (BYTE)n; /* End cylinder */ + ST_DWORD(tbl+8, 63); /* Partition start in LBA */ + ST_DWORD(tbl+12, n_vol); /* Partition size in LBA */ + ST_WORD(fs->win+BS_55AA, 0xAA55); /* MBR signature */ + if (disk_write(pdrv, fs->win, 0, 1) != RES_OK) /* Write it to the MBR sector */ + return FR_DISK_ERR; + md = 0xF8; + } + } + + /* Create BPB in the VBR */ tbl = fs->win; /* Clear sector */ mem_set(tbl, 0, SS(fs)); mem_cpy(tbl, "\xEB\xFE\x90" "MSDOS5.0", 11);/* Boot jump code, OEM name */ @@ -3699,10 +3725,10 @@ FRESULT f_mkfs ( mem_cpy(tbl+BS_VolLab, "NO NAME " "FAT ", 19); /* Volume label, FAT signature */ } ST_WORD(tbl+BS_55AA, 0xAA55); /* Signature (Offset is fixed here regardless of sector size) */ - if (disk_write(drv, tbl, b_vol, 1) != RES_OK) /* Write VBR */ + if (disk_write(pdrv, tbl, b_vol, 1) != RES_OK) /* Write it to the VBR sector */ return FR_DISK_ERR; if (fmt == FS_FAT32) /* Write backup VBR if needed (VBR+6) */ - disk_write(drv, tbl, b_vol + 6, 1); + disk_write(pdrv, tbl, b_vol + 6, 1); /* Initialize FAT area */ wsect = b_fat; @@ -3718,11 +3744,11 @@ FRESULT f_mkfs ( ST_DWORD(tbl+4, 0xFFFFFFFF); ST_DWORD(tbl+8, 0x0FFFFFFF); /* Reserve cluster #2 for root dir */ } - if (disk_write(drv, tbl, wsect++, 1) != RES_OK) + if (disk_write(pdrv, tbl, wsect++, 1) != RES_OK) return FR_DISK_ERR; mem_set(tbl, 0, SS(fs)); /* Fill following FAT entries with zero */ for (n = 1; n < n_fat; n++) { /* This loop may take a time on FAT32 volume due to many single sector writes */ - if (disk_write(drv, tbl, wsect++, 1) != RES_OK) + if (disk_write(pdrv, tbl, wsect++, 1) != RES_OK) return FR_DISK_ERR; } } @@ -3730,7 +3756,7 @@ FRESULT f_mkfs ( /* Initialize root directory */ i = (fmt == FS_FAT32) ? au : n_dir; do { - if (disk_write(drv, tbl, wsect++, 1) != RES_OK) + if (disk_write(pdrv, tbl, wsect++, 1) != RES_OK) return FR_DISK_ERR; } while (--i); @@ -3739,7 +3765,7 @@ FRESULT f_mkfs ( DWORD eb[2]; eb[0] = wsect; eb[1] = wsect + (n_clst - ((fmt == FS_FAT32) ? 1 : 0)) * au - 1; - disk_ioctl(drv, CTRL_ERASE_SECTOR, eb); + disk_ioctl(pdrv, CTRL_ERASE_SECTOR, eb); } #endif @@ -3750,13 +3776,82 @@ FRESULT f_mkfs ( ST_DWORD(tbl+FSI_Free_Count, n_clst - 1); /* Number of free clusters */ ST_DWORD(tbl+FSI_Nxt_Free, 2); /* Last allocated cluster# */ ST_WORD(tbl+BS_55AA, 0xAA55); - disk_write(drv, tbl, b_vol + 1, 1); /* Write original (VBR+1) */ - disk_write(drv, tbl, b_vol + 7, 1); /* Write backup (VBR+7) */ + disk_write(pdrv, tbl, b_vol + 1, 1); /* Write original (VBR+1) */ + disk_write(pdrv, tbl, b_vol + 7, 1); /* Write backup (VBR+7) */ } - return (disk_ioctl(drv, CTRL_SYNC, (void*)0) == RES_OK) ? FR_OK : FR_DISK_ERR; + return (disk_ioctl(pdrv, CTRL_SYNC, 0) == RES_OK) ? FR_OK : FR_DISK_ERR; } + +#if _MULTI_PARTITION == 2 +/*-----------------------------------------------------------------------*/ +/* Divide Physical Drive */ +/*-----------------------------------------------------------------------*/ + +FRESULT f_fdisk ( + BYTE pdrv, /* Physical drive number */ + const DWORD szt[], /* Pointer to the size table for each partitions */ + void* work /* Pointer to the working buffer */ +) +{ + UINT i, n, sz_cyl, tot_cyl, b_cyl, e_cyl, p_cyl; + BYTE s_hd, e_hd, *p, *buf = (BYTE*)work; + DSTATUS stat; + DWORD sz_disk, sz_part, s_part; + + + stat = disk_initialize(pdrv); + if (stat & STA_NOINIT) return FR_NOT_READY; + if (stat & STA_PROTECT) return FR_WRITE_PROTECTED; + if (disk_ioctl(pdrv, GET_SECTOR_COUNT, &sz_disk)) return FR_DISK_ERR; + + /* Determine CHS in the table regardless of the drive geometry */ + for (n = 16; n < 256 && sz_disk / n / 63 > 1024; n *= 2) ; + if (n == 256) n--; + e_hd = n - 1; + sz_cyl = 63 * n; + tot_cyl = sz_disk / sz_cyl; + + /* Create partition table */ + mem_set(buf, 0, _MAX_SS); + p = buf + MBR_Table; b_cyl = 0; + for (i = 0; i < 4; i++, p += SZ_PTE) { + p_cyl = (szt[i] <= 100) ? (DWORD)tot_cyl * szt[i] / 100 : szt[i] / sz_cyl; + if (!p_cyl) continue; + s_part = (DWORD)sz_cyl * b_cyl; + sz_part = (DWORD)sz_cyl * p_cyl; + if (i == 0) { /* Exclude first track of cylinder 0 */ + s_hd = 1; + s_part += 63; sz_part -= 63; + } else { + s_hd = 0; + } + e_cyl = b_cyl + p_cyl - 1; + if (e_cyl >= tot_cyl) return FR_INVALID_PARAMETER; + + /* Set partition table */ + p[1] = s_hd; /* Start head */ + p[2] = (BYTE)((b_cyl >> 2) + 1); /* Start sector */ + p[3] = (BYTE)b_cyl; /* Start cylinder */ + p[4] = 0x06; /* System type (temporary setting) */ + p[5] = e_hd; /* End head */ + p[6] = (BYTE)((e_cyl >> 2) + 63); /* End sector */ + p[7] = (BYTE)e_cyl; /* End cylinder */ + ST_DWORD(p + 8, s_part); /* Start sector in LBA */ + ST_DWORD(p + 12, sz_part); /* Partition size */ + + /* Next partition */ + b_cyl += p_cyl; + } + ST_WORD(p, 0xAA55); + + /* Write it to the MBR */ + return (disk_write(pdrv, buf, 0, 1) || disk_ioctl(pdrv, CTRL_SYNC, 0)) ? FR_DISK_ERR : FR_OK; +} + + +#endif /* _MULTI_PARTITION == 2 */ #endif /* _USE_MKFS && !_FS_READONLY */ @@ -3894,7 +3989,7 @@ int f_printf ( UINT i, j, w; ULONG v; TCHAR c, d, s[16], *p; - int res, cc; + int res, chc, cc; va_start(arp, str); @@ -3930,11 +4025,13 @@ int f_printf ( case 'S' : /* String */ p = va_arg(arp, TCHAR*); for (j = 0; p[j]; j++) ; - res = 0; - while (!(f & 2) && j++ < w) res += (cc = f_putc(' ', fil)); - res += (cc = f_puts(p, fil)); - while (j++ < w) res += (cc = f_putc(' ', fil)); - if (cc != EOF) cc = res; + chc = 0; + if (!(f & 2)) { + while (j++ < w) chc += (cc = f_putc(' ', fil)); + } + chc += (cc = f_puts(p, fil)); + while (j++ < w) chc += (cc = f_putc(' ', fil)); + if (cc != EOF) cc = chc; continue; case 'C' : /* Character */ cc = f_putc((TCHAR)va_arg(arp, int), fil); continue; @@ -3952,7 +4049,7 @@ int f_printf ( } /* Get an argument and put it in numeral */ - v = (f & 4) ? va_arg(arp, long) : ((d == 'D') ? (long)va_arg(arp, int) : va_arg(arp, unsigned int)); + v = (f & 4) ? (ULONG)va_arg(arp, long) : ((d == 'D') ? (ULONG)(long)va_arg(arp, int) : (ULONG)va_arg(arp, unsigned int)); if (d == 'D' && (v & 0x80000000)) { v = 0 - v; f |= 8; diff --git a/src/ff.h b/src/ff.h index a3aad84..b1ff465 100644 --- a/src/ff.h +++ b/src/ff.h @@ -1,5 +1,5 @@ /*---------------------------------------------------------------------------/ -/ FatFs - FAT file system module include file R0.08b (C)ChaN, 2011 +/ FatFs - FAT file system module include file R0.09 (C)ChaN, 2011 /----------------------------------------------------------------------------/ / FatFs module is a generic FAT file system module for small embedded systems. / This is a free software that opened for education, research and commercial @@ -15,7 +15,7 @@ /----------------------------------------------------------------------------*/ #ifndef _FATFS -#define _FATFS 8237 /* Revision ID */ +#define _FATFS 6502 /* Revision ID */ #ifdef __cplusplus extern "C" { @@ -33,17 +33,17 @@ extern "C" { /* Definitions of volume management */ #if _MULTI_PARTITION /* Multiple partition configuration */ -#define LD2PD(vol) (VolToPart[vol].pd) /* Get physical drive# */ -#define LD2PT(vol) (VolToPart[vol].pt) /* Get partition# */ typedef struct { - BYTE pd; /* Physical drive# */ - BYTE pt; /* Partition # (0-3) */ + BYTE pd; /* Physical drive number */ + BYTE pt; /* Partition: 0:Auto detect, 1-4:Forced partition) */ } PARTITION; -extern const PARTITION VolToPart[]; /* Volume - Physical location resolution table */ +extern PARTITION VolToPart[]; /* Volume - Partition resolution table */ +#define LD2PD(vol) (VolToPart[vol].pd) /* Get physical drive number */ +#define LD2PT(vol) (VolToPart[vol].pt) /* Get partition index */ #else /* Single partition configuration */ -#define LD2PD(vol) (vol) /* Logical drive# is bound to the same physical drive# */ -#define LD2PT(vol) 0 /* Always mounts the 1st partition */ +#define LD2PD(vol) (vol) /* Each logical drive is bound to the same physical drive number */ +#define LD2PT(vol) 0 /* Always mounts the 1st partition or in SFD */ #endif @@ -84,7 +84,7 @@ typedef struct { WORD id; /* File system mount ID */ WORD n_rootdir; /* Number of root directory entries (FAT12/16) */ #if _MAX_SS != 512 - WORD ssize; /* Bytes per sector (512,1024,2048,4096) */ + WORD ssize; /* Bytes per sector (512, 1024, 2048 or 4096) */ #endif #if _FS_REENTRANT _SYNC_t sobj; /* Identifier of sync object */ @@ -188,12 +188,13 @@ typedef enum { FR_WRITE_PROTECTED, /* (10) The physical drive is write protected */ FR_INVALID_DRIVE, /* (11) The logical drive number is invalid */ FR_NOT_ENABLED, /* (12) The volume has no work area */ - FR_NO_FILESYSTEM, /* (13) There is no valid FAT volume on the physical drive */ + FR_NO_FILESYSTEM, /* (13) There is no valid FAT volume */ FR_MKFS_ABORTED, /* (14) The f_mkfs() aborted due to any parameter error */ FR_TIMEOUT, /* (15) Could not get a grant to access the volume within defined period */ FR_LOCKED, /* (16) The operation is rejected according to the file shareing policy */ FR_NOT_ENOUGH_CORE, /* (17) LFN working buffer could not be allocated */ - FR_TOO_MANY_OPEN_FILES /* (18) Number of open files > _FS_SHARE */ + FR_TOO_MANY_OPEN_FILES, /* (18) Number of open files > _FS_SHARE */ + FR_INVALID_PARAMETER /* (19) Given parameter is invalid */ } FRESULT; @@ -218,25 +219,26 @@ FRESULT f_mkdir (const TCHAR*); /* Create a new directory */ FRESULT f_chmod (const TCHAR*, BYTE, BYTE); /* Change attriburte of the file/dir */ FRESULT f_utime (const TCHAR*, const FILINFO*); /* Change timestamp of the file/dir */ FRESULT f_rename (const TCHAR*, const TCHAR*); /* Rename/Move a file or directory */ -FRESULT f_forward (FIL*, UINT(*)(const BYTE*,UINT), UINT, UINT*); /* Forward data to the stream */ -FRESULT f_mkfs (BYTE, BYTE, UINT); /* Create a file system on the drive */ FRESULT f_chdrive (BYTE); /* Change current drive */ FRESULT f_chdir (const TCHAR*); /* Change current directory */ FRESULT f_getcwd (TCHAR*, UINT); /* Get current directory */ +FRESULT f_forward (FIL*, UINT(*)(const BYTE*,UINT), UINT, UINT*); /* Forward data to the stream */ +FRESULT f_mkfs (BYTE, BYTE, UINT); /* Create a file system on the drive */ +FRESULT f_fdisk (BYTE, const DWORD[], void*); /* Divide a physical drive into some partitions */ int f_putc (TCHAR, FIL*); /* Put a character to the file */ int f_puts (const TCHAR*, FIL*); /* Put a string to the file */ int f_printf (FIL*, const TCHAR*, ...); /* Put a formatted string to the file */ TCHAR* f_gets (TCHAR*, int, FIL*); /* Get a string from the file */ -#ifndef EOF -#define EOF (-1) -#endif - #define f_eof(fp) (((fp)->fptr == (fp)->fsize) ? 1 : 0) #define f_error(fp) (((fp)->flag & FA__ERROR) ? 1 : 0) #define f_tell(fp) ((fp)->fptr) #define f_size(fp) ((fp)->fsize) +#ifndef EOF +#define EOF (-1) +#endif + @@ -308,7 +310,7 @@ int ff_del_syncobj (_SYNC_t); /* Delete a sync object */ #define AM_MASK 0x3F /* Mask of defined bits */ -/* Fast seek function */ +/* Fast seek feature */ #define CREATE_LINKMAP 0xFFFFFFFF diff --git a/src/ffconf.h b/src/ffconf.h index 9ace5a0..8733943 100644 --- a/src/ffconf.h +++ b/src/ffconf.h @@ -1,5 +1,5 @@ /*---------------------------------------------------------------------------/ -/ FatFs - FAT file system module configuration file R0.08b (C)ChaN, 2011 +/ FatFs - FAT file system module configuration file R0.09 (C)ChaN, 2011 /----------------------------------------------------------------------------/ / / CAUTION! Do not forget to make clean the project after any changes to @@ -7,11 +7,11 @@ / /----------------------------------------------------------------------------*/ #ifndef _FFCONF -#define _FFCONF 8237 /* Revision ID */ +#define _FFCONF 6502 /* Revision ID */ /*---------------------------------------------------------------------------/ -/ Function and Buffer Configurations +/ Functions and Buffer Configurations /----------------------------------------------------------------------------*/ #define _FS_TINY 0 /* 0:Normal or 1:Tiny */ @@ -36,7 +36,7 @@ / 3: f_lseek is removed in addition to 2. */ -#define _USE_STRFUNC 0 /* 0:Disable or 1/2:Enable */ +#define _USE_STRFUNC 0 /* 0:Disable or 1-2:Enable */ /* To enable string functions, set _USE_STRFUNC to 1 or 2. */ @@ -137,7 +137,7 @@ / and GET_SECTOR_SIZE command must be implememted to the disk_ioctl function. */ -#define _MULTI_PARTITION 0 /* 0:Single partition or 1:Multiple partition */ +#define _MULTI_PARTITION 0 /* 0:Single partition, 1/2:Enable multiple partition */ /* When set to 0, each volume is bound to the same physical drive number and / it can mount only first primaly partition. When it is set to 1, each volume / is tied to the partitions listed in VolToPart[]. */ @@ -163,7 +163,8 @@ / When the byte order on the memory is big-endian or address miss-aligned word / access results incorrect behavior, the _WORD_ACCESS must be set to 0. / If it is not the case, the value can also be set to 1 to improve the -/ performance and code size. */ +/ performance and code size. +*/ /* A header file that defines sync object types on the O/S, such as