summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/adv.c2
-rw-r--r--src/diskacc.c2
-rw-r--r--src/fat.c10
-rw-r--r--src/fat_adv.c7
-rw-r--r--src/fatp.c6
-rw-r--r--src/file_asf.c1
-rw-r--r--src/file_ds2.c2
-rw-r--r--src/file_dss.c2
-rw-r--r--src/file_fits.c2
-rw-r--r--src/file_jpg.c2
-rw-r--r--src/file_sp3.c2
-rw-r--r--src/file_txt.c4
-rw-r--r--src/file_zip.c2
-rw-r--r--src/godmode.c8
-rw-r--r--src/hdaccess.c2
-rw-r--r--src/hdcache.c2
-rw-r--r--src/hidden.c2
-rw-r--r--src/intrf.c6
-rw-r--r--src/list.c3
-rw-r--r--src/ntfs.c2
-rw-r--r--src/ntfs_adv.c2
-rw-r--r--src/partgpt.c4
-rw-r--r--src/parti386.c112
-rw-r--r--src/partmac.c4
-rw-r--r--src/partnone.c4
-rw-r--r--src/partsun.c4
-rw-r--r--src/partxbox.c4
-rw-r--r--src/pdisksel.c11
-rw-r--r--src/photorec.c4
-rw-r--r--src/ppartsel.c26
-rw-r--r--src/rfs_dir.c20
-rw-r--r--src/savehdr.c6
-rw-r--r--src/tdisksel.c13
33 files changed, 140 insertions, 143 deletions
diff --git a/src/adv.c b/src/adv.c
index baa4f6b..e887410 100644
--- a/src/adv.c
+++ b/src/adv.c
@@ -241,7 +241,6 @@ void interface_adv(disk_t *disk_car, const int verbose,const int dump_ind, const
if(element!=NULL)
wprintw(stdscr, "Next");
#endif
- menu=0;
if(current_element==NULL)
{
options="q";
@@ -464,7 +463,6 @@ void interface_adv(disk_t *disk_car, const int verbose,const int dump_ind, const
case 'C':
{
char *image_dd;
- menu=0;
if(*current_cmd!=NULL)
image_dd=get_default_location();
else
diff --git a/src/diskacc.c b/src/diskacc.c
index 6cb078c..47d9b4a 100644
--- a/src/diskacc.c
+++ b/src/diskacc.c
@@ -86,7 +86,7 @@ static int interface_check_disk_access_ncurses(disk_t *disk_car)
wmove(stdscr,line++,0);
wprintw(stdscr,"and press Umount button for each volume from this disk\n");
#endif
- wmove(stdscr,line++,0);
+ wmove(stdscr,line,0);
wprintw(stdscr,"- This media may be physically write-protected, check the jumpers.\n");
car= wmenuSelect_ext(stdscr, 23, INTER_DISK_Y, INTER_DISK_X, menuDiskAccess, 10,
"CQ", MENU_VERT | MENU_VERT_WARN | MENU_BUTTON, &menu,NULL);
diff --git a/src/fat.c b/src/fat.c
index 50fb16c..5889503 100644
--- a/src/fat.c
+++ b/src/fat.c
@@ -511,8 +511,7 @@ unsigned int fat32_get_prev_cluster(disk_t *disk_car,const partition_t *partitio
for(prev_cluster=2;prev_cluster<=no_of_cluster+1;prev_cluster++)
{
- unsigned int offset_s,offset_o;
- offset_s=prev_cluster/(disk_car->sector_size/4);
+ unsigned int offset_o;
offset_o=prev_cluster%(disk_car->sector_size/4);
if((offset_o==0)||(prev_cluster==2))
{
@@ -547,7 +546,6 @@ static unsigned int get_prev_cluster(disk_t *disk_car,const partition_t *partiti
int test_FAT(disk_t *disk_car,const struct fat_boot_sector *fat_header, partition_t *partition,const int verbose, const int dump_ind)
{
- upart_type_t upart_type=UP_UNK;
uint64_t start_fat1,start_fat2,start_rootdir,start_data,part_size,end_data;
unsigned long int no_of_cluster,fat_length,fat_length_calc;
const char *buffer=(const char*)fat_header;
@@ -629,7 +627,6 @@ int test_FAT(disk_t *disk_car,const struct fat_boot_sector *fat_header, partitio
}
if(no_of_cluster<4085)
{
- upart_type=UP_FAT12;
if(verbose>0)
{
log_info("FAT12 at %u/%u/%u\n",
@@ -670,7 +667,6 @@ int test_FAT(disk_t *disk_car,const struct fat_boot_sector *fat_header, partitio
}
else if(no_of_cluster<65525)
{
- upart_type=UP_FAT16;
if(verbose>0)
{
log_info("FAT16 at %u/%u/%u\n",
@@ -706,7 +702,6 @@ int test_FAT(disk_t *disk_car,const struct fat_boot_sector *fat_header, partitio
}
else
{
- upart_type=UP_FAT32;
if(verbose>0)
{
log_info("FAT32 at %u/%u/%u\n",
@@ -1213,8 +1208,7 @@ int fat32_free_info(disk_t *disk_car,const partition_t *partition, const unsigne
for(prev_cluster=2;prev_cluster<=no_of_cluster+1;prev_cluster++)
{
unsigned long int cluster;
- unsigned int offset_s,offset_o;
- offset_s=prev_cluster/(disk_car->sector_size/4);
+ unsigned int offset_o;
offset_o=prev_cluster%(disk_car->sector_size/4);
if((offset_o==0)||(prev_cluster==2))
{
diff --git a/src/fat_adv.c b/src/fat_adv.c
index f0866ba..68b49b3 100644
--- a/src/fat_adv.c
+++ b/src/fat_adv.c
@@ -451,7 +451,7 @@ static unsigned int fat32_find_root_cluster(disk_t *disk_car,const partition_t *
{
if((nb_subdir_ok>nb_subdir*0.90)&&(nb_subdir>=3))
{
- unsigned long int new_root_cluster=root_cluster;
+ unsigned long int new_root_cluster;
unsigned long int tmp=root_cluster;
int back=0; /* To avoid an endless loop... */
/* Il faut ajouter un parcours arriere de la FAT
@@ -1770,7 +1770,6 @@ static upart_type_t fat_find_info(disk_t *disk_car,unsigned int*reserved, unsign
static upart_type_t select_fat_info(const info_offset_t *info_offset, const unsigned int nbr_offset,unsigned int*reserved, unsigned int*fat_length, const unsigned long int max_sector_offset, unsigned int *fats)
{
unsigned int i;
- int reserved_can_be_one=0;
unsigned long int fat2_location=*reserved+*fat_length;
struct MenuItem menuSelectFAT[]=
{
@@ -1786,10 +1785,6 @@ static upart_type_t select_fat_info(const info_offset_t *info_offset, const unsi
{
if(nbr_offset<30 || info_offset[i].nbr>1)
screen_buffer_add(" %02d %8lu %u\n",info_offset[i].fat_type,info_offset[i].offset,info_offset[i].nbr);
- if(info_offset[i].fat_type<32)
- {
- reserved_can_be_one=1;
- }
}
aff_copy(stdscr);
wmove(stdscr,4,0);
diff --git a/src/fatp.c b/src/fatp.c
index 0294b8a..5f90309 100644
--- a/src/fatp.c
+++ b/src/fatp.c
@@ -53,8 +53,7 @@ static void fat16_remove_used_space(disk_t *disk_car,const partition_t *partitio
partition->part_offset+(uint64_t)(start_data*sector_size));
for(prev_cluster=2;prev_cluster<=no_of_cluster+1;prev_cluster++)
{
- unsigned int offset_s,offset_o;
- offset_s=prev_cluster/(sector_size/2);
+ unsigned int offset_o;
offset_o=prev_cluster%(sector_size/2);
if((offset_o==0)||(prev_cluster==2))
{
@@ -97,8 +96,7 @@ static void fat32_remove_used_space(disk_t *disk_car,const partition_t *partitio
for(prev_cluster=2;prev_cluster<=no_of_cluster+1;prev_cluster++)
{
unsigned long int cluster;
- unsigned int offset_s,offset_o;
- offset_s=prev_cluster/(sector_size/4);
+ unsigned int offset_o;
offset_o=prev_cluster%(sector_size/4);
if((offset_o==0)||(prev_cluster==2))
{
diff --git a/src/file_asf.c b/src/file_asf.c
index 6997d7c..819678c 100644
--- a/src/file_asf.c
+++ b/src/file_asf.c
@@ -41,7 +41,6 @@ const file_hint_t file_hint_asf= {
.max_filesize=PHOTOREC_MAX_FILE_SIZE,
.recover=1,
.enable_by_default=1,
- .enable_by_default=1,
.register_header_check=&register_header_check_asf
};
diff --git a/src/file_ds2.c b/src/file_ds2.c
index 1bbc94a..c35f6cc 100644
--- a/src/file_ds2.c
+++ b/src/file_ds2.c
@@ -81,7 +81,7 @@ static int header_check_ds2(const unsigned char *buffer, const unsigned int buff
tm_time.tm_year=(date_asc[0]-'0')*10+(date_asc[1]-'0'); /* year */
if(tm_time.tm_year<80)
tm_time.tm_year+=100; /* year 2000 - 2079 */
- tm_time.tm_isdst=-1; /* unknown daylight saving time */
+ tm_time.tm_isdst = -1; /* unknown daylight saving time */
file_recovery_new->time=mktime(&tm_time);
return 1;
}
diff --git a/src/file_dss.c b/src/file_dss.c
index e3688de..6e115d7 100644
--- a/src/file_dss.c
+++ b/src/file_dss.c
@@ -84,7 +84,7 @@ static int header_check_dss(const unsigned char *buffer, const unsigned int buff
tm_time.tm_year=(date_asc[0]-'0')*10+(date_asc[1]-'0'); /* year */
if(tm_time.tm_year<80)
tm_time.tm_year+=100; /* year 2000 - 2079 */
- tm_time.tm_isdst=-1; /* unknown daylight saving time */
+ tm_time.tm_isdst = -1; /* unknown daylight saving time */
file_recovery_new->time=mktime(&tm_time);
return 1;
}
diff --git a/src/file_fits.c b/src/file_fits.c
index 037b31b..95f2afa 100644
--- a/src/file_fits.c
+++ b/src/file_fits.c
@@ -121,7 +121,7 @@ static int header_check_fits(const unsigned char *buffer, const unsigned int buf
tm_time.tm_mon=(date_asc[5]-'0')*10+(date_asc[6]-'0')-1; /* month 0-11 */
tm_time.tm_year=(date_asc[0]-'0')*1000+(date_asc[1]-'0')*100+
(date_asc[2]-'0')*10+(date_asc[3]-'0')-1900; /* year */
- tm_time.tm_isdst=-1; /* unknown daylight saving time */
+ tm_time.tm_isdst = -1; /* unknown daylight saving time */
file_recovery_new->time=mktime(&tm_time);
}
}
diff --git a/src/file_jpg.c b/src/file_jpg.c
index 8753657..d57b22a 100644
--- a/src/file_jpg.c
+++ b/src/file_jpg.c
@@ -192,7 +192,7 @@ static time_t get_date_from_tiff_header(const struct tiff_entry *tiff, const uns
tm_time.tm_mon=(date_asc[5]-'0')*10+(date_asc[6]-'0')-1; /* month 0-11 */
tm_time.tm_year=(date_asc[0]-'0')*1000+(date_asc[1]-'0')*100+
(date_asc[2]-'0')*10+(date_asc[3]-'0')-1900; /* year */
- tm_time.tm_isdst=-1; /* unknown daylight saving time */
+ tm_time.tm_isdst = -1; /* unknown daylight saving time */
return mktime(&tm_time);
}
diff --git a/src/file_sp3.c b/src/file_sp3.c
index d06e4d6..0a1893c 100644
--- a/src/file_sp3.c
+++ b/src/file_sp3.c
@@ -84,7 +84,7 @@ static int header_check_sp3(const unsigned char *buffer, const unsigned int buff
tm_time.tm_mday=h->DataExameDia-1;
tm_time.tm_mon=h->DataExameMes-1;
tm_time.tm_year=le16(h->DataExameAno)-1900;
- tm_time.tm_isdst=-1; /* unknown daylight saving time */
+ tm_time.tm_isdst = -1; /* unknown daylight saving time */
file_recovery_new->time= mktime(&tm_time);
filesize=td_max(filesize, file_offset_end(le32(h->TimeBaseDelta_POS), le32(h->TimeBaseDelta_LEN)));
filesize=td_max(filesize, file_offset_end(le32(h->ExtraInfoFlag_POS), le32(h->ExtraInfoFlag_LEN)));
diff --git a/src/file_txt.c b/src/file_txt.c
index 1a902c4..c390484 100644
--- a/src/file_txt.c
+++ b/src/file_txt.c
@@ -72,7 +72,7 @@ const file_hint_t file_hint_fasttxt= {
const file_hint_t file_hint_txt= {
.extension="txt",
- .description="Other text files: txt,html,asp,bat,C,jsp,perl,php,py... scripts",
+ .description="Other text files: txt,html,asp,bat,C,jsp,perl,php,py/emlx... scripts",
.min_header_distance=0,
.max_filesize=PHOTOREC_MAX_FILE_SIZE,
.recover=1,
@@ -493,7 +493,7 @@ static int header_check_fasttxt(const unsigned char *buffer, const unsigned int
tm_time.tm_mon=(date_asc[4]-'0')*10+(date_asc[5]-'0')-1; /* month 0-11 */
tm_time.tm_year=(date_asc[0]-'0')*1000+(date_asc[1]-'0')*100+
(date_asc[2]-'0')*10+(date_asc[3]-'0')-1900; /* year */
- tm_time.tm_isdst=-1; /* unknown daylight saving time */
+ tm_time.tm_isdst = -1; /* unknown daylight saving time */
file_recovery_new->time=mktime(&tm_time);
}
free(buffer2);
diff --git a/src/file_zip.c b/src/file_zip.c
index 4bda072..21870bf 100644
--- a/src/file_zip.c
+++ b/src/file_zip.c
@@ -496,7 +496,7 @@ static void file_check_zip(file_recovery_t *fr)
else
log_trace("Unparsable block with ID 0x%04X\n", header>>16);
#endif
- status=-1;
+ status = -1;
break;
}
diff --git a/src/godmode.c b/src/godmode.c
index 32413c5..a475f3e 100644
--- a/src/godmode.c
+++ b/src/godmode.c
@@ -545,7 +545,7 @@ static list_part_t *search_part(disk_t *disk_car, const list_part_t *list_part_o
{ /* Search Linux software RAID */
if(disk_car->read(disk_car,8*DEFAULT_SECTOR_SIZE, buffer_disk, search_location)!=0)
{
- res=-1;
+ res = -1;
}
else
{
@@ -641,7 +641,7 @@ static list_part_t *search_part(disk_t *disk_car, const list_part_t *list_part_o
}
else
{
- res=-1;
+ res = -1;
}
}
}
@@ -722,7 +722,9 @@ static list_part_t *search_part(disk_t *disk_car, const list_part_t *list_part_o
{ /* Detect Linux md 0.9 software raid */
unsigned int disk_factor;
unsigned int help_factor;
+#if 0
unsigned int help_factor_max;
+#endif
const int align=2;
CHS_t end;
offset2CHS_inline(disk_car,partition->part_offset+partition->part_size-1,&end);
@@ -732,10 +734,12 @@ static list_part_t *search_part(disk_t *disk_car, const list_part_t *list_part_o
if(align>1)
end.head=disk_car->geom.heads_per_cylinder-1;
}
+#if 0
help_factor_max=((uint64_t)CHS2offset_inline(disk_car, &end)-partition->part_offset+disk_car->sector_size-partition->part_size)/MD_RESERVED_BYTES;
if(help_factor_max<3)
help_factor_max=3;
help_factor_max+=MD_MAX_CHUNK_SIZE/MD_RESERVED_BYTES;
+#endif
for(disk_factor=6;disk_factor>=1 && ind_stop==0;disk_factor--)
{ /* disk_factor=1, detect Raid 0/1 */
/* disk_factor>1, detect Raid 5 */
diff --git a/src/hdaccess.c b/src/hdaccess.c
index fae2b5e..0938c8e 100644
--- a/src/hdaccess.c
+++ b/src/hdaccess.c
@@ -1287,7 +1287,7 @@ disk_t *file_test_availability(const char *device, const int verbose, const arch
{
try_readonly=1;
close(hd_h);
- hd_h=-1;
+ hd_h = -1;
}
}
#endif
diff --git a/src/hdcache.c b/src/hdcache.c
index 7cd822c..1d53807 100644
--- a/src/hdcache.c
+++ b/src/hdcache.c
@@ -171,7 +171,7 @@ static int cache_read_aux(disk_t *disk_car,const unsigned int count, void *nom_b
}
/* split the read sector by sector */
cache->cache_size=0;
- res=-1;
+ res = -1;
for(i=0;i*disk_car->sector_size<count;i++)
{
const int newres=cache_read_aux(disk_car, (count>(i+1)*disk_car->sector_size?disk_car->sector_size:count - i*disk_car->sector_size), (unsigned char*)nom_buffer+i*disk_car->sector_size, offset+i*disk_car->sector_size, 0);
diff --git a/src/hidden.c b/src/hidden.c
index 275162e..3bdceb7 100644
--- a/src/hidden.c
+++ b/src/hidden.c
@@ -83,7 +83,7 @@ static int interface_check_hidden_ncurses(disk_t *disk)
}
if(disk->native_max < disk->dco)
{
- wmove(stdscr,line++,0);
+ wmove(stdscr,line,0);
wprintw(stdscr, "Device Configuration Overlay (DCO) present.\n");
}
car= wmenuSelect_ext(stdscr, 23, INTER_DISK_Y, INTER_DISK_X, menuHidden, 10,
diff --git a/src/intrf.c b/src/intrf.c
index a8eefca..1082316 100644
--- a/src/intrf.c
+++ b/src/intrf.c
@@ -235,7 +235,7 @@ const char *aff_part_aux(const unsigned int newline, const disk_t *disk_car, con
if(partition->partname[0]!='\0')
pos+=snprintf(&msg[pos],sizeof(msg)-pos-1, " [%s]",partition->partname);
if(partition->fsname[0]!='\0')
- pos+=snprintf(&msg[pos],sizeof(msg)-pos-1, " [%s]",partition->fsname);
+ snprintf(&msg[pos],sizeof(msg)-pos-1, " [%s]",partition->fsname);
return msg;
}
@@ -1195,8 +1195,10 @@ static char *filename_to_directory(const char *filename)
buf[sizeof(buf)-1]='\0';
#endif
res=dirname(buf);
+ if(res==NULL)
+ return NULL;
#ifdef HAVE_GETCWD
- if(res!=NULL && strcmp(res,".")==0 && getcwd(buf, sizeof(buf)-1)!=NULL)
+ if(strcmp(res,".")==0 && getcwd(buf, sizeof(buf)-1)!=NULL)
{
buf[sizeof(buf)-1]='\0';
res=buf;
diff --git a/src/list.c b/src/list.c
index 042bb49..d64c3eb 100644
--- a/src/list.c
+++ b/src/list.c
@@ -2,7 +2,7 @@
File: list.c
- Copyright (C) 2006-2007 Christophe GRENIER <grenier@cgsecurity.org>
+ Copyright (C) 2006-2008 Christophe GRENIER <grenier@cgsecurity.org>
This software is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -29,7 +29,6 @@
#include "types.h"
#include "common.h"
#include "list.h"
-#include "log.h"
void list_truncate(alloc_list_t *list, const uint64_t file_size)
{
diff --git a/src/ntfs.c b/src/ntfs.c
index 24acab0..11fdacd 100644
--- a/src/ntfs.c
+++ b/src/ntfs.c
@@ -309,7 +309,7 @@ static int ntfs_get_attr_aux(const char *attr_record, const int my_type, partiti
volume_name_length=sizeof(partition->fsname)-1;
for(name_it=attr_td_list_entry;(volume_name_length>0) && (*name_it!='\0') && (name_it[1]=='\0'); name_it+=2,volume_name_length--)
*dest++=*name_it;
- *dest++='\0'; /* 27 january 2003: Correct a bug found by Andreas du Plessis-Denz */
+ *dest='\0'; /* 27 january 2003: Correct a bug found by Andreas du Plessis-Denz */
}
return 1;
case 0x90: /* AT_INDEX_ROOT */
diff --git a/src/ntfs_adv.c b/src/ntfs_adv.c
index d04ec2a..682a0e0 100644
--- a/src/ntfs_adv.c
+++ b/src/ntfs_adv.c
@@ -658,7 +658,7 @@ static int testdisk_ffs(int x)
r += 2;
}
if (!(x & 1)) {
- x >>= 1;
+// x >>= 1;
r += 1;
}
return r;
diff --git a/src/partgpt.c b/src/partgpt.c
index 809781a..5e04ee5 100644
--- a/src/partgpt.c
+++ b/src/partgpt.c
@@ -138,12 +138,12 @@ arch_fnct_t arch_gpt=
.set_prev_status=set_next_status_gpt,
.set_next_status=set_next_status_gpt,
.test_structure=test_structure_gpt,
+ .get_part_type=NULL,
.set_part_type=NULL,
- .is_part_known=is_part_known_gpt,
.init_structure=init_structure_gpt,
.erase_list_part=NULL,
.get_partition_typename=get_partition_typename_gpt,
- .get_part_type=NULL
+ .is_part_known=&is_part_known_gpt
};
static void swap_uuid_and_efi_guid(efi_guid_t *guid)
diff --git a/src/parti386.c b/src/parti386.c
index b0d97a1..144049a 100644
--- a/src/parti386.c
+++ b/src/parti386.c
@@ -232,12 +232,12 @@ arch_fnct_t arch_i386= {
.set_prev_status=set_prev_status_i386,
.set_next_status=set_next_status_i386,
.test_structure=test_structure_i386,
+ .get_part_type=get_part_type_i386,
.set_part_type=set_part_type_i386,
- .is_part_known=is_part_known_i386,
.init_structure=init_structure_i386,
.erase_list_part=erase_list_part_i386,
.get_partition_typename=get_partition_typename_i386,
- .get_part_type=get_part_type_i386
+ .is_part_known=is_part_known_i386
};
static uint64_t C_H_S2offset(const disk_t *disk_car,const unsigned int C, const unsigned int H, const unsigned int S)
@@ -478,7 +478,6 @@ static void test_MBR_data(list_part_t *list_part)
static list_part_t *get_ext_data_i386(disk_t *disk_car, list_part_t *list_part, const int verbose, const int saveheader)
{
list_part_t *element;
- int res=0;
partition_t *partition_main_ext=NULL;
for(element=list_part;element!=NULL;element=element->next)
{
@@ -557,13 +556,11 @@ static list_part_t *get_ext_data_i386(disk_t *disk_car, list_part_t *list_part,
if(new_partition->errcode!=BAD_NOERR)
{
screen_buffer_add("%s\n",errmsg_i386_entry2partition(new_partition->errcode));
- res=1;
}
{
if((new_partition->part_offset<=partition_main_ext->part_offset) ||
(new_partition->part_offset+new_partition->part_size-1 > partition_main_ext->part_offset+partition_main_ext->part_size-1))
{ /* Must be IN partition_main_ext */
- res=1;
screen_buffer_add("Must be in extended partition\n");
aff_part_buffer(AFF_PART_ORDER|AFF_PART_STATUS,disk_car,partition_main_ext);
aff_part_buffer(AFF_PART_ORDER|AFF_PART_STATUS,disk_car,new_partition);
@@ -578,7 +575,6 @@ static list_part_t *get_ext_data_i386(disk_t *disk_car, list_part_t *list_part,
if(((partition->part_offset>=new_partition->part_offset) && (partition->part_offset<=new_partition->part_offset+new_partition->part_size-1)) ||
((partition->part_offset+partition->part_size-1>=new_partition->part_offset) && (partition->part_offset+partition->part_size-1<=new_partition->part_offset+partition->part_size-1)))
{ /* New Partition start or end mustn't been in partition */
- res=1;
screen_buffer_add( "Logical partition must be in its own extended partition\n");
aff_part_buffer(AFF_PART_ORDER|AFF_PART_STATUS,disk_car,partition);
aff_part_buffer(AFF_PART_ORDER|AFF_PART_STATUS,disk_car,new_partition);
@@ -598,13 +594,11 @@ static list_part_t *get_ext_data_i386(disk_t *disk_car, list_part_t *list_part,
if(new_partition->errcode!=BAD_NOERR)
{
screen_buffer_add("%s\n",errmsg_i386_entry2partition(new_partition->errcode));
- res=1;
}
{
if((new_partition->part_offset<=partition_main_ext->part_offset) ||
(new_partition->part_offset+new_partition->part_size-1 > partition_main_ext->part_offset+partition_main_ext->part_size-1))
{ /* Must be IN partition_main_ext */
- res=1;
screen_buffer_add( msg_SAME_SPACE);
aff_part_buffer(AFF_PART_ORDER|AFF_PART_STATUS,disk_car,partition_main_ext);
aff_part_buffer(AFF_PART_ORDER|AFF_PART_STATUS,disk_car,new_partition);
@@ -1453,17 +1447,9 @@ static int is_part_known_i386(const partition_t *partition)
static void init_structure_i386(const disk_t *disk_car,list_part_t *list_part, const int verbose)
{
- /* Reconstruit une structure
- * nbr_prim nombre de partition primaire
- * end_log_block : partition etendu du block etendu
- * nbr_log_block : nombre de block de partition etendu
- * devrait etre 0 ou 1 */
unsigned int nbr_prim=0, nbr_log_block=0;
unsigned int vista_partition=0;
- unsigned int log_block_size=0,biggest_log_block_size=0;
list_part_t *element;
- list_part_t *end_log_block=NULL;
- list_part_t *end_biggest_log_block=NULL;
list_part_t *new_list_part=NULL;
/* Create new list */
for(element=list_part;element!=NULL;element=element->next)
@@ -1492,62 +1478,70 @@ static void init_structure_i386(const disk_t *disk_car,list_part_t *list_part, c
new_list_part=insert_new_partition(new_list_part,element->part, 0, &insert_error);
}
}
- /* Verify */
- for(element=new_list_part;element!=NULL;element=element->next)
+
+/* Set primary, extended, logical */
+ if(vista_partition==0)
{
- if(can_be_ext(disk_car,element->part)==0)
+ /* log_block_size must be 0 or 1 for a valid partition table */
+ unsigned int log_block_size=0;
+ unsigned int biggest_log_block_size=0;
+ list_part_t *end_log_block=NULL;
+ list_part_t *end_biggest_log_block=NULL;
+ /* Verify */
+ for(element=new_list_part;element!=NULL;element=element->next)
{
- nbr_prim++;
- if((end_log_block!=NULL) && (end_log_block->next==element))
+ if(can_be_ext(disk_car,element->part)==0)
{
- if(log_block_size>biggest_log_block_size)
+ nbr_prim++;
+ if((end_log_block!=NULL) && (end_log_block->next==element))
{
- biggest_log_block_size=log_block_size;
- end_biggest_log_block=end_log_block;
+ if(log_block_size>biggest_log_block_size)
+ {
+ biggest_log_block_size=log_block_size;
+ end_biggest_log_block=end_log_block;
+ }
+ nbr_log_block++;
+ end_log_block=NULL;
}
- nbr_log_block++;
- end_log_block=NULL;
+ }
+ else
+ {
+ log_block_size++;
+ end_log_block=element;
}
}
- else
- {
- log_block_size++;
- end_log_block=element;
- }
- }
- /* Verification */
- if((end_log_block!=NULL) && (end_log_block->next==NULL))
- {
- if(log_block_size>biggest_log_block_size)
+ /* Verification */
+ if((end_log_block!=NULL) && (end_log_block->next==NULL))
{
- biggest_log_block_size=log_block_size;
- end_biggest_log_block=end_log_block;
- }
- nbr_log_block++;
- }
- if(verbose>1)
- log_info("\nRes: nbr_prim %u, nbr_log_block %u, vista_partition=%u\n", nbr_prim, nbr_log_block, vista_partition);
-/* Set primary, extended, logical */
- if(vista_partition==0 && nbr_prim+nbr_log_block<=4)
- {
- int set_prim_bootable_done=0;
- for(element=end_biggest_log_block;element!=NULL && can_be_ext(disk_car,element->part);element=element->prev)
- {
- element->part->status=STATUS_LOG;
+ if(log_block_size>biggest_log_block_size)
+ {
+ end_biggest_log_block=end_log_block;
+ }
+ nbr_log_block++;
}
- for(element=new_list_part;element!=NULL;element=element->next)
+ if(verbose>1)
+ log_info("\nRes: nbr_prim %u, nbr_log_block %u, vista_partition=%u\n", nbr_prim, nbr_log_block, vista_partition);
+ if(nbr_prim+nbr_log_block<=4)
{
- if(element->part->status!=STATUS_LOG)
+ int set_prim_bootable_done=0;
+ for(element=end_biggest_log_block;element!=NULL && can_be_ext(disk_car,element->part);element=element->prev)
{
- /* The first primary partition is bootable unless it's a swap */
- if(set_prim_bootable_done==0 &&
- element->part->upart_type!=UP_LINSWAP && element->part->upart_type!=UP_LVM && element->part->upart_type!=UP_LVM2)
+ element->part->status=STATUS_LOG;
+ }
+ for(element=new_list_part;element!=NULL;element=element->next)
+ {
+ if(element->part->status!=STATUS_LOG)
{
- element->part->status=STATUS_PRIM_BOOT;
- set_prim_bootable_done=1;
+ /* The first primary partition is bootable unless it's a swap */
+ if(set_prim_bootable_done==0 &&
+ element->part->upart_type!=UP_LINSWAP && element->part->upart_type!=UP_LVM && element->part->upart_type!=UP_LVM2)
+ {
+ element->part->status=STATUS_PRIM_BOOT;
+ set_prim_bootable_done=1;
+ }
+ else
+ element->part->status=STATUS_PRIM;
}
- else
- element->part->status=STATUS_PRIM;
}
}
}
diff --git a/src/partmac.c b/src/partmac.c
index a67f06d..e196943 100644
--- a/src/partmac.c
+++ b/src/partmac.c
@@ -102,12 +102,12 @@ arch_fnct_t arch_mac=
.set_prev_status=set_next_status_mac,
.set_next_status=set_next_status_mac,
.test_structure=test_structure_mac,
+ .get_part_type=get_part_type_mac,
.set_part_type=set_part_type_mac,
- .is_part_known=is_part_known_mac,
.init_structure=init_structure_mac,
.erase_list_part=NULL,
.get_partition_typename=get_partition_typename_mac,
- .get_part_type=get_part_type_mac
+ .is_part_known=is_part_known_mac
};
static unsigned int get_part_type_mac(const partition_t *partition)
diff --git a/src/partnone.c b/src/partnone.c
index d9a9c99..25436a9 100644
--- a/src/partnone.c
+++ b/src/partnone.c
@@ -134,12 +134,12 @@ arch_fnct_t arch_none=
.set_prev_status=set_next_status_none,
.set_next_status=set_next_status_none,
.test_structure=test_structure_none,
+ .get_part_type=get_part_type_none,
.set_part_type=set_part_type_none,
- .is_part_known=is_part_known_none,
.init_structure=init_structure_none,
.erase_list_part=NULL,
.get_partition_typename=get_partition_typename_none,
- .get_part_type=get_part_type_none
+ .is_part_known=is_part_known_none
};
unsigned int get_part_type_none(const partition_t *partition)
diff --git a/src/partsun.c b/src/partsun.c
index ad701b0..922030c 100644
--- a/src/partsun.c
+++ b/src/partsun.c
@@ -107,12 +107,12 @@ arch_fnct_t arch_sun=
.set_prev_status=set_next_status_sun,
.set_next_status=set_next_status_sun,
.test_structure=test_structure_sun,
+ .get_part_type=get_part_type_sun,
.set_part_type=set_part_type_sun,
- .is_part_known=is_part_known_sun,
.init_structure=init_structure_sun,
.erase_list_part=NULL,
.get_partition_typename=get_partition_typename_sun,
- .get_part_type=get_part_type_sun
+ .is_part_known=is_part_known_sun
};
static unsigned int get_part_type_sun(const partition_t *partition)
diff --git a/src/partxbox.c b/src/partxbox.c
index 93c35b2..2dfdceb 100644
--- a/src/partxbox.c
+++ b/src/partxbox.c
@@ -80,12 +80,12 @@ arch_fnct_t arch_xbox=
.set_prev_status=set_next_status_xbox,
.set_next_status=set_next_status_xbox,
.test_structure=test_structure_xbox,
+ .get_part_type=get_part_type_xbox,
.set_part_type=set_part_type_xbox,
- .is_part_known=is_part_known_xbox,
.init_structure=init_structure_xbox,
.erase_list_part=NULL,
.get_partition_typename=get_partition_typename_xbox,
- .get_part_type=get_part_type_xbox
+ .is_part_known=is_part_known_xbox
};
static unsigned int get_part_type_xbox(const partition_t *partition)
diff --git a/src/pdisksel.c b/src/pdisksel.c
index 4a714ec..bf21c15 100644
--- a/src/pdisksel.c
+++ b/src/pdisksel.c
@@ -79,6 +79,8 @@ static void photorec_disk_selection_ncurses(int verbose, const char *recup_dir,
static alloc_data_t list_search_space={
.list = TD_LIST_HEAD_INIT(list_search_space.list)
};
+ if(list_disk==NULL)
+ return ;
/* ncurses interface */
while(done==0)
{
@@ -112,8 +114,7 @@ static void photorec_disk_selection_ncurses(int verbose, const char *recup_dir,
else
options="PNOQ";
{
- int line=INTER_NOTE_Y;
- mvwaddstr(stdscr,line++,0,"Note: ");
+ mvwaddstr(stdscr, INTER_NOTE_Y,0,"Note: ");
#if defined(__CYGWIN__) || defined(__MINGW32__)
#else
#ifndef DJGPP
@@ -129,11 +130,11 @@ static void photorec_disk_selection_ncurses(int verbose, const char *recup_dir,
#endif
#endif
#endif
- wmove(stdscr,line++,0);
+ wmove(stdscr, INTER_NOTE_Y+1, 0);
wprintw(stdscr,"Disk capacity must be correctly detected for a successful recovery.");
- wmove(stdscr,line++,0);
+ wmove(stdscr, INTER_NOTE_Y+2, 0);
wprintw(stdscr,"If a disk listed above has incorrect size, check HD jumper settings, BIOS");
- wmove(stdscr,line++,0);
+ wmove(stdscr, INTER_NOTE_Y+3, 0);
wprintw(stdscr,"detection, and install the latest OS patches and disk drivers.");
}
command = wmenuSelect_ext(stdscr, INTER_NOTE_Y-1, INTER_DISK_Y, INTER_DISK_X, menuMain, 8,
diff --git a/src/photorec.c b/src/photorec.c
index 45375e8..90ec7e8 100644
--- a/src/photorec.c
+++ b/src/photorec.c
@@ -1119,7 +1119,7 @@ int main( int argc, char **argv )
if(start_ncurses("PhotoRec", argv[0]))
return 1;
#endif
- create_log=log_open(logfile, create_log, 1, "PhotoRec", argc, argv);
+ log_open(logfile, create_log, 1, "PhotoRec", argc, argv);
log_info("PhotoRec %s, Data Recovery Utility, %s\nChristophe GRENIER <grenier@cgsecurity.org>\nhttp://www.cgsecurity.org\n", VERSION, TESTDISKDATE);
log_info("OS: %s\n" , get_os());
log_info("Compiler: %s\n", get_compiler());
@@ -1385,7 +1385,7 @@ int file_finish(file_recovery_t *file_recovery, const char *recup_dir, const int
free_list_allocation(&file_recovery->location);
}
if(file_recovery->file_size==0 && file_recovery->offset_error!=0)
- file_recovered=-1;
+ file_recovered = -1;
else
reset_file_recovery(file_recovery);
#ifdef DEBUG_FILE_FINISH
diff --git a/src/ppartsel.c b/src/ppartsel.c
index c71ed4c..63662da 100644
--- a/src/ppartsel.c
+++ b/src/ppartsel.c
@@ -75,8 +75,6 @@ void menu_photorec(disk_t *disk_car, const int verbose, const char *recup_dir, f
{
int insert_error=0;
list_part_t *list_part;
- list_part_t *element;
- partition_t *partition_wd;
list_part_t *current_element;
int allow_partial_last_cylinder=0;
int paranoid=1;
@@ -104,17 +102,25 @@ void menu_photorec(disk_t *disk_car, const int verbose, const char *recup_dir, f
};
#endif
list_part=disk_car->arch->read_part(disk_car,verbose,0);
- partition_wd=new_whole_disk(disk_car);
- list_part=insert_new_partition(list_part, partition_wd, 0, &insert_error);
- if(insert_error>0)
{
- free(partition_wd);
+ partition_t *partition_wd;
+ partition_wd=new_whole_disk(disk_car);
+ list_part=insert_new_partition(list_part, partition_wd, 0, &insert_error);
+ if(insert_error>0)
+ {
+ free(partition_wd);
+ }
}
- for(element=list_part;element!=NULL;element=element->next)
+ if(list_part==NULL)
+ return;
{
- log_partition(disk_car,element->part);
+ list_part_t *element;
+ for(element=list_part;element!=NULL;element=element->next)
+ {
+ log_partition(disk_car,element->part);
+ }
}
- if(list_part!=NULL && list_part->next!=NULL)
+ if(list_part->next!=NULL)
{
current_element_num=1;
current_element=list_part->next;
@@ -265,6 +271,7 @@ void menu_photorec(disk_t *disk_car, const int verbose, const char *recup_dir, f
}
else if(isdigit(*current_cmd[0]))
{
+ list_part_t *element;
unsigned int order;
order= atoi(*current_cmd);
while(*current_cmd[0]!=',' && *current_cmd[0]!='\0')
@@ -285,6 +292,7 @@ void menu_photorec(disk_t *disk_car, const int verbose, const char *recup_dir, f
#ifdef HAVE_NCURSES
else
{ /* ncurses interface */
+ list_part_t *element;
unsigned int i;
aff_copy(stdscr);
wmove(stdscr,4,0);
diff --git a/src/rfs_dir.c b/src/rfs_dir.c
index 6951b82..6303dda 100644
--- a/src/rfs_dir.c
+++ b/src/rfs_dir.c
@@ -138,20 +138,22 @@ static int file_read(dal_t *dal, void *buff, blk_t block, blk_t count) {
static int file_write(dal_t *dal, void *buff, blk_t block, blk_t count)
{
- uint64_t off, blocklen;
if (!dal || !buff)
return 0;
+#ifdef ENABLE_REISERFS_WRITE
+ {
+ uint64_t off, blocklen;
#ifdef HAVE_DAL_T_BLOCK_SIZE
- off = (uint64_t)block * (uint64_t)dal->block_size;
- blocklen = (uint64_t)count * (uint64_t)dal->block_size;
+ off = (uint64_t)block * (uint64_t)dal->block_size;
+ blocklen = (uint64_t)count * (uint64_t)dal->block_size;
#else
- off = (uint64_t)block * (uint64_t)dal->blocksize;
- blocklen = (uint64_t)count * (uint64_t)dal->blocksize;
+ off = (uint64_t)block * (uint64_t)dal->blocksize;
+ blocklen = (uint64_t)count * (uint64_t)dal->blocksize;
#endif
-#ifdef ENABLE_REISERFS_WRITE
- if(my_data->disk_car->write(my_data->disk_car,blocklen,buff,my_data->partition->part_offset+off))
- return 0;
- return 1;
+ if(my_data->disk_car->write(my_data->disk_car,blocklen,buff,my_data->partition->part_offset+off))
+ return 0;
+ return 1;
+ }
#else
log_info("reiser file_write not implemented\n");
return 0;
diff --git a/src/savehdr.c b/src/savehdr.c
index 0cbea56..fb78963 100644
--- a/src/savehdr.c
+++ b/src/savehdr.c
@@ -80,11 +80,11 @@ int save_header(disk_t *disk_car,partition_t *partition, const int verbose)
(unsigned long)(partition->part_size/disk_car->sector_size));
}
if(fwrite(buffer,DEFAULT_SECTOR_SIZE,1,f_backup)!=1)
- res=-1;
+ res = -1;
if(res>=0 && disk_car->read(disk_car,256*DEFAULT_SECTOR_SIZE, buffer, partition->part_offset)!=0)
- res=-1;
+ res = -1;
if(res>=0 && fwrite(buffer,DEFAULT_SECTOR_SIZE,256,f_backup)!=256)
- res=-1;
+ res = -1;
fclose(f_backup);
free(buffer);
return res;
diff --git a/src/tdisksel.c b/src/tdisksel.c
index 561a043..dadf1e1 100644
--- a/src/tdisksel.c
+++ b/src/tdisksel.c
@@ -60,6 +60,7 @@ static int testdisk_disk_selection_ncurses(int verbose,int dump_ind, const list_
unsigned int menu=0;
int offset=0;
int pos_num=0;
+ int use_sudo=0;
const list_disk_t *element_disk;
const list_disk_t *current_disk;
static struct MenuItem menuMain[]=
@@ -70,12 +71,14 @@ static int testdisk_disk_selection_ncurses(int verbose,int dump_ind, const list_
{ 'Q',"Quit","Quit program"},
{ 0,NULL,NULL}
};
- current_disk=list_disk;
- if(current_disk==NULL)
+ if(list_disk==NULL)
{
- return intrf_no_disk("TestDisk");
+ use_sudo=intrf_no_disk("TestDisk");
}
- /* ncurses interface */
+ if(list_disk==NULL || use_sudo>0)
+ return use_sudo;
+ current_disk=list_disk;
+ /* ncurses interface */
while(1)
{
const char *options;
@@ -129,7 +132,7 @@ static int testdisk_disk_selection_ncurses(int verbose,int dump_ind, const list_
waddstr(stdscr,"Disk capacity must be correctly detected for a successful recovery.");
wmove(stdscr,line++,0);
wprintw(stdscr,"If a disk listed above has incorrect size, check HD jumper settings, BIOS");
- wmove(stdscr,line++,0);
+ wmove(stdscr,line,0);
wprintw(stdscr,"detection, and install the latest OS patches and disk drivers.");
}
command = wmenuSelect_ext(stdscr, INTER_NOTE_Y-1, INTER_DISK_Y, INTER_DISK_X, menuMain, 8,