mirror of
https://github.com/d0k3/GodMode9.git
synced 2025-06-26 13:42:47 +00:00
Update FatFS to R0.13c
This commit is contained in:
parent
e8c853a384
commit
0906b4e6d8
@ -322,3 +322,9 @@ R0.13b (April 07, 2018)
|
||||
|
||||
|
||||
|
||||
R0.13c (October 14, 2018)
|
||||
Supported stdint.h for C99 and later. (integer.h was included in ff.h)
|
||||
Fixed reading a directory gets infinite loop when the last directory entry is not empty. (appeared at R0.12)
|
||||
Fixed creating a sub-directory in the fragmented sub-directory on the exFAT volume collapses FAT chain of the parent directory. (appeared at R0.12)
|
||||
Fixed f_getcwd() cause output buffer overrun when the buffer has a valid drive number. (appeared at R0.13b)
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
FatFs Module Source Files R0.13b
|
||||
FatFs Module Source Files R0.13c
|
||||
|
||||
|
||||
FILES
|
||||
@ -10,7 +10,6 @@ FILES
|
||||
ff.h Common include file for FatFs and application module.
|
||||
diskio.h Common include file for FatFs and disk I/O module.
|
||||
diskio.c An example of glue function to attach existing disk I/O module to FatFs.
|
||||
integer.h Integer type definitions for FatFs.
|
||||
ffunicode.c Optional Unicode utility functions.
|
||||
ffsystem.c An example of optional O/S related functions.
|
||||
|
||||
|
24
arm9/source/fatfs/LICENSE.txt
Normal file
24
arm9/source/fatfs/LICENSE.txt
Normal file
@ -0,0 +1,24 @@
|
||||
FatFs License
|
||||
|
||||
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 heading the source files.
|
||||
|
||||
/*----------------------------------------------------------------------------/
|
||||
/ FatFs - Generic FAT Filesystem Module Rx.xx /
|
||||
/-----------------------------------------------------------------------------/
|
||||
/
|
||||
/ Copyright (C) 20xx, ChaN, all right reserved.
|
||||
/
|
||||
/ FatFs module is an open source software. Redistribution and use of FatFs in
|
||||
/ source and binary forms, with or without modification, are permitted provided
|
||||
/ that the following condition is met:
|
||||
/
|
||||
/ 1. Redistributions of source code must retain the above copyright notice,
|
||||
/ this condition and the following disclaimer.
|
||||
/
|
||||
/ 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 of 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 license that not conflict with FatFs license.
|
@ -1,5 +1,5 @@
|
||||
/*-----------------------------------------------------------------------*/
|
||||
/* Low level disk I/O module skeleton for FatFs (C)ChaN, 2014 */
|
||||
/* Low level disk I/O module skeleton for FatFs (C)ChaN, d0k3, 2019 */
|
||||
/*-----------------------------------------------------------------------*/
|
||||
/* If a working storage control module is available, it should be */
|
||||
/* attached to the FatFs via a glue function rather than modifying it. */
|
||||
@ -7,7 +7,8 @@
|
||||
/* storage control modules to the FatFs module with a defined API. */
|
||||
/*-----------------------------------------------------------------------*/
|
||||
|
||||
#include "diskio.h" /* FatFs lower layer API */
|
||||
#include "ff.h" /* Obtains integer types */
|
||||
#include "diskio.h" /* Declarations of disk functions */
|
||||
#include "image.h"
|
||||
#include "ramdrive.h"
|
||||
#include "nand.h"
|
||||
|
@ -12,8 +12,6 @@ extern "C" {
|
||||
#define _USE_WRITE 1 /* 1: Enable disk_write function */
|
||||
#define _USE_IOCTL 1 /* 1: Enable disk_ioctl fucntion */
|
||||
|
||||
#include "integer.h"
|
||||
|
||||
|
||||
/* Status of Disk Functions */
|
||||
typedef BYTE DSTATUS;
|
||||
@ -50,11 +48,11 @@ DRESULT disk_ioctl (BYTE pdrv, BYTE cmd, void* buff);
|
||||
/* Command code for disk_ioctrl fucntion */
|
||||
|
||||
/* Generic command (Used by FatFs) */
|
||||
#define CTRL_SYNC 0 /* Complete pending write process (needed at _FS_READONLY == 0) */
|
||||
#define GET_SECTOR_COUNT 1 /* Get media size (needed at _USE_MKFS == 1) */
|
||||
#define CTRL_SYNC 0 /* Complete pending write process (needed at FF_FS_READONLY == 0) */
|
||||
#define GET_SECTOR_COUNT 1 /* Get media size (needed at FF_USE_MKFS == 1) */
|
||||
#define GET_SECTOR_SIZE 2 /* Get sector size (needed at FF_MAX_SS != FF_MIN_SS) */
|
||||
#define GET_BLOCK_SIZE 3 /* Get erase block size (needed at _USE_MKFS == 1) */
|
||||
#define CTRL_TRIM 4 /* Inform device that the data on the block of sectors is no longer used (needed at _USE_TRIM == 1) */
|
||||
#define GET_BLOCK_SIZE 3 /* Get erase block size (needed at FF_USE_MKFS == 1) */
|
||||
#define CTRL_TRIM 4 /* Inform device that the data on the block of sectors is no longer used (needed at FF_USE_TRIM == 1) */
|
||||
|
||||
/* Generic command (Not used by FatFs) */
|
||||
#define CTRL_POWER 5 /* Get/Set power status */
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*----------------------------------------------------------------------------/
|
||||
/ FatFs - Generic FAT Filesystem Module R0.13b /
|
||||
/ FatFs - Generic FAT Filesystem Module R0.13c /
|
||||
/-----------------------------------------------------------------------------/
|
||||
/
|
||||
/ Copyright (C) 2018, ChaN, all right reserved.
|
||||
@ -29,11 +29,20 @@
|
||||
|
||||
---------------------------------------------------------------------------*/
|
||||
|
||||
#if FF_DEFINED != 63463 /* Revision ID */
|
||||
#if FF_DEFINED != 86604 /* Revision ID */
|
||||
#error Wrong include file (ff.h).
|
||||
#endif
|
||||
|
||||
|
||||
/* Limits and boundaries */
|
||||
#define MAX_DIR 0x200000 /* Max size of FAT directory */
|
||||
#define MAX_DIR_EX 0x10000000 /* Max size of exFAT directory */
|
||||
#define MAX_FAT12 0xFF5 /* Max FAT12 clusters (differs from specs, but right for real DOS/Windows behavior) */
|
||||
#define MAX_FAT16 0xFFF5 /* Max FAT16 clusters (differs from specs, but right for real DOS/Windows behavior) */
|
||||
#define MAX_FAT32 0x0FFFFFF5 /* Max FAT32 clusters (not specified, practical limit) */
|
||||
#define MAX_EXFAT 0x7FFFFFFD /* Max exFAT clusters (differs from specs, implementation limit) */
|
||||
|
||||
|
||||
/* Character code support macros */
|
||||
#define IsUpper(c) ((c) >= 'A' && (c) <= 'Z')
|
||||
#define IsLower(c) ((c) >= 'a' && (c) <= 'z')
|
||||
@ -43,18 +52,18 @@
|
||||
#define IsSurrogateL(c) ((c) >= 0xDC00 && (c) <= 0xDFFF)
|
||||
|
||||
|
||||
/* Additional file attribute bits for internal use */
|
||||
#define AM_VOL 0x08 /* Volume label */
|
||||
#define AM_LFN 0x0F /* LFN entry */
|
||||
#define AM_MASK 0x3F /* Mask of defined bits */
|
||||
|
||||
|
||||
/* Additional file access control and file status flags for internal use */
|
||||
#define FA_SEEKEND 0x20 /* Seek to end of the file on file open */
|
||||
#define FA_MODIFIED 0x40 /* File has been modified */
|
||||
#define FA_DIRTY 0x80 /* FIL.buf[] needs to be written-back */
|
||||
|
||||
|
||||
/* Additional file attribute bits for internal use */
|
||||
#define AM_VOL 0x08 /* Volume label */
|
||||
#define AM_LFN 0x0F /* LFN entry */
|
||||
#define AM_MASK 0x3F /* Mask of defined bits */
|
||||
|
||||
|
||||
/* Name status flags in fn[11] */
|
||||
#define NSFLAG 11 /* Index of the name status byte */
|
||||
#define NS_LOSS 0x01 /* Out of 8.3 format */
|
||||
@ -67,13 +76,13 @@
|
||||
#define NS_NONAME 0x80 /* Not followed */
|
||||
|
||||
|
||||
/* Limits and boundaries */
|
||||
#define MAX_DIR 0x200000 /* Max size of FAT directory */
|
||||
#define MAX_DIR_EX 0x10000000 /* Max size of exFAT directory */
|
||||
#define MAX_FAT12 0xFF5 /* Max FAT12 clusters (differs from specs, but right for real DOS/Windows behavior) */
|
||||
#define MAX_FAT16 0xFFF5 /* Max FAT16 clusters (differs from specs, but right for real DOS/Windows behavior) */
|
||||
#define MAX_FAT32 0x0FFFFFF5 /* Max FAT32 clusters (not specified, practical limit) */
|
||||
#define MAX_EXFAT 0x7FFFFFFD /* Max exFAT clusters (differs from specs, implementation limit) */
|
||||
/* exFAT directory entry types */
|
||||
#define ET_BITMAP 0x81 /* Allocation bitmap */
|
||||
#define ET_UPCASE 0x82 /* Up-case table */
|
||||
#define ET_VLABEL 0x83 /* Volume label */
|
||||
#define ET_FILEDIR 0x85 /* File and directory */
|
||||
#define ET_STREAM 0xC0 /* Stream extension */
|
||||
#define ET_FILENAME 0xC1 /* Name extension */
|
||||
|
||||
|
||||
/* FatFs refers the FAT structure as simple byte array instead of structure member
|
||||
@ -521,6 +530,7 @@ static WCHAR LfnBuf[FF_MAX_LFN + 1]; /* LFN working buffer */
|
||||
#define CODEPAGE CodePage
|
||||
static WORD CodePage; /* Current code page */
|
||||
static const BYTE *ExCvt, *DbcTbl; /* Pointer to current SBCS up-case table and DBCS code range table below */
|
||||
|
||||
static const BYTE Ct437[] = TBL_CT437;
|
||||
static const BYTE Ct720[] = TBL_CT720;
|
||||
static const BYTE Ct737[] = TBL_CT737;
|
||||
@ -1093,7 +1103,7 @@ static FRESULT sync_fs ( /* Returns FR_OK or FR_DISK_ERR */
|
||||
if (res == FR_OK) {
|
||||
if (fs->fs_type == FS_FAT32 && fs->fsi_flag == 1) { /* FAT32: Update FSInfo sector if needed */
|
||||
/* Create FSInfo structure */
|
||||
mem_set(fs->win, 0, SS(fs));
|
||||
mem_set(fs->win, 0, sizeof fs->win);
|
||||
st_word(fs->win + BS_55AA, 0xAA55);
|
||||
st_dword(fs->win + FSI_LeadSig, 0x41615252);
|
||||
st_dword(fs->win + FSI_StrucSig, 0x61417272);
|
||||
@ -1293,7 +1303,7 @@ static DWORD find_bitmap ( /* 0:Not found, 2..:Cluster block found, 0xFFFFFFFF:D
|
||||
if (clst >= fs->n_fatent - 2) clst = 0;
|
||||
scl = val = clst; ctr = 0;
|
||||
for (;;) {
|
||||
if (move_window(fs, fs->database + val / 8 / SS(fs)) != FR_OK) return 0xFFFFFFFF; /* (assuming bitmap is located top of the cluster heap) */
|
||||
if (move_window(fs, fs->bitbase + val / 8 / SS(fs)) != FR_OK) return 0xFFFFFFFF;
|
||||
i = val / 8 % SS(fs); bm = 1 << (val % 8);
|
||||
do {
|
||||
do {
|
||||
@ -1331,9 +1341,9 @@ static FRESULT change_bitmap (
|
||||
|
||||
|
||||
clst -= 2; /* The first bit corresponds to cluster #2 */
|
||||
sect = fs->database + clst / 8 / SS(fs); /* Sector address (assuming bitmap is located top of the cluster heap) */
|
||||
i = clst / 8 % SS(fs); /* Byte offset in the sector */
|
||||
bm = 1 << (clst % 8); /* Bit mask in the byte */
|
||||
sect = fs->bitbase + clst / 8 / SS(fs); /* Sector address */
|
||||
i = clst / 8 % SS(fs); /* Byte offset in the sector */
|
||||
bm = 1 << (clst % 8); /* Bit mask in the byte */
|
||||
for (;;) {
|
||||
if (move_window(fs, sect++) != FR_OK) return FR_DISK_ERR;
|
||||
do {
|
||||
@ -1406,7 +1416,7 @@ static FRESULT fill_last_frag (
|
||||
static FRESULT remove_chain ( /* FR_OK(0):succeeded, !=0:error */
|
||||
FFOBJID* obj, /* Corresponding object */
|
||||
DWORD clst, /* Cluster to remove a chain from */
|
||||
DWORD pclst /* Previous cluster of clst (0:entire chain) */
|
||||
DWORD pclst /* Previous cluster of clst (0 if entire chain) */
|
||||
)
|
||||
{
|
||||
FRESULT res = FR_OK;
|
||||
@ -1644,7 +1654,7 @@ static FRESULT dir_clear ( /* Returns FR_OK or FR_DISK_ERR */
|
||||
if (sync_window(fs) != FR_OK) return FR_DISK_ERR; /* Flush disk access window */
|
||||
sect = clst2sect(fs, clst); /* Top of the cluster */
|
||||
fs->winsect = sect; /* Set window to top of the cluster */
|
||||
mem_set(fs->win, 0, SS(fs)); /* Clear window buffer */
|
||||
mem_set(fs->win, 0, sizeof fs->win); /* Clear window buffer */
|
||||
#if FF_USE_LFN == 3 /* Quick table clear by using multi-secter write */
|
||||
/* Allocate a temporary buffer */
|
||||
for (szb = ((DWORD)fs->csize * SS(fs) >= MAX_MALLOC) ? MAX_MALLOC : fs->csize * SS(fs), ibuf = 0; szb > SS(fs) && (ibuf = ff_memalloc(szb)) == 0; szb /= 2) ;
|
||||
@ -1728,7 +1738,8 @@ static FRESULT dir_next ( /* FR_OK(0):succeeded, FR_NO_FILE:End of table, FR_DEN
|
||||
|
||||
|
||||
ofs = dp->dptr + SZDIRE; /* Next entry */
|
||||
if (dp->sect == 0 || ofs >= (DWORD)((FF_FS_EXFAT && fs->fs_type == FS_EXFAT) ? MAX_DIR_EX : MAX_DIR)) return FR_NO_FILE; /* Report EOT when offset has reached max value */
|
||||
if (ofs >= (DWORD)((FF_FS_EXFAT && fs->fs_type == FS_EXFAT) ? MAX_DIR_EX : MAX_DIR)) dp->sect = 0; /* Disable it if the offset reached the max value */
|
||||
if (dp->sect == 0) return FR_NO_FILE; /* Report EOT if it has been disabled */
|
||||
|
||||
if (ofs % SS(fs) == 0) { /* Sector changed? */
|
||||
dp->sect++; /* Next sector */
|
||||
@ -2153,33 +2164,33 @@ static FRESULT load_xdir ( /* FR_INT_ERR: invalid entry block */
|
||||
BYTE* dirb = dp->obj.fs->dirbuf; /* Pointer to the on-memory direcotry entry block 85+C0+C1s */
|
||||
|
||||
|
||||
/* Load 85 entry */
|
||||
/* Load file-directory entry */
|
||||
res = move_window(dp->obj.fs, dp->sect);
|
||||
if (res != FR_OK) return res;
|
||||
if (dp->dir[XDIR_Type] != 0x85) return FR_INT_ERR; /* Invalid order */
|
||||
if (dp->dir[XDIR_Type] != ET_FILEDIR) return FR_INT_ERR; /* Invalid order */
|
||||
mem_cpy(dirb + 0 * SZDIRE, dp->dir, SZDIRE);
|
||||
sz_ent = (dirb[XDIR_NumSec] + 1) * SZDIRE;
|
||||
if (sz_ent < 3 * SZDIRE || sz_ent > 19 * SZDIRE) return FR_INT_ERR;
|
||||
|
||||
/* Load C0 entry */
|
||||
/* Load stream-extension entry */
|
||||
res = dir_next(dp, 0);
|
||||
if (res == FR_NO_FILE) res = FR_INT_ERR; /* It cannot be */
|
||||
if (res != FR_OK) return res;
|
||||
res = move_window(dp->obj.fs, dp->sect);
|
||||
if (res != FR_OK) return res;
|
||||
if (dp->dir[XDIR_Type] != 0xC0) return FR_INT_ERR; /* Invalid order */
|
||||
if (dp->dir[XDIR_Type] != ET_STREAM) return FR_INT_ERR; /* Invalid order */
|
||||
mem_cpy(dirb + 1 * SZDIRE, dp->dir, SZDIRE);
|
||||
if (MAXDIRB(dirb[XDIR_NumName]) > sz_ent) return FR_INT_ERR;
|
||||
|
||||
/* Load C1 entries */
|
||||
i = 2 * SZDIRE; /* C1 offset to load */
|
||||
/* Load file-name entries */
|
||||
i = 2 * SZDIRE; /* Name offset to load */
|
||||
do {
|
||||
res = dir_next(dp, 0);
|
||||
if (res == FR_NO_FILE) res = FR_INT_ERR; /* It cannot be */
|
||||
if (res != FR_OK) return res;
|
||||
res = move_window(dp->obj.fs, dp->sect);
|
||||
if (res != FR_OK) return res;
|
||||
if (dp->dir[XDIR_Type] != 0xC1) return FR_INT_ERR; /* Invalid order */
|
||||
if (dp->dir[XDIR_Type] != ET_FILENAME) return FR_INT_ERR; /* Invalid order */
|
||||
if (i < MAXDIRB(FF_MAX_LFN)) mem_cpy(dirb + i, dp->dir, SZDIRE);
|
||||
} while ((i += SZDIRE) < sz_ent);
|
||||
|
||||
@ -2284,16 +2295,16 @@ static void create_xdir (
|
||||
WCHAR wc;
|
||||
|
||||
|
||||
/* Create 85,C0 entry */
|
||||
/* Create file-directory and stream-extension entry */
|
||||
mem_set(dirb, 0, 2 * SZDIRE);
|
||||
dirb[0 * SZDIRE + XDIR_Type] = 0x85; /* 85 entry */
|
||||
dirb[1 * SZDIRE + XDIR_Type] = 0xC0; /* C0 entry */
|
||||
dirb[0 * SZDIRE + XDIR_Type] = ET_FILEDIR;
|
||||
dirb[1 * SZDIRE + XDIR_Type] = ET_STREAM;
|
||||
|
||||
/* Create C1 entries */
|
||||
i = SZDIRE * 2; /* Top of C1 entries */
|
||||
/* Create file-name entries */
|
||||
i = SZDIRE * 2; /* Top of file_name entries */
|
||||
nlen = nc1 = 0; wc = 1;
|
||||
do {
|
||||
dirb[i++] = 0xC1; dirb[i++] = 0; /* Entry type C1 */
|
||||
dirb[i++] = ET_FILENAME; dirb[i++] = 0;
|
||||
do { /* Fill name field */
|
||||
if (wc != 0 && (wc = lfn[nlen]) != 0) nlen++; /* Get a character if exist */
|
||||
st_word(dirb + i, wc); /* Store it */
|
||||
@ -2317,8 +2328,8 @@ static void create_xdir (
|
||||
/* Read an object from the directory */
|
||||
/*-----------------------------------------------------------------------*/
|
||||
|
||||
#define dir_read_file(dp) dir_read(dp, 0)
|
||||
#define dir_read_label(dp) dir_read(dp, 1)
|
||||
#define DIR_READ_FILE(dp) dir_read(dp, 0)
|
||||
#define DIR_READ_LABEL(dp) dir_read(dp, 1)
|
||||
|
||||
static FRESULT dir_read (
|
||||
DIR* dp, /* Pointer to the directory object */
|
||||
@ -2327,7 +2338,7 @@ static FRESULT dir_read (
|
||||
{
|
||||
FRESULT res = FR_NO_FILE;
|
||||
FATFS *fs = dp->obj.fs;
|
||||
BYTE a, c;
|
||||
BYTE attr, b;
|
||||
#if FF_USE_LFN
|
||||
BYTE ord = 0xFF, sum = 0xFF;
|
||||
#endif
|
||||
@ -2335,16 +2346,16 @@ static FRESULT dir_read (
|
||||
while (dp->sect) {
|
||||
res = move_window(fs, dp->sect);
|
||||
if (res != FR_OK) break;
|
||||
c = dp->dir[DIR_Name]; /* Test for the entry type */
|
||||
if (c == 0) {
|
||||
b = dp->dir[DIR_Name]; /* Test for the entry type */
|
||||
if (b == 0) {
|
||||
res = FR_NO_FILE; break; /* Reached to end of the directory */
|
||||
}
|
||||
#if FF_FS_EXFAT
|
||||
if (fs->fs_type == FS_EXFAT) { /* On the exFAT volume */
|
||||
if (FF_USE_LABEL && vol) {
|
||||
if (c == 0x83) break; /* Volume label entry? */
|
||||
if (b == ET_VLABEL) break; /* Volume label entry? */
|
||||
} else {
|
||||
if (c == 0x85) { /* Start of the file entry block? */
|
||||
if (b == ET_FILEDIR) { /* Start of the file entry block? */
|
||||
dp->blk_ofs = dp->dptr; /* Get location of the block */
|
||||
res = load_xdir(dp); /* Load the entry block */
|
||||
if (res == FR_OK) {
|
||||
@ -2356,19 +2367,19 @@ static FRESULT dir_read (
|
||||
} else
|
||||
#endif
|
||||
{ /* On the FAT/FAT32 volume */
|
||||
dp->obj.attr = a = dp->dir[DIR_Attr] & AM_MASK; /* Get attribute */
|
||||
dp->obj.attr = attr = dp->dir[DIR_Attr] & AM_MASK; /* Get attribute */
|
||||
#if FF_USE_LFN /* LFN configuration */
|
||||
if (c == DDEM || c == '.' || (int)((a & ~AM_ARC) == AM_VOL) != vol) { /* An entry without valid data */
|
||||
if (b == DDEM || b == '.' || (int)((attr & ~AM_ARC) == AM_VOL) != vol) { /* An entry without valid data */
|
||||
ord = 0xFF;
|
||||
} else {
|
||||
if (a == AM_LFN) { /* An LFN entry is found */
|
||||
if (c & LLEF) { /* Is it start of an LFN sequence? */
|
||||
if (attr == AM_LFN) { /* An LFN entry is found */
|
||||
if (b & LLEF) { /* Is it start of an LFN sequence? */
|
||||
sum = dp->dir[LDIR_Chksum];
|
||||
c &= (BYTE)~LLEF; ord = c;
|
||||
b &= (BYTE)~LLEF; ord = b;
|
||||
dp->blk_ofs = dp->dptr;
|
||||
}
|
||||
/* Check LFN validity and capture it */
|
||||
ord = (c == ord && sum == dp->dir[LDIR_Chksum] && pick_lfn(fs->lfnbuf, dp->dir)) ? ord - 1 : 0xFF;
|
||||
ord = (b == ord && sum == dp->dir[LDIR_Chksum] && pick_lfn(fs->lfnbuf, dp->dir)) ? ord - 1 : 0xFF;
|
||||
} else { /* An SFN entry is found */
|
||||
if (ord != 0 || sum != sum_sfn(dp->dir)) { /* Is there a valid LFN? */
|
||||
dp->blk_ofs = 0xFFFFFFFF; /* It has no LFN. */
|
||||
@ -2377,7 +2388,7 @@ static FRESULT dir_read (
|
||||
}
|
||||
}
|
||||
#else /* Non LFN configuration */
|
||||
if (c != DDEM && c != '.' && a != AM_LFN && (int)((a & ~AM_ARC) == AM_VOL) == vol) { /* Is it a valid entry? */
|
||||
if (b != DDEM && b != '.' && attr != AM_LFN && (int)((attr & ~AM_ARC) == AM_VOL) == vol) { /* Is it a valid entry? */
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
@ -2417,7 +2428,7 @@ static FRESULT dir_find ( /* FR_OK(0):succeeded, !=0:error */
|
||||
UINT di, ni;
|
||||
WORD hash = xname_sum(fs->lfnbuf); /* Hash value of the name to find */
|
||||
|
||||
while ((res = dir_read_file(dp)) == FR_OK) { /* Read an item */
|
||||
while ((res = DIR_READ_FILE(dp)) == FR_OK) { /* Read an item */
|
||||
#if FF_MAX_LFN < 255
|
||||
if (fs->dirbuf[XDIR_NumName] > FF_MAX_LFN) continue; /* Skip comparison if inaccessible object name */
|
||||
#endif
|
||||
@ -2496,17 +2507,17 @@ static FRESULT dir_register ( /* FR_OK:succeeded, FR_DENIED:no free entry or too
|
||||
#if FF_FS_EXFAT
|
||||
if (fs->fs_type == FS_EXFAT) { /* On the exFAT volume */
|
||||
nent = (nlen + 14) / 15 + 2; /* Number of entries to allocate (85+C0+C1s) */
|
||||
res = dir_alloc(dp, nent); /* Allocate entries */
|
||||
res = dir_alloc(dp, nent); /* Allocate directory entries */
|
||||
if (res != FR_OK) return res;
|
||||
dp->blk_ofs = dp->dptr - SZDIRE * (nent - 1); /* Set the allocated entry block offset */
|
||||
|
||||
if (dp->obj.stat & 4) { /* Has the directory been stretched? */
|
||||
if (dp->obj.stat & 4) { /* Has the directory been stretched by new allocation? */
|
||||
dp->obj.stat &= ~4;
|
||||
res = fill_first_frag(&dp->obj); /* Fill the first fragment on the FAT if needed */
|
||||
if (res != FR_OK) return res;
|
||||
res = fill_last_frag(&dp->obj, dp->clust, 0xFFFFFFFF); /* Fill the last fragment on the FAT if needed */
|
||||
if (res != FR_OK) return res;
|
||||
if (dp->obj.sclust != 0) { /* Is it a sub directory? */
|
||||
if (dp->obj.sclust != 0) { /* Is it a sub-directory? */
|
||||
DIR dj;
|
||||
|
||||
res = load_obj_xdir(&dj, &dp->obj); /* Load the object status */
|
||||
@ -3256,7 +3267,7 @@ static FRESULT find_volume ( /* FR_OK(0): successful, !=0: an error occurred */
|
||||
if (SS(fs) > FF_MAX_SS || SS(fs) < FF_MIN_SS || (SS(fs) & (SS(fs) - 1))) return FR_DISK_ERR;
|
||||
#endif
|
||||
|
||||
/* Find an FAT partition on the drive. Supports only generic partitioning rules, FDISK and SFD. */
|
||||
/* Find an FAT partition on the drive. Supports only generic partitioning rules, FDISK (MBR) and SFD (w/o partition). */
|
||||
bsect = 0;
|
||||
fmt = check_fs(fs, bsect); /* Load sector 0 and check if it is an FAT-VBR as SFD */
|
||||
if (fmt == 2 || (fmt < 2 && LD2PT(vol) != 0)) { /* Not an FAT-VBR or forced partition number */
|
||||
@ -3279,6 +3290,7 @@ static FRESULT find_volume ( /* FR_OK(0): successful, !=0: an error occurred */
|
||||
#if FF_FS_EXFAT
|
||||
if (fmt == 1) {
|
||||
QWORD maxlba;
|
||||
DWORD so, cv, bcl;
|
||||
|
||||
for (i = BPB_ZeroedEx; i < BPB_ZeroedEx + 53 && fs->win[i] == 0; i++) ; /* Check zero filler */
|
||||
if (i < BPB_ZeroedEx + 53) return FR_NO_FILESYSTEM;
|
||||
@ -3311,12 +3323,27 @@ static FRESULT find_volume ( /* FR_OK(0): successful, !=0: an error occurred */
|
||||
if (maxlba < (QWORD)fs->database + nclst * fs->csize) return FR_NO_FILESYSTEM; /* (Volume size must not be smaller than the size requiered) */
|
||||
fs->dirbase = ld_dword(fs->win + BPB_RootClusEx);
|
||||
|
||||
/* Check if bitmap location is in assumption (at the first cluster) */
|
||||
if (move_window(fs, clst2sect(fs, fs->dirbase)) != FR_OK) return FR_DISK_ERR;
|
||||
for (i = 0; i < SS(fs); i += SZDIRE) {
|
||||
if (fs->win[i] == 0x81 && ld_dword(fs->win + i + 20) == 2) break; /* 81 entry with cluster #2? */
|
||||
/* Get bitmap location and check if it is contiguous (implementation assumption) */
|
||||
so = i = 0;
|
||||
for (;;) { /* Find the bitmap entry in the root directory (in only first cluster) */
|
||||
if (i == 0) {
|
||||
if (so >= fs->csize) return FR_NO_FILESYSTEM; /* Not found? */
|
||||
if (move_window(fs, clst2sect(fs, fs->dirbase) + so) != FR_OK) return FR_DISK_ERR;
|
||||
so++;
|
||||
}
|
||||
if (fs->win[i] == ET_BITMAP) break; /* Is it a bitmap entry? */
|
||||
i = (i + SZDIRE) % SS(fs); /* Next entry */
|
||||
}
|
||||
if (i == SS(fs)) return FR_NO_FILESYSTEM;
|
||||
bcl = ld_dword(fs->win + i + 20); /* Bitmap cluster */
|
||||
if (bcl < 2 || bcl >= fs->n_fatent) return FR_NO_FILESYSTEM;
|
||||
fs->bitbase = fs->database + fs->csize * (bcl - 2); /* Bitmap sector */
|
||||
for (;;) { /* Check if bitmap is contiguous */
|
||||
if (move_window(fs, fs->fatbase + bcl / (SS(fs) / 4)) != FR_OK) return FR_DISK_ERR;
|
||||
cv = ld_dword(fs->win + bcl % (SS(fs) / 4) * 4);
|
||||
if (cv == 0xFFFFFFFF) break; /* Last link? */
|
||||
if (cv != ++bcl) return FR_NO_FILESYSTEM; /* Fragmented? */
|
||||
}
|
||||
|
||||
#if !FF_FS_READONLY
|
||||
fs->last_clst = fs->free_clst = 0xFFFFFFFF; /* Initialize cluster allocation information */
|
||||
#endif
|
||||
@ -3666,7 +3693,7 @@ FRESULT f_open (
|
||||
fp->fptr = 0; /* Set file pointer top of the file */
|
||||
#if !FF_FS_READONLY
|
||||
#if !FF_FS_TINY
|
||||
mem_set(fp->buf, 0, FF_MAX_SS); /* Clear sector buffer */
|
||||
mem_set(fp->buf, 0, sizeof fp->buf); /* Clear sector buffer */
|
||||
#endif
|
||||
if ((mode & FA_SEEKEND) && fp->obj.objsize > 0) { /* Seek to end of file if FA_OPEN_APPEND is specified */
|
||||
fp->fptr = fp->obj.objsize; /* Offset to seek */
|
||||
@ -4146,6 +4173,7 @@ FRESULT f_getcwd (
|
||||
|
||||
|
||||
/* Get logical drive */
|
||||
buff[0] = 0; /* Set null string to get current volume */
|
||||
res = find_volume((const TCHAR**)&buff, &fs, 0); /* Get current volume */
|
||||
if (res == FR_OK) {
|
||||
dj.obj.fs = fs;
|
||||
@ -4164,7 +4192,7 @@ FRESULT f_getcwd (
|
||||
res = dir_sdi(&dj, 0);
|
||||
if (res != FR_OK) break;
|
||||
do { /* Find the entry links to the child directory */
|
||||
res = dir_read_file(&dj);
|
||||
res = DIR_READ_FILE(&dj);
|
||||
if (res != FR_OK) break;
|
||||
if (ccl == ld_clust(fs, dj.dir)) break; /* Found the entry */
|
||||
res = dir_next(&dj, 0);
|
||||
@ -4496,7 +4524,7 @@ FRESULT f_readdir (
|
||||
res = dir_sdi(dp, 0); /* Rewind the directory object */
|
||||
} else {
|
||||
INIT_NAMBUF(fs);
|
||||
res = dir_read_file(dp); /* Read an item */
|
||||
res = DIR_READ_FILE(dp); /* Read an item */
|
||||
if (res == FR_NO_FILE) res = FR_OK; /* Ignore end of directory */
|
||||
if (res == FR_OK) { /* A valid entry is found */
|
||||
get_fileinfo(dp, fno); /* Get the object information */
|
||||
@ -4641,7 +4669,7 @@ FRESULT f_getfree (
|
||||
UINT b;
|
||||
|
||||
clst = fs->n_fatent - 2; /* Number of clusters */
|
||||
sect = fs->database; /* Assuming bitmap starts at cluster 2 */
|
||||
sect = fs->bitbase; /* Bitmap sector */
|
||||
i = 0; /* Offset in the sector */
|
||||
do { /* Counts numbuer of bits with zero in the bitmap */
|
||||
if (i == 0) {
|
||||
@ -4804,7 +4832,7 @@ FRESULT f_unlink (
|
||||
#endif
|
||||
res = dir_sdi(&sdj, 0);
|
||||
if (res == FR_OK) {
|
||||
res = dir_read_file(&sdj); /* Test if the directory is empty */
|
||||
res = DIR_READ_FILE(&sdj); /* Test if the directory is empty */
|
||||
if (res == FR_OK) res = FR_DENIED; /* Not empty? */
|
||||
if (res == FR_NO_FILE) res = FR_OK; /* Empty? */
|
||||
}
|
||||
@ -4842,73 +4870,69 @@ FRESULT f_mkdir (
|
||||
{
|
||||
FRESULT res;
|
||||
DIR dj;
|
||||
FFOBJID sobj;
|
||||
FATFS *fs;
|
||||
BYTE *dir;
|
||||
DWORD dcl, pcl, tm;
|
||||
DEF_NAMBUF
|
||||
|
||||
|
||||
/* Get logical drive */
|
||||
res = find_volume(&path, &fs, FA_WRITE);
|
||||
res = find_volume(&path, &fs, FA_WRITE); /* Get logical drive */
|
||||
if (res == FR_OK) {
|
||||
dj.obj.fs = fs;
|
||||
INIT_NAMBUF(fs);
|
||||
res = follow_path(&dj, path); /* Follow the file path */
|
||||
if (res == FR_OK) res = FR_EXIST; /* Any object with same name is already existing */
|
||||
if (FF_FS_RPATH && res == FR_NO_FILE && (dj.fn[NSFLAG] & NS_DOT)) {
|
||||
if (res == FR_OK) res = FR_EXIST; /* Name collision? */
|
||||
if (FF_FS_RPATH && res == FR_NO_FILE && (dj.fn[NSFLAG] & NS_DOT)) { /* Invalid name? */
|
||||
res = FR_INVALID_NAME;
|
||||
}
|
||||
if (res == FR_NO_FILE) { /* Can create a new directory */
|
||||
dcl = create_chain(&dj.obj, 0); /* Allocate a cluster for the new directory table */
|
||||
dj.obj.objsize = (DWORD)fs->csize * SS(fs);
|
||||
if (res == FR_NO_FILE) { /* It is clear to create a new directory */
|
||||
sobj.fs = fs; /* New object id to create a new chain */
|
||||
dcl = create_chain(&sobj, 0); /* Allocate a cluster for the new directory */
|
||||
res = FR_OK;
|
||||
if (dcl == 0) res = FR_DENIED; /* No space to allocate a new cluster */
|
||||
if (dcl == 1) res = FR_INT_ERR;
|
||||
if (dcl == 0xFFFFFFFF) res = FR_DISK_ERR;
|
||||
if (res == FR_OK) res = sync_window(fs); /* Flush FAT */
|
||||
if (dcl == 0) res = FR_DENIED; /* No space to allocate a new cluster? */
|
||||
if (dcl == 1) res = FR_INT_ERR; /* Any insanity? */
|
||||
if (dcl == 0xFFFFFFFF) res = FR_DISK_ERR; /* Disk error? */
|
||||
tm = GET_FATTIME();
|
||||
if (res == FR_OK) { /* Initialize the new directory table */
|
||||
res = dir_clear(fs, dcl); /* Clean up the new table */
|
||||
if (res == FR_OK && (!FF_FS_EXFAT || fs->fs_type != FS_EXFAT)) { /* Create dot entries (FAT only) */
|
||||
dir = fs->win;
|
||||
mem_set(dir + DIR_Name, ' ', 11); /* Create "." entry */
|
||||
dir[DIR_Name] = '.';
|
||||
dir[DIR_Attr] = AM_DIR;
|
||||
st_dword(dir + DIR_ModTime, tm);
|
||||
st_clust(fs, dir, dcl);
|
||||
mem_cpy(dir + SZDIRE, dir, SZDIRE); /* Create ".." entry */
|
||||
dir[SZDIRE + 1] = '.'; pcl = dj.obj.sclust;
|
||||
st_clust(fs, dir + SZDIRE, pcl);
|
||||
fs->wflag = 1;
|
||||
}
|
||||
}
|
||||
if (res == FR_OK) {
|
||||
res = dir_register(&dj); /* Register the object to the directoy */
|
||||
res = dir_clear(fs, dcl); /* Clean up the new table */
|
||||
if (res == FR_OK) {
|
||||
if (!FF_FS_EXFAT || fs->fs_type != FS_EXFAT) { /* Create dot entries (FAT only) */
|
||||
mem_set(fs->win + DIR_Name, ' ', 11); /* Create "." entry */
|
||||
fs->win[DIR_Name] = '.';
|
||||
fs->win[DIR_Attr] = AM_DIR;
|
||||
st_dword(fs->win + DIR_ModTime, tm);
|
||||
st_clust(fs, fs->win, dcl);
|
||||
mem_cpy(fs->win + SZDIRE, fs->win, SZDIRE); /* Create ".." entry */
|
||||
fs->win[SZDIRE + 1] = '.'; pcl = dj.obj.sclust;
|
||||
st_clust(fs, fs->win + SZDIRE, pcl);
|
||||
fs->wflag = 1;
|
||||
}
|
||||
res = dir_register(&dj); /* Register the object to the parent directoy */
|
||||
}
|
||||
}
|
||||
if (res == FR_OK) {
|
||||
#if FF_FS_EXFAT
|
||||
if (fs->fs_type == FS_EXFAT) { /* Initialize directory entry block */
|
||||
st_dword(fs->dirbuf + XDIR_ModTime, tm); /* Created time */
|
||||
st_dword(fs->dirbuf + XDIR_FstClus, dcl); /* Table start cluster */
|
||||
st_dword(fs->dirbuf + XDIR_FileSize, (DWORD)dj.obj.objsize); /* File size needs to be valid */
|
||||
st_dword(fs->dirbuf + XDIR_ValidFileSize, (DWORD)dj.obj.objsize);
|
||||
st_dword(fs->dirbuf + XDIR_FileSize, (DWORD)fs->csize * SS(fs)); /* File size needs to be valid */
|
||||
st_dword(fs->dirbuf + XDIR_ValidFileSize, (DWORD)fs->csize * SS(fs));
|
||||
fs->dirbuf[XDIR_GenFlags] = 3; /* Initialize the object flag */
|
||||
fs->dirbuf[XDIR_Attr] = AM_DIR; /* Attribute */
|
||||
res = store_xdir(&dj);
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
dir = dj.dir;
|
||||
st_dword(dir + DIR_ModTime, tm); /* Created time */
|
||||
st_clust(fs, dir, dcl); /* Table start cluster */
|
||||
dir[DIR_Attr] = AM_DIR; /* Attribute */
|
||||
st_dword(dj.dir + DIR_ModTime, tm); /* Created time */
|
||||
st_clust(fs, dj.dir, dcl); /* Table start cluster */
|
||||
dj.dir[DIR_Attr] = AM_DIR; /* Attribute */
|
||||
fs->wflag = 1;
|
||||
}
|
||||
if (res == FR_OK) {
|
||||
res = sync_fs(fs);
|
||||
}
|
||||
} else {
|
||||
remove_chain(&dj.obj, dcl, 0); /* Could not register, remove cluster chain */
|
||||
remove_chain(&sobj, dcl, 0); /* Could not register, remove the allocated cluster */
|
||||
}
|
||||
}
|
||||
FREE_NAMBUF();
|
||||
@ -5148,7 +5172,7 @@ FRESULT f_getlabel (
|
||||
dj.obj.fs = fs; dj.obj.sclust = 0; /* Open root directory */
|
||||
res = dir_sdi(&dj, 0);
|
||||
if (res == FR_OK) {
|
||||
res = dir_read_label(&dj); /* Find a volume label entry */
|
||||
res = DIR_READ_LABEL(&dj); /* Find a volume label entry */
|
||||
if (res == FR_OK) {
|
||||
#if FF_FS_EXFAT
|
||||
if (fs->fs_type == FS_EXFAT) {
|
||||
@ -5293,7 +5317,7 @@ FRESULT f_setlabel (
|
||||
dj.obj.fs = fs; dj.obj.sclust = 0; /* Open root directory */
|
||||
res = dir_sdi(&dj, 0);
|
||||
if (res == FR_OK) {
|
||||
res = dir_read_label(&dj); /* Get volume label entry */
|
||||
res = DIR_READ_LABEL(&dj); /* Get volume label entry */
|
||||
if (res == FR_OK) {
|
||||
if (FF_FS_EXFAT && fs->fs_type == FS_EXFAT) {
|
||||
dj.dir[XDIR_NumLabel] = (BYTE)di; /* Change the volume label */
|
||||
@ -5315,7 +5339,7 @@ FRESULT f_setlabel (
|
||||
if (res == FR_OK) {
|
||||
mem_set(dj.dir, 0, SZDIRE); /* Clean the entry */
|
||||
if (FF_FS_EXFAT && fs->fs_type == FS_EXFAT) {
|
||||
dj.dir[XDIR_Type] = 0x83; /* Create 83 entry */
|
||||
dj.dir[XDIR_Type] = ET_VLABEL; /* Create volume label entry */
|
||||
dj.dir[XDIR_NumLabel] = (BYTE)di;
|
||||
mem_cpy(dj.dir + XDIR_Label, dirvn, 22);
|
||||
} else {
|
||||
@ -5701,11 +5725,11 @@ FRESULT f_mkfs (
|
||||
|
||||
/* Initialize the root directory */
|
||||
mem_set(buf, 0, szb_buf);
|
||||
buf[SZDIRE * 0 + 0] = 0x83; /* 83 entry (volume label) */
|
||||
buf[SZDIRE * 1 + 0] = 0x81; /* 81 entry (allocation bitmap) */
|
||||
buf[SZDIRE * 0 + 0] = ET_VLABEL; /* Volume label entry */
|
||||
buf[SZDIRE * 1 + 0] = ET_BITMAP; /* Bitmap entry */
|
||||
st_dword(buf + SZDIRE * 1 + 20, 2); /* cluster */
|
||||
st_dword(buf + SZDIRE * 1 + 24, szb_bit); /* size */
|
||||
buf[SZDIRE * 2 + 0] = 0x82; /* 82 entry (up-case table) */
|
||||
buf[SZDIRE * 2 + 0] = ET_UPCASE; /* Up-case table entry */
|
||||
st_dword(buf + SZDIRE * 2 + 4, sum); /* sum */
|
||||
st_dword(buf + SZDIRE * 2 + 20, 2 + tbl[0]); /* cluster */
|
||||
st_dword(buf + SZDIRE * 2 + 24, szb_case); /* size */
|
||||
@ -6193,8 +6217,7 @@ typedef struct { /* Putchar output buffer and work area */
|
||||
} putbuff;
|
||||
|
||||
|
||||
static
|
||||
void putc_bfd ( /* Buffered write with code conversion */
|
||||
static void putc_bfd ( /* Buffered write with code conversion */
|
||||
putbuff* pb,
|
||||
TCHAR c
|
||||
)
|
||||
@ -6305,7 +6328,7 @@ void putc_bfd ( /* Buffered write with code conversion */
|
||||
#else /* Write it in ANSI/OEM */
|
||||
if (hs != 0) return;
|
||||
wc = ff_uni2oem(wc, CODEPAGE); /* UTF-16 ==> ANSI/OEM */
|
||||
if (wc == 0) return;;
|
||||
if (wc == 0) return;
|
||||
if (wc >= 0x100) {
|
||||
pb->buf[i++] = (BYTE)(wc >> 8); nc++;
|
||||
}
|
||||
@ -6325,8 +6348,7 @@ void putc_bfd ( /* Buffered write with code conversion */
|
||||
}
|
||||
|
||||
|
||||
static
|
||||
int putc_flush ( /* Flush left characters in the buffer */
|
||||
static int putc_flush ( /* Flush left characters in the buffer */
|
||||
putbuff* pb
|
||||
)
|
||||
{
|
||||
@ -6339,8 +6361,7 @@ int putc_flush ( /* Flush left characters in the buffer */
|
||||
}
|
||||
|
||||
|
||||
static
|
||||
void putc_init ( /* Initialize write buffer */
|
||||
static void putc_init ( /* Initialize write buffer */
|
||||
putbuff* pb,
|
||||
FIL* fp
|
||||
)
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*----------------------------------------------------------------------------/
|
||||
/ FatFs - Generic FAT Filesystem module R0.13b /
|
||||
/ FatFs - Generic FAT Filesystem module R0.13c /
|
||||
/-----------------------------------------------------------------------------/
|
||||
/
|
||||
/ Copyright (C) 2018, ChaN, all right reserved.
|
||||
@ -20,13 +20,12 @@
|
||||
|
||||
|
||||
#ifndef FF_DEFINED
|
||||
#define FF_DEFINED 63463 /* Revision ID */
|
||||
#define FF_DEFINED 86604 /* Revision ID */
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "integer.h" /* Basic integer types */
|
||||
#include "ffconf.h" /* FatFs configuration options */
|
||||
|
||||
#if FF_DEFINED != FFCONF_DEF
|
||||
@ -34,6 +33,30 @@ extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
/* Integer types used for FatFs API */
|
||||
|
||||
#if defined(_WIN32) /* Main development platform */
|
||||
#define FF_INTDEF 2
|
||||
#include <windows.h>
|
||||
typedef unsigned __int64 QWORD;
|
||||
#elif (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) || defined(__cplusplus) /* C99 or later */
|
||||
#define FF_INTDEF 2
|
||||
#include <stdint.h>
|
||||
typedef unsigned int UINT; /* int must be 16-bit or 32-bit */
|
||||
typedef unsigned char BYTE; /* char must be 8-bit */
|
||||
typedef uint16_t WORD; /* 16-bit unsigned integer */
|
||||
typedef uint16_t WCHAR; /* 16-bit unsigned integer */
|
||||
typedef uint32_t DWORD; /* 32-bit unsigned integer */
|
||||
typedef uint64_t QWORD; /* 64-bit unsigned integer */
|
||||
#else /* Earlier than C99 */
|
||||
#define FF_INTDEF 1
|
||||
typedef unsigned int UINT; /* int must be 16-bit or 32-bit */
|
||||
typedef unsigned char BYTE; /* char must be 8-bit */
|
||||
typedef unsigned short WORD; /* 16-bit unsigned integer */
|
||||
typedef unsigned short WCHAR; /* 16-bit unsigned integer */
|
||||
typedef unsigned long DWORD; /* 32-bit unsigned integer */
|
||||
#endif
|
||||
|
||||
|
||||
/* Definitions of volume management */
|
||||
|
||||
@ -85,6 +108,9 @@ typedef char TCHAR;
|
||||
/* Type of file size variables */
|
||||
|
||||
#if FF_FS_EXFAT
|
||||
#if FF_INTDEF != 2
|
||||
#error exFAT feature wants C99 or later
|
||||
#endif
|
||||
typedef QWORD FSIZE_t;
|
||||
#else
|
||||
typedef DWORD FSIZE_t;
|
||||
@ -95,8 +121,8 @@ typedef DWORD FSIZE_t;
|
||||
/* Filesystem object structure (FATFS) */
|
||||
|
||||
typedef struct {
|
||||
BYTE fs_type; /* Filesystem type (0:N/A) */
|
||||
BYTE pdrv; /* Physical drive number */
|
||||
BYTE fs_type; /* Filesystem type (0:not mounted) */
|
||||
BYTE pdrv; /* Associated physical drive */
|
||||
BYTE n_fats; /* Number of FATs (1 or 2) */
|
||||
BYTE wflag; /* win[] flag (b0:dirty) */
|
||||
BYTE fsi_flag; /* FSINFO flags (b7:disabled, b0:dirty) */
|
||||
@ -133,6 +159,9 @@ typedef struct {
|
||||
DWORD fatbase; /* FAT base sector */
|
||||
DWORD dirbase; /* Root directory base sector/cluster */
|
||||
DWORD database; /* Data base sector */
|
||||
#if FF_FS_EXFAT
|
||||
DWORD bitbase; /* Allocation bitmap base sector */
|
||||
#endif
|
||||
DWORD winsect; /* Current sector appearing in the win[] */
|
||||
BYTE win[FF_MAX_SS]; /* Disk access window for Directory, FAT (and file data at tiny cfg) */
|
||||
} FATFS;
|
||||
@ -145,7 +174,7 @@ typedef struct {
|
||||
FATFS* fs; /* Pointer to the hosting volume of this object */
|
||||
WORD id; /* Hosting volume mount ID */
|
||||
BYTE attr; /* Object attribute */
|
||||
BYTE stat; /* Object chain status (b1-0: =0:not contiguous, =2:contiguous, =3:flagmented in this session, b2:sub-directory stretched) */
|
||||
BYTE stat; /* Object chain status (b1-0: =0:not contiguous, =2:contiguous, =3:fragmented in this session, b2:sub-directory stretched) */
|
||||
DWORD sclust; /* Object data start cluster (0:no cluster or root directory) */
|
||||
FSIZE_t objsize; /* Object size (valid when sclust != 0) */
|
||||
#if FF_FS_EXFAT
|
||||
|
@ -1,8 +1,8 @@
|
||||
/*---------------------------------------------------------------------------/
|
||||
/ FatFs - Configuration file
|
||||
/ FatFs Functional Configurations
|
||||
/---------------------------------------------------------------------------*/
|
||||
|
||||
#define FFCONF_DEF 63463 /* Revision ID */
|
||||
#define FFCONF_DEF 86604 /* Revision ID */
|
||||
|
||||
/*---------------------------------------------------------------------------/
|
||||
/ Function Configurations
|
||||
@ -262,6 +262,7 @@
|
||||
/ lock control is independent of re-entrancy. */
|
||||
|
||||
|
||||
/* #include <somertos.h> // O/S definitions */
|
||||
#define FF_FS_REENTRANT 0
|
||||
#define FF_FS_TIMEOUT 1000
|
||||
#define FF_SYNC_t HANDLE
|
||||
@ -282,8 +283,6 @@
|
||||
/ SemaphoreHandle_t and etc. A header file for O/S definitions needs to be
|
||||
/ included somewhere in the scope of ff.h. */
|
||||
|
||||
/* #include <windows.h> // O/S definitions */
|
||||
|
||||
|
||||
|
||||
/*--- End of configuration options ---*/
|
||||
|
@ -1,20 +1,19 @@
|
||||
/*------------------------------------------------------------------------*/
|
||||
/* Sample Code of OS Dependent Functions for FatFs */
|
||||
/* (C)ChaN, 2017 */
|
||||
/* (C)ChaN, 2018 */
|
||||
/*------------------------------------------------------------------------*/
|
||||
|
||||
|
||||
#include "ff.h"
|
||||
|
||||
|
||||
|
||||
#if FF_USE_LFN == 3 /* Dynamic memory allocation */
|
||||
|
||||
/*------------------------------------------------------------------------*/
|
||||
/* Allocate a memory block */
|
||||
/*------------------------------------------------------------------------*/
|
||||
|
||||
void* ff_memalloc ( /* Returns pointer to the allocated memory block (null on not enough core) */
|
||||
void* ff_memalloc ( /* Returns pointer to the allocated memory block (null if not enough core) */
|
||||
UINT msize /* Number of bytes to allocate */
|
||||
)
|
||||
{
|
||||
@ -27,7 +26,7 @@ void* ff_memalloc ( /* Returns pointer to the allocated memory block (null on no
|
||||
/*------------------------------------------------------------------------*/
|
||||
|
||||
void ff_memfree (
|
||||
void* mblock /* Pointer to the memory block to free (nothing to do for null) */
|
||||
void* mblock /* Pointer to the memory block to free (nothing to do if null) */
|
||||
)
|
||||
{
|
||||
free(mblock); /* Free the memory block with POSIX API */
|
||||
@ -47,7 +46,7 @@ void ff_memfree (
|
||||
/ When a 0 is returned, the f_mount() function fails with FR_INT_ERR.
|
||||
*/
|
||||
|
||||
//const osMutexDef_t Mutex[FF_VOLUMES]; /* CMSIS-RTOS */
|
||||
//const osMutexDef_t Mutex[FF_VOLUMES]; /* Table of CMSIS-RTOS mutex */
|
||||
|
||||
|
||||
int ff_cre_syncobj ( /* 1:Function succeeded, 0:Could not create the sync object */
|
||||
@ -74,7 +73,7 @@ int ff_cre_syncobj ( /* 1:Function succeeded, 0:Could not create the sync object
|
||||
// return (int)(*sobj != NULL);
|
||||
|
||||
/* CMSIS-RTOS */
|
||||
// *sobj = osMutexCreate(Mutex + vol);
|
||||
// *sobj = osMutexCreate(&Mutex[vol]);
|
||||
// return (int)(*sobj != NULL);
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*------------------------------------------------------------------------*/
|
||||
/* Unicode handling functions for FatFs R0.13b */
|
||||
/* Unicode handling functions for FatFs R0.13c */
|
||||
/*------------------------------------------------------------------------*/
|
||||
/* This module will occupy a huge memory in the .const section when the /
|
||||
/ FatFs is configured for LFN with DBCS. If the system has any Unicode /
|
||||
@ -25,9 +25,9 @@
|
||||
|
||||
#include "ff.h"
|
||||
|
||||
#if FF_USE_LFN /* This module is blanked when non-LFN configuration */
|
||||
#if FF_USE_LFN /* This module will be blanked at non-LFN configuration */
|
||||
|
||||
#if FF_DEFINED != 63463 /* Revision ID */
|
||||
#if FF_DEFINED != 86604 /* Revision ID */
|
||||
#error Wrong include file (ff.h).
|
||||
#endif
|
||||
|
||||
|
@ -1,36 +0,0 @@
|
||||
/*-------------------------------------------*/
|
||||
/* Integer type definitions for FatFs module */
|
||||
/*-------------------------------------------*/
|
||||
|
||||
#ifndef FF_INTEGER
|
||||
#define FF_INTEGER
|
||||
|
||||
#ifdef _WIN32 /* FatFs development platform */
|
||||
|
||||
#include <windows.h>
|
||||
typedef unsigned __int64 QWORD;
|
||||
|
||||
#else /* Embedded platform */
|
||||
|
||||
/* These types MUST be 16-bit or 32-bit */
|
||||
typedef int INT;
|
||||
typedef unsigned int UINT;
|
||||
|
||||
/* This type MUST be 8-bit */
|
||||
typedef unsigned char BYTE;
|
||||
|
||||
/* These types MUST be 16-bit */
|
||||
typedef short SHORT;
|
||||
typedef unsigned short WORD;
|
||||
typedef unsigned short WCHAR;
|
||||
|
||||
/* These types MUST be 32-bit */
|
||||
typedef long LONG;
|
||||
typedef unsigned long DWORD;
|
||||
|
||||
/* This type MUST be 64-bit (Remove this for ANSI C (C89) compatibility) */
|
||||
typedef unsigned long long QWORD;
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
@ -364,7 +364,7 @@ FRESULT fvx_findnopath (TCHAR* path, const TCHAR* pattern) {
|
||||
if (!n_rep) return (fvx_stat(path, NULL) == FR_OK) ? FR_NO_PATH : FR_OK;
|
||||
|
||||
while (fvx_stat(path, NULL) == FR_OK) {
|
||||
for (INT i = n_rep - 1; (i >= 0); i--) {
|
||||
for (int i = n_rep - 1; (i >= 0); i--) {
|
||||
if (*(rep[i]) == '9') {
|
||||
if (!i) return FR_NO_PATH;
|
||||
*(rep[i]) = '0';
|
||||
|
Loading…
x
Reference in New Issue
Block a user