summaryrefslogtreecommitdiffstats
path: root/src/godmode.c
diff options
context:
space:
mode:
authorChristophe Grenier <grenier@cgsecurity.org>2013-05-24 08:51:29 +0200
committerChristophe Grenier <grenier@cgsecurity.org>2013-05-24 08:51:29 +0200
commiteb3b555b50e2c82f67559472bdf0a1d54325550f (patch)
treef3aaea1d3c9cd8e8423d69eeda0fba794bed7eb0 /src/godmode.c
parent91c44757340fd6f598e2708f8e20038158766c8e (diff)
Get rid of pread_fast(), it's too error prone
Diffstat (limited to 'src/godmode.c')
-rw-r--r--src/godmode.c20
1 files changed, 8 insertions, 12 deletions
diff --git a/src/godmode.c b/src/godmode.c
index adb0aab..617ae49 100644
--- a/src/godmode.c
+++ b/src/godmode.c
@@ -573,12 +573,11 @@ static list_part_t *search_part(disk_t *disk_car, const list_part_t *list_part_o
{
if(search_now_raid>0 || fast_mode>1)
{ /* Search Linux software RAID */
- void *data=disk_car->pread_fast(disk_car, buffer_disk, 8 * DEFAULT_SECTOR_SIZE, search_location);
- if(data!=NULL)
+ if(disk_car->pread(disk_car, buffer_disk, 8 * DEFAULT_SECTOR_SIZE, search_location) == 8 *DEFAULT_SECTOR_SIZE)
{
- if(recover_MD(disk_car, (const struct mdp_superblock_s*)data, partition, verbose, dump_ind)==0)
+ if(recover_MD(disk_car, (const struct mdp_superblock_s*)buffer_disk, partition, verbose, dump_ind)==0)
{
- const struct mdp_superblock_1 *sb1=(const struct mdp_superblock_1 *)data;
+ const struct mdp_superblock_1 *sb1=(const struct mdp_superblock_1 *)buffer_disk;
if(le32(sb1->md_magic)==(unsigned int)MD_SB_MAGIC)
{
if(le32(sb1->major_version)==0)
@@ -666,10 +665,9 @@ static list_part_t *search_part(disk_t *disk_car, const list_part_t *list_part_o
if((disk_car->arch==&arch_i386 && start_ext2.sector==1 && (start_ext2.head<=2 || fast_mode>1)) ||
(disk_car->arch!=&arch_i386 && search_location%location_boundary==0))
{
- void *data=disk_car->pread_fast(disk_car, buffer_disk, 1024, search_location);
- if(data!=NULL)
+ if(disk_car->pread(disk_car, buffer_disk, 1024, search_location)==1024)
{
- const struct ext2_super_block *sb=(const struct ext2_super_block*)data;
+ const struct ext2_super_block *sb=(const struct ext2_super_block*)buffer_disk;
if(le16(sb->s_block_group_nr)>0)
{
if(le16(sb->s_magic)==EXT2_SUPER_MAGIC &&
@@ -726,7 +724,7 @@ static list_part_t *search_part(disk_t *disk_car, const list_part_t *list_part_o
if(res<=0 && test_nbr==12)
{
/* read to fill the cache */
- disk_car->pread_fast(disk_car, buffer_disk, 8 * DEFAULT_SECTOR_SIZE,
+ disk_car->pread(disk_car, buffer_disk, 8 * DEFAULT_SECTOR_SIZE,
partition->part_offset + (63 + 16) * 512);
/* Try to catch disklabel before BSD FFS partition */
res=search_type_128(buffer_disk,disk_car,partition,verbose,dump_ind);
@@ -898,13 +896,11 @@ static list_part_t *search_part(disk_t *disk_car, const list_part_t *list_part_o
unsigned int i;
for(i=32;i>0;i--)
{
- void *data;
partition->part_size=(uint64_t)0;
partition->part_offset=element->part->part_offset - i * disk_car->sector_size;
- data=disk_car->pread_fast(disk_car, buffer_disk, DEFAULT_SECTOR_SIZE, partition->part_offset);
- if(data!=NULL)
+ if(disk_car->pread(disk_car, buffer_disk, DEFAULT_SECTOR_SIZE, partition->part_offset)==DEFAULT_SECTOR_SIZE)
{
- if(recover_NTFS(disk_car, (const struct ntfs_boot_sector*)data, partition, verbose, dump_ind, 0)==0)
+ if(recover_NTFS(disk_car, (const struct ntfs_boot_sector*)buffer_disk, partition, verbose, dump_ind, 0)==0)
{
partition->status=STATUS_DELETED;
if(disk_car->arch->is_part_known(partition)!=0 && partition->part_size>1 &&