亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? nfshash.c

?? vxworks的完整的源代碼
?? C
?? 第 1 頁 / 共 2 頁
字號:
/* nfsHash.c - file based hash table for file handle to file name and reverse *//* Copyright 1998 - 2001 Wind River Systems, Inc. */#include "copyright_wrs.h" /*modification history--------------------01b,19oct01,rae  merge from truestack ver 01g, base o1a (SPRs 62705, 35767)01a,15nov98,rjc  written*//*INTERNALDESCRIPTIONThe nfs server is required to maintain a mapping of file names to filehandles since the file handle is of limited size but nfs  requestsuse a file handle to id the file. This map is being implemented as a 2 way hash table so given a file name we can find out the correspondingfile handle and correspondingly get the file name given the file handle.The name to handle operation would typically be done infrequentlycompared to the handle to name op since the former corresponds to opening the file while the latter is needed for every nfs request. Therefore the hash table has been implememnted with a bias towardskeeping the latter operation more efficient.Conceptually the hash table is simple. Given a hash table entry wecompute the hash value for each of the 2 hashing functions and then plece the entry into two lists. While deleting we remove it from bothlists. However since we must keep this data structure on disk wemust avoid the typical in memory implementation as a linked list of entries. That's because it is inefficient to implement a fragmentation/compaction memory management system as is done in the case of thestandard malloc/free based implementation.Our design allocates the disk space in larger chunks (than may be neededto store a single entry) and uses a bit map to keep track of free blocks.The hash table is maintained in a dos file. The file offset is used asa pointer.Data structuresFile block bit map tableThis structure which is maintained in memory contains a bit per blockof the dos file. In order to locate a free block we simply scan this bit from the start until a free block is found. If none are found we wouldexpand the hash file by seeking beyond the existing end of the file and update the bit map block correspondingly. Freeing a block is done by turning off the bit. Currently we do not reduce the size of the fileas it would be extremely inefficient in general (in case free block is notat the end of the file. Free blocks at the end of the list could be returned to the file system by truncating the file.Contents of a hash table block. Each block contains a sequence of entries followed by a pointer to the next block in the list keyed by file handle. In other words all entriesin a block and the blocks after it, would have hashed to the same value,and we can locate a required entry given the file handle by examining theentries in a block and traversing the linked list of blocksContents of an entry -Each entry consists of a triple comprising a next entry pointer, thefile handle , and the file name. The next entry pointer points to the nextentry in the hash chain, keyed by file name. Unlike the file handle based chain these entries are not organized into blocks as doing so would require that we maintain a duplicate entry since in general entries which hash intoa block when keyed by file handle will not hash into the same block whenkeyed by file name. While maintaining duplicates will work around thisproblem we would end up doubling the storage requirements and increasingthe size of this file would increase search times anyway and most likelynegate most of the benefits of this organization.To use this feature, include the following component:INCLUDE_NETWRS_NFSHASHNOMANUAL*//* includes */#include "vxWorks.h"#include "unistd.h"#include "xdr_nfs.h"#include "string.h"#include "fcntl.h"#include "stdio.h"#include "stdlib.h"#include "memLib.h"#include "nfsdLib.h"#include "ctype.h"#include "sys/stat.h"#include "semLib.h"#include "memPartLib.h"/* defines */#define MAX_DEVS 10#define MAX_MNTS 20#define MAX_HASH_BLKS  10000#define HASH_BKT_SZ   (1 * 1024)#define CHAR_BIT_LEN    8#define INT_BIT_LEN     (sizeof (int) * CHAR_BIT_LEN)#define BAD_OFFSET      ((off_t)(~0x0))#define FH_HASH_TBL_LEN      512#define NAME_HASH_TBL_LEN    512#define MIN_ENTRY_SZ    (sizeof (HNDL_NAME))#define STR_INT_LEN(s)  ((strlen (s) + 1 + sizeof (int) - 1) / sizeof (int))#define STR_ALIGN_LEN(s) (((strlen (s) + 1 + sizeof (int) - 1) / sizeof (int)) \			   *  sizeof (int))#define HASH_BKT_HDR_SZ    (sizeof (off_t) + sizeof (int))#define ENTRY_HDR_SZ    (sizeof (HNDL_NAME) - sizeof(int))/* forward declaration */LOCAL int blkRead (int, off_t, char *, int);LOCAL int blkWrite (int, off_t, char *, int );/* typedefs *//* descriptor for a nfs hashtable */typedef struct tblDesc      {    int     allocBits [MAX_HASH_BLKS/INT_BIT_LEN + 1];  /* bits allocated */    int     numBlocks;                          /* number of blocks allocated */    int     fd;              /* file descriptor of file containing hash table*/    off_t   nameHash [NAME_HASH_TBL_LEN - 1];  /* hash by name table */    int     nextInode;        /* next inode number to allocate */    int     refCnt;           /* reference count */    SEM_ID  sem;              /* protection lock */    char    nmBuf [NFS_MAXPATHLEN];  /* file name for hash table */    }  TBL_DESC;/*  * nfs handle and name pairs are stored in this structure. This structure  * is contained within the hash buckets which are written to disk. These * structures will have overall length a multple of sizeof (int) so * that  the next field stays aligned on a word boundary when in * memory  */typedef struct hndlName    {    off_t        next;         /* next entry ptr */    off_t        prev;         /* prev entry ptr */    short        totalLen;     /* total length of entry */    short        nameLen;      /* length of name string, 0 for free netry */    int          fh;     /* file handlei/inode  */    char         name [sizeof (int)]; /* actual str length is upto max 					 pathname lwngth, this is just for 					 a minimum string. Entry length must 					 be a multiple of sizeof (int) for					 alignment */    }   HNDL_NAME;/*  * hash bucket contains a number of HNDL_NAME pairs along with free space */typedef struct hashBkt      {    off_t        next;       /* next bkt ptr */    int          freeSpace;  /* free space remaining in bucket */    char         entries [HASH_BKT_SZ - sizeof (off_t) - sizeof (int)];			  /* buffer for entries of type HNDL_NAME */    }  HASH_BKT;/*  * Mapping from a file system device id to corresponding hash table descriptor. * There is one hash table per file system device if there are nfs exported *  directories in that file system */typedef struct devIdPair    {    int         dev;    TBL_DESC *  pTbl;    } DEV_ID_PAIR  ;/*  * Mapping from the nfs volume mount id to the hash table descriptor. * The nfs volume id is generated in the nfsExport () routine and is * maintained within the nfs file handle. */typedef struct mntIdPair    {    int         mntId;    TBL_DESC *  pTbl;    } MNT_ID_PAIR;/* locals *//* device to hash table descriptor table */LOCAL DEV_ID_PAIR   devTbl[MAX_DEVS];/* mount volume  to hash table descriptor table */LOCAL MNT_ID_PAIR   mntTbl[MAX_MNTS];/******************************************************************************* * insertMntId - insert entry into mount id based table ** Inserts pointer <pTbl> to a hash file table descriptor in the mount id* based table for nfs mount point <mntId>** NOMANUAL** RETURNS: N/A.*/LOCAL void insertMntId     (    TBL_DESC *    pTbl,    int           mntId    )    {    MNT_ID_PAIR *   pMnt;    for (pMnt = mntTbl; pMnt < mntTbl + MAX_MNTS; ++pMnt)	{	if (pMnt->mntId == 0)	    {	    pMnt->mntId = mntId;	    pMnt->pTbl = pTbl;	    return ;	    }        }    }/******************************************************************************* * getTblEnt - get entry from mnt table ** Returns ptr to table descriptor for give mount id <id>.** RETURNS: ptr to entry or NULL*/LOCAL TBL_DESC *  tblDescGet     (    int   id   /* mount id */    )    {    int ix;    for (ix = 0; ix < MAX_MNTS; ++ix)	{	if (mntTbl[ix].mntId ==  id)	    return (mntTbl[ix].pTbl);        }    return (NULL);    }/******************************************************************************* * nfsHashTblInit - initialize a hash table ** Initialize a hash table given the corresponding descriptor <pTbl>* creating the hash file in dir <dirName>.** RETURNS: OK or ERROR*/LOCAL STATUS nfsHashTblInit    (    TBL_DESC *   pTbl,    char *       dirName    )    {    off_t *      pOff;    HASH_BKT     initBuf;    HNDL_NAME *  pEnt;    int          ix;    memset ((char*) pTbl->allocBits, 0, sizeof (pTbl->allocBits));    for (pOff = pTbl->nameHash; pOff < (pTbl->nameHash + NAME_HASH_TBL_LEN); 	 ++pOff)	{	*pOff = BAD_OFFSET;	}     sprintf  (pTbl->nmBuf, "%s/leofs", dirName);     if ((pTbl->fd = open (pTbl->nmBuf, O_CREAT | O_RDWR | O_TRUNC, 0777)) 	 == ERROR)	 {	 printf ("cannot create file %s\n", pTbl->nmBuf);	 return (ERROR);	 }     /* create the fh hash blocks in the file */     pTbl->numBlocks = FH_HASH_TBL_LEN;     initBuf.next = BAD_OFFSET;     initBuf.freeSpace = sizeof (initBuf) - sizeof (initBuf.next) - 			 sizeof (initBuf.freeSpace);     pEnt = (HNDL_NAME*)initBuf.entries;     pEnt->totalLen = initBuf.freeSpace;     pEnt->nameLen = 0;     for (ix = 0; ix < FH_HASH_TBL_LEN ; ++ix)	 {	 if (write (pTbl->fd, (char *)&initBuf, sizeof (initBuf)) 	     != sizeof (initBuf))	     {	     return (ERROR);	     }	 }     pTbl->refCnt = 0;     pTbl->nextInode = 0;     pTbl->sem = semBCreate (SEM_Q_PRIORITY, SEM_FULL);     if (pTbl->sem == NULL)	return (ERROR);     return (OK);     }/*******************************************************************************  * nfsHashTblSet - set up nfs hash table** Set up an nfs hash table for exported directory <pDir> with mount voleume id* <mntId> and file system device id <devId>. If a hash fiel already exists* for <devId> then we simply need to setup a ptr to the existing hash table* descriptor alse a new hash file must be allocated adn initialized.** RETURNS: N/A*/void nfsHashTblSet    (    char *   pDir,     /* directory name */    int      mntId,    /*mount id */    u_long   devId     /* device Id */    )    {    DEV_ID_PAIR *   pDev;    for (pDev = devTbl; pDev < devTbl + MAX_DEVS; ++pDev)	{	if (pDev->dev != 0 && pDev->dev == devId)	    break;	}    if (pDev >= devTbl + MAX_DEVS)	{        for (pDev = devTbl; pDev < devTbl + MAX_DEVS; ++pDev)	    {	    if (pDev->dev == 0)		{		pDev->dev = devId;		pDev->pTbl = KHEAP_ALLOC (sizeof (TBL_DESC));		if (nfsHashTblInit (pDev->pTbl, pDir) == ERROR)		    {		    printf ("cannot initialize nfs hash file\n");		    KHEAP_FREE((char *)pDev->pTbl);		    return;		    }		break;                }            }        }    pDev->pTbl->refCnt++;    insertMntId (pDev->pTbl, mntId);    }/*******************************************************************************  * nfsHashTblUnset - clean up  nfs hash table** Clean up an nfs hash table for exported directory <pDir> with mount volume id* <mntId> and file system device id <devId>. Delete the allocated table * descriptor if there are no other references to it. ** RETURNS: N/A*/void nfsHashTblUnset    (    char *   pDir,     /* directory name */    int      mntId    /*mount id */    )    {    DEV_ID_PAIR *   pDev;    MNT_ID_PAIR *   pMnt;    TBL_DESC *      pTbl;    for (pMnt = mntTbl; pMnt < mntTbl + MAX_MNTS; ++pMnt)	{	if (pMnt->mntId  == mntId)	    break;	}    if (pMnt >= mntTbl + MAX_MNTS)	{	return;	}    else	{	pTbl = pMnt->pTbl;	pMnt->mntId = 0;	pMnt->pTbl -= 0;	pTbl->refCnt--;	if (pTbl->refCnt == 0)	    {	    close (pTbl->fd);	    unlink (pTbl->nmBuf);	    semDelete (pTbl->sem);	    for (pDev = devTbl; pDev < devTbl + MAX_DEVS; ++pDev)		{		if (pDev->pTbl == pTbl)		    {		    KHEAP_FREE (pTbl);		    pDev->pTbl = 0;		    pDev->dev = 0;		    }	         }             }         }    }/*******************************************************************************  * blockAlloc - allocates block from the file to be used as a hash bucket ** The length of the file being used is incremented by HASH_BKT_SZ* and the bit map updated to reflect that. The bit corresponding to* the allocated block is turned off marking the block as being in use,* so in case caller does not actually use the block he shuld free the block* with blockFree below** RETURNS: file offset of allocated block else BAD_OFFSET* NOMANUAL*/LOCAL off_t blockAlloc    (    TBL_DESC *     pTbl    )    {    int *  pBits = pTbl->allocBits;    int *  pMax = pTbl->allocBits + 		  ((pTbl->numBlocks + INT_BIT_LEN -1) / sizeof (int));  		  /* 1 beyond last word */    char *  pIx;    int     bitPos; /* bit position of allocated block */    int     ix;    if (pTbl->numBlocks >= MAX_HASH_BLKS)	{	return (BAD_OFFSET);	}    for ( ; *pBits == 0 && pBits < pMax ; ++pBits)	{}    if (pBits == pMax)	{        /* allocate a new block in the file at the end */

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
精品国产sm最大网站免费看 | 成人av在线资源| 亚洲乱码国产乱码精品精98午夜 | 久久精品在这里| 欧美亚洲综合在线| 成人午夜电影小说| 秋霞电影一区二区| 亚洲精品第一国产综合野| 久久综合久久鬼色中文字| 欧美群妇大交群中文字幕| 99久久国产综合精品麻豆| 国产乱码精品一品二品| 丝袜国产日韩另类美女| 一区二区不卡在线视频 午夜欧美不卡在 | 日本一区二区三区久久久久久久久不 | 99久久婷婷国产精品综合| 看电影不卡的网站| 亚洲超碰精品一区二区| 亚洲美女电影在线| 中文字幕一区免费在线观看| 久久久久久久综合狠狠综合| 日韩欧美亚洲一区二区| 欧美日韩美少妇| 欧美日韩一级二级三级| 色拍拍在线精品视频8848| av影院午夜一区| 成人精品国产福利| 国产99久久久国产精品潘金| 国内久久精品视频| 久久97超碰国产精品超碰| 琪琪久久久久日韩精品| 日本欧美在线看| 日韩电影在线观看一区| 日韩精品电影一区亚洲| 亚洲高清视频在线| 亚洲图片自拍偷拍| 亚洲成国产人片在线观看| 亚洲国产美女搞黄色| 亚洲一区二区综合| 一区二区三区视频在线观看| 一区二区三区四区在线免费观看| 最新国产成人在线观看| 亚洲天堂av老司机| 一区二区三区四区高清精品免费观看 | 国产91在线|亚洲| 高清av一区二区| 国产乱码精品一区二区三区忘忧草 | 石原莉奈在线亚洲二区| 日韩精品91亚洲二区在线观看| 丝袜美腿亚洲综合| 久久99精品视频| 国产99精品国产| av电影一区二区| 欧美在线不卡视频| 91麻豆精品国产91久久久更新时间| 欧美一级午夜免费电影| 久久影音资源网| 中文字幕一区免费在线观看| 亚洲欧美激情插| 亚洲综合色丁香婷婷六月图片| 午夜精品一区二区三区电影天堂 | 亚洲成人av一区二区三区| 91麻豆免费看片| 色婷婷综合久久| 欧美一区二区在线看| 26uuu精品一区二区三区四区在线| 国产日韩欧美高清在线| 亚洲精品高清在线| 免费视频最近日韩| 丁香婷婷综合五月| 欧美午夜一区二区| 久久久久久免费网| 亚洲精品大片www| 免费看精品久久片| 成人午夜碰碰视频| 欧美狂野另类xxxxoooo| 久久久99精品久久| 亚洲成av人片一区二区| 国产乱淫av一区二区三区| 在线观看免费亚洲| 久久久www成人免费毛片麻豆| 亚洲激情图片一区| 国产麻豆精品在线| 在线观看视频一区二区欧美日韩| 日韩午夜三级在线| 亚洲日本在线天堂| 国产一区二区三区最好精华液| 一道本成人在线| 精品久久久久一区| 亚洲成人手机在线| 成人免费看黄yyy456| 欧美一级生活片| 一区二区三区在线免费视频| 国产精品一色哟哟哟| 欧美日韩在线不卡| 中文一区在线播放| 蜜桃久久精品一区二区| 91网站在线播放| 久久精品一区二区三区不卡牛牛| 亚洲a一区二区| av资源网一区| 久久免费午夜影院| 美腿丝袜一区二区三区| 在线观看成人小视频| 欧美国产综合一区二区| 美国一区二区三区在线播放| 欧美影视一区在线| 中文字幕五月欧美| 国产精品88888| 精品国精品国产| 午夜免费欧美电影| 欧美性感一区二区三区| 日韩美女精品在线| 波多野结衣的一区二区三区| 欧美xxx久久| 美女视频网站久久| 欧美精品三级在线观看| 亚洲综合色自拍一区| 99精品久久只有精品| 欧美韩国日本不卡| 国产精品1区2区3区在线观看| 日韩亚洲欧美成人一区| 日韩成人午夜电影| 欧美体内she精高潮| 一区二区三区在线视频免费观看| hitomi一区二区三区精品| 国产欧美一区二区精品性色| 国产裸体歌舞团一区二区| 精品剧情v国产在线观看在线| 亚洲成人激情自拍| 欧美老女人第四色| 视频在线观看一区二区三区| 7777精品伊人久久久大香线蕉超级流畅 | 亚洲免费资源在线播放| 国产成人精品三级| 国产色91在线| 成人av在线播放网站| 中文字幕色av一区二区三区| 成人成人成人在线视频| 国产精品国产三级国产aⅴ原创| 成人免费视频视频在线观看免费| 久久久99久久| 99国内精品久久| 亚洲男人的天堂在线aⅴ视频| 在线观看不卡视频| 亚洲国产精品久久人人爱| 欧美日韩电影在线播放| 亚洲一区国产视频| 日韩一区二区不卡| 国产一区二区三区在线观看免费视频| 26uuu亚洲| 成人小视频在线| 一区二区三区视频在线观看| 8x8x8国产精品| 国产一区二区主播在线| 中文字幕亚洲区| 在线免费不卡电影| 青青草91视频| 欧美国产激情一区二区三区蜜月| 99久久精品国产毛片| 亚洲一区二区三区自拍| 日韩一卡二卡三卡四卡| 国产精品一卡二卡在线观看| 综合久久给合久久狠狠狠97色| 欧美又粗又大又爽| 免费在线观看日韩欧美| 国产欧美一区二区精品久导航| 91色九色蝌蚪| 久久精工是国产品牌吗| 欧美国产日本韩| 欧美四级电影网| 国产一区二区三区在线观看免费 | 3d成人h动漫网站入口| 麻豆精品一区二区三区| 国产精品久线在线观看| 欧美另类z0zxhd电影| 国产精品综合av一区二区国产馆| 一区免费观看视频| 欧美一区三区四区| 成人福利视频在线看| 日日夜夜一区二区| 国产精品视频免费看| 欧美妇女性影城| 成人一区在线看| 五月开心婷婷久久| 国产精品久久看| 日韩欧美在线网站| 色婷婷一区二区| 国产精品一二三在| 五月激情丁香一区二区三区| 亚洲国产成人自拍| 日韩精品一区二区三区swag| 成人aaaa免费全部观看| 蜜桃传媒麻豆第一区在线观看| 亚洲欧洲成人av每日更新| 日韩一区二区三区在线视频| 在线看一区二区| heyzo一本久久综合| 国产剧情av麻豆香蕉精品| 99久久精品99国产精品|