📄 ridxio.h
字号:
/* *---------------------------------------------------------------------- * T-Kernel / Standard Extension * * Copyright (C) 2006 by Ken Sakamura. All rights reserved. * T-Kernel / Standard Extension is distributed * under the T-License for T-Kernel / Standard Extension. *---------------------------------------------------------------------- * * Version: 1.00.00 * Released by T-Engine Forum(http://www.t-engine.org) at 2006/8/11. * *---------------------------------------------------------------------- *//* * ridxio.h (file) * * File management * Input/Output of the record index. */#ifndef _FM_RIDXIO_H_#define _FM_RIDXIO_H_#include "fsinfo.h"/* * Record I/O information */typedef struct RIdx { IdxAdr adr; /* Location of the current record index. */ UW lblk; /* Logical block being mapped. */ DfRecordIndex *mapbase; /* Map address of the logical block */ DfRecordIndex *mapadr; /* Map address of the location of adr */ W cp; /* Location of data block read */ OFCB *ofcb; /* Target file */ ID mid; /* Map ID */ UW mflag; /* Map state flag (Initial state MD_RDONLY) */ ER err;} RIdx;/* * Start position of the indirect index/record index */#define TopRIdxLv0(ofcb) ((W)(ofcb)->ridxofs / sizeof(DfRecordIndex))#define TopIIdxLv0(ofcb) ((W)(ofcb)->ridxofs / sizeof(DfIndirectIndex))#define TopRIdx(idxlv, ofcb) (( (idxlv) == 0 )? TopRIdxLv0(ofcb): 0)#define TopIIdx(idxlv, ofcb) (( (idxlv) == 0 )? TopIIdxLv0(ofcb): 0)/* * First disk address of the indirect index/record index in the file header * */Inline DskAdr FHeadIdxDAdr( OFCB *ofcb ){ DskAdr dadr; dadr.lblk = ofcb->fhead.lblk; dadr.offset = (VP)((VB*)ofcb->fhead.offset + ofcb->ridxofs); return dadr;}/* * Set the map state flag. * When writing is made to the data mapped by ri, * the flag must be updated with fmpSetRIdxMapFlag(ri, MD_WRITE). */Inline void fmpSetRIdxMapFlag( RIdx *ri, UW mflag ){ ri->mflag = mflag;}/* * Obtain the location of the current record index. */Inline IdxAdr fmpGetIdxAdr( RIdx *ri ){ IdxAdr idxadr = ri->adr; idxadr.ridx.offset = (VP)((VB*)idxadr.ridx.offset - sizeof(DfRecordIndex)); return idxadr;}/* * Obtain the map address of the current record index. */Inline DfRecordIndex* fmpGetMapAdr( RIdx *ri, W *cp ){ *cp = ri->cp - 1; return ri->mapadr - 1;}#define fmpGetRIdxError(ri) ( (ri)->err )#define fmpGetMapBlkRIdx(ri) ( (ri)->lblk )/* * Special specification of idxadr of fmpOpenRIdx */#define FIRST_RIdx ( (IdxAdr*)0 ) /* First record index */#define LAST_RIdx ( (IdxAdr*)(-1) ) /* Last record index */IMPORT ER fmpOpenRIdx( RIdx *ri, IdxAdr *idxadr, OFCB *ofcb );IMPORT ER fmpCloseRIdx( RIdx *ri );IMPORT ER fmpSeekRIdx( RIdx *ri, IdxAdr *idxadr );IMPORT DfRecordIndex* fmpGetRIdx( RIdx *ri );IMPORT DfRecordIndex* fmpGetRecordRIdx( RIdx *ri );IMPORT ER fmpGetDataBlkAdr( RIdx *ri, LogBlk *lblk );IMPORT ER fmpFindLastDataBlkAdr( RIdx *ri, LogBlk *lblk );IMPORT DfRecordIndex* fmpAppendRIdx( RIdx *ri, RCB *rcb );IMPORT DfRecordIndex* fmpInsertRIdx( RIdx *ri, RCB *rcb );IMPORT ER fmpSetRIdx( RIdx *ri, W rtype, UH stype, LINK *lnk );IMPORT ER fmpDeleteRIdx( RIdx *ri );IMPORT ER fmpDeleteDataBlk( RIdx *ri, W top, W end, BOOL topf );#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -