diff options
author | Christophe Grenier <[email protected]> | 2012-08-12 20:38:12 +0200 |
---|---|---|
committer | Christophe Grenier <[email protected]> | 2012-08-12 20:38:12 +0200 |
commit | de04a6886a6fb2dda1eb38c26691091f955a1918 (patch) | |
tree | 2309ec6e628ed1222bb64dcf18fec21838cfd772 | |
parent | a1a86ea8e96e799c8e0c74e5fcddd97975b7190c (diff) |
TestDisk: detects cramfs filesystem with offset 0
-rw-r--r-- | src/analyse.c | 5 | ||||
-rw-r--r-- | src/cramfs.c | 21 |
2 files changed, 19 insertions, 7 deletions
diff --git a/src/analyse.c b/src/analyse.c index 9201738c..c901c9b8 100644 --- a/src/analyse.c +++ b/src/analyse.c @@ -139,7 +139,9 @@ int search_FAT_backup(unsigned char *buffer, disk_t *disk, partition_t *partitio int search_type_0(const unsigned char *buffer, disk_t *disk, partition_t *partition, const int verbose, const int dump_ind) { + /* Expect a buffer filled with 8k to handle the SWAP detection */ const pv_disk_t *pv=(const pv_disk_t *)buffer; + const struct cramfs_super *cramfs=(const struct cramfs_super *)buffer; const struct disk_fatx *fatx_block=(const struct disk_fatx*)buffer; const struct disk_netware *netware_block=(const struct disk_netware *)buffer; const struct exfat_super_block *exfat_header=(const struct exfat_super_block *)buffer; @@ -206,6 +208,9 @@ int search_type_0(const unsigned char *buffer, disk_t *disk, partition_t *partit if(memcmp(&wbfs->magic,"WBFS",4)==0 && recover_WBFS(disk, wbfs, partition, verbose, dump_ind)==0) return 1; + if(cramfs->magic==le32(CRAMFS_MAGIC) && + recover_cramfs(disk, cramfs, partition, verbose, dump_ind)==0) + return 1; /* Try to locate logical partition that may host truecrypt encrypted filesystem */ if(buffer[0x1fe]==0x55 && buffer[0x1ff]==0xAA && recover_i386_logical(disk, buffer, partition)==0 && diff --git a/src/cramfs.c b/src/cramfs.c index a78b1e03..898f59c5 100644 --- a/src/cramfs.c +++ b/src/cramfs.c @@ -43,16 +43,23 @@ static int test_cramfs(const disk_t *disk_car, const struct cramfs_super *sb, pa int check_cramfs(disk_t *disk_car,partition_t *partition,const int verbose) { unsigned char *buffer=(unsigned char*)MALLOC(CRAMFS_SUPERBLOCK_SIZE); - if(disk_car->pread(disk_car, buffer, CRAMFS_SUPERBLOCK_SIZE, partition->part_offset + 0x200) != CRAMFS_SUPERBLOCK_SIZE) + if(disk_car->pread(disk_car, buffer, CRAMFS_SUPERBLOCK_SIZE, partition->part_offset + 0x200) == CRAMFS_SUPERBLOCK_SIZE) { - free(buffer); - return 1; + if(test_cramfs(disk_car, (struct cramfs_super*)buffer, partition, verbose)==0) + { + set_cramfs_info((struct cramfs_super*)buffer, partition); + free(buffer); + return 0; + } } - if(test_cramfs(disk_car, (struct cramfs_super*)buffer, partition, verbose)==0) + if(disk_car->pread(disk_car, buffer, CRAMFS_SUPERBLOCK_SIZE, partition->part_offset) == CRAMFS_SUPERBLOCK_SIZE) { - set_cramfs_info((struct cramfs_super*)buffer, partition); - free(buffer); - return 0; + if(test_cramfs(disk_car, (struct cramfs_super*)buffer, partition, verbose)==0) + { + set_cramfs_info((struct cramfs_super*)buffer, partition); + free(buffer); + return 0; + } } free(buffer); return 1; |