support large files

J

Joseph

Hi,

I'm having bit of questions on recursive pointer. I have following
code that supports upto 8K files but when i do a file like 12K i get a
segment fault. I Know it is in this line of code. How do i make the
last pointer in the indirect sector that has another level of indirect
pointer, and be defined recursively to support infinite large files?

-code-

bool
FileHeader::Allocate(BitMap *freeMap, int fileSize)
{
int i;

numBytes = fileSize;
numSectors = divRoundUp(fileSize, SectorSize);
if (freeMap->NumClear() < (numSectors+1))
return FALSE; // not enough space

int directSectors = numSectors % NumDirect;

for (i = 0; i < directSectors; i++)
dataSectors = freeMap->Find();

if( (numSectors / NumDirect) > 0 ) {
indirectHdrSector = freeMap->Find();
FileHeader *hdr = new FileHeader;
for( i = 0; i < (numSectors - directSectors); i++ )
hdr->dataSectors = freeMap->Find();
hdr->WriteBack(indirectHdrSector);
delete hdr;
}
return TRUE;
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,011
Latest member
AjaUqq1950

Latest Threads

Top