Improve default partition table selection
This commit is contained in:
parent
70cdc4ed1b
commit
2832afabc7
14 changed files with 100 additions and 85 deletions
|
@ -72,6 +72,8 @@
|
|||
#include "log.h"
|
||||
#include "hdaccess.h"
|
||||
|
||||
extern const arch_fnct_t arch_none;
|
||||
|
||||
static const char *fewf_description(disk_t *disk);
|
||||
static const char *fewf_description_short(disk_t *disk);
|
||||
static int fewf_clean(disk_t *disk);
|
||||
|
@ -94,7 +96,7 @@ struct info_fewf_struct
|
|||
unsigned int buffer_size;
|
||||
};
|
||||
|
||||
disk_t *fewf_init(const char *device, const arch_fnct_t *arch, const int mode)
|
||||
disk_t *fewf_init(const char *device, const int mode)
|
||||
{
|
||||
unsigned int num_files=0;
|
||||
char **filenames= NULL;
|
||||
|
@ -217,7 +219,7 @@ disk_t *fewf_init(const char *device, const arch_fnct_t *arch, const int mode)
|
|||
#endif
|
||||
disk=(disk_t *)MALLOC(sizeof(*disk));
|
||||
init_disk(disk);
|
||||
disk->arch=arch;
|
||||
disk->arch=&arch_none;
|
||||
disk->device=strdup(device);
|
||||
disk->data=data;
|
||||
disk->description=fewf_description;
|
||||
|
|
|
@ -24,7 +24,7 @@ extern "C" {
|
|||
#endif
|
||||
|
||||
#if defined(HAVE_LIBEWF_H) && defined(HAVE_LIBEWF)
|
||||
disk_t *fewf_init(const char *device, const arch_fnct_t *arch, const int testdisk_mode);
|
||||
disk_t *fewf_init(const char *device, const int testdisk_mode);
|
||||
#endif
|
||||
const char*td_ewf_version(void);
|
||||
|
||||
|
|
|
@ -112,6 +112,8 @@
|
|||
//#define HDCLONE 1
|
||||
#endif
|
||||
|
||||
extern const arch_fnct_t arch_none;
|
||||
|
||||
struct tdewf_file_header
|
||||
{
|
||||
/* The EWF file signature (magic header)
|
||||
|
@ -204,7 +206,7 @@ list_disk_t *insert_new_disk_nodup(list_disk_t *list_disk, disk_t *disk_car, con
|
|||
#endif
|
||||
|
||||
#ifdef HAVE_GLOB_H
|
||||
static list_disk_t *hd_glob_parse(const char *device_pattern, list_disk_t *list_disk, const int verbose, const arch_fnct_t *arch, const int testdisk_mode)
|
||||
static list_disk_t *hd_glob_parse(const char *device_pattern, list_disk_t *list_disk, const int verbose, const int testdisk_mode)
|
||||
{
|
||||
glob_t globbuf;
|
||||
globbuf.gl_offs = 0;
|
||||
|
@ -214,7 +216,7 @@ static list_disk_t *hd_glob_parse(const char *device_pattern, list_disk_t *list_
|
|||
unsigned int i;
|
||||
for (i=0; i<globbuf.gl_pathc; i++)
|
||||
{
|
||||
list_disk=insert_new_disk(list_disk,file_test_availability(globbuf.gl_pathv[i], verbose,arch,testdisk_mode));
|
||||
list_disk=insert_new_disk(list_disk, file_test_availability(globbuf.gl_pathv[i], verbose, testdisk_mode));
|
||||
}
|
||||
}
|
||||
globfree(&globbuf);
|
||||
|
@ -223,14 +225,14 @@ static list_disk_t *hd_glob_parse(const char *device_pattern, list_disk_t *list_
|
|||
#endif
|
||||
|
||||
|
||||
list_disk_t *hd_parse(list_disk_t *list_disk, const int verbose, const arch_fnct_t *arch, const int testdisk_mode)
|
||||
list_disk_t *hd_parse(list_disk_t *list_disk, const int verbose, const int testdisk_mode)
|
||||
{
|
||||
unsigned int i;
|
||||
#ifdef DJGPP
|
||||
int ind_stop=0;
|
||||
for(i=0x80;(i<0x88)&&!ind_stop;i++)
|
||||
{
|
||||
disk_t *disk_car=hd_identify(verbose,i,arch,testdisk_mode);
|
||||
disk_t *disk_car=hd_identify(verbose, i, testdisk_mode);
|
||||
if(disk_car)
|
||||
list_disk=insert_new_disk(list_disk,disk_car);
|
||||
else
|
||||
|
@ -247,7 +249,7 @@ list_disk_t *hd_parse(list_disk_t *list_disk, const int verbose, const arch_fnct
|
|||
for(i=0;i<16;i++)
|
||||
{
|
||||
device_scsi[strlen(device_scsi)-1]='a'+i;
|
||||
list_disk=insert_new_disk(list_disk,file_test_availability(device_scsi,verbose,arch,testdisk_mode));
|
||||
list_disk=insert_new_disk(list_disk, file_test_availability(device_scsi, verbose, testdisk_mode));
|
||||
}
|
||||
#endif
|
||||
/* Disk */
|
||||
|
@ -258,7 +260,7 @@ list_disk_t *hd_parse(list_disk_t *list_disk, const int verbose, const arch_fnct
|
|||
{
|
||||
disk_t *disk_car;
|
||||
sprintf(device_hd,"\\\\.\\PhysicalDrive%u", i);
|
||||
disk_car=file_test_availability_win32(device_hd,verbose,arch,testdisk_mode);
|
||||
disk_car=file_test_availability_win32(device_hd, verbose, testdisk_mode);
|
||||
if(do_insert>0 || (testdisk_mode&TESTDISK_O_ALL)==TESTDISK_O_ALL)
|
||||
list_disk=insert_new_disk(list_disk,disk_car);
|
||||
else
|
||||
|
@ -270,7 +272,7 @@ list_disk_t *hd_parse(list_disk_t *list_disk, const int verbose, const arch_fnct
|
|||
{
|
||||
disk_t *disk_car;
|
||||
device_cdrom[strlen(device_cdrom)-2]=i;
|
||||
disk_car=file_test_availability_win32(device_cdrom,verbose,arch,testdisk_mode);
|
||||
disk_car=file_test_availability_win32(device_cdrom, verbose, testdisk_mode);
|
||||
if((testdisk_mode&TESTDISK_O_ALL)==TESTDISK_O_ALL)
|
||||
list_disk=insert_new_disk(list_disk,disk_car);
|
||||
else
|
||||
|
@ -284,12 +286,12 @@ list_disk_t *hd_parse(list_disk_t *list_disk, const int verbose, const arch_fnct
|
|||
for(i=0;i<20;i++)
|
||||
{
|
||||
snprintf(device, sizeof(device), "/dev/disk%u", i);
|
||||
list_disk=insert_new_disk(list_disk,file_test_availability(device, verbose, arch, testdisk_mode));
|
||||
list_disk=insert_new_disk(list_disk, file_test_availability(device, verbose, testdisk_mode));
|
||||
}
|
||||
for(i=0;i<20;i++)
|
||||
{
|
||||
snprintf(device, sizeof(device), "/dev/rdisk%u", i);
|
||||
list_disk=insert_new_disk(list_disk,file_test_availability(device, verbose, arch, testdisk_mode));
|
||||
list_disk=insert_new_disk(list_disk, file_test_availability(device, verbose, testdisk_mode));
|
||||
}
|
||||
}
|
||||
#elif defined(TARGET_LINUX)
|
||||
|
@ -307,13 +309,13 @@ list_disk_t *hd_parse(list_disk_t *list_disk, const int verbose, const arch_fnct
|
|||
for(i=0;i<8;i++)
|
||||
{
|
||||
device_ide[strlen(device_ide)-1]='a'+i;
|
||||
list_disk=insert_new_disk(list_disk,file_test_availability(device_ide,verbose,arch,testdisk_mode));
|
||||
list_disk=insert_new_disk(list_disk, file_test_availability(device_ide, verbose, testdisk_mode));
|
||||
}
|
||||
/* Disk SCSI */
|
||||
for(i=0;i<26;i++)
|
||||
{
|
||||
device_scsi[strlen(device_scsi)-1]='a'+i;
|
||||
list_disk=insert_new_disk(list_disk,file_test_availability(device_scsi,verbose,arch,testdisk_mode));
|
||||
list_disk=insert_new_disk(list_disk, file_test_availability(device_scsi, verbose, testdisk_mode));
|
||||
}
|
||||
/* Device RAID Compaq */
|
||||
for(j=0;j<8;j++)
|
||||
|
@ -322,51 +324,51 @@ list_disk_t *hd_parse(list_disk_t *list_disk, const int verbose, const arch_fnct
|
|||
for(i=0;i<8;i++)
|
||||
{
|
||||
device_ida[strlen(device_ida)-1]='0'+i;
|
||||
list_disk=insert_new_disk(list_disk,file_test_availability(device_ida,verbose,arch,testdisk_mode));
|
||||
list_disk=insert_new_disk(list_disk, file_test_availability(device_ida, verbose, testdisk_mode));
|
||||
}
|
||||
}
|
||||
for(i=0;i<8;i++)
|
||||
{
|
||||
device_cciss[strlen(device_cciss)-1]='0'+i;
|
||||
list_disk=insert_new_disk(list_disk,file_test_availability(device_cciss,verbose,arch,testdisk_mode));
|
||||
list_disk=insert_new_disk(list_disk, file_test_availability(device_cciss, verbose, testdisk_mode));
|
||||
}
|
||||
/* Device RAID */
|
||||
for(i=0;i<10;i++)
|
||||
{
|
||||
snprintf(device,sizeof(device),"/dev/rd/c0d%u",i);
|
||||
list_disk=insert_new_disk(list_disk,file_test_availability(device,verbose,arch,testdisk_mode));
|
||||
list_disk=insert_new_disk(list_disk, file_test_availability(device, verbose, testdisk_mode));
|
||||
}
|
||||
/* Device RAID IDE */
|
||||
for(i=0;i<15;i++)
|
||||
{
|
||||
snprintf(device,sizeof(device),"/dev/ataraid/d%u",i);
|
||||
list_disk=insert_new_disk(list_disk,file_test_availability(device,verbose,arch,testdisk_mode));
|
||||
list_disk=insert_new_disk(list_disk, file_test_availability(device, verbose, testdisk_mode));
|
||||
}
|
||||
/* Parallel port IDE disk */
|
||||
for(i=0;i<4;i++)
|
||||
{
|
||||
device_p_ide[strlen(device_p_ide)-1]='a'+i;
|
||||
list_disk=insert_new_disk(list_disk,file_test_availability(device_p_ide,verbose,arch,testdisk_mode));
|
||||
list_disk=insert_new_disk(list_disk, file_test_availability(device_p_ide, verbose, testdisk_mode));
|
||||
}
|
||||
/* I2O hard disk */
|
||||
for(i=0;i<26;i++)
|
||||
{
|
||||
device_i2o_hd[strlen(device_i2o_hd)-1]='a'+i;
|
||||
list_disk=insert_new_disk(list_disk,file_test_availability(device_i2o_hd,verbose,arch,testdisk_mode));
|
||||
list_disk=insert_new_disk(list_disk, file_test_availability(device_i2o_hd, verbose, testdisk_mode));
|
||||
}
|
||||
/* Memory card */
|
||||
for(i=0;i<10;i++)
|
||||
{
|
||||
device_mmc[strlen(device_mmc)-1]='0'+i;
|
||||
list_disk=insert_new_disk(list_disk,file_test_availability(device_mmc,verbose,arch,testdisk_mode));
|
||||
list_disk=insert_new_disk(list_disk, file_test_availability(device_mmc, verbose, testdisk_mode));
|
||||
}
|
||||
#ifdef HAVE_GLOB_H
|
||||
list_disk=hd_glob_parse("/dev/mapper/*", list_disk, verbose, arch, testdisk_mode);
|
||||
list_disk=hd_glob_parse("/dev/mapper/*", list_disk, verbose, testdisk_mode);
|
||||
/* Software Raid (partition level) */
|
||||
list_disk=hd_glob_parse("/dev/md*", list_disk, verbose, arch, testdisk_mode);
|
||||
list_disk=hd_glob_parse("/dev/sr?", list_disk, verbose, arch, testdisk_mode);
|
||||
list_disk=hd_glob_parse("/dev/md*", list_disk, verbose, testdisk_mode);
|
||||
list_disk=hd_glob_parse("/dev/sr?", list_disk, verbose, testdisk_mode);
|
||||
/* Software (ATA)Raid configured (disk level) via dmraid */
|
||||
list_disk=hd_glob_parse("/dev/dm-*", list_disk, verbose, arch, testdisk_mode);
|
||||
list_disk=hd_glob_parse("/dev/dm-*", list_disk, verbose, testdisk_mode);
|
||||
#endif
|
||||
}
|
||||
#elif defined(TARGET_SOLARIS)
|
||||
|
@ -377,14 +379,14 @@ list_disk_t *hd_parse(list_disk_t *list_disk, const int verbose, const arch_fnct
|
|||
if(i!=7)
|
||||
{
|
||||
rdsk[13]='0'+i;
|
||||
list_disk=insert_new_disk(list_disk,file_test_availability(rdsk,verbose,arch,testdisk_mode));
|
||||
list_disk=insert_new_disk(list_disk, file_test_availability(rdsk, verbose, testdisk_mode));
|
||||
}
|
||||
}
|
||||
}
|
||||
#elif defined(__HAIKU__)
|
||||
{
|
||||
#ifdef HAVE_GLOB_H
|
||||
list_disk=hd_glob_parse("/dev/disk/*/*/master/raw", list_disk, verbose, arch, testdisk_mode);
|
||||
list_disk=hd_glob_parse("/dev/disk/*/*/master/raw", list_disk, verbose, testdisk_mode);
|
||||
#endif
|
||||
}
|
||||
#else
|
||||
|
@ -406,61 +408,61 @@ list_disk_t *hd_parse(list_disk_t *list_disk, const int verbose, const arch_fnct
|
|||
for(i=0;i<8;i++)
|
||||
{
|
||||
device_ide[strlen(device_ide)-1]='0'+i;
|
||||
list_disk=insert_new_disk(list_disk,file_test_availability(device_ide,verbose,arch,testdisk_mode));
|
||||
list_disk=insert_new_disk(list_disk, file_test_availability(device_ide, verbose, testdisk_mode));
|
||||
}
|
||||
for(i=0;i<8;i++)
|
||||
{
|
||||
device_ide2[strlen(device_ide2)-1]='0'+i;
|
||||
list_disk=insert_new_disk(list_disk,file_test_availability(device_ide2,verbose,arch,testdisk_mode));
|
||||
list_disk=insert_new_disk(list_disk, file_test_availability(device_ide2, verbose, testdisk_mode));
|
||||
}
|
||||
for(i=0;i<8;i++)
|
||||
{
|
||||
device_ide3[strlen(device_ide3)-2]='0'+i;
|
||||
list_disk=insert_new_disk(list_disk,file_test_availability(device_ide3,verbose,arch,testdisk_mode));
|
||||
list_disk=insert_new_disk(list_disk, file_test_availability(device_ide3, verbose, testdisk_mode));
|
||||
}
|
||||
for(i=0;i<8;i++)
|
||||
{
|
||||
device_ide4[strlen(device_ide4)-2]='0'+i;
|
||||
list_disk=insert_new_disk(list_disk,file_test_availability(device_ide4,verbose,arch,testdisk_mode));
|
||||
list_disk=insert_new_disk(list_disk, file_test_availability(device_ide4, verbose, testdisk_mode));
|
||||
}
|
||||
for(i=0;i<8;i++)
|
||||
{
|
||||
device_ide_hd[strlen(device_ide_hd)-1]='0'+i;
|
||||
list_disk=insert_new_disk(list_disk,file_test_availability(device_ide_hd,verbose,arch,testdisk_mode));
|
||||
list_disk=insert_new_disk(list_disk, file_test_availability(device_ide_hd, verbose, testdisk_mode));
|
||||
}
|
||||
/* Disk SCSI */
|
||||
for(i=0;i<8;i++)
|
||||
{
|
||||
device_scsi[strlen(device_scsi)-1]='0'+i;
|
||||
list_disk=insert_new_disk(list_disk,file_test_availability(device_scsi,verbose,arch,testdisk_mode));
|
||||
list_disk=insert_new_disk(list_disk, file_test_availability(device_scsi, verbose, testdisk_mode));
|
||||
}
|
||||
for(i=0;i<8;i++)
|
||||
{
|
||||
device_scsi2[strlen(device_scsi2)-2]='0'+i;
|
||||
list_disk=insert_new_disk(list_disk,file_test_availability(device_scsi2,verbose,arch,testdisk_mode));
|
||||
list_disk=insert_new_disk(list_disk, file_test_availability(device_scsi2, verbose, testdisk_mode));
|
||||
}
|
||||
for(i=0;i<8;i++)
|
||||
{
|
||||
device_scsi_hd[strlen(device_scsi_hd)-1]='0'+i;
|
||||
list_disk=insert_new_disk(list_disk,file_test_availability(device_scsi_hd,verbose,arch,testdisk_mode));
|
||||
list_disk=insert_new_disk(list_disk, file_test_availability(device_scsi_hd, verbose, testdisk_mode));
|
||||
}
|
||||
/* optical disks */
|
||||
for(i=0;i<8;i++)
|
||||
{
|
||||
device_optdisk[strlen(device_scsi)-1]='a'+i;
|
||||
list_disk=insert_new_disk(list_disk,file_test_availability(device_optdisk,verbose,arch,testdisk_mode));
|
||||
list_disk=insert_new_disk(list_disk, file_test_availability(device_optdisk, verbose, testdisk_mode));
|
||||
}
|
||||
/* CD */
|
||||
for(i=0;i<8;i++)
|
||||
{
|
||||
device_cd[strlen(device_cd)-1]='0'+i;
|
||||
list_disk=insert_new_disk(list_disk,file_test_availability(device_cd,verbose,arch,testdisk_mode));
|
||||
list_disk=insert_new_disk(list_disk, file_test_availability(device_cd, verbose, testdisk_mode));
|
||||
}
|
||||
/* VND */
|
||||
for(i=0;i<4;i++)
|
||||
{
|
||||
device_vnd[strlen(device_vnd)-2]='0'+i;
|
||||
list_disk=insert_new_disk(list_disk,file_test_availability(device_vnd,verbose,arch,testdisk_mode));
|
||||
list_disk=insert_new_disk(list_disk, file_test_availability(device_vnd, verbose, testdisk_mode));
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
@ -1335,7 +1337,7 @@ static void autoset_geometry(disk_t *disk, const unsigned char *buffer, const in
|
|||
disk->geom.sectors_per_head / disk->geom.heads_per_cylinder;
|
||||
}
|
||||
|
||||
disk_t *file_test_availability(const char *device, const int verbose, const arch_fnct_t *arch, int testdisk_mode)
|
||||
disk_t *file_test_availability(const char *device, const int verbose, int testdisk_mode)
|
||||
{
|
||||
disk_t *disk_car=NULL;
|
||||
struct stat stat_rec;
|
||||
|
@ -1440,7 +1442,7 @@ disk_t *file_test_availability(const char *device, const int verbose, const arch
|
|||
else if(strcmp(device, "/dev/sda135") == 0)
|
||||
dos_nr = 0x87;
|
||||
if(dos_nr>0)
|
||||
disk_car = hd_identify(verbose, dos_nr, arch, testdisk_mode);
|
||||
disk_car = hd_identify(verbose, dos_nr, testdisk_mode);
|
||||
if(disk_car!=NULL)
|
||||
return disk_car;
|
||||
}
|
||||
|
@ -1449,13 +1451,13 @@ disk_t *file_test_availability(const char *device, const int verbose, const arch
|
|||
if(strncmp(device,"/dev/",5)!=0)
|
||||
{
|
||||
#if defined(HAVE_LIBEWF_H) && defined(HAVE_LIBEWF) && defined(HAVE_GLOB_H)
|
||||
return fewf_init(device, arch, testdisk_mode);
|
||||
return fewf_init(device, testdisk_mode);
|
||||
#endif
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
disk_car=(disk_t *)MALLOC(sizeof(*disk_car));
|
||||
disk_car->arch=arch;
|
||||
disk_car->arch=&arch_none;
|
||||
init_disk(disk_car);
|
||||
disk_car->device=strdup(device);
|
||||
data=(struct info_file_struct *)MALLOC(sizeof(*data));
|
||||
|
@ -1532,7 +1534,7 @@ disk_t *file_test_availability(const char *device, const int verbose, const arch
|
|||
free(disk_car);
|
||||
close(hd_h);
|
||||
#if defined(HAVE_LIBEWF_H) && defined(HAVE_LIBEWF)
|
||||
return fewf_init(device, arch, testdisk_mode);
|
||||
return fewf_init(device, testdisk_mode);
|
||||
#else
|
||||
return NULL;
|
||||
#endif
|
||||
|
@ -1612,7 +1614,7 @@ void hd_update_geometry(disk_t *disk, const int verbose)
|
|||
#ifdef DJGPP
|
||||
if(disk->description==disk_description)
|
||||
{
|
||||
struct info_disk_struct*data=disk->data;
|
||||
struct info_disk_struct*data=(struct info_disk_struct*)disk->data;
|
||||
data->geo_phys.cylinders=disk->geom.cylinders;
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -26,8 +26,8 @@ extern "C" {
|
|||
|
||||
void hd_update_geometry(disk_t *disk_car, const int verbose);
|
||||
void hd_update_all_geometry(const list_disk_t * list_disk, const int verbose);
|
||||
list_disk_t *hd_parse(list_disk_t *list_disk, const int verbose, const arch_fnct_t *arch, const int testdisk_mode);
|
||||
disk_t *file_test_availability(const char *device, const int verbose, const arch_fnct_t *arch, const int testdisk_mode);
|
||||
list_disk_t *hd_parse(list_disk_t *list_disk, const int verbose, const int testdisk_mode);
|
||||
disk_t *file_test_availability(const char *device, const int verbose, const int testdisk_mode);
|
||||
void update_disk_car_fields(disk_t *disk_car);
|
||||
void init_disk(disk_t *disk);
|
||||
int generic_clean(disk_t *disk_car);
|
||||
|
|
|
@ -46,6 +46,9 @@
|
|||
#define HDPARM_BUF_SIZ 0x1A
|
||||
#define MAX_IO_NBR 3
|
||||
#define MAX_HD_ERR 100
|
||||
|
||||
extern const arch_fnct_t arch_none;
|
||||
|
||||
static void free_dos_buffer(void);
|
||||
static int alloc_cmd_dos_buffer(void);
|
||||
static int hd_identify_enh_bios(disk_t *param_disk,const int verbose);
|
||||
|
@ -350,7 +353,7 @@ static int hd_identify_enh_bios(disk_t *disk_car,const int verbose)
|
|||
return 0;
|
||||
}
|
||||
|
||||
disk_t *hd_identify(const int verbose, const unsigned int disk, const arch_fnct_t *arch, const int testdisk_mode)
|
||||
disk_t *hd_identify(const int verbose, const unsigned int disk, const int testdisk_mode)
|
||||
{
|
||||
unsigned char buf[0x200];
|
||||
memset(buf,0,sizeof(buf));
|
||||
|
@ -368,7 +371,7 @@ disk_t *hd_identify(const int verbose, const unsigned int disk, const arch_fnct_
|
|||
data->disk=disk;
|
||||
data->bad_geometry=0;
|
||||
data->mode_enh=0;
|
||||
disk_car->arch=arch;
|
||||
disk_car->arch=&arch_none;
|
||||
snprintf(device,sizeof(device),"/dev/sda%u",disk);
|
||||
disk_car->device=strdup(device);
|
||||
disk_car->model=NULL;
|
||||
|
|
|
@ -31,7 +31,7 @@ struct info_disk_struct
|
|||
int bad_geometry;
|
||||
};
|
||||
|
||||
disk_t *hd_identify(const int verbose, const unsigned int disk, const arch_fnct_t *arch, const int testdisk_mode);
|
||||
disk_t *hd_identify(const int verbose, const unsigned int disk, const int testdisk_mode);
|
||||
const char *disk_description(disk_t *disk_car);
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
|
|
@ -42,10 +42,9 @@ extern const arch_fnct_t arch_none;
|
|||
extern const arch_fnct_t arch_sun;
|
||||
extern const arch_fnct_t arch_xbox;
|
||||
|
||||
void autodetect_arch(disk_t *disk)
|
||||
void autodetect_arch(disk_t *disk, const arch_fnct_t *arch)
|
||||
{
|
||||
list_part_t *list_part=NULL;
|
||||
const arch_fnct_t *arch=disk->arch;
|
||||
#ifdef DEBUG_PARTAUTO
|
||||
const int verbose=2;
|
||||
#else
|
||||
|
@ -53,7 +52,6 @@ void autodetect_arch(disk_t *disk)
|
|||
unsigned int old_levels;
|
||||
old_levels=log_set_levels(0);
|
||||
#endif
|
||||
if(list_part==NULL)
|
||||
{
|
||||
disk->arch=&arch_none;
|
||||
list_part=disk->arch->read_part(disk,verbose,0);
|
||||
|
@ -100,12 +98,31 @@ void autodetect_arch(disk_t *disk)
|
|||
{
|
||||
disk->arch_autodetected=disk->arch;
|
||||
log_info("Partition table type (auto): %s\n", disk->arch->part_name);
|
||||
part_free_list(list_part);
|
||||
return ;
|
||||
}
|
||||
disk->arch_autodetected=NULL;
|
||||
if(arch!=NULL)
|
||||
{
|
||||
disk->arch=arch;
|
||||
}
|
||||
else
|
||||
{
|
||||
disk->arch_autodetected=NULL;
|
||||
disk->arch=arch;
|
||||
log_info("Partition table type default to %s\n", arch->part_name);
|
||||
#ifdef TARGET_SOLARIS
|
||||
disk->arch=&arch_sun;
|
||||
#elif defined __APPLE__
|
||||
#ifdef TESTDISK_LSB
|
||||
disk->arch=&arch_gpt;
|
||||
#else
|
||||
disk->arch=&arch_mac;
|
||||
#endif
|
||||
#else
|
||||
/* PC/Intel partition table is limited to 2 TB, 2^32 512-bytes sectors */
|
||||
if(disk->disk_size < ((uint64_t)1<<(32+9)))
|
||||
disk->arch=&arch_i386;
|
||||
else
|
||||
disk->arch=&arch_gpt;
|
||||
#endif
|
||||
}
|
||||
part_free_list(list_part);
|
||||
log_info("Partition table type default to %s\n", disk->arch->part_name);
|
||||
}
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
extern "C" {
|
||||
#endif
|
||||
|
||||
void autodetect_arch(disk_t *disk);
|
||||
void autodetect_arch(disk_t *disk, const arch_fnct_t *arch);
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* closing brace for extern "C" */
|
||||
|
|
|
@ -61,6 +61,8 @@
|
|||
#define INTER_NOTE_Y (LINES-4)
|
||||
#endif
|
||||
|
||||
extern const arch_fnct_t arch_none;
|
||||
|
||||
static int photorec_disk_selection_cli(struct ph_param *params, struct ph_options *options, const list_disk_t *list_disk, alloc_data_t *list_search_space)
|
||||
{
|
||||
const list_disk_t *element_disk;
|
||||
|
@ -90,7 +92,7 @@ static int photorec_disk_selection_cli(struct ph_param *params, struct ph_option
|
|||
current_search_space->end=current_search_space->end*disk->sector_size+disk->sector_size-1;
|
||||
}
|
||||
}
|
||||
autodetect_arch(disk);
|
||||
autodetect_arch(disk, &arch_none);
|
||||
params->disk=disk;
|
||||
if(interface_partition_type(disk, options->verbose, ¶ms->cmd_run)==0)
|
||||
menu_photorec(params, options, list_search_space);
|
||||
|
@ -266,7 +268,7 @@ static int photorec_disk_selection_ncurses(struct ph_param *params, struct ph_op
|
|||
{
|
||||
disk_t *disk=current_disk->disk;
|
||||
const int hpa_dco=is_hpa_or_dco(disk);
|
||||
autodetect_arch(disk);
|
||||
autodetect_arch(disk, &arch_none);
|
||||
params->disk=disk;
|
||||
if((hpa_dco==0 || interface_check_hidden_ncurses(disk, hpa_dco)==0) &&
|
||||
(options->expert == 0 ||
|
||||
|
|
|
@ -78,7 +78,6 @@
|
|||
#include "pdisksel.h"
|
||||
#include "dfxml.h"
|
||||
|
||||
extern const arch_fnct_t arch_none;
|
||||
extern file_enable_t list_file_enable[];
|
||||
|
||||
#ifdef HAVE_SIGACTION
|
||||
|
@ -109,7 +108,6 @@ int main( int argc, char **argv )
|
|||
list_disk_t *list_disk=NULL;
|
||||
list_disk_t *element_disk;
|
||||
const char *logfile="photorec.log";
|
||||
const arch_fnct_t *arch=&arch_none;
|
||||
FILE *log_handle=NULL;
|
||||
struct ph_options options={
|
||||
.paranoid=1,
|
||||
|
@ -201,7 +199,7 @@ int main( int argc, char **argv )
|
|||
params.cmd_device=argv[++i];
|
||||
params.cmd_run=argv[++i];
|
||||
/* There is no log currently */
|
||||
disk_car=file_test_availability(params.cmd_device, options.verbose, arch, testdisk_mode);
|
||||
disk_car=file_test_availability(params.cmd_device, options.verbose, testdisk_mode);
|
||||
if(disk_car==NULL)
|
||||
{
|
||||
printf("\nUnable to open file or device %s\n", params.cmd_device);
|
||||
|
@ -213,7 +211,7 @@ int main( int argc, char **argv )
|
|||
}
|
||||
else
|
||||
{
|
||||
disk_t *disk_car=file_test_availability(argv[i], options.verbose, arch, testdisk_mode);
|
||||
disk_t *disk_car=file_test_availability(argv[i], options.verbose, testdisk_mode);
|
||||
if(disk_car==NULL)
|
||||
{
|
||||
printf("\nUnable to open file or device %s\n",argv[i]);
|
||||
|
@ -325,7 +323,7 @@ int main( int argc, char **argv )
|
|||
screen_buffer_reset();
|
||||
/* Scan for available device only if no device or image has been supplied in parameter */
|
||||
if(list_disk==NULL)
|
||||
list_disk=hd_parse(list_disk, options.verbose, arch, testdisk_mode);
|
||||
list_disk=hd_parse(list_disk, options.verbose, testdisk_mode);
|
||||
hd_update_all_geometry(list_disk, options.verbose);
|
||||
/* Activate the cache, even if photorec has its own */
|
||||
for(element_disk=list_disk;element_disk!=NULL;element_disk=element_disk->next)
|
||||
|
|
|
@ -190,7 +190,7 @@ static int testdisk_disk_selection_ncurses(int verbose,int dump_ind, const list_
|
|||
{
|
||||
disk_t *disk=current_disk->disk;
|
||||
const int hpa_dco=is_hpa_or_dco(disk);
|
||||
autodetect_arch(disk);
|
||||
autodetect_arch(disk, NULL);
|
||||
autoset_unit(disk);
|
||||
if(interface_check_disk_capacity(disk)==0 &&
|
||||
interface_check_disk_access(disk, current_cmd)==0 &&
|
||||
|
@ -242,7 +242,7 @@ static int testdisk_disk_selection_cli(int verbose,int dump_ind, const list_disk
|
|||
(*current_cmd)++;
|
||||
{
|
||||
disk_t *disk=current_disk->disk;
|
||||
autodetect_arch(disk);
|
||||
autodetect_arch(disk, NULL);
|
||||
autoset_unit(disk);
|
||||
if(interface_check_disk_capacity(disk)==0 &&
|
||||
interface_check_disk_access(disk, current_cmd)==0 &&
|
||||
|
|
|
@ -67,10 +67,6 @@
|
|||
#include "autoset.h"
|
||||
#include "hidden.h"
|
||||
|
||||
extern const arch_fnct_t arch_i386;
|
||||
extern const arch_fnct_t arch_mac;
|
||||
extern const arch_fnct_t arch_sun;
|
||||
|
||||
#ifdef HAVE_SIGACTION
|
||||
static struct sigaction action;
|
||||
static void sighup_hdlr(int sig);
|
||||
|
@ -108,13 +104,6 @@ int main( int argc, char **argv )
|
|||
const char *cmd_device=NULL;
|
||||
char *cmd_run=NULL;
|
||||
const char *logfile="testdisk.log";
|
||||
#ifdef TARGET_SOLARIS
|
||||
const arch_fnct_t *arch=&arch_sun;
|
||||
#elif defined __APPLE__
|
||||
const arch_fnct_t *arch=&arch_mac;
|
||||
#else
|
||||
const arch_fnct_t *arch=&arch_i386;
|
||||
#endif
|
||||
FILE *log_handle=NULL;
|
||||
/* srand needed for GPT creation (weak is ok) */
|
||||
srand(time(NULL));
|
||||
|
@ -196,7 +185,7 @@ int main( int argc, char **argv )
|
|||
disk_t *disk_car;
|
||||
cmd_device=argv[++i];
|
||||
cmd_run=argv[++i];
|
||||
disk_car=file_test_availability(cmd_device,verbose,arch,testdisk_mode);
|
||||
disk_car=file_test_availability(cmd_device, verbose, testdisk_mode);
|
||||
if(disk_car==NULL)
|
||||
{
|
||||
printf("\nUnable to open file or device %s\n",cmd_device);
|
||||
|
@ -208,7 +197,7 @@ int main( int argc, char **argv )
|
|||
}
|
||||
else
|
||||
{
|
||||
disk_t *disk_car=file_test_availability(argv[i],verbose,arch,testdisk_mode);
|
||||
disk_t *disk_car=file_test_availability(argv[i], verbose, testdisk_mode);
|
||||
if(disk_car==NULL)
|
||||
{
|
||||
printf("\nUnable to open file or device %s\n",argv[i]);
|
||||
|
@ -260,7 +249,7 @@ int main( int argc, char **argv )
|
|||
printf("Please wait...\n");
|
||||
/* Scan for available device only if no device or image has been supplied in parameter */
|
||||
if(list_disk==NULL)
|
||||
list_disk=hd_parse(list_disk,verbose,arch,testdisk_mode);
|
||||
list_disk=hd_parse(list_disk, verbose, testdisk_mode);
|
||||
/* Activate the cache */
|
||||
for(element_disk=list_disk;element_disk!=NULL;element_disk=element_disk->next)
|
||||
element_disk->disk=new_diskcache(element_disk->disk,testdisk_mode);
|
||||
|
@ -301,7 +290,7 @@ int main( int argc, char **argv )
|
|||
{
|
||||
disk_t *disk=element_disk->disk;
|
||||
const int hpa_dco=is_hpa_or_dco(disk);
|
||||
autodetect_arch(disk);
|
||||
autodetect_arch(disk, NULL);
|
||||
if(unit==UNIT_DEFAULT)
|
||||
autoset_unit(disk);
|
||||
else
|
||||
|
@ -389,7 +378,7 @@ int main( int argc, char **argv )
|
|||
#endif
|
||||
/* Scan for available device only if no device or image has been supplied in parameter */
|
||||
if(list_disk==NULL)
|
||||
list_disk=hd_parse(list_disk,verbose,arch,testdisk_mode);
|
||||
list_disk=hd_parse(list_disk, verbose, testdisk_mode);
|
||||
/* Activate the cache */
|
||||
for(element_disk=list_disk;element_disk!=NULL;element_disk=element_disk->next)
|
||||
element_disk->disk=new_diskcache(element_disk->disk,testdisk_mode);
|
||||
|
|
|
@ -53,6 +53,8 @@
|
|||
#include "hdaccess.h"
|
||||
#include "alignio.h"
|
||||
|
||||
extern const arch_fnct_t arch_none;
|
||||
|
||||
static unsigned int file_win32_compute_sector_size(HANDLE handle);
|
||||
static uint64_t filewin32_getfilesize(HANDLE handle, const char *device);
|
||||
static const char *file_win32_description(disk_t *disk_car);
|
||||
|
@ -246,7 +248,7 @@ static uint64_t filewin32_setfilepointer(HANDLE handle, const char *device)
|
|||
return disk_size;
|
||||
}
|
||||
|
||||
disk_t *file_test_availability_win32(const char *device, const int verbose, const arch_fnct_t *arch, int testdisk_mode)
|
||||
disk_t *file_test_availability_win32(const char *device, const int verbose, int testdisk_mode)
|
||||
{
|
||||
disk_t *disk_car=NULL;
|
||||
HANDLE handle=INVALID_HANDLE_VALUE;
|
||||
|
@ -314,7 +316,7 @@ disk_t *file_test_availability_win32(const char *device, const int verbose, cons
|
|||
struct info_file_win32_struct *data;
|
||||
disk_car=(disk_t *)MALLOC(sizeof(*disk_car));
|
||||
init_disk(disk_car);
|
||||
disk_car->arch=arch;
|
||||
disk_car->arch=&arch_none;
|
||||
disk_car->device=strdup(device);
|
||||
data=(struct info_file_win32_struct *)MALLOC(sizeof(*data));
|
||||
data->handle=handle;
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
extern "C" {
|
||||
#endif
|
||||
#if defined(__CYGWIN__) || defined(__MINGW32__)
|
||||
disk_t *file_test_availability_win32(const char *device, const int verbose, const arch_fnct_t *arch, const int testdisk_mode);
|
||||
disk_t *file_test_availability_win32(const char *device, const int verbose, const int testdisk_mode);
|
||||
unsigned int disk_get_sector_size_win32(HANDLE handle, const char *device, const int verbose);
|
||||
uint64_t disk_get_size_win32(HANDLE handle, const char *device, const int verbose);
|
||||
void disk_get_geometry_win32(CHSgeometry_t *geom, HANDLE handle, const char *device, const int verbose);
|
||||
|
|
Loading…
Reference in a new issue