summaryrefslogtreecommitdiffstats
path: root/src/exfat.c
diff options
context:
space:
mode:
authorChristophe Grenier <grenier@cgsecurity.org>2011-02-07 09:17:12 +0100
committerChristophe Grenier <grenier@cgsecurity.org>2011-02-07 09:17:12 +0100
commit237b0d53ac0d638ccbd8671293b6695436bad32c (patch)
treead4178e092a225fe05d9cf69aa312b0db41367e2 /src/exfat.c
parent2d02984cbcde496a462304bb2bdcdfe5550c8e43 (diff)
Minimal support to list and copy files from exFAT for TestDisk.
PhotoRec:Can carve files from exFAT free space only
Diffstat (limited to 'src/exfat.c')
-rw-r--r--src/exfat.c17
1 files changed, 15 insertions, 2 deletions
diff --git a/src/exfat.c b/src/exfat.c
index f0611c9..a2b38e6 100644
--- a/src/exfat.c
+++ b/src/exfat.c
@@ -34,6 +34,19 @@
#include "common.h"
#include "exfat.h"
+uint64_t exfat_cluster_to_offset(const struct exfat_super_block *exfat_header, const unsigned int cluster)
+{
+ return ((uint64_t)(((cluster-2) << exfat_header->block_per_clus_bits) + le32(exfat_header->clus_blocknr))) << exfat_header->blocksize_bits;
+}
+
+int exfat_read_cluster(disk_t *disk, const partition_t *partition, const struct exfat_super_block*exfat_header, void *buffer, const unsigned int cluster)
+{
+ return disk->pread(disk,
+ buffer,
+ 1 << (exfat_header->block_per_clus_bits + exfat_header->blocksize_bits),
+ partition->part_offset + exfat_cluster_to_offset(exfat_header, cluster));
+}
+
static int set_EXFAT_info(partition_t *partition)
{
partition->fsname[0]='\0';
@@ -44,10 +57,10 @@ static int set_EXFAT_info(partition_t *partition)
return 0;
}
-int check_EXFAT(disk_t *disk_car, partition_t *partition)
+int check_EXFAT(disk_t *disk, partition_t *partition)
{
unsigned char *buffer=(unsigned char*)MALLOC(EXFAT_BS_SIZE);
- if(disk_car->pread(disk_car, buffer, EXFAT_BS_SIZE, partition->part_offset) != EXFAT_BS_SIZE)
+ if(disk->pread(disk, buffer, EXFAT_BS_SIZE, partition->part_offset) != EXFAT_BS_SIZE)
{
free(buffer);
return 1;