From 70702af1370e44e32fb2c3c507e4759a187b4fe5 Mon Sep 17 00:00:00 2001 From: Leo C Date: Thu, 8 Sep 2016 19:15:27 +0200 Subject: Import fatfs R0.12b --- fatfs/doc/en/appnote.html | 287 +++++++++++++++++++++++--------------------- fatfs/doc/en/chdir.html | 8 +- fatfs/doc/en/chdrive.html | 2 +- fatfs/doc/en/chmod.html | 6 +- fatfs/doc/en/close.html | 5 +- fatfs/doc/en/closedir.html | 4 +- fatfs/doc/en/config.html | 204 +++++++++++++++++++++++++++++++ fatfs/doc/en/dinit.html | 4 +- fatfs/doc/en/dioctl.html | 15 ++- fatfs/doc/en/dread.html | 12 +- fatfs/doc/en/dstat.html | 6 +- fatfs/doc/en/dwrite.html | 10 +- fatfs/doc/en/eof.html | 4 +- fatfs/doc/en/error.html | 4 +- fatfs/doc/en/expand.html | 116 ++++++++++++++++++ fatfs/doc/en/fattime.html | 8 +- fatfs/doc/en/fdisk.html | 25 ++-- fatfs/doc/en/filename.html | 53 ++++---- fatfs/doc/en/findfirst.html | 110 +++++++++++++++++ fatfs/doc/en/findnext.html | 69 +++++++++++ fatfs/doc/en/forward.html | 7 +- fatfs/doc/en/getcwd.html | 5 +- fatfs/doc/en/getfree.html | 4 +- fatfs/doc/en/getlabel.html | 4 +- fatfs/doc/en/gets.html | 6 +- fatfs/doc/en/lseek.html | 27 +++-- fatfs/doc/en/mkdir.html | 2 +- fatfs/doc/en/mkfs.html | 59 +++++---- fatfs/doc/en/mount.html | 22 ++-- fatfs/doc/en/open.html | 24 ++-- fatfs/doc/en/opendir.html | 4 +- fatfs/doc/en/printf.html | 8 +- fatfs/doc/en/putc.html | 10 +- fatfs/doc/en/puts.html | 10 +- fatfs/doc/en/rc.html | 73 +++++++---- fatfs/doc/en/read.html | 5 +- fatfs/doc/en/readdir.html | 64 +++++----- fatfs/doc/en/rename.html | 17 +-- fatfs/doc/en/sdir.html | 18 ++- fatfs/doc/en/setlabel.html | 10 +- fatfs/doc/en/sfatfs.html | 32 +++-- fatfs/doc/en/sfile.html | 22 ++-- fatfs/doc/en/sfileinfo.html | 33 +++-- fatfs/doc/en/size.html | 6 +- fatfs/doc/en/stat.html | 18 ++- fatfs/doc/en/sync.html | 5 +- fatfs/doc/en/tell.html | 4 +- fatfs/doc/en/truncate.html | 4 +- fatfs/doc/en/unlink.html | 4 +- fatfs/doc/en/utime.html | 4 +- fatfs/doc/en/write.html | 5 +- 51 files changed, 1002 insertions(+), 466 deletions(-) create mode 100644 fatfs/doc/en/config.html create mode 100644 fatfs/doc/en/expand.html create mode 100644 fatfs/doc/en/findfirst.html create mode 100644 fatfs/doc/en/findnext.html (limited to 'fatfs/doc/en') diff --git a/fatfs/doc/en/appnote.html b/fatfs/doc/en/appnote.html index fee2af9..4cd111f 100644 --- a/fatfs/doc/en/appnote.html +++ b/fatfs/doc/en/appnote.html @@ -15,9 +15,10 @@
  • How to Port
  • Limits
  • Memory Usage
  • -
  • Module Size Reduction
  • +
  • Reducing Module Size
  • Long File Name
  • Unicode API
  • +
  • exFAT File System
  • Re-entrancy
  • Duplicated File Access
  • Performance Effective File Access
  • @@ -26,9 +27,8 @@
  • Extended Use of FatFs API
  • About FatFs License
  • -
    -
    +

    How to Port

    Basic considerations

    @@ -37,193 +37,195 @@
  • ANSI C
    The FatFs module is a middleware written in ANSI C (C89). There is no platform dependence, so long as the compiler is in compliance with ANSI C.
  • Size of integer types
    -The FatFs module assumes that size of char/short/long are 8/16/32 bit and int is 16 or 32 bit. These correspondence are defined in integer.h. This will not be a problem on most compilers. When any conflict with existing definitions is occured, you must resolve it with care.
  • +The FatFs module assumes that size of char/short/long are 8/16/32 bit and int is 16 or 32 bit. These correspondence are defined in integer.h. This will not be a problem on most compilers. When a conflict with existing definitions is occured, you must resolve it with care.

    System organizations

    -

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

    -

    dependency diagram

    -

    (a) If a working disk module with FatFs API is provided, no additional function is needed. (b) To attach existing disk drivers with different API, glue functions are needed to translate the APIs between FatFs and the drivers.

    -

    functional diagram

    +

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

    +

    dependency diagram

    +

    (a) If a working disk module with FatFs disk interface is provided, nothing else will be needed. (b) To attach existing disk drivers with different interface, glue functions are needed to translate the interfaces between FatFs and the drivers.

    +

    functional 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. Most of defined functions are not that always required. For example, disk write function is not required in read-only configuration. Following table shows which function is required depends on configuration options.

    +

    The functions required

    +

    You need to provide only low level disk I/O functions required by FatFs module and nothing else. If a working disk module for the target system is already existing, you need to write only glue functions to attach it to the FatFs module. If not, you need to port any other disk module or write it from scratch. Most of defined functions are not that always required. For example, disk write function is not required at read-only configuration. Following table shows which function is required depends on the configuration options.

    - + - +
    FunctionRequired when:Note
    FunctionRequired whenNote
    disk_status
    disk_initialize
    disk_read
    AlwaysDisk I/O functions.
    Samples available in ffsample.zip.
    There are many implementations on the web.
    disk_write
    get_fattime
    disk_ioctl (CTRL_SYNC)
    _FS_READONLY == 0
    disk_ioctl (GET_SECTOR_COUNT)
    disk_ioctl (GET_BLOCK_SIZE)
    _USE_MKFS == 1
    disk_ioctl (GET_SECTOR_SIZE)_MAX_SS != _MIN_SS
    disk_ioctl (CTRL_TRIM)_USE_TRIM == 1
    ff_convert
    ff_wtoupper
    _USE_LFN >= 1Unicode support functions.
    Available in option/unicode.c.
    ff_convert
    ff_wtoupper
    _USE_LFN != 0Unicode support functions.
    Just add option/unicode.c to the project.
    ff_cre_syncobj
    ff_del_syncobj
    ff_req_grant
    ff_rel_grant
    _FS_REENTRANT == 1O/S dependent functions.
    Samples available in option/syscall.c.
    ff_mem_alloc
    ff_mem_free
    _USE_LFN == 3
    -
    +

    Limits

      -
    • FAT sub-types: FAT12, FAT16 and FAT32.
    • -
    • Number of open files: Unlimited, depends on available memory.
    • +
    • File system type: FAT12, FAT16, FAT32(r0.0) and exFAT(r1.0).
    • +
    • Number of open files: Unlimited. (depends on available memory)
    • Number of volumes: Upto 10.
    • -
    • File size: Depends on the FAT specs. (upto 4G-1 bytes)
    • -
    • Volume size: Depends on the FAT specs. (upto 2T bytes at 512 bytes/sector)
    • -
    • Cluster size: Depends on the FAT specs. (upto 64K bytes at 512 bytes/sector)
    • -
    • Sector size: Depends on the FAT specs. (512, 1024, 2048 and 4096 bytes)
    • +
    • Volume size: Upto 2 TiB at 512 bytes/sector.
    • +
    • File size: Upto 4 GiB - 1 on FAT volume and virtually unlimited on exFAT volume.
    • +
    • Cluster size: Upto 128 sectors on FAT volume and upto 16 MiB on exFAT volume.
    • +
    • Sector size: 512, 1024, 2048 and 4096 bytes.
    -
    +

    Memory Usage

    +

    The memory usage varies depends on the configuration options.

    - - - - - - - - - - + + + + + + + + +
    ARM7
    32bit
    ARM7
    Thumb
    CM3
    Thumb-2
    AVRH8/300HPIC24RL78V850ESSH-2ARX600IA-32
    CompilerGCCGCCGCCGCCCH38C30CC78K0RCA850SHCRXCVC6
    _WORD_ACCESS00010001011
    text (Full, R/W)1067571716617133551094011722132628113904860327952
    text (Min, R/W) 672746314331 8569 7262 7720 90885287580039485183
    text (Full, R/O) 473131472889 6235 5170 5497 64823833397228623719
    text (Min, R/O) 355924852295 4575 4064 4240 50192993310422142889
    bssV*4 + 2V*4 + 2V*4 + 2V*2 + 2V*4 + 2V*2 + 2V*2 + 2V*4 + 2V*4 + 2V*4 + 2V*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
    CompilerGCCGCCGCCGCCCH38C30CC78K0RCA850SHCRXCMSC
    text (Full, R/W)10.4k6.8k6.3k12.4k 9.8k11.1k12.8k8.6k8.9k6.4k8.5k
    text (Min, R/W) 6.8k4.6k4.3k 8.2k 6.7k 7.6k 9.1k6.0k5.9k4.5k5.9k
    text (Full, R/O) 4.8k3.1k2.8k 5.6k 4.6k 5.3k 6.3k4.0k3.9k3.0k3.9k
    text (Min, R/O) 3.6k2.4k2.3k 4.4k 3.5k 4.0k 4.9k3.3k3.0k2.4k3.1k
    bssV*4 + 2V*4 + 2V*4 + 2V*2 + 2V*4 + 2V*2 + 2V*2 + 2V*4 + 2V*4 + 2V*4 + 2V*4 + 2
    Work area
    (_FS_TINY == 0)
    V*564
    + F*552
    V*564
    + F*552
    V*564
    + F*552
    V*560
    + F*546
    V*560
    + F*546
    V*560
    + F*546
    V*560
    + F*546
    V*564
    + F*552
    V*564
    + F*552
    V*564
    + F*552
    V*564
    + F*552
    Work area
    (_FS_TINY == 1)
    V*564
    + F*40
    V*564
    + F*40
    V*564
    + F*40
    V*560
    + F*34
    V*560
    + F*34
    V*560
    + F*34
    V*560
    + F*34
    V*564
    + F*40
    V*564
    + F*40
    V*564
    + F*40
    V*564
    + F*40
    -

    These are the memory usage on some target systems with following condition. The memory sizes are in unit of byte, V denotes number of volumes and F denotes number of open files. All samples are optimezed in code size.

    +

    These are the memory usage on some target systems with following condition. The memory sizes are in unit of byte, V denotes option _VOLUMES and F denotes number of open files. All samples here are optimezed in code size.

    -FatFs R0.10a options:
    -_FS_READONLY     0 (R/W) or 1 (R/O)
    -_FS_MINIMIZE     0 (Full function) or 3 (Minimized function)
    -_USE_STRFUNC     0 (Disable string functions)
    -_USE_MKFS        0 (Disable f_mkfs function)
    -_USE_FORWARD     0 (Disable f_forward function)
    -_USE_FASTSEEK    0 (Disable fast seek feature)
    -_CODE_PAGE       932 (Japanese Shift_JIS)
    -_USE_LFN         0 (Disable LFN feature)
    -_MAX_SS          512 (Fixed sector size)
    -_FS_RPATH        0 (Disable relative path feature)
    -_FS_LABEL        0 (Disable volume label functions)
    -_VOLUMES         V (Number of logical drives to be used)
    -_MULTI_PARTITION 0 (Single partition per drive)
    -_FS_REENTRANT    0 (Disable thread safe)
    -_FS_LOCK         0 (Disable file lock control)
    +FatFs R0.12b options:
    +_FS_READONLY   0 (R/W) or 1 (R/O)
    +_FS_MINIMIZE   0 (Full, with all basic functions) or 3 (Min, with fully minimized)
    +_FS_TINY       0 (Default) or 1 (Tiny file object)
    +And other options are left unchanged from original setting.
     
    -
    -

    Module Size Reduction

    -

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

    +
    +

    Reducing Modle Size

    +

    Follwing table shows which API function is removed by configuration options for the module size reduction. To use any API function, the row of the function must be clear.

    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    Function_FS_MINIMIZE_FS_READONLY_USE_STRFUNC_FS_RPATH_FS_LABEL_USE_MKFS_USE_FORWARD_MULTI_PARTITION
    0123010  1/201201010101
    f_mount
    f_open
    f_close
    f_read
    f_writex
    f_syncx
    f_lseekx
    f_opendirxx
    f_closedirxx
    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_getlabelx
    f_setlabelxx
    f_forwardx
    f_mkfsxx
    f_fdiskxxx
    f_putcxx
    f_putsxx
    f_printfxx
    f_getsx
    Function_FS_
    MINIMIZE
    _FS_
    READONLY
    _USE_
    STRFUNC
    _FS_
    RPATH
    _USE_
    FIND
    _USE_
    CHMOD
    _USE_
    EXPAND
    _USE_
    LABEL
    _USE_
    MKFS
    _USE_
    FORWARD
    _MULTI_
    PARTITION
    0123010101201010101010101
    f_mount
    f_open
    f_close
    f_read
    f_write x
    f_sync x
    f_lseek x
    f_opendir xx
    f_closedir xx
    f_readdir xx
    f_findfirst xx x
    f_findnext xx x
    f_stat xxx
    f_getfree xxx x
    f_truncate xxx x
    f_unlink xxx x
    f_mkdir xxx x
    f_rename xxx x
    f_chdir x
    f_chdrive x
    f_getcwd xx
    f_chmod x x
    f_utime x x
    f_getlabel x
    f_setlabel x x
    f_expand x x
    f_forward x
    f_mkfs x x
    f_fdisk x x x
    f_putc xx
    f_puts xx
    f_printf xx
    f_gets x
    -
    +

    Long File Name

    -

    FatFs module supports LFN (long file name). The two different file names, SFN (short file name) and LFN, of a file is transparent on the API except for f_readdir() function. The LFN feature is disabled by default. To enable it, set _USE_LFN to 1, 2 or 3, and add option/unicode.c to the project. The LFN feature requiers a certain working buffer in addition. The buffer size can be configured by _MAX_LFN according to the available memory. The length of an LFN will reach up to 255 characters, so that the _MAX_LFN should be set to 255 for full featured LFN operation. If the size of working buffer is insufficient for the input file name, the file function fails with FR_INVALID_NAME. When enable the LFN feature under re-entrant configuration, _USE_LFN must be set to 2 or 3. In this case, the file function allocates the working buffer on the stack or heap. The working buffer occupies (_MAX_LFN + 1) * 2 bytes.

    +

    FatFs module supports long file name (LFN). The two different file names, short file name (SFN) and LFN, of a file is transparent on the API except for f_readdir function. The support for LFN is disabled by default. To enable the LFN, set _USE_LFN to 1, 2 or 3, and add option/unicode.c to the project. The LFN requiers a certain working buffer in addition. The buffer size can be configured by _MAX_LFN according to the available memory. The length of an LFN will be up to 255 characters, so that the _MAX_LFN should be set to 255 for all file names. If the size of working buffer is insufficient for the input file name, the file function fails with FR_INVALID_NAME. When use any re-entry to the API with LFN is enabled, _USE_LFN must be set to 2 or 3. In this case, the file function allocates the working buffer on the stack or heap. The working buffer occupies (_MAX_LFN + 1) * 2 bytes and additional 608 bytes when exFAT enabled.

    - - - - - - - + + + + + + +
    LFN cfg on ARM7TDMI
    Code pageProgram size
    SBCS+3.7K
    932(Shift_JIS)+62K
    936(GBK)+177K
    949(Korean)+139K
    950(Big5)+111K
    With LFN at CM3+gcc
    _CODE_PAGECode size
    SBCS+2.8K
    932(Japanese)+62.6k
    936(Simplified Chinese)+177k
    949(Korean)+139k
    950(Traditional Chinese)+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. Especially, in the CJK region, tens of thousands of characters are being used. Unfortunately, it requires a huge OEM-Unicode bidirectional conversion table and the module size will be drastically increased as shown in the table. As the result, the FatFs with LFN feature with those code pages will not able to be implemented to most 8-bit microcontrollers.

    -

    Note that the LFN feature on the FAT file system is a patent of Microsoft Corporation. This is not the case on FAT32 but most FAT32 drivers come with the LFN feature. FatFs can swich the LFN feature off by configuration option. When enable LFN feature on the commercial products, a license from Microsoft may be required depends on the final destination.

    +

    When the LFN is enabled, the module size will be increased depends on the configured code page. Right table shows how much code size increased when LFN is enabled with some code pages. Especially, in the CJK region, tens of thousands of characters are being used. Unfortunately, it requires a huge OEM-Unicode bidirectional conversion table and the module size will be drastically increased as shown in the table. As the result, the FatFs with LFN enebled with those code pages will not able to be ported on the most 8-bit MCU systems.

    +

    Note that the support for LFN on the FAT volume is a patent of Microsoft Corporation. This is not the case on FAT32 but most FAT32 drivers come with the support for LFN. FatFs can switch the LFN on/off by configuration option. When enable LFN on the commercial products, you will need to be licensed by Microsoft depends on the final destination of the products.

    -
    +

    Unicode API

    -

    By default, FatFs uses ANSI/OEM code set on the API under LFN configuration. FatFs can also switch the character encoding to Unicode on the API by _LFN_UNICODE option. This means that the FatFs supports the True-LFN feature. For more information, refer to the description in the file name.

    +

    By default, FatFs uses ANSI/OEM code set on the API even at LFN configuration. FatFs can also switch the character encoding on the API to Unicode by configuration option _LFN_UNICODE. This means that FatFs supports the full featured LFN specification. The data type TCHAR specifies strings on the API is an alias of char(ANSI/OEM) or WCHAR(UTF-16). For more information, refer to the description in the file name.

    -
    +
    +

    exFAT File System

    +

    The exFAT (Microsoft's Extended File Allocation Table) file system is a replacement of the FAT file system which has been widely used in the embedded systems and consumer devices. It is adopted by SDA (SD Association) as a recommended file system for high capacity SD cards (>32GB) and they are being shipped with this format, so that the exFAT will soon become one of the standard file systems for removable media.

    +

    The exFAT file system allows the file size larger than 4 GiB limit what FAT file system allows upto and some file system overhead, especially file allocation delay, are reduced as well. This feature improves the write throughput to the file. However a problem on the current implementation of FatFs is that write throughput at writing to the growing edge of the fragmented file gets less than the throughput on the FAT volume. Pre-allocating a contiguous block with f_expand function may be a workaround of this problem.

    +

    Note that the exFAT is a patent of Microsoft Corporation. The exFAT function of FatFs is an implementation based on US. Pat. App. Pub. No. 2009/0164440 A1. FatFs module can swich the exFAT on/off by configuration option. When enable the exFAT on the commercial products, you will need to be licensed by Microsoft depends on the final destination of the products.

    +

    Remark: Enabling exFAT discards C89 compatibility because of need for 64-bit integer type.

    + +

    Re-entrancy

    -

    The file operations to the different volume is always re-entrant and can work simultaneously. The file operations to the same volume is not re-entrant but it can also be configured to thread-safe by _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. There are some examples in the option/syscall.c.

    -

    When a file function is called while the volume is in use by any other task, the file function is suspended until that task leaves the file function. If wait time exceeded a period defined by _TIMEOUT, the file function will abort with FR_TIMEOUT. The timeout feature might not be supported by some RTOS.

    -

    There is an exception for f_mount(), f_mkfs(), f_fdisk() function. These functions are not re-entrant to the same volume or corresponding physical drive. When use these functions, all other tasks must unmount the volume and avoid to access the volume.

    -

    Note that this section describes on the re-entrancy of the FatFs module itself but also the low level disk I/O layer will need to be re-entrant.

    +

    The file operations to the different volume is always re-entrant regardless of configurations except when LFN enabled with static working buffer. It can work simultaneously without any mutual exclusion.

    +

    The file operations to the same volume is not re-entrant but it can also be configured thread-safe by option _FS_REENTRANT. It enables to control exclusive use of each file system object. In this case, also the OS dependent synchronization object control functions, ff_cre_syncobj/ff_del_syncobj/ff_req_grant/ff_rel_grant, needed to be added to the project. There are some examples in the option/syscall.c.

    +

    When a file function is called while the volume is being accessed by other task, the file function to the volume will be suspended until that task leaves the file function. If the wait time exceeded a period defined by _TIMEOUT, the file function will abort with FR_TIMEOUT. The timeout function might not be supported on the some RTOSs.

    +

    There is an exception on the re-entrancy for f_mount/f_mkfs/f_fdisk function. These volume management functions are not re-entrant to the same volume and corresponding physical drive. When use these functions, other tasks need to avoid to access the volume.

    +

    Note that this section describes on the re-entrancy of the FatFs module itself. The _FS_REENTRANT controls only exclusive use of each file system object and it does not that prevent to re-enter the low level disk functions. For example, only disk_status function can be re-entered at single volume system and any disk function can be re-entered at multiple volume system. Thus the low level disk I/O layer must be always thread-safe when any FatFs API is re-entered by two or more tasks.

    -
    +

    Duplicated File Access

    -

    FatFs module does not support the read/write collision control of duplicated open to a file. The duplicated open is permitted only when each of open method to a file is read mode. The duplicated open with one or more write mode to a file is always prohibited, and also open file must not be renamed and deleted. A violation of these rules can cause data colluption.

    -

    The file lock control can be enabled by _FS_LOCK option. The value of option defines the number of open objects to manage simultaneously. In this case, if any open, rename or remove that violating the file shareing rule that described above is attempted, the file function will fail with FR_LOCKED. If number of open objects, files and sub-directories, is equal to _FS_LOCK, an extra f_open(), f_optndir() function will fail with FR_TOO_MANY_OPEN_FILES.

    +

    FatFs module does not support the read/write collision control of duplicated open to a file. The duplicated open is permitted only when each of open method to a file is read mode. The duplicated open with one or more write mode to a file is always prohibited, and also open file must not be renamed or deleted. A violation of these rules can cause data colluption.

    +

    The file lock control can be enabled by _FS_LOCK option. The value of option defines the number of open objects to manage simultaneously. In this case, if any open, rename or remove that violating the file shareing rule that described above is attempted, the file function will rejected with FR_LOCKED. If number of open objects, files and sub-directories, is equal to _FS_LOCK, an extra f_open/f_opendir function will fail with FR_TOO_MANY_OPEN_FILES.

    -
    +

    Performance Effective File Access

    -

    For good read/write throughput on the small embedded systems with limited size of memory, application programmer should consider what process is done in the FatFs module. The file data on the volume is transferred in following sequence by f_read() function.

    +

    For good read/write throughput on the small embedded systems with limited size of memory, application programmer should consider what process is done in the FatFs module. The file data on the volume is transferred in following sequence by f_read function.

    Figure 1. Sector misaligned read (short)
    - +

    Figure 2. Sector misaligned read (long)
    - +

    Figure 3. Fully sector aligned read
    - +

    -

    The file I/O buffer is a sector buffer to read/write a partial data on the sector. The sector buffer is either file private sector buffer on each file object or shared sector buffer in the file system object. The buffer configuration option _FS_TINY determins which sector buffer is used for the file data transfer. When tiny buffer configuration (1) is selected, data memory consumption is reduced _MAX_SS bytes each file object. In this case, FatFs module uses only a sector buffer in the file system object for file data transfer and FAT/directory access. The disadvantage of the tiny buffer configuration is: the FAT data cached in the sector buffer will be lost by file data transfer and it must be reloaded at every cluster boundary. However it will be suitable for most application from view point of the decent performance and low memory comsumption.

    -

    Figure 1 shows that a partial sector, sector misaligned part of the file, is transferred via the file I/O buffer. At long data transfer shown in Figure 2, middle of transfer data that covers one or more sector is transferred to the application buffer directly. Figure 3 shows that the case of entier transfer data is aligned to the sector boundary. In this case, file I/O buffer is not used. On the direct transfer, the maximum extent of sectors are read with disk_read() function at a time but the multiple sector transfer is divided at cluster boundary even if it is contiguous.

    +

    The file I/O buffer is a sector buffer to read/write a part of data on the sector. The sector buffer is either file private sector buffer on each file object or shared sector buffer in the file system object. The buffer configuration option _FS_TINY determins which sector buffer is used for the file data transfer. When tiny buffer configuration (1) is selected, data memory consumption is reduced _MAX_SS bytes each file object. In this case, FatFs module uses only a sector buffer in the file system object for file data transfer and FAT/directory access. The disadvantage of the tiny buffer configuration is: the FAT data cached in the sector buffer will be lost by file data transfer and it must be reloaded at every cluster boundary. However it will be suitable for most application from view point of the decent performance and low memory comsumption.

    +

    Figure 1 shows that a partial sector, sector misaligned part of the file, is transferred via the file I/O buffer. At long data transfer shown in Figure 2, middle of transfer data that covers one or more sector is transferred to the application buffer directly. Figure 3 shows that the case of entier transfer data is aligned to the sector boundary. In this case, file I/O buffer is not used. On the direct transfer, the maximum extent of sectors are read with disk_read function at a time but the multiple sector transfer is divided at cluster boundary even if it is contiguous.

    Therefore taking effort to sector aligned read/write accesss eliminates buffered data transfer and the read/write performance will be improved. Besides the effect, cached FAT data will not be flushed by file data transfer at the tiny configuration, so that it can achieve same performance as non-tiny configuration with small memory footprint.

    -
    +

    Considerations on Flash Memory Media

    To maximize the write performance of flash memory media, such as SDC, CFC and U Disk, it must be controlled in consideration of its characteristitcs.

    Using Mutiple-Sector Write

    Figure 6. Comparison between Multiple/Single Sector Write
    -fig.6 +fig.6
    -

    The write throughput of the flash memory media becomes the worst at single sector write transaction. The write throughput increases as the number of sectors per a write transaction. This effect more appers at faster interface speed and the performance ratio often becomes grater than ten. This graph is clearly explaining how fast is multiple block write (W:16K, 32 sectors) than single block write (W:100, 1 sector), and also larger card tends to be slow at single block write. The number of write transactions also affects the life time of the flash memory media. Therefore the application program should write the data in large block as possible. The ideal write chunk size and alighment is size of sector, and size of cluster is the best. Of course all layers between the application and the storage device must have consideration on multiple sector write, however most of open-source disk drivers lack it. Do not split a multiple sector write request into single sector write transactions or the write throughput gets poor. Note that FatFs module and its sample disk drivers supprt multiple sector read/write feature.

    +

    The write throughput of the flash memory media becomes the worst at single sector write transaction. The write throughput increases as the number of sectors per a write transaction as shown in Figure 6. This effect more appers at faster interface speed and the performance ratio often becomes grater than ten. This graph is clearly explaining how fast is multiple block write (W:16K, 32 sectors) than single block write (W:100, 1 sector), and also larger card tends to be slow at single block write. Number of write transactions also affects life time of the flash memory media. When compared at same amount of write data, the single sector write in Figure 6 above wears flash memory media 16 times more than multiple sector write in Figure 6 below. Single sector write is pretty pain for the flash memory media.

    +

    Therefore the application program should write the data in large block as possible. The ideal write chunk size and alighment is size of sector, and size of cluster is the best. Of course all layers between the application and the storage device must have consideration on multiple sector write, however most of open-source memory card drivers lack it. Do not split a multiple sector write request into single sector write transactions or the write throughput gets poor. Note that FatFs module and its sample disk drivers supprt multiple sector read/write operation.

    Forcing Memory Erase

    -

    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 block'. If the file data is forced erased on removing the file, those data blocks will be turned in to the free block pool. This may skip internal block erase operation to the data block on next write operation. As the result the write performance might be improved. FatFs can manage this feature by setting _USE_TRIM to 1. Note that this is an expectation of internal process of the flash memory storage and not that always effective. Also f_remove() function will take a time when remove a large file. Most applications will not need this feature.

    +

    When remove a file with f_unlink function, the data clusters occupied by the file are marked 'free' on the FAT. But the data sectors containing the file data are not that applied any process, so that the file data left occupies a part of the flash memory array as 'live block'. If the file data can be erased on removing the file, those data blocks will be turned into the free block pool. This may skip internal block erase operation to the data block on next write operation. As the result the write performance might be improved. FatFs can manage this function by setting _USE_TRIM to 1. Note that this is an expectation of internal process of the storage device and not that always effective. Most applications will not need this function. Also f_unlink function can take a time when remove a large file.

    -
    +

    Critical Section

    -

    If a write operation to the FAT volume is interrupted due to any accidental failure, such as sudden blackout, incorrect disk removal and unrecoverable disk error, the FAT structure on the volume can be broken. Following images shows the critical section of the FatFs module.

    +

    If a write operation to the FAT volume is interrupted due to an accidental failure, such as sudden blackout, incorrect media removal and unrecoverable disk error, the FAT structure on the volume can be broken. Following images shows the critical section of the FatFs module.

    Figure 4. Long critical section
    -fig.4 +fig.4
    Figure 5. Minimized critical section
    -fig.5 +fig.5

    An interruption in the red section can cause a cross link; as a result, the object being changed can be lost. If an interruption in the yellow section is occured, there is one or more possibility listed below.

    @@ -234,42 +236,47 @@ Figure 5. Minimized critical section
  • The file created as new or overwritten remains but no content.
  • Efficiency of disk use gets worse due to lost clusters.
  • -

    Each case does not affect the files that not opened in write mode. To minimize risk of data loss, the critical section can be minimized by minimizing the time that file is opened in write mode or using f_sync() function as shown in Figure 5.

    +

    Each case does not affect the files that not opened in write mode. To minimize risk of data loss, the critical section can be minimized by minimizing the time that file is opened in write mode or using f_sync function as shown in Figure 5.

    -
    +

    Extended Use of FatFs API

    These are examples of extended use of FatFs APIs. New item will be added whenever a useful code is found.

      -
    1. Open or create a file for append
    2. -
    3. Empty a directory
    4. -
    5. Allocate contiguous area to the file
    6. -
    7. Function/Compatible checker for low level disk I/O module
    8. -
    9. FAT image creator
    10. +
    11. Open or create a file for append (for only R0.12 and earlier)
    12. +
    13. Empty a directory
    14. +
    15. Allocate contiguous area to the file (for only R0.11a and earlier)
    16. +
    17. Compatibility checker for low level disk I/O module
    18. +
    19. FAT image creator
    -
    +

    About FatFs License

    -

    FatFs has being developped as a personal project of author, ChaN. It is free from the code anyone else wrote. Following code block shows a copy of the FatFs license document that included in the source files.

    -
    /*----------------------------------------------------------------------------/
    -/  FatFs - FAT file system module  R0.10b                    (C)ChaN, 2014
    +

    FatFs has being developped as a personal project of the author, ChaN. It is free from the code anyone else wrote at current release. Following code block shows a copy of the FatFs license document that included in the source files.

    +
    +/*----------------------------------------------------------------------------/
    +/  FatFs - Generic FAT file system module  R0.12a                             /
     /-----------------------------------------------------------------------------/
    -/ FatFs module is a generic FAT file system module for small embedded systems.
    -/ This is a free software that opened for education, research and commercial
    -/ developments under license policy of following trems.
     /
    -/  Copyright (C) 2014, ChaN, all right reserved.
    +/ Copyright (C) 2016, ChaN, all right reserved.
     /
    -/ * The FatFs module is a free software and there is NO WARRANTY.
    -/ * No restriction on use. You can use, modify and redistribute it for
    -/   personal, non-profit or commercial products UNDER YOUR RESPONSIBILITY.
    -/ * Redistributions of source code must retain the above copyright notice.
    +/ FatFs module is an open source software. Redistribution and use of FatFs in
    +/ source and binary forms, with or without modification, are permitted provided
    +/ that the following condition is met:
    +
    +/ 1. Redistributions of source code must retain the above copyright notice,
    +/    this condition and the following disclaimer.
     /
    -/-----------------------------------------------------------------------------/
    -

    Therefore FatFs license is one of the BSD-style licenses but there is a significant feature. Because FatFs is mainly intended for embedded projects, the redistributions in binary form, such as embedded code or any forms without source code, need not to explain about FatFs in order to extend usability for commercial products. The documentation of the distributions need not include about FatFs and its license documents, and it may also. This is equivalent to the BSD 1-Clause License. Of course FatFs is compatible with the projects under GNU GPL. When redistribute the FatFs with any modification or branch it as a fork, the license can also be changed to GNU GPL, BSD-style license or any free software licenses that not conflict with FatFs license.

    +/ This software is provided by the copyright holder and contributors "AS IS" +/ and any warranties related to this software are DISCLAIMED. +/ The copyright owner or contributors be NOT LIABLE for any damages caused +/ by use of this software. +/----------------------------------------------------------------------------*/ +
    +

    Therefore FatFs license is one of the BSD-style licenses but there is a significant feature. FatFs is mainly intended for embedded systems. In order to extend the usability for commercial products, the redistributions of FatFs in binary form, such as embedded code, binary library and any forms without source code, does not need to include about FatFs in the documentations. This is equivalent to the 1-clause BSD license. Of course FatFs is compatible with the most open source software licenses including GNU GPL. When you redistribute the FatFs source code with any changes or create a fork, the license can also be changed to GNU GPL, BSD-style license or any open source software licenses that not conflict with FatFs license.

    -

    Return

    +

    Return Home

    diff --git a/fatfs/doc/en/chdir.html b/fatfs/doc/en/chdir.html index 063b8f5..41935fc 100644 --- a/fatfs/doc/en/chdir.html +++ b/fatfs/doc/en/chdir.html @@ -25,7 +25,7 @@ FRESULT f_chdir (

    Parameters

    path
    -
    Pointer to the null-terminated string that specifies a directory to go.
    +
    Pointer to the null-terminated string that specifies the directory to go.
    @@ -50,7 +50,7 @@ FRESULT f_chdir (

    Description

    -

    The f_chdir() function changes the current directory of the logical drive. The current directory of a drive is initialized to the root directory when the drive is auto-mounted. Note that the current directory is retained in the each file system object so that it also affects other tasks that using the volume.

    +

    The f_chdir function changes the current directory of the logical drive. The current directory of a drive is set to the root directory when the drive is mounted. Note that the current directory is retained in the each file system object, so that it also affects other tasks that use the volume.

    @@ -63,10 +63,10 @@ FRESULT f_chdir (

    Example

    -    /* Change current direcoty of the current drive (dir1 under root dir) */
    +    /* Change current direcoty of the current drive ('dir1' under root directory) */
         f_chdir("/dir1");
     
    -    /* Change current direcoty of drive 2 (parent dir) */
    +    /* Change current direcoty of drive 2 (parent directory) */
         f_chdir("2:..");
     
    diff --git a/fatfs/doc/en/chdrive.html b/fatfs/doc/en/chdrive.html index 665e543..7950994 100644 --- a/fatfs/doc/en/chdrive.html +++ b/fatfs/doc/en/chdrive.html @@ -41,7 +41,7 @@ FRESULT f_chdrive (

    Description

    -

    The f_chdrive() function changes the current drive. The initial value of the current drive number is 0. Note that the current drive is retained in a static variable so that it also affects other tasks that using the file functions.

    +

    The f_chdrive function changes the current drive. The initial value of the current drive number is 0. Note that the current drive is retained in a static variable so that it also affects other tasks that using the file functions.

    diff --git a/fatfs/doc/en/chmod.html b/fatfs/doc/en/chmod.html index 6d53974..6a3ffd0 100644 --- a/fatfs/doc/en/chmod.html +++ b/fatfs/doc/en/chmod.html @@ -66,13 +66,13 @@ FRESULT f_chmod (

    Description

    -

    The f_chmod() function changes the attribute of a file or sub-directory.

    +

    The f_chmod function changes the attribute of a file or sub-directory.

    QuickInfo

    -

    Available when _FS_READONLY == 0 and _FS_MINIMIZE == 0.

    +

    Available when _FS_READONLY == 0 and _USE_CHMOD == 1.

    @@ -80,7 +80,7 @@ FRESULT f_chmod (

    Example

         /* Set read-only flag, clear archive flag and others are left unchanged. */
    -    f_chmod("file.txt", AR_RDO, AR_RDO | AR_ARC);
    +    f_chmod("file.txt", AM_RDO, AM_RDO | AM_ARC);
     
    diff --git a/fatfs/doc/en/close.html b/fatfs/doc/en/close.html index f3423fa..c16dfa6 100644 --- a/fatfs/doc/en/close.html +++ b/fatfs/doc/en/close.html @@ -36,7 +36,6 @@ FRESULT f_close ( FR_OK, FR_DISK_ERR, FR_INT_ERR, -FR_NOT_READY, FR_INVALID_OBJECT, FR_TIMEOUT

    @@ -45,8 +44,8 @@ FRESULT f_close (

    Description

    -

    The f_close() function closes an open file object. If any data has been written to the file, the cached information of the file is written back to the volume. After the function succeeded, the file object is no longer valid and it can be discarded.

    -

    Note that if the file object is in read-only mode and _FS_LOCK option is not enabled, the file object can also be discarded without this process. However this is not recommended for future compatibility.

    +

    The f_close function closes an open file object. If any data has been written to the file, the cached information of the file is written back to the volume. After the function succeeded, the file object is no longer valid and it can be discarded.

    +

    Note that if the file object is in read-only mode and _FS_LOCK is not enabled, the file object can also be discarded without this process. However this is not recommended for future compatibility.

    diff --git a/fatfs/doc/en/closedir.html b/fatfs/doc/en/closedir.html index 4f97b6b..253d67a 100644 --- a/fatfs/doc/en/closedir.html +++ b/fatfs/doc/en/closedir.html @@ -43,8 +43,8 @@ FRESULT f_closedir (

    Description

    -

    The f_closedir() function closes an open directory object. After the function succeeded, the directory object is no longer valid and it can be discarded.

    -

    Note that the directory object can also be discarded without this process if _FS_LOCK option is not enabled. However this is not recommended for future compatibility.

    +

    The f_closedir function closes an open directory object. After the function succeeded, the directory object is no longer valid and it can be discarded.

    +

    Note that the directory object can also be discarded without this process when option _FS_LOCK is not enabled. However this is not recommended for future compatibility.

    diff --git a/fatfs/doc/en/config.html b/fatfs/doc/en/config.html new file mode 100644 index 0000000..395369f --- /dev/null +++ b/fatfs/doc/en/config.html @@ -0,0 +1,204 @@ + + + + + + + + +FatFs - Configuration Options + + + +

    Configuration Options

    +

    There are many options to configure the functions of FatFs for each project. The configuration options are defined in the ffconf.h.

    + +
    +

    Function Configurations

    + +

    _FS_READONLY

    +

    Read/Write (0) or Read-only (1). Read-only configuration removes writing API functions, f_write, f_sync, f_unlink, f_mkdir, f_chmod, f_rename, f_truncate, f_getfree and optional writing functions as well.

    + +

    _FS_MINIMIZE

    +

    This option defines minimization level to remove some basic API functions as follows:

    + + + + + + +
    ValueDescription
    0All basic API functions are available.
    1f_stat, f_getfree, f_unlink, f_mkdir, f_chmod, f_utime, f_truncate and f_rename function are removed.
    2f_opendir, f_readdir and f_closedir function are removed in addition to 1.
    3f_lseek function is removed in addition to 2.
    + +

    _USE_STRFUNC

    +

    This option switches string functions, f_gets, f_putc, f_puts and f_printf.

    + + + + + +
    ValueDescription
    0Disable string functions.
    1Enable string functions without LF-CRLF conversion.
    2Enable string functions with LF-CRLF conversion.
    + +

    _USE_FIND

    +

    Disable (0) or Enable (1) filtered directory read functions, f_findfirst and f_findnext. Also _FS_MINIMIZE needs to be 0 or 1.

    + +

    _USE_MKFS

    +

    Disable (0) or Enable (1) f_mkfs function.

    + +

    _USE_FASTSEEK

    +

    Disable (0) or Enable (1) fast seek function to enable accelerated mode for f_lseek, f_read and f_write function. For more information, read here.

    + +

    _USE_EXPAND

    +

    Disable (0) or Enable (1) , f_enpand function. Also _FS_READONLY needs to be 0.

    + +

    _USE_CHMOD

    +

    Disable (0) or Enable (1) metadata control functions, f_chmod and f_utime. Also _FS_READONLY needs to be 0.

    + +

    _USE_LABEL

    +

    Disable (0) or Enable (1) API functions for volume label, f_getlabel and f_setlabel.

    + +

    _USE_FORWARD

    +

    Disable (0) or Enable (1) f_forward function.

    + +
    + + +
    +

    Namespace and Locale Configurations

    + +

    _CODE_PAGE

    +

    This option specifies the OEM code page to be used on the target system. Incorrect setting of the code page can cause a file open failure. If any extended character is not used at all, there is no difference between any code pages.

    + + + + + + + + + + + + + + + + + + + + + + + + +
    ValueDescription
    1ASCII (valid at non-LFN cfg.)
    437U.S.
    720Arabic
    737Greek
    771KBL
    775Baltic
    850Latin 1
    852Latin 2
    855Cyrillic
    857Turkish
    860Portuguese
    861Icelandic
    862Hebrew
    863Canadian French
    864Arabic
    865Nordic
    866Russian
    869Greek 2
    932Japanese (DBCS)
    936Simplified Chinese (DBCS)
    949Korean (DBCS)
    950Traditional Chinese (DBCS)
    + +

    _USE_LFN

    +

    This option switches the support for long file name (LFN). When enable the LFN, Unicode support functions option/unicode.c need to be added to the project. The working buffer occupies (_MAX_LFN + 1) * 2 bytes and additional 608 bytes when exFAT enabled. When use stack for the working buffer, take care on stack overflow. When use heap memory for the working buffer, memory management functions, ff_memalloc and ff_memfree, need to be added to the project.

    + + + + + + +
    ValueDescription
    0Disable LFN. Only 8.3 format can be used.
    1Enable LFN with static working buffer on the BSS. Always NOT thread-safe.
    2Enable LFN with dynamic working buffer on the STACK.
    3Enable LFN with dynamic working buffer on the HEAP.
    + +

    _MAX_LFN

    +

    This option defines the size of LFN working buffer from 12 to 255 in unit of character. This option has no effect when LFN is disabled.

    + +

    _LFN_UNICODE

    +

    ANSI/OEM (0) or Unicode (1). This option switches character encoding on the API. To use Unicode (UTF16) string for the path name, enable LFN and set this option to 1. This option also affects behavior of string I/O functions. When LFN is disabled, this option must be 0. For more information, read here.

    + +

    _STRF_ENCODE

    +

    When Unicode API is selected by setting _LFN_UNICODE 1, this option defines the assumption of character encoding on the file to be read/written via string I/O functions, f_gets, f_putc, f_puts and f_printf. This option has no effect when _LFN_UNICODE = 0.

    + + + + + + +
    ValueDescription
    0ANSI/OEM
    1UTF-16LE
    2UTF-16BE
    3UTF-8
    + +

    _FS_RPATH

    +

    This option configures relative path function. For more information, read here.

    + + + + + +
    ValueDescription
    0Disable relative path function and remove related functions.
    1Enable relative path function. f_chdir and f_chdrive function is available.
    2f_getcwd function is available in addition to 1
    + +
    + + +
    +

    Volume/Drive Configurations

    + +

    _VOLUMES

    +

    This option configures number of volumes (logical drives, from 1 to 10) to be used.

    + +

    _STR_VOLUME_ID

    +

    Disable (0) or Enable (1). This option switches the support for string volume ID. When enabled, also pre-defined strings in _VOLUME_STRS can be used as drive identifier in the path name.

    + +

    _VOLUME_STRS

    +

    This option defines the drive ID strings for each logical drives. Number of items must not be less than _VOLUMES. Valid characters for the drive ID string are: A-Z and 0-9.

    + +

    _MULTI_PARTITION

    +

    Disable (0) or Enable (1). This option switches multi-partition function. By default (0), each logical drive number is bound to the same physical drive number and only an FAT volume in the physical drive is mounted. When enabled, each logical drive is bound to the partition on the physical drive listed in the user defined partition resolution table VolToPart[]. Also f_fdisk funciton will be available. For more information, read here.

    + +

    _MIN_SS, _MAX_SS

    +

    This set of options defines the size of sector on low level disk I/O interface, disk_read and disk_write function. Valid values are 512, 1024, 2048 and 4096. _MIN_SS defines minimum sector size and _MAX_SS defines the maximum sector size. Always set both 512 for any type of memory card and harddisk. But a larger value may be required for on-board flash memory and some type of optical media. When _MAX_SS > _MIN_SS, FatFs is configured to variable sector size and GET_SECTOR_SIZE command must be implemented to the disk_ioctl function.

    + +

    _USE_TRIM

    +

    Disable (0) or Enable (1). This option switches ATA-TRIM function. To enable Trim function, also CTRL_TRIM command should be implemented to the disk_ioctl function.

    + +

    _FS_NOFSINFO

    +

    0 to 3. If you need to know correct free space on the FAT32 volume, set bit 0 of this option, and f_getfree function at first time after volume mount will force a full FAT scan. Bit 1 controls the use of last allocated cluster number.

    + + + + + + +
    ValueDescription
    bit0=0Use free cluster count in the FSINFO if available.
    bit0=1Do not trust free cluster count in the FSINFO.
    bit1=0Use last allocated cluster number in the FSINFO to find a free cluster if available.
    bit1=1Do not trust last allocated cluster number in the FSINFO.
    + +
    + + +
    +

    System Configurations

    + +

    _FS_TINY

    +

    Normal (0) or Tiny (1). At the tiny configuration, size of the file object FIL is reduced _MAX_SS bytes. Instead of private data buffer eliminated from the file object, common sector buffer in the file system object FATFS is used for the file data transfer.

    + +

    _FS_EXFAT

    +

    This option switches support for the exFAT file system in addition to the FAT file system, Enabled(1) or Disabled(1). To enable this feature, also LFN must be enabled and configureing _LFN_UNICODE = 1 and _MAX_LFN = 255 is recommended for full-featured exFAT function. Note that enabling exFAT discards C89 compatibility because of need for 64-bit integer type.

    + +

    _FS_NORTC

    +

    Use RTC (0) or Do not use RTC (1). This option controls timestamp function. If the system does not have an RTC function or valid timestamp is not needed, set _FS_NORTC to 1 to disable the timestamp function. Any object modified by FatFs will have a fixed timestamp defined by _NORTC_MON, _NORTC_MDAY and _NORTC_YEAR. To use the timestamp function, set _FS_NORTC = 0 and add get_fattime function to the project to get the current time form real-time clock. This option has no effect at read-only configuration.

    + +

    _NORTC_MON, _NORTC_MDAY, _NORTC_YEAR

    +

    This set of options defines the time to be used at no RTC systems. This option has no effect at read-only configuration or _FS_NORTC = 0.

    + +

    _FS_LOCK

    +

    This option switches file lock function to control duplicated file open and illegal operations to open objects. Note that the file lock function is independent of re-entrancy. This option must be 0 at read-only configuration.

    + + + + +
    ValueDescription
    0Disable file lock function. To avoid collapsing file by wrong file operation, application program needs to avoid illegal open, remove and rename to the open objects.
    >0Enable file lock function. The value defines how many files/sub-directories can be opened simultaneously under the file lock control. Illigal operations to the open object will be rejected with FR_LOCKED.
    + +

    _FS_REENTRANT

    +

    Disable (0) or Enable (1). This option switches the re-entrancy (thread safe) of the FatFs module itself. Note that file/directory access to the different volume is always re-entrant and it can work simultaneously regardless of this option but volume control functions. f_mount, f_mkfs and f_fdisk, are always not re-entrant. Only file/directory access to the same volume, in other words, exclusive use of each file system object, is under control of this function. To enable this feature, also user provided synchronization handlers, ff_req_grant, ff_rel_grant, ff_del_syncobj and ff_cre_syncobj, need to be added to the project. Sample code is available in option/syscall.c.

    + +

    _FS_TIMEOUT

    +

    Number of time ticks to abort the file function with FR_TIMEOUT when wait time is too long. This option has no effect when _FS_REENTRANT = 0.

    + +

    _SYNC_t

    +

    This option defines O/S dependent sync object type. e.g. HANDLE, ID, OS_EVENT*, SemaphoreHandle_t and etc. A header file for O/S definitions needs to be included somewhere in the scope of ff.c. This option has no effect when _FS_REENTRANT = 0.

    + +
    + +

    Return

    + + diff --git a/fatfs/doc/en/dinit.html b/fatfs/doc/en/dinit.html index a85eecd..4a003e7 100644 --- a/fatfs/doc/en/dinit.html +++ b/fatfs/doc/en/dinit.html @@ -32,13 +32,13 @@ DSTATUS disk_initialize (

    Return Values

    -

    This function returns the current drive status flags as the result. For details of the drive status, refer to the disk_status() function.

    +

    This function returns the current drive status flags as the result. For details of the drive status, refer to the disk_status function.

    Description

    This function initializes the storage device and put it ready to generic read/write. When the function succeeded, STA_NOINIT flag in the return value is cleared.

    -

    Application program MUST NOT call this function, or FAT structure on the volume can be broken. To re-initialize the file system, use f_mount() function instead. This function is called at volume mount process by FatFs module to manage the media change.

    +

    Remarks: This function needs to be under control of FatFs module. Application program MUST NOT call this function, or FAT structure on the volume can be broken. To re-initialize the file system, use f_mount function instead.

    Return

    diff --git a/fatfs/doc/en/dioctl.html b/fatfs/doc/en/dioctl.html index 8fe62ec..7c69251 100644 --- a/fatfs/doc/en/dioctl.html +++ b/fatfs/doc/en/dioctl.html @@ -13,7 +13,7 @@

    disk_ioctl

    -

    The disk_ioctl function cntrols device specific features and miscellaneous functions other than generic read/write.

    +

    The disk_ioctl function controls device specific features and miscellaneous functions other than generic read/write.

     DRESULT disk_ioctl (
       BYTE pdrv,     /* [IN] Drive number */
    @@ -57,11 +57,11 @@ DRESULT disk_ioctl (
     
    -
    -
    +
    +
    -
    -
    +
    +
    Standard ioctl command used by FatFs
    CommandDescription
    CTRL_SYNCMake sure that the device has finished pending write process. If the disk I/O module has a write back cache, the dirty buffers must be written back to the media immediately. Nothing to do for this command if each write operation to the media is completed within the disk_write() function.
    GET_SECTOR_COUNTReturns number of available sectors on the drive into the DWORD variable pointed by buff. This command is used by only f_mkfs() and f_fdisk() function to determine the volume/partition size to be created. Required at _USE_MKFS == 1 or _MULTI_PARTITION == 1.
    CTRL_SYNCMake sure that the device has finished pending write process. If the disk I/O module has a write back cache, the dirty buffers must be written back to the media immediately. Nothing to do for this command if each write operation to the media is completed within the disk_write function.
    GET_SECTOR_COUNTReturns number of available sectors on the drive into the DWORD variable pointed by buff. This command is used by only f_mkfs and f_fdisk function to determine the volume/partition size to be created. Required at _USE_MKFS == 1 or _MULTI_PARTITION == 1.
    GET_SECTOR_SIZEReturns sector size of the media into the WORD variable pointed by buff. Valid return values of this command are 512, 1024, 2048 and 4096. This command is required only at variable sector size configuration, _MAX_SS > _MIN_SS. At fixed sector size configuration, _MAX_SS == _MIN_SS, this command is not used and the device must work at that sector size.
    GET_BLOCK_SIZEReturns erase block size of the flash memory media in unit of sector into the DWORD variable pointed by buff. The allowable value is from 1 to 32768 in power of 2. Return 1 if the erase block size is unknown or non flash memory media. This command is used by only f_mkfs() function and it attempts to align data area to the erase block boundary. Required at _USE_MKFS == 1.
    CTRL_TRIMInforms the device the data on the block of sectors that specified by DWORD array {<start sector>, <end sector>} pointed by buff is no longer needed and it may be erased. This is an identical command to Trim of ATA device. When this feature is not supported or not a flash memory device, nothing to do for this command. The FatFs does not check the result code and the file function is not affected even if the sector block was not erased well. This command is called on removing a cluster chain and f_mkfs() function. Required at _USE_TRIM == 1.
    GET_BLOCK_SIZEReturns erase block size of the flash memory media in unit of sector into the DWORD variable pointed by buff. The allowable value is from 1 to 32768 in power of 2. Return 1 if the erase block size is unknown or non flash memory media. This command is used by only f_mkfs function and it attempts to align data area to the erase block boundary. Required at _USE_MKFS == 1.
    CTRL_TRIMInforms the device the data on the block of sectors that specified by DWORD array {<start sector>, <end sector>} pointed by buff is no longer needed and it may be erased. This is an identical command to Trim of ATA device. Nothing to do for this command if this funcion is not supported or not a flash memory device. The FatFs does not check the result code and the file function is not affected even if the sector block was not erased well. This command is called on remove a cluster chain and in the f_mkfs function. Required at _USE_TRIM == 1.

    FatFs never uses any device dependent command nor user defined command. Following table shows an example of non-standard commands usable for some applications.

    @@ -70,7 +70,7 @@ DRESULT disk_ioctl ( CommandDescription CTRL_FORMATCreate a physical format on the media. If buff is not null, it is pointer to the call-back function for progress notification. CTRL_POWER_IDLEPut the device idle state. STA_NOINIT in status flag may not be set if the device goes active state by generic read/write function. -CTRL_POWER_OFFPut the device off state. Shut-down the power to the device and deinitialize the device interface if needed. STA_NOINIT in status flag must be set. The device goes active state by disk_initialize() function. +CTRL_POWER_OFFPut the device off state. Shut-down the power to the device and deinitialize the device interface if needed. STA_NOINIT in status flag must be set. The device goes active state by disk_initialize function. CTRL_LOCKLock media eject mechanism. CTRL_UNLOCKUnlock media eject mechanism. CTRL_EJECTEject media cartridge. STA_NOINIT and STA_NODISK in status flag are set after the function succeeded. @@ -82,6 +82,9 @@ DRESULT disk_ioctl ( ATA_GET_REVGet the revision string into a 16-byte buffer pointed by buff. (ATA/CFC specific command) ATA_GET_MODELGet the model string into a 40-byte buffer pointed by buff. (ATA/CFC specific command) ATA_GET_SNGet the serial number string into a 20-byte buffer pointed by buff. (ATA/CFC specific command) +ISDIO_READRead a block of iSDIO registers specified by command structure pointed by buff. (FlashAir specific command) +ISDIO_WRITEWrite a block of data to iSDIO registers specified by command structure pointed by buff. (FlashAir specific command) +ISDIO_MRITEChange bits in an iSDIO register specified by command structure pointed by buff. (FlashAir specific command)
    diff --git a/fatfs/doc/en/dread.html b/fatfs/doc/en/dread.html index 2e7c279..e7c2d7d 100644 --- a/fatfs/doc/en/dread.html +++ b/fatfs/doc/en/dread.html @@ -30,11 +30,11 @@ DRESULT disk_read (
    pdrv
    Physical drive number to identify the target device.
    buff
    -
    Pointer to the byte array to store the read data.
    +
    Pointer to the first item of the byte array to store read data.
    sector
    Start sector number in 32-bit LBA.
    count
    -
    Number of sectors to read in range of from 1 to 128..
    +
    Number of sectors to read.
    @@ -56,12 +56,12 @@ DRESULT disk_read (

    Description

    -

    The data read/write operation to the storage devices is done in unit of sector. FatFs supports the sector size in range of from 512 to 4096 bytes. When FatFs is configured to fixed sector size (_MIN_SS == MAX_SS, this will be the most case), the read/write function must work at that sector size. If variable sector size is selected (_MIN_SS < MAX_SS), FatFs inquires the sector size with disk_ioctl() after initialization. -

    The memory address specified by buff is not that always aligned to word boundary because the argument is defined as BYTE*. The misaligned read/write request can occure at direct transfer. If the bus architecture, especially DMA controller, does not allow misaligned memory access, it should be solved in this function. There are some workarounds described below to avoid this issue.

    +

    The data read/write operation to the storage devices is done in unit of sector. FatFs supports the sector size in range of from 512 to 4096 bytes. When FatFs is configured to fixed sector size (_MIN_SS == MAX_SS, this will be the most case), the read/write function must work at that sector size. When FatFs is configured to variable sector size (_MIN_SS != MAX_SS), sector size is inquired with disk_ioctl function following disk_initialize function.

    +

    The memory address specified by buff is not that always aligned to word boundary because the argument is defined as BYTE*. The unaligned read/write request can occure at direct transfer. If the bus architecture, especially DMA controller, does not allow unaligned memory access, it should be solved in this function. There are some workarounds described below to avoid this issue.

    • Convert word transfer to byte transfer in this function if needed. - Recommended.
    • -
    • For f_read(), avoid long read request that includes a whole of sector. - Direct transfer will never occure.
    • -
    • For f_read(fp, buff, btr, &br), make sure that (((UINT)buff & 3) == (f_tell(fp) & 3)) is true. - Word aligned direct transfer is guaranteed.
    • +
    • On the f_read calls, avoid long read request that includes a whole of sector. - Any direct transfer never occures.
    • +
    • On the f_read calls, make sure that (((UINT)data & 3) == (f_tell(fp) & 3)) is true. - Word alignment of buff is guaranteed.

    Generally, a multiple sector transfer request must not be split into single sector transactions to the storage device, or you will not get good read throughput.

    diff --git a/fatfs/doc/en/dstat.html b/fatfs/doc/en/dstat.html index c8204cc..0751460 100644 --- a/fatfs/doc/en/dstat.html +++ b/fatfs/doc/en/dstat.html @@ -35,11 +35,11 @@ DSTATUS disk_status (

    The current drive status is returned in combination of status flags described below. FatFs refers only STA_NOINIT and STA_PROTECT.

    STA_NOINIT
    -
    Indicates that the device is not initialized. This flag is set on system reset, media removal or failure of disk_initialize() function. It 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. If the system does not support media change detect feature, application program needs to force de-initialize the file system object with f_mount() function after the media change.
    +
    Indicates that the device is not initialized and not ready to work. This flag is set on system reset, media removal or failure of disk_initialize function. It is cleared on disk_initialize function succeeded. Any media change that occurs asynchronously must be captured and reflect it to the status flags, or auto-mount function will not work correctly. If the system does not support media change detection, application program needs to force de-initialize the file system object and re-mount the volume with f_mount function after each media change.
    STA_NODISK
    -
    Indicates that no medium in the drive. This is always cleared on fixed disk drive. Note that FatFs does not refer this flag.
    +
    Indicates that no medium in the drive. This is always cleared at fixed disk drive. Note that FatFs does not refer this flag.
    STA_PROTECT
    -
    Indicates that the medium is write protected. This is always cleared on the drives without write protect feature. Not valid if no medium in the drive.
    +
    Indicates that the medium is write protected. This is always cleared at the drives without write protect function. Not valid if no medium in the drive.
    diff --git a/fatfs/doc/en/dwrite.html b/fatfs/doc/en/dwrite.html index fd4bf48..b97f177 100644 --- a/fatfs/doc/en/dwrite.html +++ b/fatfs/doc/en/dwrite.html @@ -30,11 +30,11 @@ DRESULT disk_write (
    pdrv
    Physical drive number to identify the target device.
    buff
    -
    Pointer to the byte array to be written. The size of data to be written is sector size * count bytes.
    +
    Pointer to the first item of the byte array to be written. The size of data to be written is sector size * count bytes.
    sector
    Start sector number in 32-bit LBA.
    count
    -
    Number of sectors to write in range of from 1 to 128.
    +
    Number of sectors to write.
    @@ -58,10 +58,10 @@ DRESULT disk_write (

    Description

    -

    The specified memory address is not that always aligned to word boundary because the type of pointer is defined as BYTE*. For more information, refer to the description of disk_read() function.

    +

    The specified memory address is not that always aligned to word boundary because the type of pointer is defined as BYTE*. For more information, refer to the description of disk_read function.

    Generally, a multiple sector transfer request must not be split into single sector transactions to the storage device, or you will never get good write throughput.

    -

    FatFs expects delayed write feature of the disk functions. The write operation to the media need not to be completed due to write operation is in progress or only stored it into the cache buffer when return from this function. But data on the buff is invalid after return from this function. The write completion request is done by CTRL_SYNC command of disk_ioctl() function. Therefore, if delayed write feature is implemented, the write throughput may be improved.

    -

    Application program MUST NOT call this function, or FAT structure on the volume can be collapsed.

    +

    FatFs expects delayed write function of the disk control layer. The write operation to the media does not need to be completed when return from this function by what write operation is in progress or data is only stored into the write-back cache. But write data on the buff is invalid after return from this function. The write completion request is done by CTRL_SYNC command of disk_ioctl function. Therefore, if a delayed write function is implemented, the write throughput will be improved.

    +

    Remarks: Application program MUST NOT call this function, or FAT structure on the volume can be collapsed.

    diff --git a/fatfs/doc/en/eof.html b/fatfs/doc/en/eof.html index 337697b..2e87506 100644 --- a/fatfs/doc/en/eof.html +++ b/fatfs/doc/en/eof.html @@ -33,13 +33,13 @@ int f_eof (

    Return Values

    -

    The f_eof() function returns a non-zero value if the read/write pointer has reached end of the file; otherwise it returns a zero.

    +

    The f_eof function returns a non-zero value if the read/write pointer has reached end of the file; otherwise it returns a zero.

    Description

    -

    In this revision, this function is implemented as a macro.

    +

    In this revision, this function is implemented as a macro. It does not have any validation and mutual exclusion.

     #define f_eof(fp) ((int)((fp)->fptr == (fp)->fsize))
     
    diff --git a/fatfs/doc/en/error.html b/fatfs/doc/en/error.html index a14deb1..3476f55 100644 --- a/fatfs/doc/en/error.html +++ b/fatfs/doc/en/error.html @@ -39,9 +39,9 @@ int f_error (

    Description

    -

    In this revision, this function is implemented as a macro.

    +

    In this revision, this function is implemented as a macro. It does not have any validation and mutual exclusion.

    -#define f_error(fp) ((fp)->flag)
    +#define f_error(fp) ((fp)->err)
     
    diff --git a/fatfs/doc/en/expand.html b/fatfs/doc/en/expand.html new file mode 100644 index 0000000..0715635 --- /dev/null +++ b/fatfs/doc/en/expand.html @@ -0,0 +1,116 @@ + + + + + + + + +FatFs - f_expand + + + + +
    +

    f_expand

    +

    The f_expand function prepares or allocates a contiguous data area to the file.

    + +
    +FRESULT f_expand (
    +  FIL*    fp,  /* [IN] File object */
    +  FSIZE_t fsz, /* [IN] File size expanded to */
    +  BYTE    opt  /* [IN] Operation mode */
    +);
    +
    +
    + +
    +

    Parameters

    +
    +
    fp
    +
    Pointer to the open file object.
    +
    fsz
    +
    Number of bytes in size to prepare or allocate for the file. The data type FSIZE_t is an alias of either DWORD(32-bit) or QWORD(64-bit) depends on the configuration option _FS_EXFAT.
    +
    opt
    +
    Operation mode. Prepare only (0) or Allocate now (1).
    +
    +
    + + + + + +
    +

    Description

    +

    The f_expand function prepares or allocates a contiguous data area to the file. When opt is 1, the function allocates a contiguous data area to the file. Unlike expansion of file by f_lseek function, the file must be truncated prior to use this function and read/write pointer of the file stays at top of the file after the function. The file content allocated with this function is undefined because no data is written to the file in this process. The function can fail with FR_DENIED due to some reasons below.

    +
      +
    • No free contiguous space was found.
    • +
    • Size of the file was not zero.
    • +
    • The file has been opened in read-only mode.
    • +
    • Not allowable file size. (>= 4GiB on FAT volume)
    • +
    +

    When opt is 0, the function finds a contiguous data area and set it as suggested point for next allocation instead of allocating it to the file. The next cluster allocation is started at top of the contiguous area found by this function. Thus the write file is guaranteed be contiguous and no allocation delay until the size reaches that size at least unless any other changes to the volume is performed.

    +

    The contiguous file would have an advantage at time-critical read/write operations. It reduces some overheads in the file system and the storage media caused by random access due to fragmented file data. Especially, at the exFAT volume, any FAT access for the contiguous file is completely eliminated and storage media will be accessed sequentially.

    +

    Also the contiguous file data can be easily accessed directly via low-level disk functions but it is not recommended in consideration for future compatibility.

    +
    + +
    +

    QuickInfo

    +

    Available when _USE_EXPAND == 1 and _FS_READONLY == 0.

    +
    + + +
    +

    Example

    +
    +    /* Creating a contiguous file */
    +
    +    /* Create a new file */
    +    res = f_open(fp = malloc(sizeof (FIL)), "file.dat", FA_WRITE|FA_CREATE_ALWAYS);
    +    if (res) { /* Check if the file has been opened */
    +        free(fp);
    +        ...
    +    }
    +
    +    /* Alloacte a 100 MiB of contiguous area to the file */
    +    res = f_expand(fp, 104857600, 1);
    +    if (res) { /* Check if the file has been expanded */
    +        ...
    +        free(fp);
    +        ...
    +    }
    +    /* Now you have a contiguous file accessible with fp */
    +
    +
    +
    +    /* Accessing the file data directly via low-level disk functions */
    +
    +    /* Get physical location of the file data */
    +    drv = fp->obj.fs->drv;
    +    sect = fp->obj.fs->database + fp->obj.fs->csize * (fp->obj.sclust - 2);
    +
    +    /* Write 2048 sectors from top of the file at a time */
    +    res = disk_write(drv, buffer, sect, 2048);
    +
    +
    +
    + + +
    +

    See Also

    +

    f_open, f_lseek, FIL

    +
    + +

    Return

    + + diff --git a/fatfs/doc/en/fattime.html b/fatfs/doc/en/fattime.html index d8c245e..42fb1c8 100644 --- a/fatfs/doc/en/fattime.html +++ b/fatfs/doc/en/fattime.html @@ -13,7 +13,7 @@

    get_fattime

    -

    The get_fattime function gets current time.

    +

    The get_fattime function gets the current time.

     DWORD get_fattime (void);
     
    @@ -22,7 +22,7 @@ DWORD get_fattime (void);

    Return Value

    -

    Currnet time is returned with packed into a DWORD value. The bit field is as follows:

    +

    Currnet local time is returned in bit-fields packed into a DWORD value. The bit field is as follows:

    bit31:25
    Year origin from the 1980 (0..127)
    @@ -42,13 +42,13 @@ DWORD get_fattime (void);

    Description

    -

    The get_fattime() function shall return any valid time even if the system does not support a real time clock. If a zero is returned, the file will not have a valid timestamp.

    +

    The get_fattime function shall return any valid time even if the system does not support a real time clock. If a zero is returned, the file will not have a valid timestamp.

    QuickInfo

    -

    This function is not needed when _FS_READONLY == 1.

    +

    This function is not needed when _FS_READONLY == 1 or _FS_NORTC == 1.

    diff --git a/fatfs/doc/en/fdisk.html b/fatfs/doc/en/fdisk.html index ad4e4fd..6581d87 100644 --- a/fatfs/doc/en/fdisk.html +++ b/fatfs/doc/en/fdisk.html @@ -16,9 +16,9 @@

    The f_fdisk fucntion divides a physical drive.

     FRESULT f_fdisk (
    -  BYTE  pdrv,         /* [IN] Physical drive number */
    -  const DWORD part[], /* [IN] Partition size */
    -  void* work          /* [IN] Work area */
    +  BYTE  pdrv,        /* [IN] Physical drive number */
    +  const DWORD* szt,  /* [IN] Partition map table */
    +  void* work         /* [IN] Work area */
     );
     
    @@ -27,9 +27,9 @@ FRESULT f_fdisk (

    Parameters

    pdrv
    -
    Specifies the physical drive to be divided.
    -
    part[]
    -
    Partition map table. It must have four items.
    +
    Specifies the physical drive to be divided. This is not the logical drive number but the drive identifier passed to the low level disk functions.
    +
    szt
    +
    Pointer to the first item of the partition map table.
    work
    Pointer to the function work area. The size must be at least _MAX_SS bytes.
    @@ -48,7 +48,7 @@ FRESULT f_fdisk (

    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. Logical volumes in the extended partition is not supported. The part[] with four items specifies how to divide the physical drive. The first item specifies the size of first primary partition and fourth item specifies the fourth primary partition. If the value is less than or equal to 100, it specifies percentage of the partition in the entire disk space. If it is larger than 100, it specifies the partition size in unit of sector.

    +

    The f_fdisk function creates partitions on the physical drive. The partitioning format is in generic FDISK format, so that it can create upto four primary partitions. Logical volumes in the extended partition is not supported. The partition map table with four items specifies how to divide the physical drive. The first item specifies the size of first primary partition and fourth item specifies the fourth primary partition. If the value is less than or equal to 100, it specifies the partition size in percentage of the entire drive space. If it is larger than 100, it specifies the partition size in unit of sector. The partitions are located on the drive in order of from first item.

    @@ -74,15 +74,10 @@ FRESULT f_fdisk ( 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_fdisk(0, plist, work); /* Divide physical drive 0 */ - f_mount(&fs, "0:", 0); /* Register work area to the logical drive 0 */ - f_mkfs("0:", 0, 0); /* Create FAT volume on the logical drive 0. 2nd argument is ignored. */ - f_mount(0, "0:", 0); /* Unregister work area from the logical drive 0 */ - - f_mount(&fs, "1:", 0); /* Register a work area to the logical drive 1 */ - f_mkfs("1:", 0, 0); /* Create FAT volume on the logical drive 1. 2nd argument is ignored. */ - f_mount(0, "1:", 0); /* Unregister work area from the logical drive 1 */ + f_mkfs("0:", FMT_ANY, work, sizeof work); /* Create FAT volume on the logical drive 0 */ + f_mkfs("1:", FMT_ANY, work, sizeof work); /* Create FAT volume on the logical drive 1 */
    diff --git a/fatfs/doc/en/filename.html b/fatfs/doc/en/filename.html index 49dcc2d..ce8735b 100644 --- a/fatfs/doc/en/filename.html +++ b/fatfs/doc/en/filename.html @@ -12,16 +12,16 @@

    Path Names

    -
    +

    Format of the path names

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

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

    The FatFs module supports long file name (LFN) and 8.3 format file name (SFN). The LFN can be used when LFN feature is enabled (_USE_LFN > 0). The sub directories are separated with a \ or / in the same way as DOS/Windows API. Duplicated separators are skipped and ignored. Only a difference is that the logical drive is specified in a numeral with a colon. When drive number is omitted, the drive number is assumed as default drive (drive 0 or current drive).

    +

    The FatFs module supports long file name (LFN) and 8.3 format file name (SFN). The LFN can be used when (_USE_LFN != 0). The sub directories are separated with a \ or / in the same way as DOS/Windows API. Duplicated separators are skipped and ignored. Only a difference is that the logical drive is specified in a numeral with a colon. When drive number is omitted, the drive number is assumed as default drive (drive 0 or current drive).

    Control characters ('\0' to '\x1F') are recognized as end of the path name. Leading/embedded spaces in the path name are valid as a part of the name at LFN configuration but the space is recognized as end of the path name at non-LFN configuration. Trailing spaces and dots are ignored at both configurations.

    -

    In default configuration (_FS_RPATH == 0), it does not have a concept of current directory like OS oriented file system. All objects on the volume are always specified in full path name that follows from the root directory. Dot directory names are not allowed. Heading separator is ignored and it can be exist or omitted. The default drive is fixed to drive 0.

    -

    When relative path feature is enabled (_FS_RPATH == 1), specified path is followed from the root directory if a heading separator is exist. If not, it is followed from the current directory of the drive set by f_chdir function. Dot names are also allowed for the path name. The default drive is the current drive set by f_chdrive function.

    +

    In default configuration (_FS_RPATH == 0), it does not have a concept of current directory like OS oriented file system. All objects on the volume are always specified in full path name that follows from the root directory. Dot directory names (".", "..") are not allowed. Heading separator is ignored and it can be exist or omitted. The default drive is fixed to drive 0.

    +

    When relative path is enabled (_FS_RPATH >= 1), specified path is followed from the root directory if a heading separator is exist. If not, it is followed from the current directory of the drive set by f_chdir function. Dot names are also allowed for the path names. The default drive is the current drive set by f_chdrive function.

    - + @@ -31,17 +31,24 @@ - +
    Path name_FS_RPATH == 0_FS_RPATH == 1
    Path name_FS_RPATH == 0_FS_RPATH >= 1
    file.txtA file in the root directory of the drive 0A file in the current directory of the current drive
    /file.txtA file in the root directory of the drive 0A file in the root directory of the current drive
    The root directory of the drive 0The current directory of the current drive
    2:file.txtA file in the root directory of the drive 2A file in the current directory of the drive 2
    ../file.txtInvalid nameA file in the parent directory
    .Invalid nameThis directory
    ..Invalid nameParent directory of the current directory
    ..Invalid nameParent directory of the current directory (*)
    dir1/..Invalid nameThe current directory
    /..Invalid nameThe root directory (sticks the top level)
    -

    When option _STR_VOLUME_ID is specified, also pre-defined strings can be used as drive identifier in the path name instead of a numeral. e.g. "sd:file1.txt" or "ram:swapfile.dat".

    +

    When option _STR_VOLUME_ID is specified, also pre-defined strings can be used as drive identifier in the path name instead of a numeral. e.g. "sd:file1.txt", "ram:swapfile.dat" and DOS/Windows style drive letter, of course.

    +

    Remark: In this revision, double dot name ".." cannot follow the parent directory on the exFAT volume. It will work as "." and stay there.

    -


    -
    +
    +

    Legal Characters and Case Sensitivity

    +

    On the FAT file system, legal characters for file name are, 0-9 A-Z ! # $ % & ' ( ) - @ ^ _ ` { } ~ and extended characters (\x80-\xFF). Under LFN supported system, also white space and + , ; = [ ] are legal for the file name and the white spaces and periods can be placed anywhere in the name except for end of the name string.

    +

    FAT file system is case-insensitive to the object names on the volume. All object names are compared in case-insensitive. For example, these three names, file.txt, File.Txt and FILE.TXT, are identical. This is applied to also extended charactres. When an object is created on the FAT volume, upper converted name is recorded to the SFN entry, and the raw name is recorded to the LFN entry.

    +

    As for the DBCS language MS-DOS, it was case-sensitive to the extended characters. To follow this specification, FatFs works with case-sensitive to the extended characters at only non-LFN with DBCS configuration (DOS/DBCS specs). But at LFN configuration, FatFs works with case-insensitive to all characters (WindowsNT specs). This can cause a problem on compatibility with Windows system when an object with extended characters is created on the volume at non-LFN and DBCS configuration; therfore the object names with DBCS extended characters should not be used on the FAT volume shared by those systems.

    +
    + +

    Unicode API

    -

    The path names are input/output in either ANSI/OEM code or Unicode depends on the configuration options. The type of arguments which specify the path names are defined as TCHAR. It is an alias of char by default. The code set used to the path name string is ANSI/OEM specifid by _CODE_PAGE. When _LFN_UNICODE is set to 1, the type of the TCHAR is switched to WCHAR to support Unicode (UTF-16 encoding). In this case, the LFN feature is fully supported and the Unicode specific characters, such as ✝☪✡☸☭, can also be used for the path name. It also affects data types and encoding of the string I/O functions. To define literal strings, _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.

    +

    The path names are input/output in either ANSI/OEM code or Unicode depends on the configuration options. The type of arguments which specify the path names are defined as TCHAR. It is an alias of char by default. The code set used to the path name string is ANSI/OEM specifid by _CODE_PAGE. When _LFN_UNICODE is set to 1, the type of the TCHAR is switched to WCHAR to support Unicode (UTF-16 encoding). In this case, the full-featured LFN specification is supported and the Unicode specific characters, such as ✝☪✡☸☭, can also be used for the path name. It also affects data types and encoding of the string I/O functions. To define literal strings, _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.

      f_open(fp, "filename.txt", FA_READ);      /* ANSI/OEM string */
      f_open(fp, L"filename.txt", FA_READ);     /* Unicode string */
    @@ -49,30 +56,30 @@
     
    -


    -
    +

    Volume Management

    -

    The FatFs module needs dynamic work area called file system object for each volume (logical drive). It is registered to the FatFs module by f_mount() function. By default, each logical drive is bound to the physical drive with the same drive number and an FAT volume on the drive is serched by auto detect feature. It loads boot sectors and checks it if it is an FAT boot sector in order of sector 0 as SFD format, 1st partition, 2nd partition, 3rd partition and 4th partition as FDISK format.

    -

    When _MULTI_PARTITION == 1 is specified by configuration option, each individual logical drive is bound to the partition on the physical drive specified by volume management table. The volume management table must be defined by user to resolve relationship between logical drives and partitions. Following code is an example of a volume management table.

    +

    FatFs module needs dynamic work area, file system object, for each volume (logical drive). It is registered/unregistered to the FatFs module by f_mount function. By default, each logical drive is bound to the physical drive with the same drive number and an FAT volume on the drive is serched by the volume mount process. It reads boot sectors and checks it if it is an FAT boot sector in order of sector 0 as SFD format, 1st partition, 2nd partition, 3rd partition and 4th partition as FDISK format.

    +

    When _MULTI_PARTITION == 1 is specified by configuration option, each individual logical drive is bound to the partition on the physical drive specified by volume management table. The volume management table must be defined by user to resolve the relationship between logical drives and partitions. Following code is an example of a volume management table.

    -Example: Logical drive 0-2 are tied to three pri-partitions on the physical drive 0 (fixed disk)
    -         Logical drive 3 is tied to an FAT volume on the physical drive 1 (removable disk)
    +Example: Logical drive 0-2 are tied to three pri-partitions on the physical drive 0 (fixed drive)
    +         Logical drive 3 is tied to an FAT volume on the physical drive 1 (removable drive)
     
     PARTITION VolToPart[] = {
    -    {0, 1},     /* 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) */
    +    {0, 1},     /* "0:" ==> Physical drive 0, 1st partition */
    +    {0, 2},     /* "1:" ==> Physical drive 0, 2nd partition */
    +    {0, 3},     /* "2:" ==> Physical drive 0, 3rd partition */
    +    {1, 0}      /* "3:" ==> Physical drive 1, auto detection */
     };
     
    -
    relationship between logical drive and physical drive
    -

    There are some considerations on using _MULTI_PARTITION configuration.

    +
    relationship between logical drive and physical drive
    +

    There are some considerations on using multi-partition configuration.

    • The physical drive that has two or more mounted partitions must be non-removable. Media change while a system operation is prohibited.
    • Only four primary partitions can be specified. Extended partition is not supported.
    • -
    • Windows does not support multiple volumes on the removable storage. Only first parition will be mounted.
    • +
    • Windows does not support multiple volumes on the removable storage. Only first parition will be recognized.
    +

    Return

    diff --git a/fatfs/doc/en/findfirst.html b/fatfs/doc/en/findfirst.html new file mode 100644 index 0000000..61670ae --- /dev/null +++ b/fatfs/doc/en/findfirst.html @@ -0,0 +1,110 @@ + + + + + + + + +FatFs - f_findfirst + + + + +
    +

    f_findfirst

    +

    The f_findfirst function searches a directroy for an item.

    +
    +FRESULT f_findfirst (
    +  DIR* dp,              /* [OUT] Poninter to the directory object */
    +  FILINFO* fno,         /* [OUT] Pointer to the file information structure */
    +  const TCHAR* path,    /* [IN] Pointer to the directory name to be opened */
    +  const TCHAR* pattern  /* [IN] Pointer to the matching pattern string */
    +);
    +
    +
    + +
    +

    Parameters

    +
    +
    dp
    +
    Pointer to the blank directory object.
    +
    fno
    +
    Pointer to the file information structure to store the information about the found item.
    +
    path
    +
    Pointer to the null-terminated string that specifies the directory name to be opened.
    +
    pattern
    +
    Pointer to the nul-terminated string that specifies the name matching pattern to be searched for. It is referred by also subsequent f_findnext function, so that the string must be valid while the successive function calls.
    +
    +
    + + + + + +
    +

    Description

    +

    After the directory specified by path could be opened, it starts to search the directory for items with the name specified by pattern. If the first item is found, the information about the object is stored into the file information structure. For more information about file information structure, refer to f_readdir function.

    +

    The matching pattern can contain wildcard characters (? and *). A ? matches an any character and an * matches an any string in length of zero or longer. When support of long file name is enabled, only fname[] is tested at _USE_FIND == 1 and also altname[] is tested at _USE_FIND == 2. In this revision, there are some differences listed below between FatFs and standard systems in matching condition.

    +
      +
    • "*.*" never matches any name without extension while it matches any name with or without extension at the standard systems.
    • +
    • Any patterns terminated with a period never matches any name while it matches any name without extensiton at the standard systems.
    • +
    • DBCS extended characters are compared in case-sensitive at LFN with non-Unicode configuration.
    • +
    +
    + + +
    +

    QuickInfo

    +

    This is a wrapper function of f_opendir and f_readdir function. Available when _USE_FIND >= 1 and _FS_MINIMIZE <= 1.

    +
    + + +
    +

    Examples

    +
    +/* Search a directory for objects and display it */
    +
    +void find_image (void)
    +{
    +    FRESULT fr;     /* Return value */
    +    DIR dj;         /* Directory search object */
    +    FILINFO fno;    /* File information */
    +
    +    fr = f_findfirst(&dj, &fno, "", "dsc*.jpg");  /* Start to search for photo files */
    +
    +    while (fr == FR_OK && fno.fname[0]) {         /* Repeat while an item is found */
    +        printf("%s\n", fno.fname);                /* Display the object name */
    +        fr = f_findnext(&dj, &fno);               /* Search for next item */
    +    }
    +    f_closedir(&dj);
    +}
    +
    +
    + + +
    +

    See Also

    +

    f_findnext, f_closedir, DIR, FILINFO

    +
    + +

    Return

    + + diff --git a/fatfs/doc/en/findnext.html b/fatfs/doc/en/findnext.html new file mode 100644 index 0000000..c8dd3f5 --- /dev/null +++ b/fatfs/doc/en/findnext.html @@ -0,0 +1,69 @@ + + + + + + + + +FatFs - f_findnext + + + + +
    +

    f_findnext

    +

    The f_findnext function searches for a next matched object

    +
    +FRESULT f_findnext (
    +  DIR* dp,              /* [IN] Poninter to the directory object */
    +  FILINFO* fno          /* [OUT] Pointer to the file information structure */
    +);
    +
    +
    + +
    +

    Parameters

    +
    +
    dp
    +
    Pointer to the valid directory object created by f_findfirst function.
    +
    fno
    +
    Pointer to the file information structure to store the information about the found directory item.
    +
    +
    + + + + + +
    +

    Description

    +

    It continues the search from a previous call to the f_findfirst or f_findnext function. If found, the information about the object is stored into the file information structure. If no item to be read, a null string will be returned into fno->fname[].

    +
    + + +
    +

    QuickInfo

    +

    This is a wrapper function of f_readdir function. Available when _USE_FIND == 1 and _FS_MINIMIZE <= 1.

    +
    + + + + +

    Return

    + + diff --git a/fatfs/doc/en/forward.html b/fatfs/doc/en/forward.html index 714c48d..eddb051 100644 --- a/fatfs/doc/en/forward.html +++ b/fatfs/doc/en/forward.html @@ -45,7 +45,6 @@ FRESULT f_forward ( FR_OK, FR_DISK_ERR, FR_INT_ERR, -FR_NOT_READY, FR_INVALID_OBJECT, FR_TIMEOUT

    @@ -54,13 +53,13 @@ FRESULT f_forward (

    Description

    -

    The f_forward() function reads the data from the file and forward it to the outgoing stream without data buffer. This is suitable for small memory system because it does not require any data buffer at application module. The file pointer of the file object increases in number of bytes forwarded. In case of *bf is less than btf without error, it means the requested bytes could not be transferred due to end of file or stream goes busy during data transfer.

    +

    The f_forward function reads the data from the file and forward it to the outgoing stream without data buffer. This is suitable for small memory system because it does not require any data buffer at application module. The file pointer of the file object increases in number of bytes forwarded. In case of *bf is less than btf without error, it means the requested bytes could not be transferred due to end of file or stream goes busy during data transfer.

    QuickInfo

    -

    Available when _USE_FORWARD == 1 and _FS_TINY == 1.

    +

    Available when _USE_FORWARD == 1.

    @@ -113,7 +112,7 @@ FRESULT play_file ( if (rc) return rc; /* Repeat until the file pointer reaches end of the file */ - while (rc == FR_OK && fil.fptr < fil.fsize) { + while (rc == FR_OK && !f_eof(&fil)) { /* any other processes... */ diff --git a/fatfs/doc/en/getcwd.html b/fatfs/doc/en/getcwd.html index 045cce4..52a7f3f 100644 --- a/fatfs/doc/en/getcwd.html +++ b/fatfs/doc/en/getcwd.html @@ -13,7 +13,7 @@

    f_getcwd

    -

    The f_getcwd function retrieves the current directory.

    +

    The f_getcwd function retrieves the current directory and current drive.

     FRESULT f_getcwd (
       TCHAR* buff, /* [OUT] Buffer to return path name */
    @@ -50,7 +50,8 @@ FRESULT f_getcwd (
     
     

    Description

    -

    The f_getcwd() function retrieves full path name of the current directory of the current drive. When _VOLUMES is larger than 1, a logical drive number is added to top of the path name.

    +

    The f_getcwd function retrieves full path name of the current directory of the current drive. When _VOLUMES is larger than 1, a logical drive number is added to top of the path name.

    +

    Note: In this revision, this function cannot retrieve the current directory path on the exFAT volume. It always returns the root directory path.

    diff --git a/fatfs/doc/en/getfree.html b/fatfs/doc/en/getfree.html index 5a68975..1cfc09a 100644 --- a/fatfs/doc/en/getfree.html +++ b/fatfs/doc/en/getfree.html @@ -27,7 +27,7 @@ FRESULT f_getfree (

    Parameters

    path
    -
    Pinter to the null-terminated string that specifies the logical drive. A null-string means the default drive.
    +
    Pointer to the null-terminated string that specifies the logical drive. A null-string means the default drive.
    nclst
    Pointer to the DWORD variable to store number of free clusters.
    fatfs
    @@ -53,7 +53,7 @@ FRESULT f_getfree (

    Descriptions

    -

    The f_getfree() function gets number of free clusters on the volume. The member csize in the file system object indicates number of sectors per cluster, so that the free space in unit of sector can be calcurated with this information. When FSINFO structure on the FAT32 volume is not in sync, this function can return an incorrect free cluster count. To avoid this problem, FatFs can be forced full FAT scan by _FS_NOFSINFO option.

    +

    The f_getfree function gets number of free clusters on the volume. The member csize in the file system object indicates number of sectors per cluster, so that the free space in unit of sector can be calcurated with this information. When FSINFO structure on the FAT32 volume is not in sync, this function can return an incorrect free cluster count. To avoid this problem, FatFs can be forced full FAT scan by _FS_NOFSINFO option.

    diff --git a/fatfs/doc/en/getlabel.html b/fatfs/doc/en/getlabel.html index 736792f..cec65aa 100644 --- a/fatfs/doc/en/getlabel.html +++ b/fatfs/doc/en/getlabel.html @@ -29,7 +29,7 @@ FRESULT f_getlabel (
    path
    Pointer to the null-terminated string that specifies the logical drive. Null-string specifies the default drive.
    label
    -
    Pointer to the buffer to store the volume label. The buffer size must be at least 12 items. If the volume has no label, a null-string will be returned. Set null pointer if this information is not needed.
    +
    Pointer to the buffer to store the volume label. The buffer size must be at least 24 items at _LFN_UNICODE == 0 or 12 items at _LFN_UNICODE == 1. If the volume has no label, a null-string will be returned. Set null pointer if this information is not needed.
    vsn
    Pointer to the DWORD variable to store the volume serial number. Set null pointer if this information is not needed.
    @@ -60,7 +60,7 @@ FRESULT f_getlabel (

    Example

    -    char str[12];
    +    char str[24];
     
         /* Get volume label of the default drive */
         f_getlabel("", str, 0);
    diff --git a/fatfs/doc/en/gets.html b/fatfs/doc/en/gets.html
    index c843952..8059d35 100644
    --- a/fatfs/doc/en/gets.html
    +++ b/fatfs/doc/en/gets.html
    @@ -44,14 +44,14 @@ TCHAR* f_gets (
     
     

    Description

    -

    The f_gets() function is a wrapper function of f_read() function. The read operation continues until a '\n' is stored, reached end of the file or the buffer is filled with len - 1 characters. The read string is terminated with a '\0'. When no character to read or any error occured during read operation, it returns a null pointer. The status of EOF and error can be examined with f_eof() and f_error() macros.

    -

    When FatFs is configured to Unicode API (_LFN_UNICODE == 1), data types on the srting fuctions, f_putc(), f_puts(), f_printf() and f_gets(), is also switched to Unicode. The character encoding on the file to be read/written via those functions is selected by _STRF_ENCODE option.

    +

    The read operation continues until a '\n' is stored, reached end of the file or the buffer is filled with len - 1 characters. The read string is terminated with a '\0'. When no character to read or any error occured during read operation, it returns a null pointer. The status of EOF and error can be examined with f_eof and f_error function.

    +

    When FatFs is configured to Unicode API (_LFN_UNICODE == 1), data types on the srting fuctions, f_putc, f_puts, f_printf and f_gets, is also switched to Unicode. The character encoding on the file to be read/written via those functions is selected by _STRF_ENCODE option.

    QuickInfo

    -

    Available when _USE_STRFUNC is 1 or 2. When it is set to 2, '\r's contained in the file are stripped out.

    +

    This is a wrapper function of f_read function. Available when _USE_STRFUNC is 1 or 2. When it is set to 2, '\r's contained in the file are stripped out.

    diff --git a/fatfs/doc/en/lseek.html b/fatfs/doc/en/lseek.html index 0f22cf9..cf4f47e 100644 --- a/fatfs/doc/en/lseek.html +++ b/fatfs/doc/en/lseek.html @@ -17,8 +17,8 @@
     FRESULT f_lseek (
    -  FIL* fp,   /* [IN] File object */
    -  DWORD ofs  /* [IN] File read/write pointer */
    +  FIL*    fp,  /* [IN] File object */
    +  FSIZE_t ofs  /* [IN] File read/write pointer */
     );
     
    @@ -29,7 +29,7 @@ FRESULT f_lseek (
    fp
    Pointer to the open file object.
    ofs
    -
    Byte offset from top of the file.
    +
    Byte offset from top of the file. The data type FSIZE_t is an alias of either DWORD(32-bit) or QWORD(64-bit) depends on the configuration option _FS_EXFAT.
    @@ -40,7 +40,6 @@ FRESULT f_lseek ( FR_OK, FR_DISK_ERR, FR_INT_ERR, -FR_NOT_READY, FR_INVALID_OBJECT, FR_TIMEOUT

    @@ -49,19 +48,19 @@ 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 beyond the file size is specified at write mode, the file size is expanded to the specified offset. The file data in the expanded area is undefined because no data is written to the file. This is suitable to pre-allocate a cluster chain quickly, for fast write operation. After the f_lseek() function succeeded, the current read/write pointer should be checked in order to make sure the read/write pointer has been moved correctry. In case of the current read/write pointer is not the expected value, either of followings has been occured.

    +

    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 beyond the file size is specified at write mode, the file size is expanded to the specified offset. The file data in the expanded area is undefined because no data is written to the file in this process. This is suitable to pre-allocate a cluster chain quickly, for fast write operation. When a contiguous data area needs to be allocated to the file, use f_expand function instead. After the f_lseek function succeeded, the current read/write pointer should be checked in order to make sure the read/write pointer has been moved correctry. In case of the read/write pointer is not the expected value, either of followings has been occured.

    • End of file. The specified ofs 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.
    • +
    • Disk full. There is no free space on the volume to expand the file.
    -

    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 using CLMT (cluster link map table). The fast seek feature is also applied to f_read()/f_write() function, however, the file size cannot be expanded by f_write()/f_lseek() function.

    -

    The CLMT must be created in the user defined DWORD array prior to use the fast seek feature. To create the CLMT, set address of 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 ofs = CREATE_LINKMAP. After the function succeeded and CLMT is created, no FAT access is occured at subsequent f_read()/f_write()/f_lseek() function to the file. If the function failed with FR_NOT_ENOUGH_CORE, the given array size is insufficient for the file and number of items required is returned into the first item of the array. The required array size is (number of fragments + 1) * 2 items. For example, when the file is fragmented in 5, 12 items will be required for the CLMT.

    +

    The fast seek function enables fast backward/long seek operations without FAT access by using an on-memory CLMT (cluster link map table). It is applied to f_read and f_write function as well, however, the file size cannot be expanded by f_write, f_lseek function while the file is in fast seek mode.

    +

    The fast seek function is enabled when the member cltbl in the file object is not NULL. The CLMT must be created into the DWORD array prior to use the fast seek function. To create the CLMT, set address of the DWORD array to the member cltbl in the open file object, set the size of array in unit of items to the first item and call the f_lseek function with ofs = CREATE_LINKMAP. After the function succeeded and CLMT is created, no FAT access is occured in subsequent f_read, f_write, f_lseek function to the file. The number of items used or required is returned into the first item of the array. The number of items to be used is (number of the file fragments + 1) * 2. For example, when the file is fragmented in 5, 12 items in the array will be used. If the function failed with FR_NOT_ENOUGH_CORE, the given array size is insufficient for the file.

    QuickInfo

    -

    Available when _FS_MINIMIZE <= 2.

    +

    Available when _FS_MINIMIZE <= 2. To use fast seek function, _USE_FASTSEEK needs to be set 1.

    @@ -94,7 +93,7 @@ FRESULT f_lseek ( if (res || f_tell(fp) != PRE_SIZE) ... /* Check if the file has been expanded */ res = f_lseek(fp, DATA_START); /* Record data stream WITHOUT cluster allocation delay */ - ... /* DATA_START and write block size should be aligned to sector boundary */ + ... /* Write operation should be aligned to sector boundary to optimize the write throughput */ res = f_truncate(fp); /* Truncate unused area */ res = f_lseek(fp, 0); /* Put file header */ @@ -103,13 +102,15 @@ FRESULT f_lseek ( res = f_close(fp);
    -/* Using fast seek feature */
    +/* Using fast seek function */
     
         DWORD clmt[SZ_TBL];                    /* Cluster link map table buffer */
     
    +    res = f_open(fp, fname, FA_READ | FA_WRITE);   /* Open a file */
    +
         res = f_lseek(fp, ofs1);               /* This is normal seek (cltbl is nulled on file open) */
     
    -    fp->cltbl = clmt;                      /* Enable fast seek feature (cltbl != NULL) */
    +    fp->cltbl = clmt;                      /* Enable fast seek function (cltbl != NULL) */
         clmt[0] = SZ_TBL;                      /* Set table size */
         res = f_lseek(fp, CREATE_LINKMAP);     /* Create CLMT */
         ...
    @@ -121,7 +122,7 @@ FRESULT f_lseek (
     
     
     
     

    Return

    diff --git a/fatfs/doc/en/mkdir.html b/fatfs/doc/en/mkdir.html index c2c1f4d..970627c 100644 --- a/fatfs/doc/en/mkdir.html +++ b/fatfs/doc/en/mkdir.html @@ -53,7 +53,7 @@ FRESULT f_mkdir (

    Description

    -

    This function creates a new directory.

    +

    This function creates a new directory. To remove a directory, use f_unlink function.

    diff --git a/fatfs/doc/en/mkfs.html b/fatfs/doc/en/mkfs.html index 5f733fa..51f8aac 100644 --- a/fatfs/doc/en/mkfs.html +++ b/fatfs/doc/en/mkfs.html @@ -13,12 +13,14 @@

    f_mkfs

    -

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

    +

    The f_mkfs fucntion creates an FAT/exFAT volume on the logical drive.

     FRESULT f_mkfs (
       const TCHAR* path,  /* [IN] Logical drive number */
    -  BYTE  sfd,          /* [IN] Partitioning rule */
    -  UINT  au            /* [IN] Size of the allocation unit */
    +  BYTE  opt,          /* [IN] Format options */
    +  DWORD au,           /* [IN] Size of the allocation unit */
    +  void* work,         /* [-]  Working buffer */
    +  UINT len            /* [IN] Size of working buffer */
     );
     
    @@ -27,11 +29,15 @@ FRESULT f_mkfs (

    Parameters

    path
    -
    Pinter to the null-terminated string that specifies the logical drive to be formatted. If there is no drive number, it means the default drive.
    -
    sfd
    -
    Specifies partitioning rule (FDISK(0) or SFD(1)). This argument will be ignored on some case.
    +
    Pointer to the null-terminated string specifies the logical drive to be formatted. If there is no drive number in it, it means the default drive. The logical drive may or may not be mounted for the format process.
    +
    opt
    +
    Specifies the format option in combination of FM_FAT, FM_FAT32, FM_EXFAT and bitwise-or of these three, FM_ANY. FM_EXFAT is ignored when exFAT is not enabled. These flags specify which FAT type to be created on the volume. If two or more types are specified, one out of them will be selected depends on the volume size. The flag FM_SFD specifies to place the volume on the drive in SFD format.
    au
    -
    Specifies size of the allocation unit (cluter) in number of bytes or sectors. When the value is from 1 to 128, it specifies number of sectors. When the value is >= _MIN_SS, it specifies number of bytes. If any invalid value, zero or not power of 2, is given, the cluster size is automatically determined depends on the volume size.
    +
    Specifies size of the allocation unit (cluter) in unit of byte. The valid value is N times the sector size. N is power of 2 from 1 to 128 for FAT volume and upto 16MiB for exFAT volume. If zero is given, the default allocation unit size is selected depends on the volume size.
    +
    work
    +
    Pointer to the working buffer used for the format process.
    +
    len
    +
    Size of the working buffer in unit of byte. It needs to be the sector size at least. Plenty of working buffer reduces number of write transaction to the device and the format process will be finished quickly.
    @@ -43,7 +49,6 @@ FRESULT f_mkfs ( FR_NOT_READY, FR_WRITE_PROTECTED, FR_INVALID_DRIVE, -FR_NOT_ENABLED, FR_MKFS_ABORTED, FR_INVALID_PARAMETER

    @@ -51,11 +56,11 @@ FRESULT f_mkfs (

    Description

    -

    The f_mkfs() function creates an FAT volume on the specified logical drive. When FDISK format is specified, a primary partition occupies entire space of the physical drive is created and then an FAT volume is created on the partition. When SFD format is specified, the FAT volume starts from the first sector of the physical drive.

    -

    If the logical drive is bound to the specific partition (1-4) by multiple partition feature (_MULTI_PARTITION), the FAT volume is created into the partition. In this case, the second argument sfd is ignored. The physical drive must have been partitioned with f_fdisk() function or any other partitioning tools prior to create the FAT volume with this function.

    -

    Note that there are two partitioning rules, FDISK and SFD. The FDISK partitioning is usually used for harddisk, MMC, SDC, CFC and U Disk. It can divide a physical drive into one or more partitions with a partition table on the MBR. However Windows does not support multiple partition on the removable disk. The SFD is non-partitioned method. The FAT volume starts from the first sector on the physical drive without partition table. It is usually used for floppy disk, Microdrive, optical disk and any type of super-floppy media.

    -

    The FAT sub-type, FAT12/FAT16/FAT32, is determined by number of clusters on the volume and nothing else, according to the FAT specification issued by Microsoft. Thus which FAT sub-type is selected, is depends on the volume size and the specified cluster size. The cluster size affects read/write throughput and space usage efficiency. Larger cluster size increases the read/write throughput and decreases the space usage efficiency of the volume.

    -

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

    +

    The FAT sub-type, FAT12/FAT16/FAT32, of FAT volume except exFAT is determined by only number of clusters on the volume and nothing else, according to the FAT specification issued by Microsoft. Thus which FAT sub-type is selected, is depends on the volume size and the specified cluster size. In case of the combination of FAT type and cluter size specified by argument cannot be valid on the volume, the function will fail with FR_MKFS_ABORTED.

    +

    The allocation unit, also called 'cluster', is a unit of disk space allocation for files. When the size of allocation unit is 32768 bytes, a file with 100 bytes in size occupies 32768 bytes of disk space. The space efficiency of disk usage gets worse as increasing size of allocation unit, but, on the other hand, the read/write performance increases as the size of allocation unit. Therefore the allocation unit is a trade-off between space efficiency and performance. For the large storages in GB order, 32768 bytes or larger cluster (this is automatically selected by default) is recommended for most case unless extremely many files are created on a volume.

    +

    There are two disk formats, FDISK and SFD. The FDISK format is usually used for harddisk, MMC, SDC, CFC and U Disk. It can divide a physical drive into one or more partitions with a partition table on the MBR (maser boot record, the first sector of the physical drive). The SFD (super-floppy disk) is non-partitioned disk format. The FAT volume starts at the first sector of the physical drive without any disk partitioning. It is usually used for floppy disk, Microdrive, optical disk and most type of super-floppy media. Some systems support only either one of two formats and other is not supported.

    +

    When FM_SFD is not specified, a primary partition occupies whole drive space is created and then the FAT volume is created in it. When FM_SFD is specified, the FAT volume occupies from the first sector of the drive is created.

    +

    If the logical drive to be formatted is bound to the specific partition (1-4) by support of multiple partition, _MULTI_PARTITION, the FAT volume is created into the partition and FM_SFD flag is ignored. The physical drive needs to be partitioned with f_fdisk function or any other partitioning tools prior to create the FAT volume with this function.

    @@ -66,42 +71,44 @@ FRESULT f_mkfs (

    Example

    -/* Format the default drive */
    +/* Format default drive and create a file */
     int main (void)
     {
    -    FATFS fs;      /* File system object (volume work area) */
    -    FIL fil;       /* File object */
    -    FRESULT res;   /* API result code */
    -    UINT bw;       /* Bytes written */
    +    FATFS fs;           /* File system object */
    +    FIL fil;            /* File object */
    +    FRESULT res;        /* API result code */
    +    UINT bw;            /* Bytes written */
    +    BYTE work[_MAX_SS]; /* Work area (larger is better for process time) */
     
     
    +    /* Create FAT volume */
    +    res = f_mkfs("", FM_ANY, 0, work, sizeof work);
    +    if (res) ...
    +
         /* Register work area */
         f_mount(&fs, "", 0);
     
    -    /* Create FAT volume with default cluster size */
    -    res = f_mkfs("", 0, 0);
    -    if (res) ...
    -
         /* Create a file as new */
    -    res = f_open(&fil, "hello.txt", FA_CREATE_NEW | FA_WRITE);
    +    res = f_open(&fil, "hello.txt", FA_CREATE_NEW | FA_WRITE);
         if (res) ...
     
         /* Write a message */
    -    f_write(&fil, "Hello, World!\r\n", 15, &bw);
    +    f_write(&fil, "Hello, World!\r\n", 15, &bw);
         if (bw != 15) ...
     
         /* Close the file */
    -    f_close(&fil);
    +    f_close(&fil);
     
         /* Unregister work area */
         f_mount(0, "", 0);
     
    +    ...
     

    Return

    diff --git a/fatfs/doc/en/mount.html b/fatfs/doc/en/mount.html index 0edb73a..0999b9c 100644 --- a/fatfs/doc/en/mount.html +++ b/fatfs/doc/en/mount.html @@ -27,11 +27,11 @@ FRESULT f_mount (

    Parameters

    fs
    -
    Pointer to the new file system object to be registered. Null pointer unregisters the registered file system object.
    +
    Pointer to the file system object to be registered and cleared. Null pointer unregisters the registered file system object.
    path
    -
    Pointer to the null-terminated string that specifies the logical drive. The string with no drive number means the default drive.
    +
    Pointer to the null-terminated string that specifies the logical drive. The string without drive number means the default drive.
    opt
    -
    Initialization option. 0: Do not mount now (to be mounted later), 1: Force mounted the volume to check if the FAT volume is available.
    +
    Mounting option. 0: Do not mount now (to be mounted on the first access to the volume), 1: Force mounted the volume to check if it is ready to work.
    @@ -49,21 +49,21 @@ FRESULT f_mount (

    Description

    -

    The f_mount() function registers/unregisters a file system object used for the logical drive to the FatFs module as follows:

    +

    The f_mount function registers/unregisters a file system object used for the volume (logical drive) to the FatFs module as follows:

    1. Determines the logical drive which specified by path.
    2. -
    3. Clears and unregisters the regsitered work area of the drive.
    4. +
    5. Clears and unregisters the regsitered work area of the drive if exist.
    6. Clears and registers the new work area to the drive if fs is not NULL.
    7. -
    8. Performs volume mount process to the drive if forced mount is specified.
    9. +
    10. Performs volume mount process to the drive if forced mounting is specified.
    -

    The file system object is the work area needed for each logical drive. It must be given to the logical drive with this function prior to use any other file functions except for f_fdisk() function. To unregister a work area, specify a NULL to the fs, and then the work area can be discarded.

    -

    If forced mount is not specified, this function always succeeds regardless of the physical drive status due to delayed mount feature. It only clears (de-initializes) the given work area and registers its address to the internal table. No activity of the physical drive in this function. It can also be used to force de-initialized the registered work area of a logical drive. The volume mount processes, initialize the corresponding physical drive, find the FAT volume in it and initialize the work area, is performed in the subsequent file access functions when either or both of following condition is true.

    +

    The file system object is the work area needed for each logical drive. It must be given to the logical drive with this function prior to use any API functions except for f_mkfs/f_fdisk function to the logical drive.

    +

    If forced mounting is not specified (opt = 0), this function always succeeds regardless of the physical drive status. It only clears (de-initializes) the given work area and registers its address to the internal table and no activity of the physical drive in this function. To unregister the work area, specify a NULL to the fs, and then the work area can be discarded. The volume mount processes, initialize the corresponding physical drive, find the FAT volume in it and initialize the work area, is performed in the subsequent file access functions when either or both of following condition is true.

      -
    • File system object is not initialized. It is cleared by f_mount().
    • +
    • File system object has not been initialized. It is de-initialized by f_mount function.
    • Physical drive is not initialized. It is de-initialized by system reset or media removal.
    -

    If the function with forced mount failed, it means that the file system object has been registered successfully but the volume is currently not ready to use. Mount process will also be attempted in subsequent file access functions.

    -

    If implementation of the disk I/O layer lacks media change detection, application program needs to perform a f_mount() after each media change to force cleared the file system object.

    +

    If the function with forced mounting (opt = 1) failed, it means that the file system object has been registered successfully but the volume is currently not ready to work. The volume mount process will be attempted at subsequent file access functions if the file system object is not initialized. (delayed mounting)

    +

    If implementation of the disk I/O layer lacks media change detection, application program needs to perform a f_mount function after each media change to force cleared the file system object.

    diff --git a/fatfs/doc/en/open.html b/fatfs/doc/en/open.html index d61a7a4..feade15 100644 --- a/fatfs/doc/en/open.html +++ b/fatfs/doc/en/open.html @@ -27,20 +27,20 @@ FRESULT f_open (

    Parameters

    fp
    -
    Pointer to the blank file object structure to be created.
    +
    Pointer to the blank file object structure.
    path
    -
    Pointer to a null-terminated string that specifies the file name to open or create.
    +
    Pointer to the null-terminated string that specifies the file name to open or create.
    mode
    Mode flags that specifies the type of access and open method for the file. It is specified by a combination of following flags.
    - - + + - + +
    ValueDescription
    FA_READSpecifies read access to the object. Data can be read from the file. Combine with FA_WRITE for read-write access.
    ValueMeaning
    FA_READSpecifies read access to the object. Data can be read from the file.
    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.
    FA_CREATE_NEWCreates a new file. The function fails with FR_EXIST if the file is existing.
    FA_CREATE_ALWAYSCreates a new file. If the file is existing, it will be truncated and overwritten.
    FA_OPEN_ALWAYSOpens the file if it is existing. If not, a new file will be created.
    FA_OPEN_APPENDSame as FA_OPEN_ALWAYS except read/write pointer is set end of the file.
    @@ -74,15 +74,15 @@ To append data to the file, use f_lseek() func

    Description

    -

    After f_open() function succeeded, the file object is valid. The file object is used for subsequent read/write functions to identify the file. To close an open file, use f_close() function. If the file is modified and not closed properly, the file data will be collapsed.

    -

    If duplicated file open is needed, read here carefully. However duplicated open of a file with write mode flag 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.

    +

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

    +

    After f_open function succeeded, the file object is valid. The file object is used for subsequent operations to the file to identify the file. Open file must be closed prior to power down, media removal or re-mount, or the file can be collapsed. To close an open file, use f_close function.

    +

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

    QuickInfo

    -

    Always available. The mode flags, FA_WRITE, FA_CREATE_ALWAYS, FA_CREATE_NEW and FA_OPEN_ALWAYS, are not available when _FS_READONLY == 1.

    +

    Always available. Only FA_READ and FA_OPEN_EXISTING are supported when _FS_READONLY == 1.

    @@ -134,11 +134,11 @@ int main (void) f_mount(&fs[1], "1:", 0); /* Open source file on the drive 1 */ - fr = f_open(&fsrc, "1:file.bin", FA_OPEN_EXISTING | FA_READ); + fr = f_open(&fsrc, "1:file.bin", FA_READ); if (fr) return (int)fr; /* Create destination file on the drive 0 */ - fr = f_open(&fdst, "0:file.bin", FA_CREATE_ALWAYS | FA_WRITE); + fr = f_open(&fdst, "0:file.bin", FA_WRITE | FA_CREATE_ALWAYS); if (fr) return (int)fr; /* Copy source to destination */ diff --git a/fatfs/doc/en/opendir.html b/fatfs/doc/en/opendir.html index 2fd4e45..56e66b2 100644 --- a/fatfs/doc/en/opendir.html +++ b/fatfs/doc/en/opendir.html @@ -28,7 +28,7 @@ FRESULT f_opendir (
    dp
    Pointer to the blank directory object to create a new one.
    path
    -
    Pinter to the null-terminated string that specifies the directory name to be opened.
    +
    Pointer to the null-terminated string that specifies the directory name to be opened.
    @@ -55,7 +55,7 @@ FRESULT f_opendir (

    Description

    -

    The f_opendir() function opens an exsisting directory and creates a directory object for subsequent f_readdir() function.

    +

    The f_opendir function opens an exsisting directory and creates a directory object for subsequent f_readdir function.

    diff --git a/fatfs/doc/en/printf.html b/fatfs/doc/en/printf.html index 96a84b8..f603052 100644 --- a/fatfs/doc/en/printf.html +++ b/fatfs/doc/en/printf.html @@ -39,13 +39,13 @@ int f_printf (

    Return Values

    -

    When the function succeeded, it returns number of characters written. When the function failed due to disk full or any error, an EOF (-1) will be returned.

    +

    When the function succeeded, it returns number of characters written. If the function could not write the generated string to the file due to disk full or an error, EOF (-1) will be returned.

    Description

    -

    The f_printf() is a wrapper function of f_write(). The format control directive is a sub-set of standard library shown as follos:

    +

    The format control directive is a sub-set of standard library shown as follos:

    • Type: c C s S d D u U x X b B
    • Size: l L
    • @@ -56,8 +56,8 @@ int f_printf (

      QuickInfo

      -

      Available when _FS_READONLY == 0 and _USE_STRFUNC is 1 or 2. When it is set to 2, '\n's contained in the output are converted to '\r'+'\n'.

      -

      When FatFs is configured to Unicode API (_LFN_UNICODE == 1), data types on the srting fuctions, f_putc(), f_puts(), f_printf() and f_gets(), is also switched to Unicode. The character encoding on the file to be read/written via those functions is selected by _STRF_ENCODE option.

      +

      This is a wrapper function of f_write function. Available when _FS_READONLY == 0 and _USE_STRFUNC is 1 or 2. When it is set to 2, '\n's contained in the output are converted to '\r'+'\n'.

      +

      When FatFs is configured to Unicode API (_LFN_UNICODE == 1), data types on the srting fuctions, f_putc, f_puts, f_printf and f_gets function, is also switched to Unicode. The character encoding on the file to be read/written via those functions is selected by _STRF_ENCODE option.

      diff --git a/fatfs/doc/en/putc.html b/fatfs/doc/en/putc.html index 52db016..9a97bab 100644 --- a/fatfs/doc/en/putc.html +++ b/fatfs/doc/en/putc.html @@ -36,19 +36,13 @@ int f_putc (

      Return Values

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

      -

      When FatFs is configured to Unicode API (_LFN_UNICODE == 1), character encoding on the string fuctions, f_putc(), f_puts(), f_printf() and f_gets(), is also switched to Unicode. The character encoding on the file to be read/written via those functions is selected by _STRF_ENCODE option.

      -
      - - -
      -

      Description

      -

      The f_putc() function is a wrapper function of f_write() function.

      +

      When FatFs is configured to Unicode API (_LFN_UNICODE == 1), character encoding on the string fuctions, f_putc, f_puts, f_printf and f_gets function, is also switched to Unicode. The character encoding on the file to be read/written via those functions is selected by _STRF_ENCODE option.

      QuickInfo

      -

      Available when _FS_READONLY == 0 and _USE_STRFUNC is 1 or 2. When it is set to 2, a '\n' is converted to '\r'+'\n'.

      +

      This is a wrapper function of f_write function. Available when _FS_READONLY == 0 and _USE_STRFUNC is 1 or 2. When it is set to 2, a '\n' is converted to '\r'+'\n'.

      diff --git a/fatfs/doc/en/puts.html b/fatfs/doc/en/puts.html index 30b1dd3..b213e44 100644 --- a/fatfs/doc/en/puts.html +++ b/fatfs/doc/en/puts.html @@ -36,19 +36,13 @@ int f_puts (

      Return Value

      When the function succeeded, it returns number of characters written. When the write operation is aborted due to disk full or any error, an EOF (-1) will be returned.

      -

      When FatFs is configured to Unicode API (_LFN_UNICODE == 1), character encoding on the srting fuctions, f_putc(), f_puts(), f_printf() and f_gets(), is also switched to Unicode. The character encoding on the file to be read/written via those functions is selected by _STRF_ENCODE option.

      -
      - - -
      -

      Description

      -

      The f_puts() function is a wrapper function of f_write() function.

      +

      When FatFs is configured to Unicode API (_LFN_UNICODE == 1), character encoding on the srting fuctions, f_putc, f_puts, f_printf and f_gets function, is also switched to Unicode. The character encoding on the file to be read/written via those functions is selected by _STRF_ENCODE option.

      QuickInfo

      -

      Available when _FS_READONLY == 0 and _USE_STRFUNC is 1 or 2. When it is set to 2, '\n's contained in the string are converted to '\r'+'\n'.

      +

      This is a wrapper function of f_write function. Available when _FS_READONLY == 0 and _USE_STRFUNC is 1 or 2. When it is set to 2, '\n's contained in the string are converted to '\r'+'\n'.

      diff --git a/fatfs/doc/en/rc.html b/fatfs/doc/en/rc.html index 306671a..0e45fbe 100644 --- a/fatfs/doc/en/rc.html +++ b/fatfs/doc/en/rc.html @@ -6,34 +6,43 @@ -FatFs - Return Codes +FatFs - API Return Code -

      Return Code of the File Functions

      -

      On the FatFs API, most of file functions return common result code as enum type FRESULT. When a function succeeded, it returns zero, otherwise returns non-zero value that indicates type of error.

      +

      Return Code of API Functions

      +

      Most of API functions return common result code as enum type FRESULT. When an API function succeeded, it returns zero (FR_OK), otherwise it returns non-zero value indicates type of error.

      +
      FR_OK (0)
      The function succeeded.
      +
      FR_DISK_ERR
      -
      An unrecoverable hard error occured in the lower layer, disk_read(), disk_write() or disk_ioctl() function.
      Note that if once this error occured at any operation to an open file, the file object is aborted and all operations to the file except for close will be rejected.
      +
      An unrecoverable hard error occured in the lower layer, disk_read, disk_write or disk_ioctl function.
      Note that if once this error occured at any operation to an open file, the file object is aborted and all operations to the file except for close will be rejected.
      +
      FR_INT_ERR
      Assertion failed. An insanity is detected in the internal process. One of the following possibilities is suspected.
      • Work area (file system object, file object or etc...) has been broken by stack overflow or any other tasks. This is the reason in most case.
      • -
      • There is any error of the FAT structure on the volume.
      • +
      • There is an error of the FAT structure on the volume.
      • +
      • There is a bug in the FatFs module itself.
      Note that if once this error occured at any operation to an open file, the file object is aborted and all operations to the file except for close will be rejected.
      +
      FR_NOT_READY
      -
      The disk drive cannot work due to incorrect medium removal or disk_initialize() function failed.
      +
      The storage device cannot work due to a failure of disk_initialize function due to no medium or any other reason.
      +
      FR_NO_FILE
      Could not find the file.
      +
      FR_NO_PATH
      Could not find the path.
      +
      FR_INVALID_NAME
      The given string is invalid as the path name.
      +
      FR_DENIED
      The required access was denied due to one of the following reasons:
        @@ -42,46 +51,66 @@ Note that if once this error occured at any operation to an open file, the file
      • Deleting the non-empty directory or current directory.
      • Reading the file opened without FA_READ flag.
      • Any modification to the file opened without FA_WRITE flag.
      • -
      • Could not create the file or directory due to the directory table is full.
      • -
      • Could not create the directory due to the volume is full.
      • +
      • Could not create the object due to root directory full or disk full.
      • +
      • Could not allocate a contiguous area to the file.
      +
      FR_EXIST
      -
      Name collision. Any object that has the same name is already existing.
      +
      Name collision. An object with the same name is already existing.
      +
      FR_INVALID_OBJECT
      -
      The file/directory object structure is invalid or a null pointer is given. All open objects of the logical drive are invalidated by the voulme mount process.
      +
      The file/directory object is invalid or a null pointer is given. There are some reasons as follows: +
        +
      • It has been closed, it has not been opened or it has been collapsed.
      • +
      • It has been invalidated by a voulme mount process. Open objects on the volume are invalidated by voulme mount process.
      • +
      • Physical drive is not ready to work due to a media removal.
      • +
      +
      +
      FR_WRITE_PROTECTED
      -
      Any write mode operation against the write-protected media.
      +
      A write mode operation against the write-protected media.
      +
      FR_INVALID_DRIVE
      -
      Invalid drive number is specified in the path name. A null pointer is given as the path name. (Related option: _VOLUMES)
      +
      Invalid drive number is specified in the path name. A null pointer is given as the path name. (Related option: _VOLUMES)
      +
      FR_NOT_ENABLED
      -
      Work area for the logical drive has not been registered by f_mount() function.
      +
      Work area for the logical drive has not been registered by f_mount function.
      +
      FR_NO_FILESYSTEM
      There is no valid FAT volume on the drive.
      +
      FR_MKFS_ABORTED
      -
      The f_mkfs() function aborted before start in format due to a reason as follows: +
      The f_mkfs function aborted before start in format due to a reason as follows:
        -
      • The disk/partition size is too small.
      • -
      • Not allowable cluster size for this disk. This can occure when number of clusters gets near the boundaries of FAT sub-types.
      • -
      • There is no partition related to the logical drive. (Related option: _MULTI_PARTITION)
      • +
      • It is pmpossible to formart with the given parameters.
      • +
      • The size of volume is too small.
      • +
      • The size of given work area is too small.
      • +
      • The partition bound to the logical drive coulud not be found. (Related option: _MULTI_PARTITION)
      +
      FR_TIMEOUT
      -
      The function was canceled due to a timeout of thread-safe control. (Related option: _TIMEOUT)
      +
      The function was canceled due to a timeout of thread-safe control. (Related option: _TIMEOUT)
      +
      FR_LOCKED
      -
      The operation to the object was rejected by file sharing control. (Related option: _FS_LOCK)
      +
      The operation to the object was rejected by file sharing control. (Related option: _FS_LOCK)
      +
      FR_NOT_ENOUGH_CORE
      Not enough memory for the operation. There is one of the following reasons:
        -
      • Could not allocate a memory for LFN working buffer. (Related option: _USE_LFN)
      • +
      • Could not allocate a memory for LFN working buffer. (Related option: _USE_LFN)
      • Size of the given buffer is insufficient for the size required.
      +
      FR_TOO_MANY_OPEN_FILES
      -
      Number of open objects has been reached maximum value and no more object can be opened. (Related option: _FS_LOCK)
      +
      Number of open objects has been reached maximum value and no more object can be opened. (Related option: _FS_LOCK)
      +
      FR_INVALID_PARAMETER
      -
      The given parameter is invalid or there is any inconsistent.
      +
      The given parameter is invalid or there is an inconsistent for the volume.
      +

      Return

      diff --git a/fatfs/doc/en/read.html b/fatfs/doc/en/read.html index de593f0..80811c9 100644 --- a/fatfs/doc/en/read.html +++ b/fatfs/doc/en/read.html @@ -34,7 +34,7 @@ FRESULT f_read (
      btr
      Number of bytes to read in range of UINT type.
      br
      -
      Pointer to the UINT variable to return number of bytes read. The value is always valid after the function call regardless of the result.
      +
      Pointer to the UINT variable to return number of bytes read. The value is always valid after the function call regardless of the result code.
    @@ -45,7 +45,6 @@ FRESULT f_read ( FR_OK, FR_DISK_ERR, FR_INT_ERR, -FR_NOT_READY, FR_INVALID_OBJECT, FR_TIMEOUT

    @@ -54,7 +53,7 @@ FRESULT f_read (

    Description

    -

    The file read/write pointer of the file object advances number of bytes read. After the function succeeded, *br should be checked to detect end of the file. In case of *br is less than btr, it means the read/write pointer reached end of the file during read operation.

    +

    The function starts to read data from the file at the position pointed by the read/write pointer. The read/write pointer advances as number of bytes read. After the function succeeded, *br should be checked to detect end of the file. In case of *br < btr, it means the read/write pointer reached end of the file during read operation.

    diff --git a/fatfs/doc/en/readdir.html b/fatfs/doc/en/readdir.html index bf83ebe..235beee 100644 --- a/fatfs/doc/en/readdir.html +++ b/fatfs/doc/en/readdir.html @@ -13,7 +13,7 @@

    f_readdir

    -

    The f_readdir function reads directory entries.

    +

    The f_readdir function reads an item of the directory.

     FRESULT f_readdir (
       DIR* dp,      /* [IN] Directory object */
    @@ -26,9 +26,9 @@ FRESULT f_readdir (
     

    Parameters

    dp
    -
    Pointer to the open directory object.
    +
    Pointer to the open directory object or null pointer.
    fno
    -
    Pointer to the file information structure to store the read item.
    +
    Pointer to the file information structure to store the information about read item.
    @@ -39,7 +39,6 @@ FRESULT f_readdir ( FR_OK, FR_DISK_ERR, FR_INT_ERR, -FR_NOT_READY, FR_INVALID_OBJECT, FR_TIMEOUT, FR_NOT_ENOUGH_CORE @@ -49,14 +48,14 @@ FRESULT f_readdir (

    Description

    -

    The f_readdir() function reads directory items, file and directory, in sequence. All items in the directory can be read by calling f_readdir() function repeatedly. When relative path feature is enabled (_FS_RPATH >= 1), dot entries ("." and "..") are not filtered out and they will appear in the read items. When all directory items have been read and no item to read, a null string is returned into the fname[] without any error. When a null pointer is given to the fno, the read index of the directory object is rewinded.

    -

    When LFN feature is enabled, lfname and lfsize in the file information structure must be initialized with valid value prior to use it. The lfname is a pointer to the LFN read buffer. The lfsize is size of the LFN read buffer in unit of TCHAR. If the LFN is not needed, set a null pointer to the lfname and the LFN is not returned. A null string will be returned into the LFN read buffer in case of following conditions.

    +

    The f_readdir function reads a directory item, informations about the object. All items in the directory can be read in sequence by f_readdir function calls. Dot entries ("." and "..") in the sub-directory are filtered out and they will never appear in the read items. When all directory items have been read and no item to read, a nul string is stored into the fno->fname[] without any error. When a null pointer is given to the fno, the read index of the directory object is rewinded.

    +

    When support of long file name (LFN) is enabled, a member altname[] is defined in the file information structure to store the short file name of the object. In case of the some conditions listed below, short file name is stored into the fname[] and altname[] has a null string.

      -
    • The directory item has no LFN information.
    • -
    • Either the size of read buffer or LFN working buffer is insufficient for the LFN.
    • -
    • The LFN contains any Unicode character that cannot be converted to OEM code. (not the case at Unicode API cfg.)
    • +
    • The item has no long file name. (Not the case at exFAT volume)
    • +
    • Setting of _MAX_LFN is insufficient for the long file name. (Not the case at _MAX_LFN == 255)
    • +
    • The long file name contains any character not allowed in ANSI/OEM code. (Not the case at _LFN_UNICODE == 1)
    -

    When the directory item has no LFN information, lower case characters can be contained in the fname[].

    +

    There is a problem on reading a directory of exFAT volume. The exFAT does not support short file name. This means no name can be returned on the condition above. If it is the case, a "?" is returned as file name to indicate that the object is not accessible. To avoid this problem, configure FatFs _LFN_UNICODE = 1 and _MAX_LFN = 255 to support the full feature of LFN specification.

    @@ -70,40 +69,28 @@ FRESULT f_readdir (

    Sample Code

     FRESULT scan_files (
    -    char* path        /* Start node to be scanned (also used as work area) */
    +    char* path        /* Start node to be scanned (***also used as work area***) */
     )
     {
         FRESULT res;
    -    FILINFO fno;
         DIR dir;
    -    int i;
    -    char *fn;   /* This function assumes non-Unicode configuration */
    -#if _USE_LFN
    -    static char lfn[_MAX_LFN + 1];   /* Buffer to store the LFN */
    -    fno.lfname = lfn;
    -    fno.lfsize = sizeof lfn;
    -#endif
    +    UINT i;
    +    static FILINFO fno;
     
     
         res = f_opendir(&dir, path);                       /* Open the directory */
         if (res == FR_OK) {
    -        i = strlen(path);
             for (;;) {
                 res = f_readdir(&dir, &fno);                   /* Read a directory item */
                 if (res != FR_OK || fno.fname[0] == 0) break;  /* Break on error or end of dir */
    -            if (fno.fname[0] == '.') continue;             /* Ignore dot entry */
    -#if _USE_LFN
    -            fn = *fno.lfname ? fno.lfname : fno.fname;
    -#else
    -            fn = fno.fname;
    -#endif
                 if (fno.fattrib & AM_DIR) {                    /* It is a directory */
    -                sprintf(&path[i], "/%s", fn);
    -                res = scan_files(path);
    -                path[i] = 0;
    +                i = strlen(path);
    +                sprintf(&path[i], "/%s", fno.fname);
    +                res = scan_files(path);                    /* Enter the directory */
                     if (res != FR_OK) break;
    +                path[i] = 0;
                 } else {                                       /* It is a file. */
    -                printf("%s/%s\n", path, fn);
    +                printf("%s/%s\n", path, fno.fname);
                 }
             }
             f_closedir(&dir)
    @@ -111,6 +98,23 @@ FRESULT scan_files (
     
         return res;
     }
    +
    +
    +int main (void)
    +{
    +    FATFS fs;
    +    FRESULT res;
    +    char buff[256];
    +
    +
    +    res = f_mount(&fs, "", 1);
    +    if (res == FR_OK) {
    +        strcpy(buff, "/");
    +        res = scan_files(buff);
    +    }
    +
    +    return res;
    +}
     
    diff --git a/fatfs/doc/en/rename.html b/fatfs/doc/en/rename.html index 2593e89..10cb4fd 100644 --- a/fatfs/doc/en/rename.html +++ b/fatfs/doc/en/rename.html @@ -13,7 +13,7 @@

    f_rename

    -

    Renames a file or sub-directory.

    +

    The f_rename function renames and/or moves a file or sub-directory.

     FRESULT f_rename (
       const TCHAR* old_name, /* [IN] Old object name */
    @@ -26,9 +26,9 @@ FRESULT f_rename (
     

    Parameters

    old_name
    -
    Pointer to a null-terminated string that specifies an existing file or sub-directory to be renamed.
    +
    Pointer to a null-terminated string that specifies the existing file or sub-directory to be renamed.
    new_name
    -
    Pointer to a null-terminated string that specifies the new object name. The drive number specified in this string is ignored and one determined by old_name is used instead.
    +
    Pointer to a null-terminated string that specifies the new object name. A drive number may be specified in this string but it is ignored and assumed as the same drive of the old_name. Any object with this path name except old_name must not be exist, or the function fails with FR_EXIST.
    @@ -58,7 +58,7 @@ FRESULT f_rename (

    Description

    -

    Renames a file or sub-directory and can also move it to other directory within the same logical drive. Do not rename open objects or directry table can be broken.

    +

    Renames a file or sub-directory and can also move it to other directory in the same volume. The object to be renamed must not be an open object, or the FAT volume can be collapsed. Such the wrong operation is rejected safely when file lock function is enabled.

    @@ -71,11 +71,14 @@ FRESULT f_rename (

    Example

    -    /* Rename an object */
    +    /* Rename an object in the default drive */
         f_rename("oldname.txt", "newname.txt");
     
    -    /* Rename and move an object to other directory */
    -    f_rename("oldname.txt", "dir1/newname.txt");
    +    /* Rename an object in the drive 2 */
    +    f_rename("2:oldname.txt", "newname.txt");
    +
    +    /* Rename an object and move it to other directory in the volume */
    +    f_rename("log.txt", "old/log0001.txt");
     
    diff --git a/fatfs/doc/en/sdir.html b/fatfs/doc/en/sdir.html index 7eba555..a01a716 100644 --- a/fatfs/doc/en/sdir.html +++ b/fatfs/doc/en/sdir.html @@ -13,23 +13,21 @@

    DIR

    -

    The DIR structure is used for the work area to read a directory by f_oepndir()/f_readdir() function. Application program must not modify any member in this structure.

    +

    The DIR structure is used for the work area to read a directory by f_oepndir, f_readdir, f_findfirst and f_findnext function. Application program must not modify any member in this structure, or any data on the FAT volume can be collapsed.

     typedef struct {
    -    FATFS*  fs;         /* Pointer to the owner file system object */
    -    WORD    id;         /* Owner file system mount ID */
    -    WORD    index;      /* Index of directory entry to start to search next */
    -    DWORD   sclust;     /* Table start cluster (0:Root directory) */
    +    _FDID   obj;        /* Owner file sytem object and object identifier */
    +    DWORD   dptr;       /* Current read/write offset */
         DWORD   clust;      /* Current cluster */
         DWORD   sect;       /* Current sector */
         BYTE*   dir;        /* Pointer to the current SFN entry in the win[] */
         BYTE*   fn;         /* Pointer to the SFN buffer (in/out) {file[8],ext[3],status[1]} */
    -#if _FS_LOCK
    -    UINT    lockid;     /* Sub-directory lock ID (0:Root directory) */
    -#endif
     #if _USE_LFN
    -    WCHAR*  lfn;        /* Pointer to the LFN buffer (in/out) */
    -    WORD    lfn_idx;    /* Index of the LFN entris (0xFFFF:No LFN) */
    +    DWORD   blk_ofs;    /* Offset of the entry block (0xFFFFFFFF:Invalid) */
    +    WCHAR*  lfn;        /* Pointer to the LFN working buffer (in/out) */
    +#endif
    +#if _USE_FIND
    +    const TCHAR*  pat;  /* Ponter to the matching pattern */
     #endif
     } DIR;
     
    diff --git a/fatfs/doc/en/setlabel.html b/fatfs/doc/en/setlabel.html index 91179fc..f7a8b0e 100644 --- a/fatfs/doc/en/setlabel.html +++ b/fatfs/doc/en/setlabel.html @@ -49,12 +49,14 @@ FRESULT f_setlabel (

    Description

    -

    When the string has a drive number, the volume label will be set to the volume specified by the drive number. If not, the label will be set to the default drive. If the given string is a null-string, the volume label on the volume will be removed. The format of the volume label is similar to the short file name but there are some differences shown below:

    +

    When the string has a drive number, the volume label will be set to the volume specified by the drive number. If not, the volume label will be set to the default drive. If length of the given volume label is zero, the volume label on the volume will be removed. The format of the volume label on the FAT volume is similar to the file name but there are some differences shown below:

      -
    • 11 bytes or less in length as local character code. LFN extention is not applied to the volume label.
    • -
    • Cannot contain period.
    • -
    • Can contain spaces anywhere in the volume label. Trailing spaces are truncated off.
    • +
    • Spaces can be contained anywhere in the volume label. Trailing spaces are truncated off at FAT volume.
    • +
    • Period is not allowed.
    • +
    • Up to 11 bytes long as conversion of OEM code page at FAT volume.
    • +
    • Up to 11 characters long at exFAT volume. Case information is preserved.
    +

    Remark: The standard system (Windows) has a problem at handling of the volume label with a heading \xE5 on the FAT volume. To avoid this problem, this function rejects such volume label as invalid name.

    diff --git a/fatfs/doc/en/sfatfs.html b/fatfs/doc/en/sfatfs.html index b420850..e701f44 100644 --- a/fatfs/doc/en/sfatfs.html +++ b/fatfs/doc/en/sfatfs.html @@ -13,37 +13,45 @@

    FATFS

    -

    The FATFS structure (file system object) holds dynamic work area of individual logical drives. It is given by application program and registerd/unregisterd to the FatFs module with f_mount() function. Initialization is done on first API call after f_mount() function or media change. Application program must not modify any member in this structure.

    +

    The FATFS structure (file system object) holds dynamic work area of individual logical drives. It is given by application program and registerd/unregisterd to the FatFs module with f_mount function. Initialization is done on first API call after f_mount function or media change. Application program must not modify any member in this structure, or any data on the FAT volume can be collapsed.

     typedef struct {
    -    BYTE    fs_type;      /* FAT sub-type (0:Not mounted) */
    +    BYTE    fs_type;      /* File system type (0, FS_FAT12, FS_FAT16, FS_FAT32 or FS_EXFAT) */
         BYTE    drv;          /* Physical drive number */
    -    BYTE    csize;        /* Sectors per cluster (1,2,4,...,128) */
         BYTE    n_fats;       /* Number of FAT copies (1,2) */
         BYTE    wflag;        /* win[] flag (b0:win[] is dirty) */
         BYTE    fsi_flag;     /* FSINFO flags (b7:Disabled, b0:Dirty) */
         WORD    id;           /* File system mount ID */
         WORD    n_rootdir;    /* Number of root directory entries (FAT12/16) */
    +    WORD    csize;        /* Sectors per cluster */
     #if _MAX_SS != _MIN_SS
         WORD    ssize;        /* Sector size (512,1024,2048 or 4096) */
     #endif
    +#if _FS_EXFAT
    +    BYTE*   dirbuf;       /* Directory entry block scratchpad buffer */
    +#endif
     #if _FS_REENTRANT
         _SYNC_t sobj;         /* Identifier of sync object */
     #endif
     #if !_FS_READONLY
    -    DWORD   last_clust;   /* FSINFO: Last allocated cluster */
    -    DWORD   free_clust;   /* FSINFO: Number of free clusters */
    +    DWORD   last_clust;   /* FSINFO: Last allocated cluster (0xFFFFFFFF if invalid) */
    +    DWORD   free_clust;   /* FSINFO: Number of free clusters (0xFFFFFFFF if invalid) */
     #endif
     #if _FS_RPATH
    -    DWORD   cdir;         /* Current directory start cluster (0:root) */
    +    DWORD   cdir;         /* Cluster number of current directory (0:root) */
    +#if _FS_EXFAT
    +    DWORD   cdc_scl;      /* Containing directory start cluster (invalid when cdir is 0) */
    +    DWORD   cdc_size;     /* b31-b8:Size of containing directory, b7-b0: Chain status */
    +    DWORD   cdc_ofs;      /* Offset in the containing directory (invalid when cdir is 0) */
    +#endif
     #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   volbase;      /* Volume start sector */
    -    DWORD   fatbase;      /* FAT area start sector */
    -    DWORD   dirbase;      /* Root directory area start sector (FAT32: Cluster#) */
    -    DWORD   database;     /* Data area start sector */
    -    DWORD   winsect;      /* Current sector appearing in the win[] */
    +    DWORD   volbase;      /* Volume base LBA */
    +    DWORD   fatbase;      /* FAT base LBA */
    +    DWORD   dirbase;      /* Root directory base (LBA|Cluster) */
    +    DWORD   database;     /* Data base LBA */
    +    DWORD   winsect;      /* Sector LBA appearing in the win[] */
         BYTE    win[_MAX_SS]; /* Disk access window for directory, FAT (and file data at tiny cfg) */
     } FATFS;
     
    diff --git a/fatfs/doc/en/sfile.html b/fatfs/doc/en/sfile.html index 1ed9899..5e53d16 100644 --- a/fatfs/doc/en/sfile.html +++ b/fatfs/doc/en/sfile.html @@ -13,31 +13,25 @@

    FIL

    -

    The FIL structure (file object) holds the state of an open file. It is created by f_open() function and discarded by f_close() function. Application program must not modify any member in this structure except for cltbl. Note that a sector buffer is defined in this structure at non-tiny configuration (_FS_TINY == 0), so that the FIL structures at that configuration should not be defined as auto variable.

    +

    The FIL structure (file object) holds the state of an open file. It is created by f_open function and discarded by f_close function. Application program must not modify any member in this structure except for cltbl, or any data on the FAT volume can be collapsed. Note that a sector buffer is defined in this structure at non-tiny configuration (_FS_TINY == 0), so that the FIL structures at that configuration should not be defined as auto variable.

     typedef struct {
    -    FATFS*  fs;           /* Pointer to the owner file system object */
    -    WORD    id;           /* Owner file system mount ID */
    +    _FDID   obj;          /* Owner file sytem object and object identifier */
         BYTE    flag;         /* File object status flags */
         BYTE    err;          /* Abort flag (error code) */
    -    DWORD   fptr;         /* File read/write pointer (Byte offset origin from top of the file) */
    -    DWORD   fsize;        /* File size in unit of byte */
    -    DWORD   sclust;       /* File start cluster */
    -    DWORD   clust;        /* Current cluster */
    -    DWORD   dsect;        /* Current data sector */
    +    FSIZE_t fptr;         /* File read/write pointer (Byte offset origin from top of the file) */
    +    DWORD   clust;        /* Current cluster of fptr (One cluster behind if fptr is on the cluster boundary. Invalid if fptr == 0.) */
    +    DWORD   sect;         /* Current data sector (Can be invalid if fptr is on the cluster boundary.)*/
     #if !_FS_READONLY
    -    DWORD   dir_sect;     /* Sector containing the directory entry */
    +    DWORD   dir_sect;     /* Sector number containing the directory entry */
         BYTE*   dir_ptr;      /* Ponter to the directory entry in the window */
     #endif
     #if _USE_FASTSEEK
    -    DWORD*  cltbl;        /* Pointer to the cluster link map table (Nulled on file open) */
    -#endif
    -#if _FS_LOCK
    -    UINT    lockid;       /* Fle lock ID */
    +    DWORD*  cltbl;        /* Pointer to the cluster link map table (Nulled on file open. Set by application.) */
     #endif
     #if !_FS_TINY
    -    BYTE    buf[_MAX_SS]; /* File private data transfer buffer */
    +    BYTE    buf[_MAX_SS]; /* File private data transfer buffer (Always valid if fptr is not on the sector boundary but can be invalid if fptr is on the sector boundary.) */
     #endif
     } FIL;
     
    diff --git a/fatfs/doc/en/sfileinfo.html b/fatfs/doc/en/sfileinfo.html index ac254a1..6dae1fe 100644 --- a/fatfs/doc/en/sfileinfo.html +++ b/fatfs/doc/en/sfileinfo.html @@ -13,17 +13,18 @@

    FILINFO

    -

    The FILINFO structure holds a file information returned by f_readdir() and f_stat() function.

    +

    The FILINFO structure holds information about the object returned by f_readdir, f_findfirst, f_findnext and f_stat function.

     typedef struct {
    -    DWORD fsize;      /* File size */
    -    WORD  fdate;      /* Last modified date */
    -    WORD  ftime;      /* Last modified time */
    -    BYTE  fattrib;    /* Attribute */
    -    TCHAR fname[13];  /* Short file name (8.3 format) */
    -#if _USE_LFN
    -    TCHAR* lfname;    /* Pointer to the LFN buffer */
    -    int   lfsize;     /* Size of the LFN buffer in unit of TCHAR */
    +    FSIZE_t fsize;               /* File size */
    +    WORD    fdate;               /* Last modified date */
    +    WORD    ftime;               /* Last modified time */
    +    BYTE    fattrib;             /* Attribute */
    +#if _USE_LFN != 0
    +    TCHAR   altname[13];         /* Alternative object name */
    +    TCHAR   fname[_MAX_LFN + 1]; /* Primary object name */
    +#else
    +    TCHAR   fname[13];           /* Object name */
     #endif
     } FILINFO;
     
    @@ -32,9 +33,9 @@

    Members

    fsize
    -
    Indicates size of the file in unit of byte. Always zero for directories.
    +
    Indicates size of the file in unit of byte. FSIZE_t is an alias of integer type either DWORD(32-bit) or QWORD(64-bit) depends on the configuration option _FS_EXFAT. Do not care when the item is a directory.
    fdate
    -
    Indicates the date that the file was modified or the directory was created.
    +
    Indicates the date when the file was modified or the directory was created.
    bit15:9
    Year origin from 1980 (0..127)
    @@ -45,7 +46,7 @@
    ftime
    -
    Indicates the time that the file was modified or the directory was created.
    +
    Indicates the time when the file was modified or the directory was created.
    bit15:11
    Hour (0..23)
    @@ -58,11 +59,9 @@
    fattrib
    Indicates the file/directory attribute in combination of AM_DIR, AM_RDO, AM_HID, AM_SYS and AM_ARC.
    fname[]
    -
    Indicates the file/directory name in 8.3 format null-terminated string. It is always returnd with upper case in non-LFN configuration but it can be returned with lower case in LFN configuration.
    -
    lfname
    -
    Pointer to the LFN buffer to store the read LFN. This member must be initialized by application program prior to use this structure. Set a null pointer if LFN is not needed. Not available at non-LFN configuration.
    -
    lfsize
    -
    Size of the LFN buffer in unit of TCHAR. This member must be initialized by application program prior to use this structure. Not available at non-LFN configuration.
    +
    The null-terminated object name is stored. A null string is stored when no item to read and it indicates this structure is invalid.
    +
    altname[]
    +
    Alternative object name is stored if available. This member is not available at non-LFN configuration.

    Return

    diff --git a/fatfs/doc/en/size.html b/fatfs/doc/en/size.html index bb786c6..08990c6 100644 --- a/fatfs/doc/en/size.html +++ b/fatfs/doc/en/size.html @@ -15,7 +15,7 @@

    f_size

    The f_size function gets the size of a file.

    -DWORD f_size (
    +FSIZE_t f_size (
       FIL* fp   /* [IN] File object */
     );
     
    @@ -39,9 +39,9 @@ DWORD f_size (

    Description

    -

    In this revision, the f_size() function is implemented as a macro.

    +

    In this revision, the f_size function is implemented as a macro. It does not have any validation and mutual exclusion.

    -#define f_size(fp) ((fp)->fsize)
    +#define f_size(fp) ((fp)->obj.objsize)
     
    diff --git a/fatfs/doc/en/stat.html b/fatfs/doc/en/stat.html index db53c5d..2924660 100644 --- a/fatfs/doc/en/stat.html +++ b/fatfs/doc/en/stat.html @@ -54,8 +54,7 @@ FRESULT f_stat (

    Description

    -

    The f_stat() function checks the existence of a file or sub-directory. If not exist, the function returns with FR_NO_FILE. If exist, the function returns with FR_OK and the informations of the object, file size, timestamp, attribute and SFN, are stored to the file information structure. For details of the file information, refer to the FILINFO structure and f_readdir() function.

    -

    When LFN feature is enabled, lfname in the file information structure must be NULLed prior to use it.

    +

    The f_stat function checks the existence of a file or sub-directory. If not exist, the function returns with FR_NO_FILE. If exist, the function returns with FR_OK and the informations of the object, file size, timestamp and attribute, are stored to the file information structure. For details of the file information, refer to the FILINFO structure and f_readdir function.

    @@ -74,23 +73,20 @@ FRESULT f_stat ( printf("Test for 'file.txt'...\n"); -#if _USE_LFN - fno.lfname = 0; -#endif fr = f_stat("file.txt", &fno); switch (fr) { case FR_OK: - printf("Size: %u\n", fno.fsize); + printf("Size: %lu\n", fno.fsize); printf("Timestamp: %u/%02u/%02u, %02u:%02u\n", (fno.fdate >> 9) + 1980, fno.fdate >> 5 & 15, fno.fdate & 31, fno.ftime >> 11, fno.ftime >> 5 & 63); printf("Attributes: %c%c%c%c%c\n", - (fno.fattrib & AM_DIR) ? 'D' : '-', - (fno.fattrib & AM_RDO) ? 'R' : '-', - (fno.fattrib & AM_HID) ? 'H' : '-', - (fno.fattrib & AM_SYS) ? 'S' : '-', - (fno.fattrib & AM_ARC) ? 'A' : '-'); + (fno.fattrib & AM_DIR) ? 'D' : '-', + (fno.fattrib & AM_RDO) ? 'R' : '-', + (fno.fattrib & AM_HID) ? 'H' : '-', + (fno.fattrib & AM_SYS) ? 'S' : '-', + (fno.fattrib & AM_ARC) ? 'A' : '-'); break; case FR_NO_FILE: diff --git a/fatfs/doc/en/sync.html b/fatfs/doc/en/sync.html index 3e86b7f..3c16ac4 100644 --- a/fatfs/doc/en/sync.html +++ b/fatfs/doc/en/sync.html @@ -36,7 +36,6 @@ FRESULT f_sync ( FR_OK, FR_DISK_ERR, FR_INT_ERR, -FR_NOT_READY, FR_INVALID_OBJECT, FR_TIMEOUT

    @@ -45,8 +44,8 @@ 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() function of periodic or immediataly after f_write() function can minimize the risk of data loss due to a sudden blackout or an unintentional media removal. For more information, refer to application note.

    -

    However there is no sense in f_sync() function immediataly before f_close() function because it performs f_sync() function 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 function of periodic or immediataly after f_write function can minimize the risk of data loss due to a sudden blackout or an unintentional media removal. For more information, refer to application note.

    +

    However there is no sense in f_sync function immediataly before f_close function because it performs f_sync function in it. In other words, the differnce between those functions is that the file object is invalidated or not.

    diff --git a/fatfs/doc/en/tell.html b/fatfs/doc/en/tell.html index 93d03c9..7e0673c 100644 --- a/fatfs/doc/en/tell.html +++ b/fatfs/doc/en/tell.html @@ -15,7 +15,7 @@

    f_tell

    The f_tell function gets the current read/write pointer of a file.

    -DWORD f_tell (
    +FSIZE_t f_tell (
       FIL* fp   /* [IN] File object */
     );
     
    @@ -39,7 +39,7 @@ DWORD f_tell (

    Description

    -

    In this revision, the f_tell() function is implemented as a macro.

    +

    In this revision, the f_tell function is implemented as a macro. It does not have any validation and mutual exclusion.

     #define f_tell(fp) ((fp)->fptr)
     
    diff --git a/fatfs/doc/en/truncate.html b/fatfs/doc/en/truncate.html index 7dc980d..d0079d7 100644 --- a/fatfs/doc/en/truncate.html +++ b/fatfs/doc/en/truncate.html @@ -36,7 +36,7 @@ FRESULT f_truncate ( FR_OK, FR_DISK_ERR, FR_INT_ERR, -FR_NOT_READY, +FR_DENIED, FR_INVALID_OBJECT, FR_TIMEOUT

    @@ -45,7 +45,7 @@ FRESULT f_truncate (

    Description

    -

    The f_truncate() function truncates the file size to the current file read/write pointer. This function has no effect if the file read/write pointer is already pointing end of the file.

    +

    The f_truncate function truncates the file size to the current file read/write pointer. This function has no effect if the file read/write pointer is already pointing end of the file.

    diff --git a/fatfs/doc/en/unlink.html b/fatfs/doc/en/unlink.html index fc884c3..4cd1f66 100644 --- a/fatfs/doc/en/unlink.html +++ b/fatfs/doc/en/unlink.html @@ -25,7 +25,7 @@ FRESULT f_unlink (

    Parameter

    path
    -
    Pointer to the null-terminated string that specifies an object to be removed.
    +
    Pointer to a null-terminated string that specifies the file or sub-directory to be removed.
    @@ -59,7 +59,7 @@ FRESULT f_unlink ( If condition of the object to be removed is applicable to the following terms, the function will be rejected.
    • The file/sub-directory must not have read-only attribute (AM_RDO), or the function will be rejected with FR_DENIED.
    • The sub-directory must be empty and must not be current directory, or the function will be rejected with FR_DENIED.
    • -
    • The file/sub-directory must not be opened, or the FAT volume can be collapsed. It can be rejected with FR_LOCKED when file lock feature is enabled.
    • +
    • The file/sub-directory must not be opened, or the FAT volume can be collapsed. It will be rejected safely when file lock function is enabled.
    diff --git a/fatfs/doc/en/utime.html b/fatfs/doc/en/utime.html index 7466c19..6b7f291 100644 --- a/fatfs/doc/en/utime.html +++ b/fatfs/doc/en/utime.html @@ -55,7 +55,7 @@ FRESULT f_utime (

    Description

    -

    The f_utime() function changes the timestamp of a file or sub-directory

    +

    The f_utime function changes the timestamp of a file or sub-directory

    @@ -85,7 +85,7 @@ FRESULT set_timestamp (

    QuickInfo

    -

    Available when _FS_READONLY == 0 and _FS_MINIMIZE == 0.

    +

    Available when _FS_READONLY == 0 and _USE_CHMOD == 1.

    diff --git a/fatfs/doc/en/write.html b/fatfs/doc/en/write.html index 925fd56..7ca8ad6 100644 --- a/fatfs/doc/en/write.html +++ b/fatfs/doc/en/write.html @@ -34,7 +34,7 @@ FRESULT f_write (
    btw
    Specifies number of bytes to write in range of UINT type.
    bw
    -
    Pointer to the UINT variable to return the number of bytes written. The value is always valid after the function call regardless of the result.
    +
    Pointer to the UINT variable to return the number of bytes written. The value is always valid after the function call regardless of the result code.
    @@ -45,7 +45,6 @@ FRESULT f_write ( FR_OK, FR_DISK_ERR, FR_INT_ERR, -FR_NOT_READY, FR_INVALID_OBJECT, FR_TIMEOUT

    @@ -54,7 +53,7 @@ FRESULT f_write (

    Description

    -

    The read/write pointer of the file object advances number of bytes written. After the function succeeded, *bw should be checked to detect the disk full. In case of *bw is less than btw, it means the volume got full during the write operation. The function can take a time when the volume is full or close to full.

    +

    The function starts to write data to the file at the position pointed by the read/write pointer. The read/write pointer advances as number of bytes written. After the function succeeded, *bw should be checked to detect the disk full. In case of *bw < btw, it means the volume got full during the write operation. The function can take a time when the volume is full or close to full.

    -- cgit v1.2.3