问题描述
我正在开发一个操作系统,我正在尝试从其他操作系统的源代码中实现 FAT12 文件系统,最后,我可以挂载一个 FAT12 格式的磁盘并获取其 FAT12 信息。
它可以读取 DriveName(当 'Location = 0' 时)。 但是当我尝试从磁盘列出目录时,它不起作用!
void FAT12_PrintDirectories(uint32_t Location,uint32_t numEntries,uint8_t DriveNum)
{
uint8_t read[((numEntries*32)/4096)+1];
AHCI::Port* port = AHCI::GlobalAHCI->ports[0];
port->Configure();
port->buffer = (uint8_t*)GlobalAllocator.RequestPage();
memset(port->buffer,((numEntries*32)/4096)+1);
port->Read(Location /* If I write here '0' Instead of Location,then Output is Image2 */,Location+((numEntries*32)/4096)+1,port->buffer);
for (int n = 0; n < sizeof(port->buffer); n++)
{
GlobalRenderer->PutChar(port->buffer[n]);
read[n] = port->buffer[n];
}
char drivename[12];
memset(&drivename,12);
memcpy(drivename,read,8);
if(read[9] != ' ')
{
drivename[8] = '.';
memcpy(drivename + 9,read + 8,3);
}
drivename[11] = 0;
// Print test read
GlobalRenderer->Next();
for (int n = 0; n < sizeof(read); n++)
{
GlobalRenderer->Print("=");
GlobalRenderer->Print(to_string((uint64_t)read[n]));
}
GlobalRenderer->Next();
GlobalRenderer->Print("Listing Dirs!");
GlobalRenderer->Next();
GlobalRenderer->Print("DriveName : ");
GlobalRenderer->Print(drivename);
GlobalRenderer->Next();
uint8_t *reads = read;
GlobalRenderer->Print("Dirs : ");
GlobalRenderer->Next();
for (unsigned int i = 0; i < numEntries; i++)
{
if(!reads[11] & 0x08 || reads[11] & 0x02 || reads[0] == 0 || reads[0] == 0xE5)
{
// Print FileName
for (uint8_t j = 0; j < 11; j++)
{
if(j == 8 && reads[j] != ' ')
{
GlobalRenderer->Print(".");
}
if(reads[j] != 0x20)
{
GlobalRenderer->Print(to_string((uint64_t)reads[j]));
}
if(reads[11] & 0x10 && j == 10)
{
GlobalRenderer->Print("/");
}
uint32_t nextCluster = (reads[27] << 8) | reads[26];
uint32_t size = *(uint32_t *)&reads[28];
}
reads += 32;
}
GlobalRenderer->Print("-");
}
}
这是我对该函数的调用代码 FAT12_PrintDirectories(dirOff,32,0);
这次dirOff = 2097153
输出:
Location = ((FAT12_MOUNT *)getdiskMount(numActiveMounts).mount)->RootDirectoryOffset*512+1;
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)