MCPcopy Create free account
hub / github.com/cgsecurity/testdisk / exfat_get_next_cluster

Function exfat_get_next_cluster

src/exfat_dir.c:177–198  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

175#define ATTR_ARCH 32 /* archived */
176
177static unsigned int exfat_get_next_cluster(disk_t *disk_car,const partition_t *partition, const uint64_t offset, const unsigned int cluster)
178{
179 unsigned char *buffer=(unsigned char*)MALLOC(disk_car->sector_size);
180 unsigned int next_cluster;
181 const uint32_t *p32=(const uint32_t*)buffer;
182 const uint64_t offset_s=cluster / (disk_car->sector_size/4);
183 const uint64_t offset_o=cluster % (disk_car->sector_size/4);
184 if((unsigned)disk_car->pread(disk_car, buffer, disk_car->sector_size,
185 partition->part_offset + offset + offset_s * disk_car->sector_size) != disk_car->sector_size)
186 {
187 log_error("exfat_get_next_cluster read error\n");
188 free(buffer);
189 return 0;
190 }
191 /* 0x00000000: free cluster
192 * 0xFFFFFFF7: bad cluster
193 * 0xFFFFFFFF: EOC End of cluster
194 * */
195 next_cluster=le32(p32[offset_o]);
196 free(buffer);
197 return next_cluster;
198}
199
200static int dir_exfat_aux(const unsigned char*buffer, const unsigned int size, const dir_data_t *dir_data, file_info_t *dir_list)
201{

Callers 2

exfat_dirFunction · 0.85
exfat_copyFunction · 0.85

Calls 1

MALLOCFunction · 0.85

Tested by

no test coverage detected