From e974af0fadeacaa13cdeebc34a1aa030343ffcd9 Mon Sep 17 00:00:00 2001 From: Morten Delenk Date: Tue, 26 Jul 2016 20:49:16 +0200 Subject: [PATCH] Added a FAT directory listing test in the temporary driver --- kernel/kernel/disk/fat.cpp | 27 +++++++++++++++++++++++++-- test.elf | Bin 14876 -> 0 bytes 2 files changed, 25 insertions(+), 2 deletions(-) delete mode 100755 test.elf diff --git a/kernel/kernel/disk/fat.cpp b/kernel/kernel/disk/fat.cpp index d95b585..520acb4 100644 --- a/kernel/kernel/disk/fat.cpp +++ b/kernel/kernel/disk/fat.cpp @@ -50,6 +50,20 @@ struct BPB { uint32_t totalSectors_b; EBPB ebpb; }__attribute__((packed)); +struct dirent { + uint8_t filename[11]; + uint8_t flags; + uint8_t reserved; + uint8_t creationTenth; + uint16_t creationTime; + uint16_t creationDate; + uint16_t accessDate; + uint16_t hiClusterNUM; + uint16_t modifyTime; + uint16_t modifyDate; + uint16_t clusterNUM; + uint32_t fileSize; +}__attribute__((packed)); void readFAT() { BPB bpb; MBR::MBR part(disk.getDriveNumByName("ATA0m")); @@ -58,7 +72,7 @@ void readFAT() { out << "Sectors per Cluster: " << (int) bpb.sectorsPerCluster << "\n"; out << "Reserved Sectors: " << (int) bpb.reservedSectors << "\n"; out << "Number of FATs: " << (int) bpb.numberFAT << "\n"; - out << "Number of root directory entries: " << (int) bpb.reservedSectors << "\n"; + out << "Number of root directory entries: " << (int) bpb.numDirent << "\n"; uint32_t totalSectors=(bpb.totalSectors_s)?bpb.totalSectors_s:bpb.totalSectors_b; out << "Total sectors: " << (int) totalSectors << "\n"; uint32_t sectorsPerFAT = (bpb.sectorsPerFAT)?bpb.sectorsPerFAT:bpb.ebpb.fat32.sectorsPerFAT; @@ -86,5 +100,14 @@ void readFAT() { if(fatVer>28) { out << "Not implemented\n"; return; - } + } + out << "Reading root directory\n"; + dirent *buf=(dirent*)new uint8_t[(sizeRootDir*512)]; + disk.readSector(disk.getDriveNumByName("ATA0m"),part.getPartB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