📄 davgnxob.c
字号:
/*### Include Files
#########################*/
#include "dav.h"
#if (DIRECT_ACCESS_VOLUME == TRUE)
/*### Local Declarations
#########################*/
HDR_SearchInfo FDI_SearchInfo;
HDR_Header FDI_SearchHeader;
/*### Global Declarations
#########################*/
/*### Local Functions
#########################*/
/*### Global Functions
#########################*/
/*#################################################################
### FDI_GetObjectHeader
###
### DESCRIPTION:
### This function will return information about the next object
### in the header table, calculate the address of the object and
### keep track of the search state using the obj_info_ptr.
### The FDI_ObjectInfoPtr must contain a name and/or
### type depending on the desired method of search.
### The name and/or type will be used to determine the starting
### point of the search. Once the start point is found then the
### next object that matches (see method below) will be returned
### in the FDI_ObjectInfoPtr. The restart parameter is used to
### start from the first object in the header table.
###
### Information such as the object address, alignment, size in
### bytes, and security key are returned only if an object is
### found. If the object is not found, then the values will
### not be valid and will contain zeroes.
###
### PARAMETERS:
### obj_info_ptr -
### IN: The name and type fields of the structure are used to
### determine the search starting point when restart is
### false. The name and/or type is also used to qualify
### the search. See method for more info.
###
### OUT: All of the header information is translated to the
### equivalent values in the structure.
###
### method - return the next object with the following
### qualities:
###
### SearchByNextObject - the next object in the header table.
### SearchByType - the next object with the specified
### type.
### SearchByName - the next object with the specified
### name.
### SearchByNameType - the next object with the specified
### name & type.
###
### restart - TRUE - Start search from the beginning of the
### header table including the first object.
### FALSE - Start search from the name & type
### specified in the info_struct.
###
### RETURNS:
### When this function passes with no errors a value of 0 is
### returned otherwise, it returns a status of type ERR_CODE.
###
### ERR_NONE - Entry was found and the obj_info_ptr contains
### valid header information.
###
### ERR_NO_MORE_ENTRIES - The entry was not found after searching
### the entire header table.
###
*/
ERR_CODE FDI_GetObjectHeader(FDI_ObjectInfoPtr obj_info_ptr,
FDI_SearchMethod method,
BOOLEAN restart)
{
UINT32 ii;
ERR_CODE status;
HDR_SearchMethod search_method;
HDR_CompareInfo compare_info;
BOOLEAN reclaim_lock = FALSE;
static FDI_Handle prev_hdr_addr;
/* Do not check type if search method is next object */
if((method != SearchByNextObject) && (method != SearchByName))
{
if( obj_info_ptr->ObjectType < MIN_DAV_TYPE )
{
return ERR_PARAM;
}
}
FDI_APILock();
/* set Alignment and RecoveryLevel to the default values. If there are any input
values for these fields, they are ignored */
obj_info_ptr->Alignment = FDI_ALIGN_Page;
obj_info_ptr->RecoveryLevel = FDI_PLR_Level0;
switch (method)
{
case SearchByNextObject:
search_method = HDR_ByNextValidObject;
break;
case SearchByType:
search_method = HDR_ByValidType;
break;
case SearchByName:
search_method = HDR_ByName;
break;
case SearchByNameType:
search_method = HDR_ByNameType;
break;
default:
FDI_APIUnlock();
return ERR_NOTEXISTS;
}
if (restart)
{
HDR_InitSearchInfo((&FDI_SearchInfo), (&FDI_SearchHeader));
prev_hdr_addr = 0;
}
else
{
FDI_SearchInfo.CurrObj.HeaderAddress = prev_hdr_addr;
}
/* Setup compare info for the search engine and locate */
/* the next object. */
compare_info.NamePtr = (HDR_NamePtr)obj_info_ptr->Name;
compare_info.NameSize = obj_info_ptr->NameSize;
compare_info.CompareValue = obj_info_ptr->ObjectType;
for (;;)
{
status = GetNextHeader(&FDI_SearchInfo, search_method, &compare_info, restart);
if (!status)
{
/* Make sure that the interface cannot see any system objects. */
if (FDI_SearchInfo.HeaderPtr->ObjectType > FDI_HT_EndReservedTypes)
{
break;
}
}
else
{
break;
}
}
if (!status)
{
/* Need to read full headers for the following */
/* types (Not done in GetNextHeader). */
/*switch (search_method) */
/* Need to switch on method, not search_method */
switch (method)
{
case SearchByType:
case SearchByNextObject:
/* Need to read full header for this type of search */
status = HDR_ReadFullHeader(FDI_SearchInfo.CurrObj.HeaderAddress,
FDI_SearchInfo.HeaderPtr, restart);
if(status)
{
FDI_APIUnlock();
return status;
}
break;
case SearchByName:
case SearchByNameType:
default:
{};
}
/* Found the object, now translate the object information to */
/* the interface function equivalent. */
HDR_SearchInfo2ObjectInfo(obj_info_ptr, &FDI_SearchInfo);
prev_hdr_addr = FDI_SearchInfo.CurrObj.HeaderAddress;
if (reclaim_lock)
{
}
}
else
{
/* Clear entries when an object is not found or an error occurs. */
for (ii = 0; ii < FDI_MaxNameLength; ii++)
{
obj_info_ptr->Name[ii] = 0;
}
obj_info_ptr->NameSize = 0;
obj_info_ptr->ObjectType = 0;
obj_info_ptr->ObjectAddress = 0;
obj_info_ptr->ObjectSize = 0;
obj_info_ptr->Alignment = 0;
obj_info_ptr->SecurityKey = 0;
obj_info_ptr->PrivilegeLevel = 0;
obj_info_ptr->RecoveryLevel = 0;
/* Add ability to detect WIP vs. Valid object
*/
obj_info_ptr->WriteStatus = FDI_WriteStatusValid;
if (status == ERR_NO_MORE_ENTRIES)
{
status = ERR_NOTEXISTS;
}
prev_hdr_addr = 0;
}
FDI_APIUnlock();
return status;
}
#endif /* DIRECT_ACCESS_VOLUME */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -