MCPcopy Create free account
hub / github.com/LemonOSProject/LemonOS / ReadClusterChain

Method ReadClusterChain

Kernel/src/fs/fat32.cpp:96–117  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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;
98 List<uint32_t>* clusterChain = GetClusterChain(cluster);
99
100 if(!clusterChain) return nullptr;
101
102 uint8_t* buf = reinterpret_cast<uint8_t*>(kmalloc(clusterChain->get_length() * clusterSizeBytes));
103 void* _buf = buf;
104
105 for(unsigned i = 0; i < clusterChain->get_length() && maxCluster; i++){
106 part->ReadBlock(ClusterToLBA(clusterChain->get_at(i)), clusterSizeBytes, buf);
107
108 buf += clusterSizeBytes;
109 }
110
111 if(clusterCount)
112 *clusterCount = clusterChain->get_length();
113
114 delete clusterChain;
115
116 return _buf;
117 }
118
119 void* Fat32Volume::ReadClusterChain(uint32_t cluster, int* clusterCount){
120 if(cluster == 0) cluster = bootRecord->ebr.rootClusterNum;

Callers

nothing calls this directly

Calls 4

kmallocFunction · 0.85
get_atMethod · 0.80
get_lengthMethod · 0.45
ReadBlockMethod · 0.45

Tested by

no test coverage detected