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

📄 fs05common.c

📁 我今天开始上传5份TI、NXP、MTK的手机开发全套资料。希望对大家有很大的帮助
💻 C
字号:
#ifdef FSS_FTR#define ACCESS_RIGHTS_INTERNAL_FS#define FS05COMMON_C#include "Fs.h"#undef  FILE_NUMBER#define FILE_NUMBER 5 /**//*P(***************************************************************************//* Procedure name : Fs05_01DetermineDichoBeginIndex                           *//* Object :    Determine the beginning index for a dychotomeus search	      *//*----------------------------------------------------------------------------*//* Input parameters  :                                                        *//* -------------------                                                        *//*    u32  vp_MaxEntries : Number of values in search table		      *//*                                                                            *//* Output parameters :                                                        *//* -------------------                                                        *//*   returned value:  u32  Beginning index                                    *//*									      *//* Used variables    :                                                        *//* -------------------                                                        *//*   							                      *//*                                                                            *//* Used procedures   :                                                        *//* -------------------                                                        *//*                                                                            *//*                                                                            *//*----------------------------------------------------------------------------*//*----------------------------------------------------------------------------*//*                                    DESCRIPTION                             *//*                                                                            *//* Determine the beginning index for a dychotomeus search		      *//*									      *//*----------------------------------------------------------------------------*//***************************************************************************)P*//* #*/#undef PROCEDURE_NUMBER #define PROCEDURE_NUMBER 1u32 Fs05_01DetermineDichoBeginIndex(u32 vp_MaxEntries){    u32 vl_BeginningIndex = 1;        if (vp_MaxEntries == 0 ) return (0);    while (  vl_BeginningIndex < vp_MaxEntries )	 vl_BeginningIndex = vl_BeginningIndex << 1;    return ( vl_BeginningIndex >> 1 );}/**//*P(***************************************************************************//* Procedure name : Fs05_02DetermineDichoBeginIndex                           *//* Object :    Determines the volume of a path				      *//*----------------------------------------------------------------------------*//* Input parameters  :                                                        *//* -------------------                                                        *//*    t_fsEntityStruct * pp_FsEntityPtr : Pointer on current entity's CB      *//*    char * pp_Path :	Path of the object				      *//*    char ** pp_RestOfPath : 	Pointer on the rest of the path to scann      *//*				by lower layer if *pp_RestOfPath is nul the   *//*				rest of path is empty			      *//*    u32 * pp_VolMgtID : Pointer on volume manager ID to update	      */ /*    u16 * pp_Status :	Pointer on status to uypdate if error		      *//*                                                                            *//* Output parameters :                                                        *//* -------------------                                                        *//*   returned value:  t_fsVolStruct *  Pointer on volume's structure	      *//*			NULL if error                                         *//*									      *//* Used variables    :                                                        *//* -------------------                                                        *//*   							                      *//*                                                                            *//* Used procedures   :                                                        *//* -------------------                                                        *//*                                                                            *//*                                                                            *//*----------------------------------------------------------------------------*//*----------------------------------------------------------------------------*//*                                    DESCRIPTION                             *//*                                                                            *//*    Search in the input path the volume name and identify it		      *//*									      *//*----------------------------------------------------------------------------*//***************************************************************************)P*//* #*/#undef PROCEDURE_NUMBER #define PROCEDURE_NUMBER 2t_fsVolStruct * Fs05_02GiveVolumeFromPath( t_fsEntityStruct * pp_FsEntityPtr, char * pp_Path,						 char ** pp_RestOfPath, t_ObjectInfo *pp_Info, 						  s32 * pp_Status ){  t_fsVolStruct * pl_Volume;  char * pl_NextSlatch;  u32 vl_VolNameSize;    /* We suppose dir or obj do not exist so set flags to false */    pp_Info->s_FileStatus.v_ObjExist = FALSE;    pp_Info->s_FileStatus.v_DirExist = FALSE;    /* If the path begin with a '/' character the volume has to be searched else		the entity structure has to contain this information */    if (  *pp_Path == '/' )    {	/* Search size of volume name until next '/'  or '\0' character */	pl_NextSlatch = strchr( pp_Path + 1, '/');	if ( pl_NextSlatch != NIL ) vl_VolNameSize = ((u32) (pl_NextSlatch - pp_Path )) - 1;	else /* No slatch found we suppose end of string after volume name */	{	    /* Determine lenght of name */	    vl_VolNameSize = strlen(pp_Path+1);		}	/* If  no string return 0 */	if ( vl_VolNameSize == 0 )	{ 	    /* Update status */	    *pp_Status = FS_ENOENT;	    /* Return 0 ( no volume name found ) */	    pl_Volume = NIL;	    * pp_RestOfPath = NIL;	}  	else 	{	    /* Updates Rest of path and VolMngtID ( if no rest in the path clear pointer ) */	    /* Point just after volume name */	    * pp_RestOfPath = pp_Path + vl_VolNameSize + 1;	    /* If end of path clear rest of path pointer */	    if ( **pp_RestOfPath == '\0' ) * pp_RestOfPath = NIL;	    /* Else point after '/' */	    else (*pp_RestOfPath)++;	    /* Determine volume */	    pl_Volume = MC_FS_VD_SEARCH_VOL_BY_NAME( pp_Path+1, vl_VolNameSize);	    /* If not found set status to unknow volume */	    if ( pl_Volume == NIL ) *pp_Status = FS_ENXIO;	}    }    else /* Entity must contain the information */    {       t_EntityPathInfo sl_PathInfo;	/* The rest of path is the input path pointer */	*pp_RestOfPath = pp_Path;	if ( *pp_Path == '\0' ) * pp_RestOfPath = NIL;	else *pp_RestOfPath = pp_Path;	/* Call entity's management to have information about current working directory */        MC_FS_ED_GET_CWD_INFO( pp_FsEntityPtr, &sl_PathInfo );	/* If the path is not valid the directory was removed return an error */	if ( sl_PathInfo.v_CurrPathValid == FALSE )	{	    *pp_Status = FS_ERR_STALE_CURR_DIR;	    return (NIL);	} 	/* Update Information structure */	if ( sl_PathInfo.v_DirLevelNExist)	{             pp_Info->s_FileStatus.v_ObjExist = TRUE;	    pp_Info->v_ObjID = sl_PathInfo.v_CurrentDirIDLevelN;	    pp_Info->s_FileStatus.v_ObjIsFile = FALSE;	}	if ( sl_PathInfo.v_DirLevelN_1Exist)	{             pp_Info->s_FileStatus.v_DirExist = TRUE;	    pp_Info->v_DirID = sl_PathInfo.v_CurrentDirIDLevelN_1;	}	/* Update pointer on volume */	pl_Volume = sl_PathInfo.p_CurrVolume;	/* If no current directory set error */	if ( pl_Volume == NIL ) *pp_Status = FS_ENOENT;	    }    /* Return pointer on volume structure */    return (pl_Volume);}/**//*P(***************************************************************************//* Procedure name : Fs05_03CheckFileAlreadyOpenMode                           *//* Object :    Checks the open mode of all streams opened on the same file    *//*----------------------------------------------------------------------------*//* Input parameters  :                                                        *//* -------------------                                                        *//*    t_fsVolStruct * pp_Volume: Pointer on volume structure containing       *//*					the file			      *//*    t_ObjectInfo * sp_Info : Information about file			      *//*    t_FileMode * sp_AlreadyOpenMode : Mode of open    		      *//*                                                                            *//* Output parameters :                                                        *//* -------------------                                                        *//*   none:  								      *//*									      *//* Used variables    :                                                        *//* -------------------                                                        *//*   							                      *//*                                                                            *//* Used procedures   :                                                        *//* -------------------                                                        *//*                                                                            *//*                                                                            *//*----------------------------------------------------------------------------*//*----------------------------------------------------------------------------*//*                                    DESCRIPTION                             *//*                                                                            *//*    Scann all files of the volume to verify if the current file is already  *//*	 open, and then determines the cumulate open modes	 	      *//*									      *//*----------------------------------------------------------------------------*//***************************************************************************)P*//* #*/#undef PROCEDURE_NUMBER #define PROCEDURE_NUMBER 3void Fs05_03CheckFileAlreadyOpenMode ( t_fsVolStruct * pp_Volume, t_ObjectInfo * sp_Info ,					 t_FileMode * sp_AlreadyOpenMode ){  t_fsFILE * pl_Stream = MC_FS_VD_GET_FIRST_FILE( pp_Volume );  u32 vl_FileID = sp_Info->v_ObjID;    /* Search in all files open for the volume files with the same ID and cumulate		file mode */    while ( pl_Stream != NIL )    {	/* Is it the same file? */	if ( pl_Stream->v_FileID == vl_FileID )                *(( u32 *) (sp_AlreadyOpenMode)) |= *((u32*)(&pl_Stream->s_OpenMode));	/* get next file of volume */	pl_Stream = MC_FS_VD_GET_NEXT_FILE( pl_Stream );    }}#undef PROCEDURE_NUMBER #define PROCEDURE_NUMBER 4void Fs05_04VerifyIfIsFileOfEntity( void * pp_Param, t_fssFILE * pp_Stream ){    /* Verify file pattern OK */    if ( pp_Stream->v_Pattern != FS_FILE_PATTERN )    { 	MC_FS_STATUS(pp_Param) = FS_EBADF;	return;    }    /* Verify if the entity which uses the file pointer is the same that which opened 		the file */    if ( MC_FS_KERNEL_ID(pp_Param) != MC_FS_ED_GET_KERNEL_ID( ((t_fsEntityStruct *)pp_Stream->p_Entity) ))			MC_FS_STATUS(pp_Param) = FS_EBADF;}    /* Verify if token acceptable ( size and characters ) */#undef PROCEDURE_NUMBER #define PROCEDURE_NUMBER 5void Fs05_05VerifyToken( ascii * pp_Token, u16 vp_SizeOfToken, u16 vp_MaxTokenSize, s32 * pp_Status ){    register u32   vl_Index;    register ascii vl_Char;      /* Verify size of token */    if ( vp_SizeOfToken > vp_MaxTokenSize )    {	* pp_Status = FS_ENAMETOOLONG;	return;    }    /* verify characters in token */    for ( vl_Index = 0 ; vl_Index <  vp_SizeOfToken; vl_Index++)    {  	vl_Char = * (pp_Token + vl_Index);		/* Is character in { [A-Z],[a-z],[0-9], . - _ } */	if ( ! (  ( ( vl_Char >= 'A' ) && ( vl_Char <= 'Z' ) )				||	       	  ( ( vl_Char >= 'a' ) && ( vl_Char <= 'z' ) )				||	       	  ( ( vl_Char >= '0' ) && ( vl_Char <= '9' ) ) 				||	       		( vl_Char == '.' )				||	 		( vl_Char == '-' )				|| 			( vl_Char == '_' )	       )	   ) 	{	    * pp_Status = FS_EINVAL;	    return;	}    }   }#undef PROCEDURE_NUMBER #define PROCEDURE_NUMBER 6void Fs05_06VerifyIfIsDirOfEntity( void * pp_Param, t_fssDIR * pp_Dir ){    /* Verify file pattern OK */    if ( pp_Dir->v_Pattern != FS_DIR_PATTERN )    { 	MC_FS_STATUS(pp_Param) = FS_EBADF;	return;    }    /* Verify if the entity which uses the file pointer is the same that which opened 		the file */    if ( MC_FS_KERNEL_ID(pp_Param) != MC_FS_ED_GET_KERNEL_ID( ((t_fsEntityStruct *)pp_Dir->p_Entity) ))			MC_FS_STATUS(pp_Param) = FS_EBADF;}bool Fs05_07VerifyIfDirOpen ( t_fsVolStruct * pp_Volume, u32 v_DirID ){   /* Point on first directory of volume */   t_fsDIR * pl_Dir = MC_FS_VD_GET_FIRST_DIR( pp_Volume );    /* Search in all open directories of volume */    while ( pl_Dir != NIL )    {	/* If ID identical return true */	if ( pl_Dir->v_DirID == v_DirID) return(TRUE);   	/* else point on next opened directory */	pl_Dir = MC_FS_VD_GET_NEXT_DIR( pl_Dir );    }    /* Not found return false */    return(FALSE);}/* + LMSqa19443 PATCH JMS 04082004 */void Fs05_08SearchObjNameByAddressInDir(u32 vp_AddressOfFile, ascii* pp_ObjName){  vp_AddressOfFile = vp_AddressOfFile - FILE_HEADER_SIZE;  mFm80_12SearchObjNameByIdInDir(MC_FVM_GET_FILE_NUMBER(vp_AddressOfFile),pp_ObjName); } /* - LMSqa19443 PATCH JMS 04082004 */ #endif /* FSS_FTR */  

⌨️ 快捷键说明

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