Beispiel #1
0
/* Find a free entity in the bitmap starting at block BMAP-START on device
   DEV which contains BMAP-LEN bits. Sets the free bit it finds then returns
   the bit number, or NO_FREE_BLOCK if an error or all bits are set. */
blkno
bmap_alloc(struct fs_device *dev, blkno bmap_start, u_long bmap_len)
{
    blkno bmap_blk = bmap_start;
    while(bmap_len > 0)
    {
	int len, bit;
	struct buf_head *buf = bread(dev, bmap_blk);
	if(buf == NULL)
	    return -1;
	len = min(bmap_len, FS_BLKSIZ * 8);
	FORBID();
	bit = find_zero_bit(buf->buf.bmap, len);
	if(bit != -1)
	{
	    set_bit(buf->buf.bmap, bit);
	    PERMIT();
	    bdirty(buf, TRUE);
	    brelse(buf);
	    return ((bmap_blk - bmap_start) * FS_BLKSIZ * 8) + bit;
	}
	PERMIT();
	brelse(buf);
	bmap_len -= len;
	bmap_blk++;
    }
    ERRNO = E_NOSPC;
    return NO_FREE_BLOCK;
}
bool FORTE_RT_E_PERMIT::checkActivation(int ){
  return PERMIT();
}