| 64 | } |
| 65 | |
| 66 | List<uint32_t>* Fat32Volume::GetClusterChain(uint32_t cluster){ |
| 67 | List<uint32_t>* list = new List<uint32_t>(); |
| 68 | |
| 69 | uint32_t* buf = (uint32_t*)kmalloc(4096); |
| 70 | |
| 71 | uint32_t lastBlock = 0xFFFFFFFF; |
| 72 | |
| 73 | do |
| 74 | { |
| 75 | list->add_back(cluster); |
| 76 | |
| 77 | uint32_t block = ((cluster * 4) / 4096); |
| 78 | uint32_t offset = cluster % (4096 / 4); |
| 79 | |
| 80 | if(block != lastBlock) { |
| 81 | if(part->ReadBlock(bootRecord->bpb.reservedSectors + block * (4096 / part->parentDisk->blocksize) /* Get Sector of Block */, 4096, buf)){ |
| 82 | delete list; |
| 83 | return nullptr; |
| 84 | } |
| 85 | |
| 86 | lastBlock = block; |
| 87 | } |
| 88 | |
| 89 | cluster = buf[offset] & 0x0FFFFFFF; |
| 90 | |
| 91 | } while(cluster && (cluster & 0x0FFFFFFF) < 0x0FFFFFF8); |
| 92 | |
| 93 | return list; |
| 94 | } |
| 95 | |
| 96 | void* Fat32Volume::ReadClusterChain(uint32_t cluster, int* clusterCount, size_t max){ |
| 97 | uint32_t maxCluster = (max / (bootRecord->bpb.sectorsPerCluster * part->parentDisk->blocksize)) + 1; |