FAT Filesystem implementation additions
This commit is contained in:
@ -107,10 +107,10 @@ DirectoryNode* FAT::Lookup (inode* currentDir , DirectoryNode* dir)
|
||||
for(int i = 0; i < sizeof(data) / sizeof (DIR); i++)
|
||||
{
|
||||
DIR* entry = (DIR*)((uint32_t)directory + (i * sizeof(DIR)));
|
||||
|
||||
|
||||
if(
|
||||
entry->Name[0] == FAT::FREE_DIR ||
|
||||
entry->Name[0] == FAT::FREE_DIR_2 ||
|
||||
entry->Name[0] == 0xE5 ||
|
||||
entry->ATTR & FAT::ATTRIBUTES::ATTR_VOLUME_ID ||
|
||||
entry->ATTR & FAT::ATTRIBUTES::ATTR_SYSTEM ||
|
||||
entry->ATTR & FAT::ATTRIBUTES::ATTR_HIDDEN
|
||||
@ -118,6 +118,20 @@ DirectoryNode* FAT::Lookup (inode* currentDir , DirectoryNode* dir)
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
if( entry->ATTR & FAT::ATTRIBUTES::ATTR_DIRECTORY){
|
||||
printf("entry in directory\n");
|
||||
for(int i = 0; i < 11 ;i ++)
|
||||
kterm_put(entry->Name[i]);
|
||||
kterm_put('\n');
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
if( entry->Name[0] == FAT::FREE_DIR_2 )
|
||||
break;
|
||||
|
||||
auto* dirNode = (DirectoryNode*) malloc(sizeof (DirectoryNode));
|
||||
|
||||
char* name = (char*)malloc(sizeof(char[11]));
|
||||
|
@ -22,22 +22,22 @@ inline MBR* GetPartitions(bool DEBUG = false){
|
||||
int S =1;
|
||||
uint32_t LBA = (C*HPC+H) * SPT + (S-1);
|
||||
|
||||
MBR* mbr =(MBR*) malloc(sizeof (MBR));
|
||||
uint16_t* mbr =(uint16_t*) malloc(sizeof (MBR));
|
||||
|
||||
ATAPIO::Read(ATAPIO_PORT::Primary, DEVICE_DRIVE::MASTER, LBA, (uint16_t*)mbr);
|
||||
ATAPIO::Read(ATAPIO_PORT::Primary, DEVICE_DRIVE::MASTER, LBA, mbr );
|
||||
auto bootRecord = (MBR*)(mbr);
|
||||
|
||||
|
||||
printf("MBR (In Memory) Address 0x%x, Size = %d\n", mbr, sizeof (MBR));
|
||||
printf("MBR (In Memory) Address 0x%x, Size = %d\n", bootRecord, sizeof (MBR));
|
||||
if(DEBUG){
|
||||
printf("BootSector: 0x%x\n", mbr->ValidBootsector );
|
||||
printf("BootSector: 0x%x\n", bootRecord->ValidBootsector );
|
||||
for( int i = 0 ; i < 4 ; i ++){
|
||||
PartitionTableEntry PT = mbr->TableEntries[i];
|
||||
PartitionTableEntry PT = bootRecord->TableEntries[i];
|
||||
|
||||
printf("Partition %d [ %d sectors, PartitionType: 0x%x, 0x%x, \nLBA Start: 0x%x ]\n" ,
|
||||
i, PT.Number_sectors_inPartition, PT.PartitionType, mbr->uniqueID, PT.LBA_partition_start );
|
||||
i, PT.Number_sectors_inPartition, PT.PartitionType, bootRecord->uniqueID, PT.LBA_partition_start );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return mbr;
|
||||
return bootRecord;
|
||||
}
|
||||
|
@ -80,20 +80,37 @@ FILE* VirtualFileSystem::open(const char* pathname, int flags){
|
||||
}
|
||||
|
||||
// let's just loop through the folder first
|
||||
printf("looking for: ");
|
||||
for(int i = 0; i < 5; i++)
|
||||
kterm_put(nextdir[i]);
|
||||
kterm_put('\n');
|
||||
auto* child = rootentry->children;
|
||||
while(child->next != nullptr){
|
||||
|
||||
auto* directory = (DirectoryNode*)child->data;
|
||||
|
||||
for(int i = 0; i < 11 ; i++)
|
||||
kterm_put(directory->name[i]);
|
||||
kterm_put('\n');
|
||||
|
||||
if( directory->compare(directory, directory->name, nextdir) == 0){
|
||||
nextdir = strtok(nullptr, "/", &tokstate);
|
||||
printf("Found dir!\n");
|
||||
if(nextdir == NULL){
|
||||
file->root = directory->node;
|
||||
file->flags =0;
|
||||
file->read = FAT::Read;
|
||||
return file;
|
||||
}
|
||||
printf("continue searching next directory!\n");
|
||||
if(directory->children == nullptr)
|
||||
directory->node->lookup(directory->node, directory);
|
||||
|
||||
|
||||
child = directory->children;
|
||||
|
||||
}else{
|
||||
child = child->next;
|
||||
}
|
||||
child = child->next;
|
||||
}
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user