📄 fs82voldata.c
字号:
do { *p_Dst = *p_Srce; p_Dst--; p_Srce--; } while ( -- vl_Size > 0 ); } /* Insert on index found and buffer shifted exit loop */ break; } /* Point on next entry in table */ pl_VolumePtr++; } /* Place pointer on volume in table */ * pl_VolumePtr = pp_Vol; /* Increment number of volumes mounted */ s_VolDataBaseStruct.v_NbrVolMounted++; /* Updates beginning index */ s_VolDataBaseStruct.v_BeginningIndex = Fs05_01DetermineDichoBeginIndex (s_VolDataBaseStruct.v_NbrVolMounted); }}/**//*P(***************************************************************************//* Procedure name : Fs82_04VDDeleteVolume *//* Object : Delete a volume from volume data *//*----------------------------------------------------------------------------*//* Input parameters : *//* ------------------- *//* t_fsVolStruct * pp_Vol : pointer on volume's control block *//* *//* *//* Output parameters : *//* ------------------- *//* *//* Used variables : *//* ------------------- *//* *//* *//* Used procedures : *//* ------------------- *//* *//* *//*----------------------------------------------------------------------------*//*----------------------------------------------------------------------------*//* DESCRIPTION *//* *//* Deletes the volume from volume data, for this: *//* - releases name of volume *//* - releases volume CB *//* - suppress volume in volume table index in alphabetical order *//* - suppress volume in table indexed in volume ID order *//* *//* WARNING: File and Dir structures attached to the volume are not *//* released, this is to make before calling *//* of this procedure *//* *//*----------------------------------------------------------------------------*//***************************************************************************)P*//* #*/#undef PROCEDURE_NUMBER #define PROCEDURE_NUMBER 4void Fs82_04VDDeleteVolume( u16 vp_VolID, t_fsVolStruct * pp_Vol ){ u16 vl_IndexInTable; /* Suppress volume in volume table index in alphabetical order */ { /* Load address of table who is indexed by volume ID */ t_fsVolStruct ** pl_VolumePtr = s_VolDataBaseStruct.p_VolTabIndexedByAlpha; u16 vl_NbrVolMounted = s_VolDataBaseStruct.v_NbrVolMounted; /* Search position in table */ for ( vl_IndexInTable = 0 ; vl_IndexInTable < vl_NbrVolMounted; vl_IndexInTable++) { if ( *pl_VolumePtr == pp_Vol ) { /* If it is not the last table entry, end of table is to shift */ if ( vl_IndexInTable != vl_NbrVolMounted - 1 ) { /* End of table is to shift */ memcpy( pl_VolumePtr+1, pl_VolumePtr, (vl_NbrVolMounted - vl_IndexInTable - 1) * sizeof (t_fsVolStruct **)); } break; } /* point on next entry in table */ pl_VolumePtr++; } } /* Free this volume ID in table indexed by volume ID */ { /* Load address of table who is indexed by volume ID */ t_fsVolStruct ** pl_VolumePtr = s_VolDataBaseStruct.p_VolTabIndexedByVolID; /* Free this ID in table */ pl_VolumePtr[vp_VolID] = (t_fsVolStruct *) FS_VD_FREE; } /* release name of volume */ MC_FS_FREE_MEMORY(pp_Vol->p_VolName); /* Release volume structure */ MC_FS_FREE_MEMORY(pp_Vol); /* Decrement number of volumes mounted */ s_VolDataBaseStruct.v_NbrVolMounted--; /* Updates beginning index */ s_VolDataBaseStruct.v_BeginningIndex = Fs05_01DetermineDichoBeginIndex (s_VolDataBaseStruct.v_NbrVolMounted);}/**//*P(***************************************************************************//* Procedure name : Fs82_05VDSearchVolByName *//* Object : Search a volume by its name *//*----------------------------------------------------------------------------*//* Input parameters : *//* ------------------- *//* char * pp_VolName : Volume Name *//* *//* *//* Output parameters : *//* ------------------- *//* t_fsVolStruct * : Pointer on the volume's structure *//* *//* Used variables : *//* ------------------- *//* *//* *//* Used procedures : *//* ------------------- *//* *//* *//*----------------------------------------------------------------------------*//*----------------------------------------------------------------------------*//* DESCRIPTION *//* *//* The volume is searched by its name via alphabetical order table *//* if volume name unknow return pointer is null *//* *//*----------------------------------------------------------------------------*//***************************************************************************)P*//* #*/#undef PROCEDURE_NUMBER #define PROCEDURE_NUMBER 5t_fsVolStruct * Fs82_05VDSearchVolByName( char * pp_VolName, u8 vp_MaxNameSize ){ /* Load address of table who is indexed by volume ID */ t_fsVolStruct ** pl_VolumePtr = s_VolDataBaseStruct.p_VolTabIndexedByAlpha; u16 vl_NbrVol, vl_Index, vl_RestIndex; s32 vl_Resu; vl_NbrVol = s_VolDataBaseStruct.v_NbrVolMounted; if ( vl_NbrVol != 0 ) { vl_Index = vl_RestIndex = s_VolDataBaseStruct.v_BeginningIndex; /* Search dichotomeus in table */ do { vl_RestIndex = vl_RestIndex >> 1; if ( vl_Index < vl_NbrVol ) { vl_Resu = strncmp( pl_VolumePtr[vl_Index]->p_VolName, pp_VolName, vp_MaxNameSize ); if ( vl_Resu == 0 ) { /* First part of string are equal, is string in table not longer than searched string */ if ( *(pl_VolumePtr[vl_Index]->p_VolName + pl_VolumePtr[vl_Index]->v_VolNameLength) == '\0' ) /* Yes than strings are equal -> found */ return ( pl_VolumePtr[vl_Index] ); /* String is longer point back in buffer */ else vl_Index = vl_Index - vl_RestIndex ; } else if ( vl_Resu < 0 ) vl_Index = vl_Index + vl_RestIndex ; else vl_Index = vl_Index - vl_RestIndex ; } else { vl_Index = vl_Index - vl_RestIndex ; } } while ( vl_RestIndex != 0 ); } /* Like index 0 was not scanned verify it */ vl_Resu = strncmp( pl_VolumePtr[0]->p_VolName, pp_VolName, vp_MaxNameSize ); if ( vl_Resu == 0 ) { /* First part of string are equal, is string in table not longer than searched string */ if ( *(pl_VolumePtr[0]->p_VolName + pl_VolumePtr[0]->v_VolNameLength) == '\0' ) /* Yes than strings are equal -> found */ return ( pl_VolumePtr[0] ); } /* Volume not found return NULL */ return(NIL);}/**//*P(***************************************************************************//* Procedure name : Fs82_06VDInsertFileInVol *//* Object : Insert a new file in volume's opened files *//*----------------------------------------------------------------------------*//* Input parameters : *//* ------------------- *//* t_fsVolStruct * pp_Vol : pointer on volume's control block *//* t_fsFILE * pp_File : Pointer on file structure *//* *//* *//* Output parameters : *//* ------------------- *//* *//* Used variables : *//* ------------------- *//* */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -