Index: ff_blk.h =================================================================== --- ff_blk.h (revision 58178) +++ ff_blk.h (working copy) @@ -1,7 +1,19 @@ /***************************************************************************** - * FullFAT - High Performance, Thread-Safe Embedded FAT File-System * - * Copyright (C) 2009 James Walmsley (james@worm.me.uk) * + * FullFAT - High Performance, Thread-Safe Embedded FAT File-System * * * + * Copyright(C) 2009 James Walmsley * + * Copyright(C) 2011 Hein Tibosch * + * * + * See RESTRICTIONS.TXT for extra restrictions on the use of FullFAT. * + * * + * WARNING : COMMERCIAL PROJECTS MUST COMPLY WITH THE GNU GPL LICENSE. * + * * + * Projects that cannot comply with the GNU GPL terms are legally obliged * + * to seek alternative licensing. Contact James Walmsley for details. * + * * + ***************************************************************************** + * See http://www.fullfat-fs.co.uk/ for more information. * + ***************************************************************************** * This program is free software: you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation, either version 3 of the License, or * @@ -15,18 +27,14 @@ * You should have received a copy of the GNU General Public License * * along with this program. If not, see . * * * - * IMPORTANT NOTICE: * - * ================= * - * Alternative Licensing is available directly from the Copyright holder, * - * (James Walmsley). For more information consult LICENSING.TXT to obtain * - * a Commercial license. * + * The Copyright of Hein Tibosch on this project recognises his efforts in * + * contributing to this project. The right to license the project under * + * any other terms (other than the GNU GPL license) remains with the * + * original copyright holder (James Walmsley) only. * * * - * See RESTRICTIONS.TXT for extra restrictions on the use of FullFAT. * - * * - * Removing the above notice is illegal and will invalidate this license. * ***************************************************************************** - * See http://worm.me.uk/fullfat for more information. * - * Or http://fullfat.googlecode.com/ for latest releases and the wiki. * + * Modification/Extensions/Bugfixes/Improvements to FullFAT must be sent to * + * James Walmsley for integration into the main development branch. * *****************************************************************************/ /** Index: ff_config.h =================================================================== --- ff_config.h (revision 58178) +++ ff_config.h (working copy) @@ -1,7 +1,19 @@ /***************************************************************************** - * FullFAT - High Performance, Thread-Safe Embedded FAT File-System * - * Copyright (C) 2009 James Walmsley (james@worm.me.uk) * + * FullFAT - High Performance, Thread-Safe Embedded FAT File-System * * * + * Copyright(C) 2009 James Walmsley * + * Copyright(C) 2011 Hein Tibosch * + * * + * See RESTRICTIONS.TXT for extra restrictions on the use of FullFAT. * + * * + * WARNING : COMMERCIAL PROJECTS MUST COMPLY WITH THE GNU GPL LICENSE. * + * * + * Projects that cannot comply with the GNU GPL terms are legally obliged * + * to seek alternative licensing. Contact James Walmsley for details. * + * * + ***************************************************************************** + * See http://www.fullfat-fs.co.uk/ for more information. * + ***************************************************************************** * This program is free software: you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation, either version 3 of the License, or * @@ -15,21 +27,22 @@ * You should have received a copy of the GNU General Public License * * along with this program. If not, see . * * * - * IMPORTANT NOTICE: * - * ================= * - * Alternative Licensing is available directly from the Copyright holder, * - * (James Walmsley). For more information consult LICENSING.TXT to obtain * - * a Commercial license. * + * The Copyright of Hein Tibosch on this project recognises his efforts in * + * contributing to this project. The right to license the project under * + * any other terms (other than the GNU GPL license) remains with the * + * original copyright holder (James Walmsley) only. * * * - * See RESTRICTIONS.TXT for extra restrictions on the use of FullFAT. * - * * - * Removing the above notice is illegal and will invalidate this license. * ***************************************************************************** - * See http://worm.me.uk/fullfat for more information. * - * Or http://fullfat.googlecode.com/ for latest releases and the wiki. * + * Modification/Extensions/Bugfixes/Improvements to FullFAT must be sent to * + * James Walmsley for integration into the main development branch. * *****************************************************************************/ + #ifndef _FF_CONFIG_H_ #define _FF_CONFIG_H_ + +#ifdef WIN32 +#define snprintf _snprintf +#endif /* Here you can change the configuration of FullFAT as appropriate to your platform. @@ -51,32 +64,46 @@ //---------- UNICODE SUPPORT -#define FF_UNICODE_SUPPORT // If this is defined, then all of FullFAT's API's will expect to receive UTF-16 formatted strings. +//#define FF_UNICODE_SUPPORT // If this is defined, then all of FullFAT's API's will expect to receive UTF-16 formatted strings. // FF_FindFirst() and FF_FindNext() will also return Filenames in UTF-16 format. // NOTE: This option may cause FullFAT to not "Clean-compile" when using GCC. This is because // pedantically GCC refuses to accept C99 library functions, unless the -std=c99 flag is used. // To use UNICODE (UTF-16, or UTF-32 depending on the size of wchar_t) you must have a C99 compliant // compiler and library. -//#define FF_UNICODE_UTF8_SUPPORT // If this is defined, then all of FullFAT's API's will expect to receive UTF-8 formatted strings. - // FF_FindFirst() and FF_FindNext() will also return Filenames in UTF-8 format. - // Note the 2 UNICODE options are mutually exclusive. Only one can be enabled. - - // Ensure that dirents are big enough to hold the maximum UTF-8 sequence. - - //---------- FAT12 SUPPORT #define FF_FAT12_SUPPORT // Enable FAT12 Suppport. You can reduce the code-size by commenting this out. // If you don't need FAT12 support, why have it. FAT12 is more complex to process, // therefore savings can be made by not having it. +#define FF_OPTIMISE_UNALIGNED_ACCESS // Optimise unaligned accesses. This requires that each FILE handle has an associated buffer + // of atleast BLOCKSIZE bytes. + // If your system is not memory constrained, you should enable this to reduce accesses + // to the underlying block device. +#define FF_CACHE_WRITE_THROUGH + +//---------- WRITE BOTH FATS +#define FF_WRITE_BOTH_FATS // Writes the 2nd FAT (backup) at runtime. Disabling this can improve performance. + // However, leaving it enabled guarantees that both FATs will match, and fs checkers + // will not complain. (More compliant). + +//#define FF_MIRROR_FATS_UMOUNT // This will cause all FAT tables to be duplicated on unmount. + // This is usually expensive in terms of time but will ensure that all FAT copies + // are consistent. (If you can guarantee an unmount operation, use this while disabling FF_WRITE_BOTH_FATS). + +#define FF_WRITE_FREE_COUNT // Enabling this option will modify the FreeCount on the disk at runtime. + // This incurs a small performance penalty, and is not required. (All filesystems should not + // trust the on-disk value anyway. + //---------- TIME SUPPORT #define FF_TIME_SUPPORT // Should FullFAT use time stamping. Only if you have provided the relevant time drivers in ff_time.c // Note, by default ff_time.c is set-up for the Windows Demonstration. Please see ff_time.c to disable. +#define FF_REMOVABLE_MEDIA // Enable removable media support. + //---------- FILE SPACE ALLOCATION PERFORMANCE // Uncomment the prefered method. (Can only choose a single method). #define FF_ALLOC_DEFAULT // Only allocate as much as is needed. (Provides good performance, without wasting space). @@ -88,7 +115,7 @@ //---------- FREE SPACE CALCULATION -//#define FF_MOUNT_FIND_FREE // Uncomment this option to check for Freespace on a volume mount. (Performance Penalty while mounting). +//#define FF_MOUNT_FIND_FREE // Uncomment this option to check for Freespace on a volume mount. (Performance Penalty while mounting). // If not done in the mount, it will be done on the first call to FF_GetFreeSize() function. @@ -114,26 +141,26 @@ //---------- BLKDEV USES SEMAPHORE -#define FF_BLKDEV_USES_SEM // When defined, each call to fnReadBlocks and fnWriteBlocks will be done while semaphore is locked +//#define FF_BLKDEV_USES_SEM // When defined, each call to fnReadBlocks and fnWriteBlocks will be done while semaphore is locked // See also ff_safety.c // (HT addition) - Thanks to Hein Tibosch //---------- MALLOC // These should map on to platform specific memory allocators. -#define FF_MALLOC(aSize) FF_Malloc(aSize) -#define FF_FREE(apPtr) FF_Free(apPtr) +#define FF_MALLOC(aSize) malloc(aSize) +#define FF_FREE(apPtr) free(apPtr) //---------- IN-LINE FUNCTIONS //---------- INLINE KeyWord // Define FF_INLINE as your compiler's inline keyword. This is placed before the type qualifier. -#define FF_INLINE static __forceinline // Keywords to inline functions (Windows) //#define FF_INLINE static inline // Standard for GCC +#define FF_INLINE static __inline //---------- Inline Memory Independence Routines for better performance, but bigger codesize. -//#define FF_INLINE_MEMORY_ACCESS +#define FF_INLINE_MEMORY_ACCESS //---------- Inline Block Calculation Routines for slightly better performance in critical sections. -//#define FF_INLINE_BLOCK_CALCULATIONS +#define FF_INLINE_BLOCK_CALCULATIONS //---------- 64-Bit Number Support @@ -186,6 +213,13 @@ #endif #ifdef FF_UNICODE_SUPPORT +#ifdef FF_HASH_CACHE +#error FullFAT Invalid ff_config.h file: HASH cache feature is not UNICODE compatible, please disable it. +#endif +#ifdef FF_INCLUDE_SHORT_NAME +#error FullFAT Invalid ff_config.h file: INCLUDE SHORT NAME is not UNICODE compatible, please disable it. +#endif + #ifdef FF_UNICODE_UTF8_SUPPORT #error FullFAT Invalid ff_config.h file: Must choose a single UNICODE support option. FF_UNICODE_SUPPORT for UTF-16, FF_UNICODE_UTF8_SUPPORT for UTF-8. #endif @@ -219,6 +253,12 @@ #endif +#ifdef FF_UNICODE_UTF8_SUPPORT +#ifdef FF_UNICODE_SUPPORT +#error FullFAT Invalid ff_config.h file: Unicode support, select FF_UNICODE_SUPPORT for UTF16 or FF_UNICODE_UTF8_SUPPORT for UTF8. #endif +#endif +#endif + //---------- END-OF-CONFIGURATION Index: ff_crc.h =================================================================== --- ff_crc.h (revision 58178) +++ ff_crc.h (working copy) @@ -1,7 +1,19 @@ /***************************************************************************** - * FullFAT - High Performance, Thread-Safe Embedded FAT File-System * - * Copyright (C) 2009 James Walmsley (james@worm.me.uk) * + * FullFAT - High Performance, Thread-Safe Embedded FAT File-System * * * + * Copyright(C) 2009 James Walmsley * + * Copyright(C) 2011 Hein Tibosch * + * * + * See RESTRICTIONS.TXT for extra restrictions on the use of FullFAT. * + * * + * WARNING : COMMERCIAL PROJECTS MUST COMPLY WITH THE GNU GPL LICENSE. * + * * + * Projects that cannot comply with the GNU GPL terms are legally obliged * + * to seek alternative licensing. Contact James Walmsley for details. * + * * + ***************************************************************************** + * See http://www.fullfat-fs.co.uk/ for more information. * + ***************************************************************************** * This program is free software: you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation, either version 3 of the License, or * @@ -15,18 +27,14 @@ * You should have received a copy of the GNU General Public License * * along with this program. If not, see . * * * - * IMPORTANT NOTICE: * - * ================= * - * Alternative Licensing is available directly from the Copyright holder, * - * (James Walmsley). For more information consult LICENSING.TXT to obtain * - * a Commercial license. * + * The Copyright of Hein Tibosch on this project recognises his efforts in * + * contributing to this project. The right to license the project under * + * any other terms (other than the GNU GPL license) remains with the * + * original copyright holder (James Walmsley) only. * * * - * See RESTRICTIONS.TXT for extra restrictions on the use of FullFAT. * - * * - * Removing the above notice is illegal and will invalidate this license. * ***************************************************************************** - * See http://worm.me.uk/fullfat for more information. * - * Or http://fullfat.googlecode.com/ for latest releases and the wiki. * + * Modification/Extensions/Bugfixes/Improvements to FullFAT must be sent to * + * James Walmsley for integration into the main development branch. * *****************************************************************************/ /** Index: ff_dir.h =================================================================== --- ff_dir.h (revision 58178) +++ ff_dir.h (working copy) @@ -1,7 +1,19 @@ /***************************************************************************** - * FullFAT - High Performance, Thread-Safe Embedded FAT File-System * - * Copyright (C) 2009 James Walmsley (james@worm.me.uk) * + * FullFAT - High Performance, Thread-Safe Embedded FAT File-System * * * + * Copyright(C) 2009 James Walmsley * + * Copyright(C) 2011 Hein Tibosch * + * * + * See RESTRICTIONS.TXT for extra restrictions on the use of FullFAT. * + * * + * WARNING : COMMERCIAL PROJECTS MUST COMPLY WITH THE GNU GPL LICENSE. * + * * + * Projects that cannot comply with the GNU GPL terms are legally obliged * + * to seek alternative licensing. Contact James Walmsley for details. * + * * + ***************************************************************************** + * See http://www.fullfat-fs.co.uk/ for more information. * + ***************************************************************************** * This program is free software: you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation, either version 3 of the License, or * @@ -15,18 +27,14 @@ * You should have received a copy of the GNU General Public License * * along with this program. If not, see . * * * - * IMPORTANT NOTICE: * - * ================= * - * Alternative Licensing is available directly from the Copyright holder, * - * (James Walmsley). For more information consult LICENSING.TXT to obtain * - * a Commercial license. * + * The Copyright of Hein Tibosch on this project recognises his efforts in * + * contributing to this project. The right to license the project under * + * any other terms (other than the GNU GPL license) remains with the * + * original copyright holder (James Walmsley) only. * * * - * See RESTRICTIONS.TXT for extra restrictions on the use of FullFAT. * - * * - * Removing the above notice is illegal and will invalidate this license. * ***************************************************************************** - * See http://worm.me.uk/fullfat for more information. * - * Or http://fullfat.googlecode.com/ for latest releases and the wiki. * + * Modification/Extensions/Bugfixes/Improvements to FullFAT must be sent to * + * James Walmsley for integration into the main development branch. * *****************************************************************************/ /** @@ -56,7 +64,6 @@ FF_T_UINT32 ulDirCluster; FF_T_UINT32 ulCurrentClusterLCN; FF_T_UINT32 ulCurrentClusterNum; - FF_T_UINT32 ulCurrentEntry; FF_BUFFER *pBuffer; } FF_FETCH_CONTEXT; @@ -83,6 +90,7 @@ #else FF_T_INT8 szWildCard[FF_MAX_FILENAME]; #endif + FF_T_BOOL bInvertWildCard; #endif #ifdef FF_UNICODE_SUPPORT @@ -110,8 +118,8 @@ #endif FF_ERROR FF_FindNext (FF_IOMAN *pIoman, FF_DIRENT *pDirent); +FF_ERROR FF_RewindFind (FF_IOMAN *pIoman, FF_DIRENT *pDirent); - // INTERNAL API FF_ERROR FF_GetEntry (FF_IOMAN *pIoman, FF_T_UINT16 nEntry, FF_T_UINT32 DirCluster, FF_DIRENT *pDirent); FF_ERROR FF_PutEntry (FF_IOMAN *pIoman, FF_T_UINT16 Entry, FF_T_UINT32 DirCluster, FF_DIRENT *pDirent); @@ -123,7 +131,7 @@ FF_ERROR FF_InitEntryFetch (FF_IOMAN *pIoman, FF_T_UINT32 ulDirCluster, FF_FETCH_CONTEXT *pContext); FF_ERROR FF_FetchEntryWithContext (FF_IOMAN *pIoman, FF_T_UINT32 ulEntry, FF_FETCH_CONTEXT *pContext, FF_T_UINT8 *pEntryBuffer); FF_ERROR FF_PushEntryWithContext (FF_IOMAN *pIoman, FF_T_UINT32 ulEntry, FF_FETCH_CONTEXT *pContext, FF_T_UINT8 *pEntryBuffer); -void FF_CleanupEntryFetch (FF_IOMAN *pIoman, FF_FETCH_CONTEXT *pContext); +FF_ERROR FF_CleanupEntryFetch (FF_IOMAN *pIoman, FF_FETCH_CONTEXT *pContext); FF_T_SINT8 FF_PushEntry (FF_IOMAN *pIoman, FF_T_UINT32 DirCluster, FF_T_UINT16 nEntry, FF_T_UINT8 *buffer, void *pParam); FF_T_BOOL FF_isEndOfDir (FF_T_UINT8 *EntryBuffer); @@ -131,10 +139,10 @@ #ifdef FF_UNICODE_SUPPORT FF_T_UINT32 FF_FindEntryInDir (FF_IOMAN *pIoman, FF_T_UINT32 DirCluster, const FF_T_WCHAR *name, FF_T_UINT8 pa_Attrib, FF_DIRENT *pDirent, FF_ERROR *pError); -FF_T_SINT8 FF_CreateShortName (FF_IOMAN *pIoman, FF_T_UINT32 DirCluster, FF_T_WCHAR *ShortName, FF_T_WCHAR *LongName); +FF_T_SINT32 FF_CreateShortName (FF_IOMAN *pIoman, FF_T_UINT32 DirCluster, FF_T_WCHAR *ShortName, FF_T_WCHAR *LongName); #else FF_T_UINT32 FF_FindEntryInDir (FF_IOMAN *pIoman, FF_T_UINT32 DirCluster, const FF_T_INT8 *name, FF_T_UINT8 pa_Attrib, FF_DIRENT *pDirent, FF_ERROR *pError); -FF_T_SINT8 FF_CreateShortName (FF_IOMAN *pIoman, FF_T_UINT32 DirCluster, FF_T_INT8 *ShortName, FF_T_INT8 *LongName); +FF_T_SINT32 FF_CreateShortName (FF_IOMAN *pIoman, FF_T_UINT32 DirCluster, FF_T_INT8 *ShortName, FF_T_INT8 *LongName); #endif Index: ff_error.h =================================================================== --- ff_error.h (revision 58178) +++ ff_error.h (working copy) @@ -1,7 +1,19 @@ /***************************************************************************** - * FullFAT - High Performance, Thread-Safe Embedded FAT File-System * - * Copyright (C) 2009 James Walmsley (james@worm.me.uk) * + * FullFAT - High Performance, Thread-Safe Embedded FAT File-System * * * + * Copyright(C) 2009 James Walmsley * + * Copyright(C) 2011 Hein Tibosch * + * * + * See RESTRICTIONS.TXT for extra restrictions on the use of FullFAT. * + * * + * WARNING : COMMERCIAL PROJECTS MUST COMPLY WITH THE GNU GPL LICENSE. * + * * + * Projects that cannot comply with the GNU GPL terms are legally obliged * + * to seek alternative licensing. Contact James Walmsley for details. * + * * + ***************************************************************************** + * See http://www.fullfat-fs.co.uk/ for more information. * + ***************************************************************************** * This program is free software: you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation, either version 3 of the License, or * @@ -15,19 +27,16 @@ * You should have received a copy of the GNU General Public License * * along with this program. If not, see . * * * - * IMPORTANT NOTICE: * - * ================= * - * Alternative Licensing is available directly from the Copyright holder, * - * (James Walmsley). For more information consult LICENSING.TXT to obtain * - * a Commercial license. * + * The Copyright of Hein Tibosch on this project recognises his efforts in * + * contributing to this project. The right to license the project under * + * any other terms (other than the GNU GPL license) remains with the * + * original copyright holder (James Walmsley) only. * * * - * See RESTRICTIONS.TXT for extra restrictions on the use of FullFAT. * - * * - * Removing the above notice is illegal and will invalidate this license. * ***************************************************************************** - * See http://worm.me.uk/fullfat for more information. * - * Or http://fullfat.googlecode.com/ for latest releases and the wiki. * + * Modification/Extensions/Bugfixes/Improvements to FullFAT must be sent to * + * James Walmsley for integration into the main development branch. * *****************************************************************************/ + #ifndef _FF_ERROR_H_ #define _FF_ERROR_H_ @@ -41,116 +50,212 @@ #include "ff_types.h" /** - Error codes are 32-bit numbers, and consist of three items: - 8Bits 8bits 16bits - ........ ........ ........ ........ - [ModuleID][FunctionID][-- ERROR CODE --] + * Error codes are 32-bit numbers, and consist of three items: + * 1Bit 7Bits 8Bits 16Bits + * . ........ ........ ........ ........ + * [ErrFlag][ModuleID][FunctionID][-- ERROR CODE --] + * + * Error Codes should always have the ErrFlag set, this is the reason why all module + * codes include it. + * + * When returning an error simply return the defined Error Code, OR'd with the function + * name (capitalised) in which the error has occured. + * + * When receiving an Error code from another layer, do not modify the code, as this will + * prevent the error code from containing the origin of the error, simply pass it to the + * next layer. + * + * Some API's have been defined to provide, useful and meaningful Error messages to the + * the 'userspace' application layer. + * + **/ -**/ +#define FF_MODULE_SHIFT 24 +#define FF_FUNCTION_SHIFT 16 -#define FF_GETERROR(x) (x & 0x0000FFFF) +#define FF_GETERROR(x) (((unsigned)x) & 0xFFFF) +#define FF_GETMODULE(x) ((((unsigned)x) >> FF_MODULE_SHIFT) & 0x7F) +#define FF_GETFUNCTION(x) ((((unsigned)x) >> FF_FUNCTION_SHIFT) & 0xFF) +#define FF_GETMOD_FUNC(x) ((((unsigned)x) >> FF_FUNCTION_SHIFT) & 0xFFFF) +#define FF_ERRFLAG 0x80000000 +#define FF_isERR(x) (x & FF_ERRFLAG) -#define FF_MODULE_SHIFT 24 -#define FF_FUNCTION_SHIFT 16 +//----- MBFullFAT Module Identifiers +#define FF_MODULE_IOMAN (( 1 << FF_MODULE_SHIFT) | FF_ERRFLAG) +#define FF_MODULE_DIR (( 2 << FF_MODULE_SHIFT) | FF_ERRFLAG) +#define FF_MODULE_FILE (( 3 << FF_MODULE_SHIFT) | FF_ERRFLAG) +#define FF_MODULE_FAT (( 4 << FF_MODULE_SHIFT) | FF_ERRFLAG) +#define FF_MODULE_CRC (( 5 << FF_MODULE_SHIFT) | FF_ERRFLAG) +#define FF_MODULE_FORMAT (( 6 << FF_MODULE_SHIFT) | FF_ERRFLAG) +#define FF_MODULE_HASH (( 7 << FF_MODULE_SHIFT) | FF_ERRFLAG) +#define FF_MODULE_MEMORY (( 8 << FF_MODULE_SHIFT) | FF_ERRFLAG) +#define FF_MODULE_STRING (( 9 << FF_MODULE_SHIFT) | FF_ERRFLAG) +#define FF_MODULE_UNICODE ((10 << FF_MODULE_SHIFT) | FF_ERRFLAG) +#define FF_MODULE_SAFETY ((11 << FF_MODULE_SHIFT) | FF_ERRFLAG) +#define FF_MODULE_TIME ((12 << FF_MODULE_SHIFT) | FF_ERRFLAG) +#define FF_MODULE_DRIVER ((13 << FF_MODULE_SHIFT) | FF_ERRFLAG) // We can mark errors from underlying layers with this code. -//----- FullFAT Module Identifiers -#define FF_MODULE_IOMAN (1 << FF_MODULE_SHIFT) -#define FF_MODULE_DIR (2 << FF_MODULE_SHIFT) -#define FF_MODULE_FILE (3 << FF_MODULE_SHIFT) -#define FF_MODULE_FAT (4 << FF_MODULE_SHIFT) -#define FF_MODULE_CRC (5 << FF_MODULE_SHIFT) -#define FF_MODULE_FORMAT (6 << FF_MODULE_SHIFT) -#define FF_MODULE_HASH (7 << FF_MODULE_SHIFT) -#define FF_MODULE_MEMORY (8 << FF_MODULE_SHIFT) -#define FF_MODULE_STRING (9 << FF_MODULE_SHIFT) -#define FF_MODULE_UNICODE (10 << FF_MODULE_SHIFT) -#define FF_MODULE_SAFETY (11 << FF_MODULE_SHIFT) -#define FF_MODULE_TIME (12 << FF_MODULE_SHIFT) -#define FF_MODULE_DRIVER (13 << FF_MODULE_SHIFT) // We can mark underlying platform error codes with this. - //----- FullFAT Function Identifiers (In Modular Order) //----- FF_IOMAN - The FullFAT I/O Manager. -#define FF_CREATEIOMAN (1 << FF_FUNCTION_SHIFT) | FF_MODULE_IOMAN -#define FF_DESTROYIOMAN (2 << FF_FUNCTION_SHIFT) | FF_MODULE_IOMAN -#define FF_REGISTERBLKDEVICE (3 << FF_FUNCTION_SHIFT) | FF_MODULE_IOMAN -#define FF_UNREGISTERBLKDEVICE (4 << FF_FUNCTION_SHIFT) | FF_MODULE_IOMAN -#define FF_MOUNTPARTITION (5 << FF_FUNCTION_SHIFT) | FF_MODULE_IOMAN -#define FF_UNMOUNTPARTITION (6 << FF_FUNCTION_SHIFT) | FF_MODULE_IOMAN -#define FF_FLUSHCACHE (7 << FF_FUNCTION_SHIFT) | FF_MODULE_IOMAN -#define FF_GETPARTITIONBLOCKSIZE (8 << FF_FUNCTION_SHIFT) | FF_MODULE_IOMAN -#define FF_BLOCKREAD (9 << FF_FUNCTION_SHIFT) | FF_MODULE_IOMAN -#define FF_BLOCKWRITE (10 << FF_FUNCTION_SHIFT) | FF_MODULE_IOMAN +#define FF_CREATEIOMAN ((1 << FF_FUNCTION_SHIFT) | FF_MODULE_IOMAN) +#define FF_DESTROYIOMAN ((2 << FF_FUNCTION_SHIFT) | FF_MODULE_IOMAN) +#define FF_REGISTERBLKDEVICE ((3 << FF_FUNCTION_SHIFT) | FF_MODULE_IOMAN) +#define FF_UNREGISTERBLKDEVICE ((4 << FF_FUNCTION_SHIFT) | FF_MODULE_IOMAN) +#define FF_MOUNTPARTITION ((5 << FF_FUNCTION_SHIFT) | FF_MODULE_IOMAN) +#define FF_UNMOUNTPARTITION ((6 << FF_FUNCTION_SHIFT) | FF_MODULE_IOMAN) +#define FF_FLUSHCACHE ((7 << FF_FUNCTION_SHIFT) | FF_MODULE_IOMAN) +#define FF_GETPARTITIONBLOCKSIZE ((8 << FF_FUNCTION_SHIFT) | FF_MODULE_IOMAN) +#define FF_BLOCKREAD ((9 << FF_FUNCTION_SHIFT) | FF_MODULE_IOMAN) +#define FF_BLOCKWRITE ((10 << FF_FUNCTION_SHIFT) | FF_MODULE_IOMAN) +#define FF_DETERMINEFATTYPE ((11 << FF_FUNCTION_SHIFT) | FF_MODULE_IOMAN) +#define FF_GETEFIPARTITIONENTRY ((12 << FF_FUNCTION_SHIFT) | FF_MODULE_IOMAN) +#define FF_USERDRIVER ((13 << FF_FUNCTION_SHIFT) | FF_MODULE_IOMAN) +#define FF_DECREASEFREECLUSTERS ((14 << FF_FUNCTION_SHIFT) | FF_MODULE_IOMAN) +#define FF_INCREASEFREECLUSTERS ((15 << FF_FUNCTION_SHIFT) | FF_MODULE_IOMAN) +//----- FullFAT Return codes for user Rd/Wr routines +#define FF_ERR_DRIVER_BUSY (FF_ERR_IOMAN_DRIVER_BUSY | FF_USERDRIVER | FF_MODULE_DRIVER) +#define FF_ERR_DRIVER_FATAL_ERROR (FF_ERR_IOMAN_DRIVER_FATAL_ERROR | FF_USERDRIVER | FF_MODULE_DRIVER) + //----- FF_DIR - The FullFAT directory handling routines. // -- COMPLETE THESE ERROR CODES TOMORROW :P +#define FF_FINDNEXTINDIR ((1 << FF_FUNCTION_SHIFT) | FF_MODULE_DIR) +#define FF_FETCHENTRYWITHCONTEXT ((2 << FF_FUNCTION_SHIFT) | FF_MODULE_DIR) +#define FF_PUSHENTRYWITHCONTEXT ((3 << FF_FUNCTION_SHIFT) | FF_MODULE_DIR) +#define FF_GETENTRY ((4 << FF_FUNCTION_SHIFT) | FF_MODULE_DIR) +#define FF_FINDFIRST ((5 << FF_FUNCTION_SHIFT) | FF_MODULE_DIR) +#define FF_FINDNEXT ((6 << FF_FUNCTION_SHIFT) | FF_MODULE_DIR) +#define FF_REWINDFIND ((7 << FF_FUNCTION_SHIFT) | FF_MODULE_DIR) +#define FF_FINDFREEDIRENT ((8 << FF_FUNCTION_SHIFT) | FF_MODULE_DIR) +#define FF_PUTENTRY ((9 << FF_FUNCTION_SHIFT) | FF_MODULE_DIR) +#define FF_CREATESHORTNAME ((10 << FF_FUNCTION_SHIFT) | FF_MODULE_DIR) +#define FF_CREATELFNS ((11 << FF_FUNCTION_SHIFT) | FF_MODULE_DIR) +#define FF_EXTENDDIRECTORY ((12 << FF_FUNCTION_SHIFT) | FF_MODULE_DIR) +#define FF_MKDIR ((13 << FF_FUNCTION_SHIFT) | FF_MODULE_DIR) +#define FF_TRAVERSE ((14 << FF_FUNCTION_SHIFT) | FF_MODULE_DIR) +//----- FF_FILE - The FullFAT file handling routines. +#define FF_GETMODEBITS ((1 << FF_FUNCTION_SHIFT) | FF_MODULE_FILE) +#define FF_OPEN ((2 << FF_FUNCTION_SHIFT) | FF_MODULE_FILE) +#define FF_ISDIREMPTY ((3 << FF_FUNCTION_SHIFT) | FF_MODULE_FILE) +#define FF_RMDIR ((4 << FF_FUNCTION_SHIFT) | FF_MODULE_FILE) +#define FF_RMFILE ((5 << FF_FUNCTION_SHIFT) | FF_MODULE_FILE) +#define FF_MOVE ((6 << FF_FUNCTION_SHIFT) | FF_MODULE_FILE) +#define FF_ISEOF ((7 << FF_FUNCTION_SHIFT) | FF_MODULE_FILE) +#define FF_GETSEQUENTIALCLUSTERS ((8 << FF_FUNCTION_SHIFT) | FF_MODULE_FILE) +#define FF_READCLUSTERS ((9 << FF_FUNCTION_SHIFT) | FF_MODULE_FILE) +#define FF_EXTENDFILE ((10 << FF_FUNCTION_SHIFT) | FF_MODULE_FILE) +#define FF_WRITECLUSTERS ((11 << FF_FUNCTION_SHIFT) | FF_MODULE_FILE) +#define FF_READ ((12 << FF_FUNCTION_SHIFT) | FF_MODULE_FILE) +#define FF_GETC ((13 << FF_FUNCTION_SHIFT) | FF_MODULE_FILE) +#define FF_GETLINE ((14 << FF_FUNCTION_SHIFT) | FF_MODULE_FILE) +#define FF_TELL ((15 << FF_FUNCTION_SHIFT) | FF_MODULE_FILE) +#define FF_WRITE ((16 << FF_FUNCTION_SHIFT) | FF_MODULE_FILE) +#define FF_PUTC ((17 << FF_FUNCTION_SHIFT) | FF_MODULE_FILE) +#define FF_SEEK ((18 << FF_FUNCTION_SHIFT) | FF_MODULE_FILE) +#define FF_INVALIDATE ((19 << FF_FUNCTION_SHIFT) | FF_MODULE_FILE) +#define FF_CHECKVALID ((20 << FF_FUNCTION_SHIFT) | FF_MODULE_FILE) +#define FF_CLOSE ((21 << FF_FUNCTION_SHIFT) | FF_MODULE_FILE) +#define FF_SETTIME ((22 << FF_FUNCTION_SHIFT) | FF_MODULE_FILE) +#define FF_BYTESLEFT ((23 << FF_FUNCTION_SHIFT) | FF_MODULE_FILE) +#define FF_SETFILETIME ((24 << FF_FUNCTION_SHIFT) | FF_MODULE_FILE) +//----- FF_FAT - The FullFAT FAT handling routines. +#define FF_GETFATENTRY ((1 << FF_FUNCTION_SHIFT) | FF_MODULE_FAT) +#define FF_CLEARCLUSTER ((2 << FF_FUNCTION_SHIFT) | FF_MODULE_FAT) +#define FF_PUTFATENTRY ((3 << FF_FUNCTION_SHIFT) | FF_MODULE_FAT) +#define FF_FINDFREECLUSTER ((4 << FF_FUNCTION_SHIFT) | FF_MODULE_FAT) +#define FF_COUNTFREECLUSTERS ((5 << FF_FUNCTION_SHIFT) | FF_MODULE_FAT) + +//----- FF_HASH - The FullFAT hashing routines. +#define FF_CLEARHASHTABLE ((1 << FF_FUNCTION_SHIFT) | FF_MODULE_HASH) +#define FF_SETHASH ((2 << FF_FUNCTION_SHIFT) | FF_MODULE_HASH) +#define FF_CLEARHASH ((3 << FF_FUNCTION_SHIFT) | FF_MODULE_HASH) +#define FF_DESTROYHASHTABLE ((4 << FF_FUNCTION_SHIFT) | FF_MODULE_HASH) + +//----- FF_UNICODE - The FullFAT hashing routines. +#define FF_UTF8CTOUTF16C ((1 << FF_FUNCTION_SHIFT) | FF_MODULE_UNICODE) +#define FF_UTF16CTOUTF8C ((2 << FF_FUNCTION_SHIFT) | FF_MODULE_UNICODE) +#define FF_UTF32CTOUTF16C ((3 << FF_FUNCTION_SHIFT) | FF_MODULE_UNICODE) +#define FF_UTF16CTOUTF32C ((4 << FF_FUNCTION_SHIFT) | FF_MODULE_UNICODE) + +//----- FF_FORMAT - The FullFAT format routine +#define FF_FORMATPARTITION ((1 << FF_FUNCTION_SHIFT) | FF_MODULE_FORMAT) + /* FullFAT defines different Error-Code spaces for each module. This ensures that all error codes remain unique, and their meaning can be quickly identified. */ // Global Error Codes -#define FF_ERR_NONE 0 ///< No Error -//#define FF_ERR_GENERIC 1 ///< BAD NEVER USE THIS! -#define FF_ERR_NULL_POINTER 2 ///< pIoman was NULL. -#define FF_ERR_NOT_ENOUGH_MEMORY 3 ///< malloc() failed! - Could not allocate handle memory. -#define FF_ERR_DEVICE_DRIVER_FAILED 4 ///< The Block Device driver reported a FATAL error, cannot continue. +#define FF_ERR_NONE 0 ///< No Error +//#define FF_ERR_GENERIC 1 ///< BAD NEVER USE THIS! -- Therefore commented out. +#define FF_ERR_NULL_POINTER 2 ///< pIoman was NULL. +#define FF_ERR_NOT_ENOUGH_MEMORY 3 ///< malloc() failed! - Could not allocate handle memory. +#define FF_ERR_DEVICE_DRIVER_FAILED 4 ///< The Block Device driver reported a FATAL error, cannot continue. +// User return codes for Rd/Wr functions: +#define FF_ERR_IOMAN_DRIVER_BUSY 10 +#define FF_ERR_IOMAN_DRIVER_FATAL_ERROR 11 // IOMAN Error Codes -#define FF_ERR_IOMAN_BAD_BLKSIZE 11 ///< The provided blocksize was not a multiple of 512. -#define FF_ERR_IOMAN_BAD_MEMSIZE 12 ///< The memory size was not a multiple of the blocksize. -#define FF_ERR_IOMAN_DEV_ALREADY_REGD 13 ///< Device was already registered. Use FF_UnRegister() to re-use this IOMAN with another device. -#define FF_ERR_IOMAN_NO_MOUNTABLE_PARTITION 14 ///< A mountable partition could not be found on the device. -#define FF_ERR_IOMAN_INVALID_FORMAT 15 ///< The -#define FF_ERR_IOMAN_INVALID_PARTITION_NUM 16 ///< The partition number provided was out of range. -#define FF_ERR_IOMAN_NOT_FAT_FORMATTED 17 ///< The partition did not look like a FAT partition. -#define FF_ERR_IOMAN_DEV_INVALID_BLKSIZE 18 ///< IOMAN object BlkSize is not compatible with the blocksize of this device driver. -#define FF_ERR_IOMAN_PARTITION_MOUNTED 19 ///< Device is in use by an actively mounted partition. Unmount the partition first. -#define FF_ERR_IOMAN_ACTIVE_HANDLES 20 ///< The partition cannot be unmounted until all active file handles are closed. (There may also be active handles on the cache). -#define FF_ERR_IOMAN_GPT_HEADER_CORRUPT 21 ///< The GPT partition table appears to be corrupt, refusing to mount. -#define FF_ERR_IOMAN_NOT_ENOUGH_FREE_SPACE 22 -#define FF_ERR_IOMAN_OUT_OF_BOUNDS_READ 23 -#define FF_ERR_IOMAN_OUT_OF_BOUNDS_WRITE 24 +#define FF_ERR_IOMAN_BAD_BLKSIZE 11 ///< The provided blocksize was not a multiple of 512. +#define FF_ERR_IOMAN_BAD_MEMSIZE 12 ///< The memory size was not a multiple of the blocksize. +#define FF_ERR_IOMAN_DEV_ALREADY_REGD 13 ///< Device was already registered. Use FF_UnRegister() to re-use this IOMAN with another device. +#define FF_ERR_IOMAN_NO_MOUNTABLE_PARTITION 14 ///< A mountable partition could not be found on the device. +#define FF_ERR_IOMAN_INVALID_FORMAT 15 ///< The +#define FF_ERR_IOMAN_INVALID_PARTITION_NUM 16 ///< The partition number provided was out of range. +#define FF_ERR_IOMAN_NOT_FAT_FORMATTED 17 ///< The partition did not look like a FAT partition. +#define FF_ERR_IOMAN_DEV_INVALID_BLKSIZE 18 ///< IOMAN object BlkSize is not compatible with the blocksize of this device driver. +#define FF_ERR_IOMAN_PARTITION_MOUNTED 19 ///< Device is in use by an actively mounted partition. Unmount the partition first. +#define FF_ERR_IOMAN_ACTIVE_HANDLES 20 ///< The partition cannot be unmounted until all active file handles are closed. (There may also be active handles on the cache). +#define FF_ERR_IOMAN_GPT_HEADER_CORRUPT 21 ///< The GPT partition table appears to be corrupt, refusing to mount. +#define FF_ERR_IOMAN_NOT_ENOUGH_FREE_SPACE 22 +#define FF_ERR_IOMAN_OUT_OF_BOUNDS_READ 23 +#define FF_ERR_IOMAN_OUT_OF_BOUNDS_WRITE 24 +// File Error Codes 30 + +#define FF_ERR_FILE_ALREADY_OPEN 30 ///< File is in use. +#define FF_ERR_FILE_NOT_FOUND 31 ///< File was not found. +#define FF_ERR_FILE_OBJECT_IS_A_DIR 32 ///< Tried to FF_Open() a Directory. +#define FF_ERR_FILE_IS_READ_ONLY 33 ///< Tried to FF_Open() a file marked read only. +#define FF_ERR_FILE_INVALID_PATH 34 ///< The path of the file was not found. +#define FF_ERR_FILE_NOT_OPENED_IN_WRITE_MODE 35 +#define FF_ERR_FILE_NOT_OPENED_IN_READ_MODE 36 +#define FF_ERR_FILE_EXTEND_FAILED 37 ///< Could not extend the file. +#define FF_ERR_FILE_DESTINATION_EXISTS 38 +#define FF_ERR_FILE_SOURCE_NOT_FOUND 39 +#define FF_ERR_FILE_DIR_NOT_FOUND 40 +#define FF_ERR_FILE_COULD_NOT_CREATE_DIRENT 41 +#define FF_ERR_FILE_BAD_HANDLE 42 ///< A file handle was invalid +#define FF_ERR_FILE_MEDIA_REMOVED 43 ///< File handle got invalid because media was removed -// File Error Codes 30 + -#define FF_ERR_FILE_ALREADY_OPEN 30 ///< File is in use. -#define FF_ERR_FILE_NOT_FOUND 31 ///< File was not found. -#define FF_ERR_FILE_OBJECT_IS_A_DIR 32 ///< Tried to FF_Open() a Directory. -#define FF_ERR_FILE_IS_READ_ONLY 33 ///< Tried to FF_Open() a file marked read only. -#define FF_ERR_FILE_INVALID_PATH 34 ///< The path of the file was not found. -#define FF_ERR_FILE_NOT_OPENED_IN_WRITE_MODE 35 -#define FF_ERR_FILE_NOT_OPENED_IN_READ_MODE 36 -#define FF_ERR_FILE_EXTEND_FAILED 37 ///< Could not extend the file. -#define FF_ERR_FILE_DESTINATION_EXISTS 38 -#define FF_ERR_FILE_SOURCE_NOT_FOUND 39 -#define FF_ERR_FILE_DIR_NOT_FOUND 40 -#define FF_ERR_FILE_COULD_NOT_CREATE_DIRENT 41 +// Directory Error Codes 50 + +#define FF_ERR_DIR_OBJECT_EXISTS 50 ///< A file or folder of the same name already exists in the current directory. +#define FF_ERR_DIR_DIRECTORY_FULL 51 ///< No more items could be added to the directory. +#define FF_ERR_DIR_END_OF_DIR 52 /// +#define FF_ERR_DIR_NOT_EMPTY 53 ///< Cannot delete a directory that contains files or folders. +#define FF_ERR_DIR_INVALID_PATH 54 ///< Could not find the directory specified by the path. +#define FF_ERR_DIR_CANT_EXTEND_ROOT_DIR 55 ///< Can't extend the root dir. +#define FF_ERR_DIR_EXTEND_FAILED 56 ///< Not enough space to extend the directory. +#define FF_ERR_DIR_NAME_TOO_LONG 57 ///< Name exceeds the number of allowed charachters for a filename. -// Directory Error Codes 50 + -#define FF_ERR_DIR_OBJECT_EXISTS 50 ///< A file or folder of the same name already exists in the current directory. -#define FF_ERR_DIR_DIRECTORY_FULL 51 ///< No more items could be added to the directory. -#define FF_ERR_DIR_END_OF_DIR 52 /// -#define FF_ERR_DIR_NOT_EMPTY 53 ///< Cannot delete a directory that contains files or folders. -#define FF_ERR_DIR_INVALID_PATH 54 ///< Could not find the directory specified by the path. -#define FF_ERR_DIR_CANT_EXTEND_ROOT_DIR 55 ///< Can't extend the root dir. -#define FF_ERR_DIR_EXTEND_FAILED 56 ///< Not enough space to extend the directory. -#define FF_ERR_DIR_NAME_TOO_LONG 57 ///< Name exceeds the number of allowed charachters for a filename. +// Fat Error Codes 70 + +#define FF_ERR_FAT_NO_FREE_CLUSTERS 70 ///< No more free space is available on the disk. -// Fat Error Codes 70 + -#define FF_ERR_FAT_NO_FREE_CLUSTERS 70 ///< No more free space is available on the disk. +// UNICODE Error Codes 100 + +#define FF_ERR_UNICODE_INVALID_CODE 100 ///< An invalid Unicode charachter was provided! +#define FF_ERR_UNICODE_DEST_TOO_SMALL 101 ///< Not enough space in the UTF-16 buffer to encode the entire sequence as UTF-16. +#define FF_ERR_UNICODE_INVALID_SEQUENCE 102 ///< An invalid UTF-16 sequence was encountered. +#define FF_ERR_UNICODE_CONVERSION_EXCEEDED 103 ///< Filename exceeds MAX long-filename length when converted to UTF-16. -// UNICODE Error Codes 100 + -#define FF_ERR_UNICODE_INVALID_CODE 100 ///< An invalid Unicode charachter was provided! -#define FF_ERR_UNICODE_DEST_TOO_SMALL 101 ///< Not enough space in the UTF-16 buffer to encode the entire sequence as UTF-16. -#define FF_ERR_UNICODE_INVALID_SEQUENCE 102 ///< An invalid UTF-16 sequence was encountered. -#define FF_ERR_UNICODE_CONVERSION_EXCEEDED 103 ///< Filename exceeds MAX long-filename length when converted to UTF-16. - #ifdef FF_DEBUG -const FF_T_INT8 *FF_GetErrMessage(FF_ERROR iErrorCode); -#else -#define FF_GetErrMessage(X) "" // A special MACRO incase FF_GetErrMessage() isn't gated with FF_DEBUG -#endif // Function call is safely replaced with a NULL string. +const FF_T_INT8 *FF_GetErrMessage (FF_ERROR iErrorCode); +const FF_T_INT8 *FF_GetErrModule (FF_ERROR iErrorCode); +const FF_T_INT8 *FF_GetErrFunction (FF_ERROR iErrorCode); +const FF_T_INT8 *FF_GetErrDescription (FF_ERROR iErrorCode, char *apBuf, int aMaxlen); // Get the complete description +#else /* !DEF FF_DEBUG */ +#define FF_GetErrMessage(X) "" // A special MACRO incase FF_GetErrMessage() isn't gated with FF_DEBUG +#define FF_GetErrModule(X) "" +#define FF_GetErrFunction(X) "" +#endif // Function call is safely replaced with a NULL string. -#endif - +#endif /* INCLUDE GUARD END */ Index: ff_fat.h =================================================================== --- ff_fat.h (revision 58178) +++ ff_fat.h (working copy) @@ -1,7 +1,19 @@ /***************************************************************************** - * FullFAT - High Performance, Thread-Safe Embedded FAT File-System * - * Copyright (C) 2009 James Walmsley (james@worm.me.uk) * + * FullFAT - High Performance, Thread-Safe Embedded FAT File-System * * * + * Copyright(C) 2009 James Walmsley * + * Copyright(C) 2011 Hein Tibosch * + * * + * See RESTRICTIONS.TXT for extra restrictions on the use of FullFAT. * + * * + * WARNING : COMMERCIAL PROJECTS MUST COMPLY WITH THE GNU GPL LICENSE. * + * * + * Projects that cannot comply with the GNU GPL terms are legally obliged * + * to seek alternative licensing. Contact James Walmsley for details. * + * * + ***************************************************************************** + * See http://www.fullfat-fs.co.uk/ for more information. * + ***************************************************************************** * This program is free software: you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation, either version 3 of the License, or * @@ -15,20 +27,15 @@ * You should have received a copy of the GNU General Public License * * along with this program. If not, see . * * * - * IMPORTANT NOTICE: * - * ================= * - * Alternative Licensing is available directly from the Copyright holder, * - * (James Walmsley). For more information consult LICENSING.TXT to obtain * - * a Commercial license. * + * The Copyright of Hein Tibosch on this project recognises his efforts in * + * contributing to this project. The right to license the project under * + * any other terms (other than the GNU GPL license) remains with the * + * original copyright holder (James Walmsley) only. * * * - * See RESTRICTIONS.TXT for extra restrictions on the use of FullFAT. * - * * - * Removing the above notice is illegal and will invalidate this license. * ***************************************************************************** - * See http://worm.me.uk/fullfat for more information. * - * Or http://fullfat.googlecode.com/ for latest releases and the wiki. * + * Modification/Extensions/Bugfixes/Improvements to FullFAT must be sent to * + * James Walmsley for integration into the main development branch. * *****************************************************************************/ - /** * @file ff_fat.h * @author James Walmsley @@ -49,15 +56,38 @@ //---------- PROTOTYPES +// HT statistics Will be taken away after testing: + +struct SFatStat { + unsigned initCount; + unsigned clearCount; + unsigned getCount[2]; // 0 = read, 1 = write + unsigned reuseCount[2]; // 0 = read, 1 = write + unsigned missCount[2]; // 0 = read, 1 = write +}; + +extern struct SFatStat fatStat; + +#if defined(FF_WRITE_BOTH_FATS) // || defined(FF_FAT12_SUPPORT) +#define BUF_STORE_COUNT 2 +#else +#define BUF_STORE_COUNT 1 +#endif + +typedef struct _FatBuffers { + FF_BUFFER *pBuffers[BUF_STORE_COUNT]; + FF_T_UINT8 Mode; // FF_MODE_READ or WRITE +} FF_FatBuffers; + FF_T_UINT32 FF_getRealLBA (FF_IOMAN *pIoman, FF_T_UINT32 LBA); FF_T_UINT32 FF_Cluster2LBA (FF_IOMAN *pIoman, FF_T_UINT32 Cluster); FF_T_UINT32 FF_LBA2Cluster (FF_IOMAN *pIoman, FF_T_UINT32 Address); - FF_T_UINT32 FF_getFatEntry (FF_IOMAN *pIoman, FF_T_UINT32 nCluster, FF_ERROR *pError); - FF_ERROR FF_putFatEntry (FF_IOMAN *pIoman, FF_T_UINT32 nCluster, FF_T_UINT32 Value); + FF_T_UINT32 FF_getFatEntry (FF_IOMAN *pIoman, FF_T_UINT32 nCluster, FF_ERROR *pError, FF_FatBuffers *pFatBuf); + FF_ERROR FF_putFatEntry (FF_IOMAN *pIoman, FF_T_UINT32 nCluster, FF_T_UINT32 Value, FF_FatBuffers *pFatBuf); FF_T_BOOL FF_isEndOfChain (FF_IOMAN *pIoman, FF_T_UINT32 fatEntry); FF_T_UINT32 FF_FindFreeCluster (FF_IOMAN *pIoman, FF_ERROR *pError); FF_T_UINT32 FF_ExtendClusterChain (FF_IOMAN *pIoman, FF_T_UINT32 StartCluster, FF_T_UINT32 Count); - FF_ERROR FF_UnlinkClusterChain (FF_IOMAN *pIoman, FF_T_UINT32 StartCluster, FF_T_UINT16 Count); + FF_ERROR FF_UnlinkClusterChain (FF_IOMAN *pIoman, FF_T_UINT32 StartCluster, FF_T_BOOL bTruncate); FF_T_UINT32 FF_TraverseFAT (FF_IOMAN *pIoman, FF_T_UINT32 Start, FF_T_UINT32 Count, FF_ERROR *pError); FF_T_UINT32 FF_CreateClusterChain (FF_IOMAN *pIoman, FF_ERROR *pError); FF_T_UINT32 FF_GetChainLength (FF_IOMAN *pIoman, FF_T_UINT32 pa_nStartCluster, FF_T_UINT32 *piEndOfChain, FF_ERROR *pError); @@ -72,5 +102,22 @@ void FF_lockFAT (FF_IOMAN *pIoman); void FF_unlockFAT (FF_IOMAN *pIoman); +FF_T_UINT32 FF_FindFreeCluster(FF_IOMAN *pIoman, FF_ERROR *pError); + +FF_ERROR FF_ReleaseFatBuffer (FF_IOMAN *pIoman, FF_FatBuffers *pFatBuf); + +FF_INLINE void FF_InitFatBuffer (FF_FatBuffers *pBuffer, unsigned aMode) +{ + pBuffer->pBuffers[0] = NULL; +#if BUF_STORE_COUNT > 1 + pBuffer->pBuffers[1] = NULL; #endif +#if BUF_STORE_COUNT > 2 +#error Please check this code, maybe it is time to use memset +#endif + pBuffer->Mode = aMode; // FF_MODE_READ/WRITE + fatStat.initCount++; +} +#endif + Index: ff_fatdef.h =================================================================== --- ff_fatdef.h (revision 58178) +++ ff_fatdef.h (working copy) @@ -1,7 +1,19 @@ /***************************************************************************** - * FullFAT - High Performance, Thread-Safe Embedded FAT File-System * - * Copyright (C) 2009 James Walmsley (james@worm.me.uk) * + * FullFAT - High Performance, Thread-Safe Embedded FAT File-System * * * + * Copyright(C) 2009 James Walmsley * + * Copyright(C) 2011 Hein Tibosch * + * * + * See RESTRICTIONS.TXT for extra restrictions on the use of FullFAT. * + * * + * WARNING : COMMERCIAL PROJECTS MUST COMPLY WITH THE GNU GPL LICENSE. * + * * + * Projects that cannot comply with the GNU GPL terms are legally obliged * + * to seek alternative licensing. Contact James Walmsley for details. * + * * + ***************************************************************************** + * See http://www.fullfat-fs.co.uk/ for more information. * + ***************************************************************************** * This program is free software: you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation, either version 3 of the License, or * @@ -15,19 +27,16 @@ * You should have received a copy of the GNU General Public License * * along with this program. If not, see . * * * - * IMPORTANT NOTICE: * - * ================= * - * Alternative Licensing is available directly from the Copyright holder, * - * (James Walmsley). For more information consult LICENSING.TXT to obtain * - * a Commercial license. * + * The Copyright of Hein Tibosch on this project recognises his efforts in * + * contributing to this project. The right to license the project under * + * any other terms (other than the GNU GPL license) remains with the * + * original copyright holder (James Walmsley) only. * * * - * See RESTRICTIONS.TXT for extra restrictions on the use of FullFAT. * - * * - * Removing the above notice is illegal and will invalidate this license. * ***************************************************************************** - * See http://worm.me.uk/fullfat for more information. * - * Or http://fullfat.googlecode.com/ for latest releases and the wiki. * + * Modification/Extensions/Bugfixes/Improvements to FullFAT must be sent to * + * James Walmsley for integration into the main development branch. * *****************************************************************************/ + #ifndef _FF_FATDEF_H_ #define _FF_FATDEF_H_ Index: ff_file.h =================================================================== --- ff_file.h (revision 58178) +++ ff_file.h (working copy) @@ -1,7 +1,19 @@ /***************************************************************************** - * FullFAT - High Performance, Thread-Safe Embedded FAT File-System * - * Copyright (C) 2009 James Walmsley (james@worm.me.uk) * + * FullFAT - High Performance, Thread-Safe Embedded FAT File-System * * * + * Copyright(C) 2009 James Walmsley * + * Copyright(C) 2011 Hein Tibosch * + * * + * See RESTRICTIONS.TXT for extra restrictions on the use of FullFAT. * + * * + * WARNING : COMMERCIAL PROJECTS MUST COMPLY WITH THE GNU GPL LICENSE. * + * * + * Projects that cannot comply with the GNU GPL terms are legally obliged * + * to seek alternative licensing. Contact James Walmsley for details. * + * * + ***************************************************************************** + * See http://www.fullfat-fs.co.uk/ for more information. * + ***************************************************************************** * This program is free software: you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation, either version 3 of the License, or * @@ -15,18 +27,14 @@ * You should have received a copy of the GNU General Public License * * along with this program. If not, see . * * * - * IMPORTANT NOTICE: * - * ================= * - * Alternative Licensing is available directly from the Copyright holder, * - * (James Walmsley). For more information consult LICENSING.TXT to obtain * - * a Commercial license. * + * The Copyright of Hein Tibosch on this project recognises his efforts in * + * contributing to this project. The right to license the project under * + * any other terms (other than the GNU GPL license) remains with the * + * original copyright holder (James Walmsley) only. * * * - * See RESTRICTIONS.TXT for extra restrictions on the use of FullFAT. * - * * - * Removing the above notice is illegal and will invalidate this license. * ***************************************************************************** - * See http://worm.me.uk/fullfat for more information. * - * Or http://fullfat.googlecode.com/ for latest releases and the wiki. * + * Modification/Extensions/Bugfixes/Improvements to FullFAT must be sent to * + * James Walmsley for integration into the main development branch. * *****************************************************************************/ /** @@ -53,6 +61,12 @@ #define FF_SEEK_END 3 #endif +#ifdef FF_OPTIMISE_UNALIGNED_ACCESS +#define FF_BUFSTATE_INVALID 0x00 ///< Data in file handle buffer is invalid. +#define FF_BUFSTATE_VALID 0x01 ///< Valid data in pBuf (Something has been read into it). +#define FF_BUFSTATE_WRITTEN 0x02 ///< Data was written into pBuf, this must be saved when leaving sector. +#endif + typedef struct _FF_FILE { FF_IOMAN *pIoman; ///< Ioman Pointer! FF_T_UINT32 Filesize; ///< File's Size. @@ -63,15 +77,24 @@ FF_T_UINT32 iEndOfChain; ///< Address of the last cluster in the chain. FF_T_UINT32 FilePointer; ///< Current Position Pointer. //FF_T_UINT32 AppendPointer; ///< Points to the Append from position. (The original filesize at open). - FF_T_UINT8 Mode; ///< Mode that File Was opened in. FF_T_UINT32 DirCluster; ///< Cluster Number that the Dirent is in. + FF_T_UINT32 ValidFlags; ///< Handle validation flags. + FF_T_UINT16 DirEntry; ///< Dirent Entry Number describing this file. - //FF_T_UINT8 NumLFNs; ///< Number of LFNs associated with this file. - FF_T_BOOL FileDeleted; + FF_T_UINT8 Mode; ///< Mode that File Was opened in. + +#ifdef FF_OPTIMISE_UNALIGNED_ACCESS + FF_T_UINT8 *pBuf; ///< A buffer for providing fast unaligned access. + FF_T_UINT8 ucState; ///< State information about the buffer. +#endif + struct _FF_FILE *Next; ///< Pointer to the next file object in the linked list. } FF_FILE, *PFF_FILE; +#define FF_VALID_FLAG_INVALID 0x00000001 +#define FF_VALID_FLAG_DELETED 0x00000002 + //---------- PROTOTYPES // PUBLIC (Interfaces): @@ -88,18 +111,43 @@ FF_ERROR FF_RmDir (FF_IOMAN *pIoman, const FF_T_INT8 *path); FF_ERROR FF_Move (FF_IOMAN *pIoman, const FF_T_INT8 *szSourceFile, const FF_T_INT8 *szDestinationFile); #endif + +#ifdef FF_TIME_SUPPORT +enum { + ETimeCreate = 1, + ETimeMod = 2, + ETimeAccess = 4, + ETimeAll = 7 +}; +FF_ERROR FF_SetFileTime(FF_FILE *pFile, FF_SYSTEMTIME *pTime, FF_T_UINT aWhat); +#ifdef FF_UNICODE_SUPPORT +FF_ERROR FF_SetTime(FF_IOMAN *pIoman, const FF_T_WCHAR *path, FF_SYSTEMTIME *pTime, FF_T_UINT aWhat); +#else +FF_ERROR FF_SetTime(FF_IOMAN *pIoman, const FF_T_INT8 *path, FF_SYSTEMTIME *pTime, FF_T_UINT aWhat); +#endif +#endif // FF_TIME_SUPPORT + FF_ERROR FF_Close (FF_FILE *pFile); FF_T_SINT32 FF_GetC (FF_FILE *pFile); FF_T_SINT32 FF_GetLine (FF_FILE *pFile, FF_T_INT8 *szLine, FF_T_UINT32 ulLimit); FF_T_SINT32 FF_Read (FF_FILE *pFile, FF_T_UINT32 ElementSize, FF_T_UINT32 Count, FF_T_UINT8 *buffer); FF_T_SINT32 FF_Write (FF_FILE *pFile, FF_T_UINT32 ElementSize, FF_T_UINT32 Count, FF_T_UINT8 *buffer); FF_T_BOOL FF_isEOF (FF_FILE *pFile); +FF_T_SINT32 FF_BytesLeft (FF_FILE *pFile); ///< Returns # of bytes left to read FF_ERROR FF_Seek (FF_FILE *pFile, FF_T_SINT32 Offset, FF_T_INT8 Origin); FF_T_SINT32 FF_PutC (FF_FILE *pFile, FF_T_UINT8 Value); -FF_T_UINT32 FF_Tell (FF_FILE *pFile); +FF_INLINE FF_T_UINT32 FF_Tell (FF_FILE *pFile) +{ + return pFile ? pFile->FilePointer : 0; +} FF_T_UINT8 FF_GetModeBits (FF_T_INT8 *Mode); +FF_ERROR FF_CheckValid (FF_FILE *pFile); ///< Check if pFile is a valid FF_FILE pointer +#ifdef FF_REMOVABLE_MEDIA +FF_T_SINT32 FF_Invalidate (FF_IOMAN *pIoman); ///< Invalidate all handles belonging to pIoman +#endif + // Private : #endif Index: ff_format.h =================================================================== --- ff_format.h (revision 58178) +++ ff_format.h (working copy) @@ -1,7 +1,19 @@ /***************************************************************************** - * FullFAT - High Performance, Thread-Safe Embedded FAT File-System * - * Copyright (C) 2009 James Walmsley (james@worm.me.uk) * + * FullFAT - High Performance, Thread-Safe Embedded FAT File-System * * * + * Copyright(C) 2009 James Walmsley * + * Copyright(C) 2011 Hein Tibosch * + * * + * See RESTRICTIONS.TXT for extra restrictions on the use of FullFAT. * + * * + * WARNING : COMMERCIAL PROJECTS MUST COMPLY WITH THE GNU GPL LICENSE. * + * * + * Projects that cannot comply with the GNU GPL terms are legally obliged * + * to seek alternative licensing. Contact James Walmsley for details. * + * * + ***************************************************************************** + * See http://www.fullfat-fs.co.uk/ for more information. * + ***************************************************************************** * This program is free software: you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation, either version 3 of the License, or * @@ -15,18 +27,14 @@ * You should have received a copy of the GNU General Public License * * along with this program. If not, see . * * * - * IMPORTANT NOTICE: * - * ================= * - * Alternative Licensing is available directly from the Copyright holder, * - * (James Walmsley). For more information consult LICENSING.TXT to obtain * - * a Commercial license. * + * The Copyright of Hein Tibosch on this project recognises his efforts in * + * contributing to this project. The right to license the project under * + * any other terms (other than the GNU GPL license) remains with the * + * original copyright holder (James Walmsley) only. * * * - * See RESTRICTIONS.TXT for extra restrictions on the use of FullFAT. * - * * - * Removing the above notice is illegal and will invalidate this license. * ***************************************************************************** - * See http://worm.me.uk/fullfat for more information. * - * Or http://fullfat.googlecode.com/ for latest releases and the wiki. * + * Modification/Extensions/Bugfixes/Improvements to FullFAT must be sent to * + * James Walmsley for integration into the main development branch. * *****************************************************************************/ /** @@ -40,8 +48,37 @@ #ifndef _FF_FORMAT_H_ #define _FF_FORMAT_H_ +#ifdef __cplusplus +extern "C" { +#endif +#include "ff_config.h" +#include "ff_types.h" +#include "ff_ioman.h" +#include "ff_dir.h" +#include "ff_format.h" +typedef struct _FF_PARTITION_ENTRY { + FF_T_UINT32 ulStartLBA; + FF_T_UINT32 ulLength; + FF_T_UINT8 ucStatus; + FF_T_UINT8 ucType; +} FF_PARTITION_ENTRY; +typedef struct _FF_PARTITION_TABLE { + FF_PARTITION_ENTRY arrPEntries[4]; +} FF_PARTITION_TABLE; +//---------- PROTOTYPES +// PUBLIC (Interfaces): + +//FF_ERROR FF_Format (FF_IOMAN *pIoman, FF_T_UINT32 SectorCount, FF_T_BOOL TryFat16); +FF_ERROR FF_Format(FF_IOMAN *pIoman, FF_T_UINT32 ulStartLBA, FF_T_UINT32 ulEndLBA, FF_T_UINT32 ulClusterSize); +FF_ERROR FF_FormatPartition(FF_IOMAN *pIoman, FF_T_UINT32 ulPartitionNumber, FF_T_UINT32 ulClusterSize); +// Private : + +#ifdef __cplusplus +} // extern "C" #endif + +#endif Index: ff_hash.h =================================================================== --- ff_hash.h (revision 58178) +++ ff_hash.h (working copy) @@ -1,7 +1,19 @@ /***************************************************************************** - * FullFAT - High Performance, Thread-Safe Embedded FAT File-System * - * Copyright (C) 2009 James Walmsley (james@worm.me.uk) * + * FullFAT - High Performance, Thread-Safe Embedded FAT File-System * * * + * Copyright(C) 2009 James Walmsley * + * Copyright(C) 2011 Hein Tibosch * + * * + * See RESTRICTIONS.TXT for extra restrictions on the use of FullFAT. * + * * + * WARNING : COMMERCIAL PROJECTS MUST COMPLY WITH THE GNU GPL LICENSE. * + * * + * Projects that cannot comply with the GNU GPL terms are legally obliged * + * to seek alternative licensing. Contact James Walmsley for details. * + * * + ***************************************************************************** + * See http://www.fullfat-fs.co.uk/ for more information. * + ***************************************************************************** * This program is free software: you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation, either version 3 of the License, or * @@ -15,18 +27,14 @@ * You should have received a copy of the GNU General Public License * * along with this program. If not, see . * * * - * IMPORTANT NOTICE: * - * ================= * - * Alternative Licensing is available directly from the Copyright holder, * - * (James Walmsley). For more information consult LICENSING.TXT to obtain * - * a Commercial license. * + * The Copyright of Hein Tibosch on this project recognises his efforts in * + * contributing to this project. The right to license the project under * + * any other terms (other than the GNU GPL license) remains with the * + * original copyright holder (James Walmsley) only. * * * - * See RESTRICTIONS.TXT for extra restrictions on the use of FullFAT. * - * * - * Removing the above notice is illegal and will invalidate this license. * ***************************************************************************** - * See http://worm.me.uk/fullfat for more information. * - * Or http://fullfat.googlecode.com/ for latest releases and the wiki. * + * Modification/Extensions/Bugfixes/Improvements to FullFAT must be sent to * + * James Walmsley for integration into the main development branch. * *****************************************************************************/ /** Index: ff_ioman.h =================================================================== --- ff_ioman.h (revision 58178) +++ ff_ioman.h (working copy) @@ -1,7 +1,19 @@ /***************************************************************************** - * FullFAT - High Performance, Thread-Safe Embedded FAT File-System * - * Copyright (C) 2009 James Walmsley (james@worm.me.uk) * + * FullFAT - High Performance, Thread-Safe Embedded FAT File-System * * * + * Copyright(C) 2009 James Walmsley * + * Copyright(C) 2011 Hein Tibosch * + * * + * See RESTRICTIONS.TXT for extra restrictions on the use of FullFAT. * + * * + * WARNING : COMMERCIAL PROJECTS MUST COMPLY WITH THE GNU GPL LICENSE. * + * * + * Projects that cannot comply with the GNU GPL terms are legally obliged * + * to seek alternative licensing. Contact James Walmsley for details. * + * * + ***************************************************************************** + * See http://www.fullfat-fs.co.uk/ for more information. * + ***************************************************************************** * This program is free software: you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation, either version 3 of the License, or * @@ -15,20 +27,15 @@ * You should have received a copy of the GNU General Public License * * along with this program. If not, see . * * * - * IMPORTANT NOTICE: * - * ================= * - * Alternative Licensing is available directly from the Copyright holder, * - * (James Walmsley). For more information consult LICENSING.TXT to obtain * - * a Commercial license. * + * The Copyright of Hein Tibosch on this project recognises his efforts in * + * contributing to this project. The right to license the project under * + * any other terms (other than the GNU GPL license) remains with the * + * original copyright holder (James Walmsley) only. * * * - * See RESTRICTIONS.TXT for extra restrictions on the use of FullFAT. * - * * - * Removing the above notice is illegal and will invalidate this license. * ***************************************************************************** - * See http://worm.me.uk/fullfat for more information. * - * Or http://fullfat.googlecode.com/ for latest releases and the wiki. * + * Modification/Extensions/Bugfixes/Improvements to FullFAT must be sent to * + * James Walmsley for integration into the main development branch. * *****************************************************************************/ - /** * @file ff_ioman.h * @author James Walmsley @@ -59,6 +66,10 @@ #define FF_MODE_TRUNCATE 0x10 ///< FILE Mode Truncate an Existing file. #define FF_MODE_DIR 0x80 ///< Special Mode to open a Dir. (Internal use ONLY!) +#define FF_MODE_RD_WR (FF_MODE_READ|FF_MODE_WRITE) ///< Just for bit filtering + +#define FF_MODE_WR_ONLY (0x40|FF_MODE_WRITE) ///< Buffer for Write-only Access (Internal use ONLY!) + #define FF_BUF_MAX_HANDLES 0xFFFF ///< Maximum number handles sharing a buffer. (16 bit integer, we don't want to overflow it!) /** @@ -79,8 +90,6 @@ typedef FF_T_SINT32 (*FF_WRITE_BLOCKS) (FF_T_UINT8 *pBuffer, FF_T_UINT32 SectorAddress, FF_T_UINT32 Count, void *pParam); typedef FF_T_SINT32 (*FF_READ_BLOCKS) (FF_T_UINT8 *pBuffer, FF_T_UINT32 SectorAddress, FF_T_UINT32 Count, void *pParam); -#define FF_ERR_DRIVER_BUSY -10 -#define FF_ERR_DRIVER_FATAL_ERROR -11 /** * @public @@ -133,32 +142,35 @@ * @note This may shrink as development and optimisation goes on. **/ typedef struct { - //FF_T_UINT8 ID; ///< Partition Incremental ID number. - FF_T_UINT8 Type; ///< Partition Type Identifier. - FF_T_UINT16 BlkSize; ///< Size of a Sector Block in bytes. - FF_T_UINT8 BlkFactor; ///< Scale Factor for blocksizes above 512! - //FF_T_INT8 Name[FF_MAX_PARTITION_NAME]; ///< Partition Identifier e.g. c: sd0: etc. - FF_T_INT8 VolLabel[12]; ///< Volume Label of the partition. - FF_T_UINT32 BeginLBA; ///< LBA start address of the partition. - FF_T_UINT32 PartSize; ///< Size of Partition in number of sectors. - FF_T_UINT32 FatBeginLBA; ///< LBA of the FAT tables. - FF_T_UINT8 NumFATS; ///< Number of FAT tables. - FF_T_UINT32 SectorsPerFAT; ///< Number of sectors per Fat. - FF_T_UINT8 SectorsPerCluster; ///< Number of sectors per Cluster. - FF_T_UINT32 TotalSectors; - FF_T_UINT32 DataSectors; - FF_T_UINT32 RootDirSectors; - FF_T_UINT32 FirstDataSector; - FF_T_UINT16 ReservedSectors; - FF_T_UINT32 ClusterBeginLBA; ///< LBA of first cluster. - FF_T_UINT32 NumClusters; ///< Number of clusters. - FF_T_UINT32 RootDirCluster; ///< Cluster number of the root directory entry. - FF_T_UINT32 LastFreeCluster; - FF_T_UINT32 FreeClusterCount; ///< Records free space on mount. - FF_T_BOOL PartitionMounted; ///< FF_TRUE if the partition is mounted, otherwise FF_FALSE. + //FF_T_UINT8 ID; ///< Partition Incremental ID number. + FF_T_UINT8 Type; ///< Partition Type Identifier. + FF_T_UINT16 BlkSize; ///< Size of a Sector Block in bytes. + FF_T_UINT8 BlkFactor; ///< Scale Factor for blocksizes above 512! + //FF_T_INT8 Name[FF_MAX_PARTITION_NAME]; ///< Partition Identifier e.g. c: sd0: etc. + FF_T_INT8 VolLabel[12]; ///< Volume Label of the partition. + FF_T_UINT32 BeginLBA; ///< LBA start address of the partition. + FF_T_UINT32 PartSize; ///< Size of Partition in number of sectors. + FF_T_UINT32 FatBeginLBA; ///< LBA of the FAT tables. + FF_T_UINT8 NumFATS; ///< Number of FAT tables. + FF_T_UINT32 SectorsPerFAT; ///< Number of sectors per Fat. + FF_T_UINT8 SectorsPerCluster; ///< Number of sectors per Cluster. + FF_T_UINT32 TotalSectors; + FF_T_UINT32 DataSectors; +#ifdef FF_WRITE_FREE_COUNT + FF_T_UINT32 FSInfoLBA; ///< LBA of the FSINFO sector. +#endif + FF_T_UINT32 RootDirSectors; + FF_T_UINT32 FirstDataSector; + FF_T_UINT16 ReservedSectors; + FF_T_UINT32 ClusterBeginLBA; ///< LBA of first cluster. + FF_T_UINT32 NumClusters; ///< Number of clusters. + FF_T_UINT32 RootDirCluster; ///< Cluster number of the root directory entry. + FF_T_UINT32 LastFreeCluster; + FF_T_UINT32 FreeClusterCount; ///< Records free space on mount. + FF_T_BOOL PartitionMounted; ///< FF_TRUE if the partition is mounted, otherwise FF_FALSE. #ifdef FF_PATH_CACHE - FF_PATHCACHE PathCache[FF_PATH_CACHE_DEPTH]; - FF_T_UINT32 PCIndex; + FF_PATHCACHE PathCache[FF_PATH_CACHE_DEPTH]; + FF_T_UINT32 PCIndex; #endif } FF_PARTITION; @@ -226,6 +238,11 @@ FF_ERROR FF_MountPartition (FF_IOMAN *pIoman, FF_T_UINT8 PartitionNumber); FF_ERROR FF_UnmountPartition (FF_IOMAN *pIoman); FF_ERROR FF_FlushCache (FF_IOMAN *pIoman); +FF_INLINE FF_T_BOOL FF_Mounted (FF_IOMAN *pIoman) +{ + return pIoman && pIoman->pPartition && pIoman->pPartition->PartitionMounted; +} + FF_T_SINT32 FF_GetPartitionBlockSize(FF_IOMAN *pIoman); #ifdef FF_64_NUM_SUPPORT @@ -235,12 +252,12 @@ #endif // PUBLIC (To FullFAT Only): -FF_T_SINT32 FF_BlockRead (FF_IOMAN *pIoman, FF_T_UINT32 ulSectorLBA, FF_T_UINT32 ulNumSectors, void *pBuffer); -FF_T_SINT32 FF_BlockWrite (FF_IOMAN *pIoman, FF_T_UINT32 ulSectorLBA, FF_T_UINT32 ulNumSectors, void *pBuffer); +FF_T_SINT32 FF_BlockRead (FF_IOMAN *pIoman, FF_T_UINT32 ulSectorLBA, FF_T_UINT32 ulNumSectors, void *pBuffer, FF_T_BOOL aSemLocked); +FF_T_SINT32 FF_BlockWrite (FF_IOMAN *pIoman, FF_T_UINT32 ulSectorLBA, FF_T_UINT32 ulNumSectors, void *pBuffer, FF_T_BOOL aSemLocked); FF_ERROR FF_IncreaseFreeClusters (FF_IOMAN *pIoman, FF_T_UINT32 Count); FF_ERROR FF_DecreaseFreeClusters (FF_IOMAN *pIoman, FF_T_UINT32 Count); FF_BUFFER *FF_GetBuffer (FF_IOMAN *pIoman, FF_T_UINT32 Sector, FF_T_UINT8 Mode); -void FF_ReleaseBuffer (FF_IOMAN *pIoman, FF_BUFFER *pBuffer); +FF_ERROR FF_ReleaseBuffer (FF_IOMAN *pIoman, FF_BUFFER *pBuffer); // PRIVATE (For this module only!): Index: ff_memory.h =================================================================== --- ff_memory.h (revision 58178) +++ ff_memory.h (working copy) @@ -1,7 +1,19 @@ /***************************************************************************** - * FullFAT - High Performance, Thread-Safe Embedded FAT File-System * - * Copyright (C) 2009 James Walmsley (james@worm.me.uk) * + * FullFAT - High Performance, Thread-Safe Embedded FAT File-System * * * + * Copyright(C) 2009 James Walmsley * + * Copyright(C) 2011 Hein Tibosch * + * * + * See RESTRICTIONS.TXT for extra restrictions on the use of FullFAT. * + * * + * WARNING : COMMERCIAL PROJECTS MUST COMPLY WITH THE GNU GPL LICENSE. * + * * + * Projects that cannot comply with the GNU GPL terms are legally obliged * + * to seek alternative licensing. Contact James Walmsley for details. * + * * + ***************************************************************************** + * See http://www.fullfat-fs.co.uk/ for more information. * + ***************************************************************************** * This program is free software: you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation, either version 3 of the License, or * @@ -15,18 +27,14 @@ * You should have received a copy of the GNU General Public License * * along with this program. If not, see . * * * - * IMPORTANT NOTICE: * - * ================= * - * Alternative Licensing is available directly from the Copyright holder, * - * (James Walmsley). For more information consult LICENSING.TXT to obtain * - * a Commercial license. * + * The Copyright of Hein Tibosch on this project recognises his efforts in * + * contributing to this project. The right to license the project under * + * any other terms (other than the GNU GPL license) remains with the * + * original copyright holder (James Walmsley) only. * * * - * See RESTRICTIONS.TXT for extra restrictions on the use of FullFAT. * - * * - * Removing the above notice is illegal and will invalidate this license. * ***************************************************************************** - * See http://worm.me.uk/fullfat for more information. * - * Or http://fullfat.googlecode.com/ for latest releases and the wiki. * + * Modification/Extensions/Bugfixes/Improvements to FullFAT must be sent to * + * James Walmsley for integration into the main development branch. * *****************************************************************************/ /** @@ -41,12 +49,6 @@ #include "ff_config.h" #include "ff_types.h" -#ifdef __REACTOS__ -// defined in fullfat.c -void *FF_Malloc(FF_T_UINT32 allocSize); -void FF_Free(void *pBuffer); -#endif - /* HT changed type of aOffset to u32 */ Index: ff_safety.h =================================================================== --- ff_safety.h (revision 58178) +++ ff_safety.h (working copy) @@ -1,7 +1,19 @@ /***************************************************************************** - * FullFAT - High Performance, Thread-Safe Embedded FAT File-System * - * Copyright (C) 2009 James Walmsley (james@worm.me.uk) * + * FullFAT - High Performance, Thread-Safe Embedded FAT File-System * * * + * Copyright(C) 2009 James Walmsley * + * Copyright(C) 2011 Hein Tibosch * + * * + * See RESTRICTIONS.TXT for extra restrictions on the use of FullFAT. * + * * + * WARNING : COMMERCIAL PROJECTS MUST COMPLY WITH THE GNU GPL LICENSE. * + * * + * Projects that cannot comply with the GNU GPL terms are legally obliged * + * to seek alternative licensing. Contact James Walmsley for details. * + * * + ***************************************************************************** + * See http://www.fullfat-fs.co.uk/ for more information. * + ***************************************************************************** * This program is free software: you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation, either version 3 of the License, or * @@ -15,18 +27,14 @@ * You should have received a copy of the GNU General Public License * * along with this program. If not, see . * * * - * IMPORTANT NOTICE: * - * ================= * - * Alternative Licensing is available directly from the Copyright holder, * - * (James Walmsley). For more information consult LICENSING.TXT to obtain * - * a Commercial license. * + * The Copyright of Hein Tibosch on this project recognises his efforts in * + * contributing to this project. The right to license the project under * + * any other terms (other than the GNU GPL license) remains with the * + * original copyright holder (James Walmsley) only. * * * - * See RESTRICTIONS.TXT for extra restrictions on the use of FullFAT. * - * * - * Removing the above notice is illegal and will invalidate this license. * ***************************************************************************** - * See http://worm.me.uk/fullfat for more information. * - * Or http://fullfat.googlecode.com/ for latest releases and the wiki. * + * Modification/Extensions/Bugfixes/Improvements to FullFAT must be sent to * + * James Walmsley for integration into the main development branch. * *****************************************************************************/ /** @@ -50,6 +58,7 @@ // PRIVATE: void *FF_CreateSemaphore (void); void FF_PendSemaphore (void *pSemaphore); +FF_T_BOOL FF_TrySemaphore (void *pSemaphore, FF_T_UINT32 TimeMs); void FF_ReleaseSemaphore (void *pSemaphore); void FF_DestroySemaphore (void *pSemaphore); void FF_Yield (void); Index: ff_string.h =================================================================== --- ff_string.h (revision 58178) +++ ff_string.h (working copy) @@ -1,7 +1,19 @@ /***************************************************************************** - * FullFAT - High Performance, Thread-Safe Embedded FAT File-System * - * Copyright (C) 2009 James Walmsley (james@worm.me.uk) * + * FullFAT - High Performance, Thread-Safe Embedded FAT File-System * * * + * Copyright(C) 2009 James Walmsley * + * Copyright(C) 2011 Hein Tibosch * + * * + * See RESTRICTIONS.TXT for extra restrictions on the use of FullFAT. * + * * + * WARNING : COMMERCIAL PROJECTS MUST COMPLY WITH THE GNU GPL LICENSE. * + * * + * Projects that cannot comply with the GNU GPL terms are legally obliged * + * to seek alternative licensing. Contact James Walmsley for details. * + * * + ***************************************************************************** + * See http://www.fullfat-fs.co.uk/ for more information. * + ***************************************************************************** * This program is free software: you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation, either version 3 of the License, or * @@ -15,18 +27,14 @@ * You should have received a copy of the GNU General Public License * * along with this program. If not, see . * * * - * IMPORTANT NOTICE: * - * ================= * - * Alternative Licensing is available directly from the Copyright holder, * - * (James Walmsley). For more information consult LICENSING.TXT to obtain * - * a Commercial license. * + * The Copyright of Hein Tibosch on this project recognises his efforts in * + * contributing to this project. The right to license the project under * + * any other terms (other than the GNU GPL license) remains with the * + * original copyright holder (James Walmsley) only. * * * - * See RESTRICTIONS.TXT for extra restrictions on the use of FullFAT. * - * * - * Removing the above notice is illegal and will invalidate this license. * ***************************************************************************** - * See http://worm.me.uk/fullfat for more information. * - * Or http://fullfat.googlecode.com/ for latest releases and the wiki. * + * Modification/Extensions/Bugfixes/Improvements to FullFAT must be sent to * + * James Walmsley for integration into the main development branch. * *****************************************************************************/ /** @@ -48,8 +56,10 @@ #include #ifdef WIN32 +#define stricmp _stricmp #define FF_stricmp stricmp #else +//#define strcasecmp strcasecmp #define FF_stricmp strcasecmp #endif Index: ff_time.h =================================================================== --- ff_time.h (revision 58178) +++ ff_time.h (working copy) @@ -1,7 +1,19 @@ /***************************************************************************** - * FullFAT - High Performance, Thread-Safe Embedded FAT File-System * - * Copyright (C) 2009 James Walmsley (james@worm.me.uk) * + * FullFAT - High Performance, Thread-Safe Embedded FAT File-System * * * + * Copyright(C) 2009 James Walmsley * + * Copyright(C) 2011 Hein Tibosch * + * * + * See RESTRICTIONS.TXT for extra restrictions on the use of FullFAT. * + * * + * WARNING : COMMERCIAL PROJECTS MUST COMPLY WITH THE GNU GPL LICENSE. * + * * + * Projects that cannot comply with the GNU GPL terms are legally obliged * + * to seek alternative licensing. Contact James Walmsley for details. * + * * + ***************************************************************************** + * See http://www.fullfat-fs.co.uk/ for more information. * + ***************************************************************************** * This program is free software: you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation, either version 3 of the License, or * @@ -15,18 +27,14 @@ * You should have received a copy of the GNU General Public License * * along with this program. If not, see . * * * - * IMPORTANT NOTICE: * - * ================= * - * Alternative Licensing is available directly from the Copyright holder, * - * (James Walmsley). For more information consult LICENSING.TXT to obtain * - * a Commercial license. * + * The Copyright of Hein Tibosch on this project recognises his efforts in * + * contributing to this project. The right to license the project under * + * any other terms (other than the GNU GPL license) remains with the * + * original copyright holder (James Walmsley) only. * * * - * See RESTRICTIONS.TXT for extra restrictions on the use of FullFAT. * - * * - * Removing the above notice is illegal and will invalidate this license. * ***************************************************************************** - * See http://worm.me.uk/fullfat for more information. * - * Or http://fullfat.googlecode.com/ for latest releases and the wiki. * + * Modification/Extensions/Bugfixes/Improvements to FullFAT must be sent to * + * James Walmsley for integration into the main development branch. * *****************************************************************************/ /** Index: ff_types.h =================================================================== --- ff_types.h (revision 58178) +++ ff_types.h (working copy) @@ -1,7 +1,19 @@ /***************************************************************************** - * FullFAT - High Performance, Thread-Safe Embedded FAT File-System * - * Copyright (C) 2009 James Walmsley (james@worm.me.uk) * + * FullFAT - High Performance, Thread-Safe Embedded FAT File-System * * * + * Copyright(C) 2009 James Walmsley * + * Copyright(C) 2011 Hein Tibosch * + * * + * See RESTRICTIONS.TXT for extra restrictions on the use of FullFAT. * + * * + * WARNING : COMMERCIAL PROJECTS MUST COMPLY WITH THE GNU GPL LICENSE. * + * * + * Projects that cannot comply with the GNU GPL terms are legally obliged * + * to seek alternative licensing. Contact James Walmsley for details. * + * * + ***************************************************************************** + * See http://www.fullfat-fs.co.uk/ for more information. * + ***************************************************************************** * This program is free software: you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation, either version 3 of the License, or * @@ -15,18 +27,14 @@ * You should have received a copy of the GNU General Public License * * along with this program. If not, see . * * * - * IMPORTANT NOTICE: * - * ================= * - * Alternative Licensing is available directly from the Copyright holder, * - * (James Walmsley). For more information consult LICENSING.TXT to obtain * - * a Commercial license. * + * The Copyright of Hein Tibosch on this project recognises his efforts in * + * contributing to this project. The right to license the project under * + * any other terms (other than the GNU GPL license) remains with the * + * original copyright holder (James Walmsley) only. * * * - * See RESTRICTIONS.TXT for extra restrictions on the use of FullFAT. * - * * - * Removing the above notice is illegal and will invalidate this license. * ***************************************************************************** - * See http://worm.me.uk/fullfat for more information. * - * Or http://fullfat.googlecode.com/ for latest releases and the wiki. * + * Modification/Extensions/Bugfixes/Improvements to FullFAT must be sent to * + * James Walmsley for integration into the main development branch. * *****************************************************************************/ /** Index: ff_unicode.h =================================================================== --- ff_unicode.h (revision 58178) +++ ff_unicode.h (working copy) @@ -1,7 +1,19 @@ /***************************************************************************** - * FullFAT - High Performance, Thread-Safe Embedded FAT File-System * - * Copyright (C) 2009 James Walmsley (james@worm.me.uk) * + * FullFAT - High Performance, Thread-Safe Embedded FAT File-System * * * + * Copyright(C) 2009 James Walmsley * + * Copyright(C) 2011 Hein Tibosch * + * * + * See RESTRICTIONS.TXT for extra restrictions on the use of FullFAT. * + * * + * WARNING : COMMERCIAL PROJECTS MUST COMPLY WITH THE GNU GPL LICENSE. * + * * + * Projects that cannot comply with the GNU GPL terms are legally obliged * + * to seek alternative licensing. Contact James Walmsley for details. * + * * + ***************************************************************************** + * See http://www.fullfat-fs.co.uk/ for more information. * + ***************************************************************************** * This program is free software: you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation, either version 3 of the License, or * @@ -15,18 +27,14 @@ * You should have received a copy of the GNU General Public License * * along with this program. If not, see . * * * - * IMPORTANT NOTICE: * - * ================= * - * Alternative Licensing is available directly from the Copyright holder, * - * (James Walmsley). For more information consult LICENSING.TXT to obtain * - * a Commercial license. * + * The Copyright of Hein Tibosch on this project recognises his efforts in * + * contributing to this project. The right to license the project under * + * any other terms (other than the GNU GPL license) remains with the * + * original copyright holder (James Walmsley) only. * * * - * See RESTRICTIONS.TXT for extra restrictions on the use of FullFAT. * - * * - * Removing the above notice is illegal and will invalidate this license. * ***************************************************************************** - * See http://worm.me.uk/fullfat for more information. * - * Or http://fullfat.googlecode.com/ for latest releases and the wiki. * + * Modification/Extensions/Bugfixes/Improvements to FullFAT must be sent to * + * James Walmsley for integration into the main development branch. * *****************************************************************************/ /** Index: fullfat.h =================================================================== --- fullfat.h (revision 58178) +++ fullfat.h (working copy) @@ -1,7 +1,19 @@ /***************************************************************************** - * FullFAT - High Performance, Thread-Safe Embedded FAT File-System * - * Copyright (C) 2009 James Walmsley (james@worm.me.uk) * + * FullFAT - High Performance, Thread-Safe Embedded FAT File-System * * * + * Copyright(C) 2009 James Walmsley * + * Copyright(C) 2011 Hein Tibosch * + * * + * See RESTRICTIONS.TXT for extra restrictions on the use of FullFAT. * + * * + * WARNING : COMMERCIAL PROJECTS MUST COMPLY WITH THE GNU GPL LICENSE. * + * * + * Projects that cannot comply with the GNU GPL terms are legally obliged * + * to seek alternative licensing. Contact James Walmsley for details. * + * * + ***************************************************************************** + * See http://www.fullfat-fs.co.uk/ for more information. * + ***************************************************************************** * This program is free software: you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation, either version 3 of the License, or * @@ -15,18 +27,14 @@ * You should have received a copy of the GNU General Public License * * along with this program. If not, see . * * * - * IMPORTANT NOTICE: * - * ================= * - * Alternative Licensing is available directly from the Copyright holder, * - * (James Walmsley). For more information consult LICENSING.TXT to obtain * - * a Commercial license. * + * The Copyright of Hein Tibosch on this project recognises his efforts in * + * contributing to this project. The right to license the project under * + * any other terms (other than the GNU GPL license) remains with the * + * original copyright holder (James Walmsley) only. * * * - * See RESTRICTIONS.TXT for extra restrictions on the use of FullFAT. * - * * - * Removing the above notice is illegal and will invalidate this license. * ***************************************************************************** - * See http://worm.me.uk/fullfat for more information. * - * Or http://fullfat.googlecode.com/ for latest releases and the wiki. * + * Modification/Extensions/Bugfixes/Improvements to FullFAT must be sent to * + * James Walmsley for integration into the main development branch. * *****************************************************************************/ #ifndef _FULLFAT_H_ @@ -36,17 +44,22 @@ extern "C" { #endif +#define FF_VERSION "2.0.0 (" __DATE__ " : "__TIME__")" // The official version number for this release. +#define FF_REVISION "FullFAT-2.0.0-RTM" // The official version control commit code for this release. + #include "ff_config.h" #include "ff_ioman.h" +#include "ff_crc.h" +#include "ff_dir.h" +#include "ff_error.h" #include "ff_fat.h" #include "ff_file.h" -#include "ff_dir.h" +#include "ff_hash.h" #include "ff_time.h" -#include "ff_crc.h" -#include "ff_hash.h" #include "ff_string.h" +#include "ff_types.h" #include "ff_unicode.h" -//#include "ff_format.h" +#include "ff_format.h" #ifdef __cplusplus } // extern "C"