Esempio n. 1
0
int GetFreeBlock()
{
/*
 * precondition		:
 * postcondition	: first-fit 조건임. free block number를 반환한다.
 * 					  성공시 0, block이 모두 사용중이면 -1 리턴
 */
	if ( fileSysInfo.numFreeBlocks == 0 )	return WRONG_VALUE;
	return fileSysInfo.dataStart + GetFreeEntry(fileSysInfo.pBlockBitmap, blockBitmapSize);
}
Esempio n. 2
0
int GetFreeInode()
{
/*
 * precondition		:
 * postcondition	: first-fit 조건임. free inode number를 반환한다.
 * 					  성공시 0, inode가 모두 사용중이면 -1 리턴
 */
	if ( fileSysInfo.numFreeInodes == 0 )	return WRONG_VALUE;
	return GetFreeEntry(fileSysInfo.pInodeBitmap, inodeBitmapSize);
}
Esempio n. 3
0
//add a new message to a queue
int CopyMessageToQ(BrokerQueue_t *q, psMessage_t *msg)
{
	BrokerQueueEntry_t *e = GetFreeEntry();

	if (e != NULL)
	{
		memcpy(&e->msg, msg, sizeof(psMessage_t));
		AppendQueueEntry(q, e);
		return 0;
	}
	else return -1;
}
Esempio n. 4
0
int SetFreeToAlloc(char* Bitmap, int BitmapBlockSize)
{
/*
 * precondition		: usage ) SetFreeToAlloc(fileSysInfo.pBlockBitmap, blockBitmapSize, dest);
 * postcondition	: 해당 dest의 bit를 사용중(0)으로 바꾼다.
 * 					  성공시 0, 해당 bitmap이 모두 사용중이면 -1 리턴
 */
	int blockno = 0;
	int bitno = 0;
	int bitLocation = 0;
	if ( (bitLocation = GetFreeEntry(Bitmap, BitmapBlockSize * BLOCK_SIZE)) == WRONG_VALUE )
	{
		fprintf(stderr, "* GetFreeEntry() error!\n");
		return WRONG_VALUE;
	}

	bitno = bitLocation % 8/*bit size of char*/;
	blockno = bitLocation / 8/*bit size of char*/;
	*(Bitmap + blockno) ^= (0x1 << bitno);
	return 0;
}