Code: Select all
int main()
{
init();
//...
kheap = create_heap(KHEAP_START, KHEAP_START+KHEAP_INITIAL_SIZE, KHEAP_MAX, 1, 0); // SV and RW
ULONG ramdisk_start = k_malloc(0x30000, 0, 0);
printformat("Ram Disk at: %x\n",ramdisk_start);
tasking_install();
sti();
k_memcpy((void*)ramdisk_start, &file_data_start, (ULONG)&file_data_end - (ULONG)&file_data_start);
fs_root = install_initrd(ramdisk_start);
// search the content of files <- data from outside "loaded" via incbin ...
settextcolor(15,0);
ULONG i = 0;
struct dirent* node = 0;
while( (node = readdir_fs(fs_root, i)) != 0)
{
fs_node_t* fsnode = finddir_fs(fs_root, node->name);
if((fsnode->flags & 0x7) == FS_DIRECTORY)
{
printformat("<DIR> %s\n",node->name);
}
else
{
UCHAR buf[4096];
ULONG sz = read_fs(fsnode, 0, fsnode->length, buf);
printformat("%d \t%s\n",sz,node->name);
ULONG j;
for(j=0; j<sz; ++j)
{
if( k_strcmp(node->name,"Test-Programm")==0 )
{
address_TEST[j] = buf[j];
}
}
}
++i;
}
50% of PCs run without problems, but some stop with a #PF.
Perhaps it has another reason, but the problem could be tracked down to fs.c.
But the situation is very complex, because I cannot debug with bochs, only with prints from the OS.
The problem seems to be in finddir_fs(...). Is there a problem or improvements known regarding this code of JM? Advice would be highly appreciated.