summaryrefslogtreecommitdiffstats
path: root/src/godmode.c
diff options
context:
space:
mode:
authorChristophe Grenier <grenier@cgsecurity.org>2008-11-10 08:12:49 +0100
committerChristophe Grenier <grenier@cgsecurity.org>2008-11-10 08:12:49 +0100
commitc509e1a2c446101c3fa6dd0922f72a73253b7425 (patch)
treefa9b175ec5e80c222404b3fa76a29d7a9e7869ff /src/godmode.c
parent3707225caf554891fed4261fef74441e9bd74345 (diff)
TestDisk: identify Linux md created on big endian architecture
Diffstat (limited to 'src/godmode.c')
-rw-r--r--src/godmode.c18
1 files changed, 14 insertions, 4 deletions
diff --git a/src/godmode.c b/src/godmode.c
index 7dd7699..32413c5 100644
--- a/src/godmode.c
+++ b/src/godmode.c
@@ -552,10 +552,20 @@ static list_part_t *search_part(disk_t *disk_car, const list_part_t *list_part_o
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 *)buffer_disk;
- if(le32(sb1->major_version)==0)
- partition->part_offset-=(uint64_t)MD_NEW_SIZE_SECTORS(partition->part_size/512)*512;
- else
- partition->part_offset-=le64(sb1->super_offset)*512;
+ if(le32(sb1->md_magic)==(unsigned int)MD_SB_MAGIC)
+ {
+ if(le32(sb1->major_version)==0)
+ partition->part_offset-=(uint64_t)MD_NEW_SIZE_SECTORS(partition->part_size/512)*512;
+ else
+ partition->part_offset-=le64(sb1->super_offset)*512;
+ }
+ else
+ {
+ if(be32(sb1->major_version)==0)
+ partition->part_offset-=(uint64_t)MD_NEW_SIZE_SECTORS(partition->part_size/512)*512;
+ else
+ partition->part_offset-=be64(sb1->super_offset)*512;
+ }
res=1;
}
else