⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 efs_intern.h

📁 这是ucfs文件系统源代码
💻 H
字号:
/*
**********************************************************************
*                          Micrium, Inc.
*                      949 Crestview Circle
*                     Weston,  FL 33327-1848
*
*                            uC/FS
*
*             (c) Copyright 2001 - 2006, Micrium, Inc.
*                      All rights reserved.
*
***********************************************************************

----------------------------------------------------------------------
File        : EFS_Intern.h
Purpose     : EFS File System Layer internal header
---------------------------END-OF-HEADER------------------------------
*/

#ifndef EFS_INTERN_H
#define EFS_INTERN_H

#include "fs_int.h"

#if defined(__cplusplus)
extern "C" {     /* Make sure we have C-declarations in C++ programs */
#endif

/*********************************************************************
*
*       #define constants
*
**********************************************************************
*/

#define EFS_VERSION   0x100
#define EFS_SIGNATURE 0x00534645      /* "EFS" */

#define EFS_MAX_DIR_ENTRY_SIZE 255
#define EFS_FIRST_CLUSTER        1    /* Can be changed, but should not be 0 */

#define EFS_ALLOC_VALUE_FREE     0
#define EFS_ALLOC_VALUE_USED     1


/*********************************************************************
*
*       EFS_SECTOR_...
*
*/
#define EFS_SECTOR_INFO        0    /* Info sector */
#define EFS_SECTOR_STATUS      1    /* Status sector */
#define EFS_SECTOR_ALLOC_MAP   2    /* Start sector of allocation map */

/*********************************************************************
*
*       DIR_ENTRY_OFF_...
*
*  Purpose
*    Defines the position of the individual elements in a directory entry
*/
#define DIR_ENTRY_OFF_OFFNEXT        0x00
#define DIR_ENTRY_OFF_ISVALID        0x01
#define DIR_ENTRY_OFF_ATTRIB         0x02
#define DIR_ENTRY_OFF_NAMELEN        0x03
#define DIR_ENTRY_OFF_FIRSTCLUSTER   0x04
#define DIR_ENTRY_OFF_SIZELO         0x08
#define DIR_ENTRY_OFF_SIZEHI         0x0C
#define DIR_ENTRY_OFF_TIMESTAMP      0x10
#define DIR_ENTRY_OFF_NAME           0x14

#define DIR_ENTRY_FIXED_SIZE         0x14       /* For total size of entry, add len of file name */


/*********************************************************************
*
*       INFO_OFF_...
*
*  Purpose
*    Defines the position of the individual elements in the info sector
*/
#define INFO_OFF_SIGNATURE             0x0
#define INFO_OFF_VERSION               0x4
#define INFO_OFF_LD_BPS                0x6          /* ld Bytes per sector */
#define INFO_OFF_NUM_SECTORS           0x8
#define INFO_OFF_NUM_CLUSTERS          0xc
#define INFO_OFF_FIRST_DATA_SECTOR     0x10
#define INFO_OFF_LD_SPC                0x14         /* ld Sectors per cluster */


/*********************************************************************
*
*       ALLOC_NODE_OFF_...
*
*  Purpose
*    Defines the position of the individual elements in the alloc node
*/
#define ALLOC_NODE_OFF_SIZE           0x0
#define ALLOC_NODE_OFF_NEXT_CLUSTER   0x4
#define SIZEOF_ALLOC_NODE             0x8


/*********************************************************************
*
*       DIR_...
*
*/
#define DIR_MAX_SIZE                 0x7FFFFFFF


/*********************************************************************
*
*       EFS_misc
*/
FS_U32 FS_EFS_AllocClusterBlock   (FS_VOLUME   * pVolume,  FS_U32 NumBytes2Write, FS_U32 * pFirstNewCluster, FS_U32 StartCluster, FS_SB * pSB);
FS_U32 FS_EFS_CalcDirSector       (FS_VOLUME   * pVolume,  FS_U32 DirStart,       FS_U32 DirSec);
FS_U32 FS_EFS_CalcDirSectorByIndex(FS_VOLUME   * pVolume,  FS_U32 FirstCluster,   FS_U32 DirEntryIndex);
FS_U32 FS_EFS_ClusterId2SectorNo  (FS_EFS_INFO * pEFSInfo, FS_U32 ClusterId);
char   FS_EFS_ClusterIsFree       (FS_EFS_INFO * pEFSInfo, FS_U32 Cluster,        FS_SB * pSB);
FS_U32 FS_EFS_FindDir             (FS_VOLUME   * pVolume,  char *pDirName,        FS_U32 DirStart, FS_U32 DirSize);
char   FS_EFS_FindEmptyDirEntry   (FS_FILE     * pDirFile, FS_SB* pSB,            unsigned * pEntryLen);
int    FS_EFS_FindFileCluster     (FS_FILE     * pFile,    FS_SB * pSB);
FS_U32 FS_EFS_FindFreeCluster     (FS_VOLUME   * pVolume,  FS_SB * pSB,           FS_U32 FirstCluster);
void   FS_EFS_MarkAsFree          (FS_VOLUME   * pVolume,  FS_U32 Cluster,        FS_SB * pSB);
void   FS_EFS_MarkAsUsed          (FS_VOLUME   * pVolume,  FS_U32 Cluster,        FS_SB * pSB);
char   FS_EFS_OpenDirFile         (FS_FILE     * pDirFile, FS_VOLUME * pVolume,   FS_U32 DirStart);
void   FS_EFS_ReadAllocNode       (FS_U8       * pBuffer,  FS_U32 * pClusterId,   FS_U32 * pNumClusters);
void   FS_EFS_WriteAllocNode      (FS_U8       * pBuffer,  FS_U32 ClusterId,      FS_U32 NumClusters);

void   FS__EFS_GetDirEntryInfo (FS_FILE * pDirFile, FS_SB* pSB, FS_U32 * pFirstCluster, FS_U32 * pFileSize, FS_U8 * pAttributes, FS_U32 * pTimeStamp);
int    FS__EFS_CheckInfoSector (FS_VOLUME * pVolume, FS_U8 * pBuffer);

/*********************************************************************
*
*       EFS_in
*/
FS_U32 FS_EFS_ReadData(FS_FILE *pFile, FS_U8 *pData, FS_U32 NumBytesReq, FS_SB * pSB);

/*********************************************************************
*
*       EFS_out
*/
FS_U32 FS_EFS_WriteData             (FS_FILE * pFile, const FS_U8 * pData, FS_U32 NumBytes2Write, FS_SB * pSB);
FS_U32 FS_EFS_WriteDataEx           (FS_FILE * pFile, const FS_U8 * pData, FS_U32 NumBytes2Write, FS_SB * pSB, char * pDirUpdateRequired);
int    FS_EFS_AllocFirstClusterIfReq(FS_FILE * pFile, FS_SB * pSB, FS_U32 NumBytes2Write, char * pDirUpdateRequired);


/*********************************************************************
*
*       EFS_open
*/
char   FS_EFS_DeleteFileOrDir      (FS_FILE  * pDirFile, FS_SB * pSB, FS_U8 IsFile);
char   FS_EFS_FindDirEntry         (FS_FILE  * pDirFile, FS_SB * pSB, const char *pEntryName, int NameLen);
char   FS_EFS_FindEmptyDirEntry    (FS_FILE  * pDirFile, FS_SB * pSB, unsigned * pEntryLen);
char   FS_EFS_FindPath             (FS_VOLUME * pVolume, FS_SB * pSB, const char *pFullName, const char * *ppFileName, FS_FILE *pDirFile);
void   FS_EFS_MarkDirEntryAsInvalid(FS_FILE  * pDirFile, FS_SB * pSB);
FS_U8  FS_EFS_ReadDirEntry         (FS_FILE  * pDirFile, FS_SB * pSB, FS_U8 * pBuffer);
char   FS_EFS_WriteDirEntry        (FS_FILE  * pDirFile, FS_SB * pSB, const char * pFileName, unsigned EntryLen, FS_U16 Time, FS_U16 Date, FS_U32 Size, FS_U32 ClusterId, FS_U8 Attrib);



/*********************************************************************
*
*       Public const
*
**********************************************************************
*/
#if FS_SUPPORT_MULTIPLE_FS
  extern const FS_FS_API FS_EFS_API;
#endif

#if defined(__cplusplus)
}                /* Make sure we have C-declarations in C++ programs */
#endif

#endif  /* Avoid multiple inclusion */

/*************************** End of file ****************************/

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -