int rawfsMount( struct mount *pMount ) { RAWFS_DEV *pFsDev; RAWFS_VOLUME_DESC *pVolDesc; unsigned sectorSize; long long totalSize; pFsDev = (RAWFS_DEV *) pMount->mnt_data; pVolDesc = &(pFsDev->volDesc); memset (pFsDev, 0, sizeof(RAWFS_DEV)); /* Get setup from device */ if ((xbdBlockSize (pMount->mnt_dev, §orSize) != OK) || (xbdSize (pMount->mnt_dev, &totalSize) != OK)) { return (EINVAL); } /* Inititalize syncer vnode */ pMount->mnt_syncer->v_ops = (struct vnode_ops *) &rawVops; /* Inititalize semaphore */ pFsDev->bioSem = semBCreate (SEM_Q_PRIORITY, SEM_EMPTY); if (pFsDev->bioSem == NULL) { return (ENOBUFS); } /* Inititalize volume desciptor */ pVolDesc->pMount = pMount; pVolDesc->device = pMount->mnt_dev; pVolDesc->blkSize = sectorSize; pVolDesc->blkSize2 = ffsMsb(pVolDesc->blkSize) - 1; pVolDesc->secPerBlk2 = 1 + pVolDesc->blkSize2 - ffsMsb(sectorSize); pVolDesc->secPerBlk = (1 << pVolDesc->blkSize2); pVolDesc->diskSize = totalSize; return (OK); }
int hashFuncMultiply ( int elements, /* number of elements in hash table */ H_NODE_INT *pHNode, /* pointer to integer keyed hash node */ int multiplier /* multiplier */ ) { FAST int hash; hash = pHNode->key * multiplier; /* multiplicative hash func */ hash = hash >> (33 - ffsMsb (elements)); /* take only the leading bits */ return (hash & (elements - 1)); /* mask hash to (0,elements-1)*/ }