summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristophe Grenier <grenier@cgsecurity.org>2007-12-06 00:29:52 +0100
committerChristophe Grenier <grenier@cgsecurity.org>2007-12-06 00:29:52 +0100
commitf51aa191c2be32b989b4ddb5fee31b8bfd75edf5 (patch)
treebfaf4e746da8d6bd071af09d4d0e5a0ad6a56884
parent980ff85c3050ff15bf8e473ead40c24dba4b4353 (diff)
"testdisk -lu device" will list the partition with sector unit
-rw-r--r--src/adv.c20
-rw-r--r--src/analyse.c2
-rw-r--r--src/chgtype.c2
-rw-r--r--src/common.h12
-rw-r--r--src/dir.c2
-rw-r--r--src/dirpart.c4
-rw-r--r--src/ext2.c2
-rw-r--r--src/ext2p.c2
-rw-r--r--src/fat_adv.c10
-rw-r--r--src/godmode.c8
-rw-r--r--src/hdaccess.c16
-rw-r--r--src/hdaccess.h2
-rw-r--r--src/hdcache.c7
-rw-r--r--src/intrf.c28
-rw-r--r--src/intrf.h4
-rw-r--r--src/intrface.c27
-rw-r--r--src/intrface.h2
-rw-r--r--src/intrfn.h2
-rw-r--r--src/log.c2
-rw-r--r--src/ntfs_adv.c8
-rw-r--r--src/ntfsp.c2
-rw-r--r--src/partgpt.c6
-rw-r--r--src/parti386.c26
-rw-r--r--src/partmac.c6
-rw-r--r--src/partnone.c2
-rw-r--r--src/partsun.c6
-rw-r--r--src/partxbox.c6
-rw-r--r--src/phrecn.c8
-rw-r--r--src/sudo.c61
-rw-r--r--src/sudo.h24
-rw-r--r--src/testdisk.c21
31 files changed, 218 insertions, 112 deletions
diff --git a/src/adv.c b/src/adv.c
index e3a0eae..9d62258 100644
--- a/src/adv.c
+++ b/src/adv.c
@@ -213,11 +213,11 @@ void interface_adv(disk_t *disk_car, const int verbose,const int dump_ind, const
if(element==current_element)
{
wattrset(stdscr, A_REVERSE);
- aff_part(stdscr,AFF_PART_ORDER,disk_car,element->part);
+ aff_part(stdscr,AFF_PART_ORDER|AFF_PART_STATUS,disk_car,element->part);
wattroff(stdscr, A_REVERSE);
} else
{
- aff_part(stdscr,AFF_PART_ORDER,disk_car,element->part);
+ aff_part(stdscr,AFF_PART_ORDER|AFF_PART_STATUS,disk_car,element->part);
}
}
#endif
@@ -438,7 +438,7 @@ static void dump_fat1x_ncurses(disk_t *disk_car, partition_t *partition, const u
wmove(window,4,0);
wprintw(window,"%s",disk_car->description(disk_car));
wmove(window,5,0);
- aff_part(window,AFF_PART_ORDER,disk_car,partition);
+ aff_part(window,AFF_PART_ORDER|AFF_PART_STATUS,disk_car,partition);
mvwaddstr(window,6,0, "Boot sector");
dump(window,buffer_bs,FAT1x_BOOT_SECTOR_SIZE);
delwin(window);
@@ -488,7 +488,7 @@ int fat1x_boot_sector(disk_t *disk_car, partition_t *partition, const int verbos
wprintw(stdscr,"%s",disk_car->description(disk_car));
mvwaddstr(stdscr,5,0,msg_PART_HEADER_LONG);
wmove(stdscr,6,0);
- aff_part(stdscr,AFF_PART_ORDER,disk_car,partition);
+ aff_part(stdscr,AFF_PART_ORDER|AFF_PART_STATUS,disk_car,partition);
#endif
log_info("\nfat1x_boot_sector\n");
log_partition(disk_car,partition);
@@ -594,7 +594,7 @@ static void dump_fat32_ncurses(disk_t *disk_car, const partition_t *partition, c
wmove(window,4,0);
wprintw(window,"%s",disk_car->description(disk_car));
wmove(window,5,0);
- aff_part(window,AFF_PART_ORDER,disk_car,partition);
+ aff_part(window,AFF_PART_ORDER|AFF_PART_STATUS,disk_car,partition);
mvwaddstr(window,6,0, "Boot sector Backup boot sector");
dump2(window, buffer_bs, buffer_backup_bs, 3*disk_car->sector_size);
delwin(window);
@@ -652,7 +652,7 @@ int fat32_boot_sector(disk_t *disk_car, partition_t *partition, const int verbos
wprintw(stdscr,"%s",disk_car->description(disk_car));
mvwaddstr(stdscr,5,0,msg_PART_HEADER_LONG);
wmove(stdscr,6,0);
- aff_part(stdscr,AFF_PART_ORDER,disk_car,partition);
+ aff_part(stdscr,AFF_PART_ORDER|AFF_PART_STATUS,disk_car,partition);
#endif
log_info("\nfat32_boot_sector\n");
log_partition(disk_car,partition);
@@ -852,7 +852,7 @@ static void dump_NTFS_ncurses(disk_t *disk_car, const partition_t *partition, co
wmove(window,4,0);
wprintw(window,"%s",disk_car->description(disk_car));
wmove(window,5,0);
- aff_part(window,AFF_PART_ORDER,disk_car,partition);
+ aff_part(window,AFF_PART_ORDER|AFF_PART_STATUS,disk_car,partition);
mvwaddstr(window,6,0, "Boot sector Backup boot sector");
dump2(window, buffer_bs, buffer_backup_bs, NTFS_BOOT_SECTOR_SIZE);
delwin(window);
@@ -912,7 +912,7 @@ int ntfs_boot_sector(disk_t *disk_car, partition_t *partition, const int verbose
wprintw(stdscr,"%s",disk_car->description(disk_car));
mvwaddstr(stdscr,5,0,msg_PART_HEADER_LONG);
wmove(stdscr,6,0);
- aff_part(stdscr,AFF_PART_ORDER,disk_car,partition);
+ aff_part(stdscr,AFF_PART_ORDER|AFF_PART_STATUS,disk_car,partition);
#endif
log_info("\nntfs_boot_sector\n");
log_partition(disk_car,partition);
@@ -1097,7 +1097,7 @@ static void hfs_dump_ncurses(disk_t *disk_car, const partition_t *partition, con
wmove(window,4,0);
wprintw(window,"%s",disk_car->description(disk_car));
wmove(window,5,0);
- aff_part(window,AFF_PART_ORDER,disk_car,partition);
+ aff_part(window,AFF_PART_ORDER|AFF_PART_STATUS,disk_car,partition);
mvwaddstr(window,6,0, "Superblock Backup superblock");
dump2(window, buffer_bs, buffer_backup_bs, HFSP_BOOT_SECTOR_SIZE);
delwin(window);
@@ -1152,7 +1152,7 @@ int HFS_HFSP_boot_sector(disk_t *disk_car, partition_t *partition, const int ver
wprintw(stdscr,"%s",disk_car->description(disk_car));
mvwaddstr(stdscr,5,0,msg_PART_HEADER_LONG);
wmove(stdscr,6,0);
- aff_part(stdscr,AFF_PART_ORDER,disk_car,partition);
+ aff_part(stdscr,AFF_PART_ORDER|AFF_PART_STATUS,disk_car,partition);
#endif
log_info("\nHFS_HFSP_boot_sector\n");
log_partition(disk_car,partition);
diff --git a/src/analyse.c b/src/analyse.c
index 70838b8..a59727c 100644
--- a/src/analyse.c
+++ b/src/analyse.c
@@ -282,7 +282,7 @@ list_part_t *search_superblock(disk_t *disk_car, const partition_t *partition, c
wprintw(stdscr,"%s",disk_car->description(disk_car));
mvwaddstr(stdscr,5,0,msg_PART_HEADER_LONG);
wmove(stdscr,6,0);
- aff_part(stdscr,AFF_PART_ORDER,disk_car,partition);
+ aff_part(stdscr,AFF_PART_ORDER|AFF_PART_STATUS,disk_car,partition);
wmove(stdscr,22,0);
wattrset(stdscr, A_REVERSE);
waddstr(stdscr," Stop ");
diff --git a/src/chgtype.c b/src/chgtype.c
index d4036a8..f4d25e5 100644
--- a/src/chgtype.c
+++ b/src/chgtype.c
@@ -109,7 +109,7 @@ static void change_part_type_ncurses(const disk_t *disk_car,partition_t *partiti
/* Ask for the new partition type*/
aff_copy(stdscr);
wmove(stdscr,4,0);
- aff_part(stdscr,AFF_PART_ORDER,disk_car,partition);
+ aff_part(stdscr,AFF_PART_ORDER|AFF_PART_STATUS,disk_car,partition);
screen_buffer_display(stdscr,"",menuType);
wmove(stdscr,23,0);
wprintw(stdscr,"New partition type [current %02x] ? ",partition->arch->get_part_type(partition));
diff --git a/src/common.h b/src/common.h
index 1896ec6..5050d0c 100644
--- a/src/common.h
+++ b/src/common.h
@@ -218,8 +218,14 @@ enum status_type { STATUS_DELETED, STATUS_PRIM, STATUS_PRIM_BOOT, STATUS_LOG, ST
typedef enum status_type status_type_t;
enum errcode_type {BAD_NOERR, BAD_SS, BAD_ES, BAD_SH, BAD_EH, BAD_EBS, BAD_RS, BAD_SC, BAD_EC, BAD_SCOUNT};
typedef enum errcode_type errcode_type_t;
-enum aff_part_type {AFF_PART_NONL, AFF_PART_ORDER, AFF_PART_SHORT};
-typedef enum aff_part_type aff_part_type_t;
+
+#define AFF_PART_BASE 0
+#define AFF_PART_ORDER 1
+#define AFF_PART_STATUS 2
+
+#define UNIT_DEFAULT 0
+#define UNIT_SECTOR 1
+#define UNIT_CHS 2
typedef struct param_disk_struct disk_t;
typedef struct partition_struct partition_t;
@@ -284,10 +290,10 @@ struct param_disk_struct
{
uint64_t disk_size;
CHS_t CHS; /* logical CHS */
- int halt_on_errors;
int write_used;
int autodetect;
int access_mode;
+ int unit;
unsigned int sector_size;
char *device;
char description_txt[DISKDESCRIPTION_MAX];
diff --git a/src/dir.c b/src/dir.c
index c47177b..de88a0c 100644
--- a/src/dir.c
+++ b/src/dir.c
@@ -221,7 +221,7 @@ static long int dir_aff_ncurses(disk_t *disk_car, const partition_t *partition,
WINDOW *window=(WINDOW*)dir_data->display;
aff_copy(window);
wmove(window,4,0);
- aff_part(window,AFF_PART_ORDER,disk_car,partition);
+ aff_part(window,AFF_PART_ORDER|AFF_PART_STATUS,disk_car,partition);
mvwaddstr(window,5,0,"Use ");
if(first_time==0)
{
diff --git a/src/dirpart.c b/src/dirpart.c
index 6ddbe31..05ef717 100644
--- a/src/dirpart.c
+++ b/src/dirpart.c
@@ -114,7 +114,7 @@ int dir_partition(disk_t *disk_car, const partition_t *partition, const int verb
#ifdef HAVE_NCURSES
aff_copy(window);
wmove(window,4,0);
- aff_part(window,AFF_PART_ORDER,disk_car,partition);
+ aff_part(window,AFF_PART_ORDER|AFF_PART_STATUS,disk_car,partition);
#endif
log_partition(disk_car,partition);
aff_buffer(BUFFER_ADD,"Support for this filesystem hasn't been enable during compilation.\n");
@@ -131,7 +131,7 @@ int dir_partition(disk_t *disk_car, const partition_t *partition, const int verb
#ifdef HAVE_NCURSES
aff_copy(window);
wmove(window,4,0);
- aff_part(window,AFF_PART_ORDER,disk_car,partition);
+ aff_part(window,AFF_PART_ORDER|AFF_PART_STATUS,disk_car,partition);
#endif
log_partition(disk_car,partition);
aff_buffer(BUFFER_ADD,"Can't open filesystem. Filesystem seems damaged.\n");
diff --git a/src/ext2.c b/src/ext2.c
index a9c0693..37a5195 100644
--- a/src/ext2.c
+++ b/src/ext2.c
@@ -119,7 +119,7 @@ int recover_EXT2(disk_t *disk_car, const struct ext2_super_block *sb,partition_t
}
partition->sb_offset=(uint64_t)block_nr * (EXT2_MIN_BLOCK_SIZE<<le32(sb->s_log_block_size));
partition->part_offset-=partition->sb_offset;
- log_warning("recover_EXT2: \"e2fsck -b %u -B %lu device\" may be needed\n",
+ log_warning("recover_EXT2: \"e2fsck -b %lu -B %u device\" may be needed\n",
block_nr, partition->blocksize);
}
else
diff --git a/src/ext2p.c b/src/ext2p.c
index 3f728c8..e74ae65 100644
--- a/src/ext2p.c
+++ b/src/ext2p.c
@@ -65,7 +65,7 @@ unsigned int ext2_remove_used_space(disk_t *disk_car,const partition_t *partitio
window=newwin(0,0,0,0); /* full screen */
aff_copy(window);
wmove(window,4,0);
- aff_part(window,AFF_PART_ORDER,disk_car,partition);
+ aff_part(window,AFF_PART_ORDER|AFF_PART_STATUS,disk_car,partition);
#endif
log_partition(disk_car,partition);
aff_buffer(BUFFER_ADD,"Can't open filesystem. Filesystem seems damaged.\n");
diff --git a/src/fat_adv.c b/src/fat_adv.c
index 42fab41..d6abf73 100644
--- a/src/fat_adv.c
+++ b/src/fat_adv.c
@@ -204,7 +204,7 @@ static int ask_root_directory(disk_t *disk_car, const partition_t *partition, co
window=newwin(0,0,0,0); /* full screen */
aff_copy(window);
wmove(window,4,0);
- aff_part(window,AFF_PART_ORDER,disk_car,partition);
+ aff_part(window,AFF_PART_ORDER|AFF_PART_STATUS,disk_car,partition);
wmove(window,6,0);
wprintw(window,"Answer Y(es), N(o) or A(bort interactive mode). N or A if not sure.");
curs_set(1);
@@ -874,7 +874,7 @@ static void fat32_dump_ncurses(disk_t *disk_car, const partition_t *partition, c
wmove(window,4,0);
wprintw(window,"%s",disk_car->description(disk_car));
wmove(window,5,0);
- aff_part(window,AFF_PART_ORDER,disk_car,partition);
+ aff_part(window,AFF_PART_ORDER|AFF_PART_STATUS,disk_car,partition);
mvwaddstr(window,6,0, " Rebuild Boot sector Boot sector");
dump2(window, newboot,orgboot, (unsigned int)(upart_type==UP_FAT32?3*disk_car->sector_size:DEFAULT_SECTOR_SIZE));
delwin(window);
@@ -920,7 +920,7 @@ static void menu_write_fat_boot_sector(disk_t *disk_car, partition_t *partition,
wprintw(stdscr,"%s",disk_car->description(disk_car));
mvwaddstr(stdscr,5,0,msg_PART_HEADER_LONG);
wmove(stdscr,6,0);
- aff_part(stdscr,AFF_PART_ORDER,disk_car,partition);
+ aff_part(stdscr,AFF_PART_ORDER|AFF_PART_STATUS,disk_car,partition);
wmove(stdscr,8,0);
#endif
if(memcmp(newboot,orgboot,DEFAULT_SECTOR_SIZE)) /* Only compare the first sector */
@@ -2098,7 +2098,7 @@ int rebuild_FAT_BS(disk_t *disk_car, partition_t *partition, const int verbose,
wprintw(stdscr,"%s",disk_car->description(disk_car));
mvwaddstr(stdscr,5,0,msg_PART_HEADER_LONG);
wmove(stdscr,6,0);
- aff_part(stdscr,AFF_PART_ORDER,disk_car,partition);
+ aff_part(stdscr,AFF_PART_ORDER|AFF_PART_STATUS,disk_car,partition);
wrefresh(stdscr);
}
#endif
@@ -2111,7 +2111,7 @@ int rebuild_FAT_BS(disk_t *disk_car, partition_t *partition, const int verbose,
wprintw(stdscr,"%s",disk_car->description(disk_car));
mvwaddstr(stdscr,5,0,msg_PART_HEADER_LONG);
wmove(stdscr,6,0);
- aff_part(stdscr,AFF_PART_ORDER,disk_car,partition);
+ aff_part(stdscr,AFF_PART_ORDER|AFF_PART_STATUS,disk_car,partition);
wmove(stdscr,8,0);
wclrtoeol(stdscr);
switch(upart_type)
diff --git a/src/godmode.c b/src/godmode.c
index 5d4a9b0..0a2741d 100644
--- a/src/godmode.c
+++ b/src/godmode.c
@@ -170,7 +170,7 @@ static int interface_part_bad_ncurses(disk_t *disk_car, list_part_t *list_part)
{
char buffer_part_size[100];
wattrset(stdscr, A_REVERSE);
- aff_part(stdscr,AFF_PART_NONL,disk_car,parts->part);
+ aff_part(stdscr, AFF_PART_BASE, disk_car, parts->part);
wattroff(stdscr, A_REVERSE);
wmove(stdscr,24,0);
wclrtoeol(stdscr); /* before addstr for BSD compatibility */
@@ -181,7 +181,7 @@ static int interface_part_bad_ncurses(disk_t *disk_car, list_part_t *list_part)
wprintw(stdscr,"%s",size_to_unit(parts->part->part_size,buffer_part_size));
} else
{
- aff_part(stdscr,AFF_PART_NONL,disk_car,parts->part);
+ aff_part(stdscr, AFF_PART_BASE, disk_car, parts->part);
}
}
wrefresh(stdscr);
@@ -654,7 +654,7 @@ static list_part_t *search_part(disk_t *disk_car, const list_part_t *list_part_o
{
partition->status=STATUS_DELETED;
log_partition(disk_car,partition);
- aff_part_buffer(AFF_PART_SHORT,disk_car,partition);
+ aff_part_buffer(AFF_PART_BASE, disk_car,partition);
if(interface)
{
aff_buffer(BUFFER_SHOW,"Q");
@@ -874,7 +874,7 @@ static void ask_mbr_order_i386(disk_t *disk_car,list_part_t *list_part)
wclrtoeol(stdscr);
if(i==pos)
standout();
- aff_part(stdscr,AFF_PART_ORDER,disk_car,table2[i]);
+ aff_part(stdscr,AFF_PART_ORDER|AFF_PART_STATUS,disk_car,table2[i]);
if(i==pos)
standend();
}
diff --git a/src/hdaccess.c b/src/hdaccess.c
index def383e..941d2ac 100644
--- a/src/hdaccess.c
+++ b/src/hdaccess.c
@@ -104,6 +104,7 @@
#include "log.h"
#include "hdaccess.h"
+extern const arch_fnct_t arch_gpt;
extern const arch_fnct_t arch_mac;
struct info_file_struct
@@ -577,6 +578,7 @@ static disk_t *hd_identify(const int verbose, const unsigned int disk, const arc
data->mode_enh=0;
free(param_disk_enh);
}
+ disk_car->unit=UNIT_CHS;
return disk_car;
}
}
@@ -1774,6 +1776,7 @@ disk_t *file_test_availability(const char *device, const int verbose, const arch
close(hd_h);
return NULL;
}
+ disk_car->unit=UNIT_CHS;
return disk_car;
}
close(hd_h);
@@ -2090,6 +2093,7 @@ disk_t *file_test_availability_win32(const char *device, const int verbose, cons
return NULL;
}
disk_car->CHS.cylinder=(disk_car->disk_size/(disk_car->CHS.head+1))/disk_car->CHS.sector/disk_car->sector_size-1;
+ disk_car->unit=UNIT_CHS;
return disk_car;
}
return NULL;
@@ -2296,3 +2300,15 @@ static int file_win32_sync(disk_t *disk_car)
return 0;
}
#endif
+
+void autoset_unit(disk_t *disk_car)
+{
+ if(disk_car==NULL)
+ return ;
+ if(disk_car->arch==&arch_mac ||
+ disk_car->arch==&arch_gpt ||
+ (disk_car->CHS.head==0 && disk_car->CHS.sector==1))
+ disk_car->unit=UNIT_SECTOR;
+ else
+ disk_car->unit=UNIT_CHS;
+}
diff --git a/src/hdaccess.h b/src/hdaccess.h
index cf6e379..bc4657c 100644
--- a/src/hdaccess.h
+++ b/src/hdaccess.h
@@ -5,4 +5,4 @@ disk_t *file_test_availability(const char *device, const int verbose, const arch
#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);
#endif
-
+void autoset_unit(disk_t *disk_car);
diff --git a/src/hdcache.c b/src/hdcache.c
index e95a3df..4a07e7f 100644
--- a/src/hdcache.c
+++ b/src/hdcache.c
@@ -233,7 +233,7 @@ static int cache_clean(disk_t *disk_car)
static int cache_sync(disk_t *disk_car)
{
struct cache_struct *data=disk_car->data;
- data->disk_car->sync(data->disk_car);
+ return data->disk_car->sync(data->disk_car);
}
disk_t *new_diskcache(disk_t *disk_car, const unsigned int testdisk_mode)
@@ -257,7 +257,6 @@ disk_t *new_diskcache(disk_t *disk_car, const unsigned int testdisk_mode)
dup_CHS(&new_disk_car->CHS,&disk_car->CHS);
new_disk_car->disk_size=disk_car->disk_size;
new_disk_car->disk_real_size=disk_car->disk_real_size;
- new_disk_car->halt_on_errors=0;
new_disk_car->write_used=0;
new_disk_car->data=data;
new_disk_car->read=cache_read;
@@ -266,6 +265,10 @@ disk_t *new_diskcache(disk_t *disk_car, const unsigned int testdisk_mode)
new_disk_car->clean=cache_clean;
new_disk_car->description=cache_description;
new_disk_car->description_short=cache_description_short;
+ new_disk_car->rbuffer=NULL;
+ new_disk_car->wbuffer=NULL;
+ new_disk_car->rbuffer_size=0;
+ new_disk_car->wbuffer_size=0;
for(i=0;i<CACHE_BUFFER_NBR;i++)
data->cache[i].buffer=NULL;
return new_disk_car;
diff --git a/src/intrf.c b/src/intrf.c
index d26489f..a2a342d 100644
--- a/src/intrf.c
+++ b/src/intrf.c
@@ -184,7 +184,7 @@ void screen_buffer_to_log()
log_info("%s\n",intr_buffer_screen[i]);
}
-const char *aff_part_aux(const aff_part_type_t newline, const disk_t *disk_car, const partition_t *partition)
+const char *aff_part_aux(const unsigned int newline, const disk_t *disk_car, const partition_t *partition)
{
char status=' ';
static char msg[200];
@@ -196,19 +196,14 @@ const char *aff_part_aux(const aff_part_type_t newline, const disk_t *disk_car,
log_error("BUG: No arch for a partition\n");
}
msg[sizeof(msg)-1]=0;
- switch(newline)
+ if((newline&AFF_PART_ORDER)==AFF_PART_ORDER)
{
- case AFF_PART_ORDER:
- if((partition->status!=STATUS_EXT_IN_EXT) && (partition->order!=NO_ORDER))
- pos+=snprintf(&msg[pos],sizeof(msg)-pos-1,"%2d ", partition->order);
- else
- pos+=snprintf(&msg[pos],sizeof(msg)-pos-1," ");
- break;
- case AFF_PART_NONL:
- case AFF_PART_SHORT:
- break;
+ if((partition->status!=STATUS_EXT_IN_EXT) && (partition->order!=NO_ORDER))
+ pos+=snprintf(&msg[pos],sizeof(msg)-pos-1,"%2d ", partition->order);
+ else
+ pos+=snprintf(&msg[pos],sizeof(msg)-pos-1," ");
}
- if(newline!=AFF_PART_SHORT)
+ if((newline&AFF_PART_STATUS)==AFF_PART_STATUS)
{
switch(partition->status)
{
@@ -229,9 +224,7 @@ const char *aff_part_aux(const aff_part_type_t newline, const disk_t *disk_car,
pos+=snprintf(&msg[pos],sizeof(msg)-pos-1, " Sys=%02X ", arch->get_part_type(partition));
else
pos+=snprintf(&msg[pos],sizeof(msg)-pos-1, " Unknown ");
- if(disk_car->arch==&arch_mac ||
- disk_car->arch==&arch_gpt ||
- (disk_car->CHS.head==0 && disk_car->CHS.sector==1))
+ if(disk_car->unit==UNIT_SECTOR)
{
pos+=snprintf(&msg[pos],sizeof(msg)-pos-1, " %10lu %10lu ",
(long unsigned)(partition->part_offset/disk_car->sector_size),
@@ -1051,7 +1044,7 @@ void aff_CHS_buffer(const CHS_t * CHS)
aff_buffer(BUFFER_ADD,"%5u %3u %2u ", CHS->cylinder, CHS->head, CHS->sector);
}
-void aff_part(WINDOW *window,const aff_part_type_t newline,const disk_t *disk_car,const partition_t *partition)
+void aff_part(WINDOW *window,const unsigned int newline,const disk_t *disk_car,const partition_t *partition)
{
const char *msg;
msg=aff_part_aux(newline, disk_car, partition);
@@ -1977,7 +1970,7 @@ unsigned long long int ask_number_cli(char **current_cmd, const unsigned long lo
return val_cur;
}
-void aff_part_buffer(const aff_part_type_t newline,const disk_t *disk_car,const partition_t *partition)
+void aff_part_buffer(const unsigned int newline,const disk_t *disk_car,const partition_t *partition)
{
const char *msg;
msg=aff_part_aux(newline, disk_car, partition);
@@ -2050,4 +2043,3 @@ int interface_partition_type(disk_t *disk_car, const int verbose, char**current_
hd_update_geometry(disk_car, 0,verbose);
return 0;
}
-
diff --git a/src/intrf.h b/src/intrf.h
index 553823b..67da251 100644
--- a/src/intrf.h
+++ b/src/intrf.h
@@ -80,8 +80,8 @@ void aff_CHS(const CHS_t * CHS);
void aff_CHS_buffer(const CHS_t * CHS);
void aff_LBA2CHS(const disk_t *disk_car, const unsigned long int pos_LBA);
void log_CHS_from_LBA(const disk_t *disk_car, const unsigned long int pos_LBA);
-const char *aff_part_aux(const aff_part_type_t newline, const disk_t *disk_car, const partition_t *partition);
-void aff_part_buffer(const aff_part_type_t newline,const disk_t *disk_car,const partition_t *partition);
+const char *aff_part_aux(const unsigned int newline, const disk_t *disk_car, const partition_t *partition);
+void aff_part_buffer(const unsigned int newline,const disk_t *disk_car,const partition_t *partition);
int ask_confirmation(const char*_format, ...) __attribute__ ((format (printf, 1, 2)));
unsigned long long int ask_number(const unsigned long long int val_cur, const unsigned long long int val_min, const unsigned long long int val_max, const char * _format, ...) __attribute__ ((format (printf, 4, 5)));
diff --git a/src/intrface.c b/src/intrface.c
index 815eda7..8fc4ff7 100644
--- a/src/intrface.c
+++ b/src/intrface.c
@@ -83,7 +83,7 @@ static int interface_check_disk_access(disk_t *disk_car, char **current_cmd);
static list_part_t *interface_analyse(disk_t *disk_car, const int verbose, const int saveheader, char**current_cmd);
static int menu_disk(disk_t *disk_car, const int verbose,int dump_ind, const int saveheader, char **current_cmd);
-void interface_list(disk_t *disk_car, const int verbose,const int test_recovery, const int saveheader, const int backup, char **current_cmd)
+void interface_list(disk_t *disk_car, const int verbose, const int saveheader, const int backup, char **current_cmd)
{
list_part_t *list_part;
log_info("\nAnalyse ");
@@ -96,22 +96,9 @@ void interface_list(disk_t *disk_car, const int verbose,const int test_recovery,
{
partition_save(disk_car,list_part,verbose);
}
- if(test_recovery>0)
- {
- list_part_t *element;
- log_info("rebuild_FAT_BS()\n");
- for(element=list_part;element!=NULL;element=element->next)
- {
- if(is_fat(element->part))
- {
- log_partition(disk_car,element->part);
- rebuild_FAT_BS(disk_car,element->part,verbose,0,0,0, current_cmd); /* dump_ind */
- }
- /* TODO ntfs */
- }
- }
part_free_list(list_part);
}
+
#ifdef HAVE_NCURSES
static int write_MBR_code(disk_t *disk_car)
{
@@ -426,6 +413,7 @@ static int testdisk_disk_selection_cli(int verbose,int dump_ind, const list_disk
{
disk_t *disk=current_disk->disk;
autodetect_arch(disk);
+ autoset_unit(disk);
if(interface_check_disk_capacity(disk)==0 &&
interface_check_disk_access(disk, current_cmd)==0 &&
interface_partition_type(disk, verbose, current_cmd)==0)
@@ -560,6 +548,7 @@ static int testdisk_disk_selection_ncurses(int verbose,int dump_ind, const list_
{
disk_t *disk=current_disk->disk;
autodetect_arch(disk);
+ autoset_unit(disk);
if(interface_check_disk_capacity(disk)==0 &&
interface_check_disk_access(disk, current_cmd)==0 &&
interface_partition_type(disk, verbose, current_cmd)==0)
@@ -801,10 +790,10 @@ int interface_write(disk_t *disk_car,list_part_t *list_part,const int can_search
#endif
for(parts=list_part;parts!=NULL;parts=parts->next)
if(parts->part->status!=STATUS_LOG)
- aff_part_buffer(AFF_PART_ORDER,disk_car,parts->part);
+ aff_part_buffer(AFF_PART_ORDER|AFF_PART_STATUS,disk_car,parts->part);
for(parts=list_part;parts!=NULL;parts=parts->next)
if(parts->part->status==STATUS_LOG)
- aff_part_buffer(AFF_PART_ORDER,disk_car,parts->part);
+ aff_part_buffer(AFF_PART_ORDER|AFF_PART_STATUS,disk_car,parts->part);
command='Q';
if(list_part==NULL)
{
@@ -1036,7 +1025,7 @@ static list_part_t *ask_structure_ncurses(disk_t *disk_car,list_part_t *list_par
}
if(structure_status==0 && parts->part->status!=STATUS_DELETED && has_colors())
wbkgdset(stdscr,' ' | COLOR_PAIR(2));
- aff_part(stdscr,AFF_PART_NONL,disk_car,parts->part);
+ aff_part(stdscr, AFF_PART_STATUS, disk_car, parts->part);
if(structure_status==0 && parts->part->status!=STATUS_DELETED && has_colors())
wbkgdset(stdscr,' ' | COLOR_PAIR(0));
if(parts==pos)
@@ -1516,7 +1505,7 @@ int interface_superblock(disk_t *disk_car,list_part_t *list_part, char**current_
old_part->part_type_mac!=partition->part_type_mac ||
old_part->upart_type!=partition->upart_type)
{
- aff_part_buffer(AFF_PART_SHORT,disk_car,partition);
+ aff_part_buffer(AFF_PART_BASE, disk_car, partition);
old_part=partition;
}
if(partition->blocksize!=0)
diff --git a/src/intrface.h b/src/intrface.h
index 30f9384..2b5f3bc 100644
--- a/src/intrface.h
+++ b/src/intrface.h
@@ -29,6 +29,6 @@ int do_curses_testdisk(int verbose, int dump_ind, const list_disk_t *list_disk,
int interface_write(disk_t *disk_car,list_part_t *list_part,const int can_search_deeper, const int can_ask_minmax_ext, int *no_confirm, char **current_cmd, unsigned int *menu);
list_part_t *ask_structure(disk_t *disk_car,list_part_t *list_part, const int verbose, char **current_cmd);
-void interface_list(disk_t *disk_car, const int verbose,const int test_recovery, const int saveheader, const int backup, char **current_cmd);
+void interface_list(disk_t *disk_car, const int verbose, const int saveheader, const int backup, char **current_cmd);
int interface_superblock(disk_t *disk_car,list_part_t *list_part,char**current_cmd);
diff --git a/src/intrfn.h b/src/intrfn.h
index 1f2c543..b777f99 100644
--- a/src/intrfn.h
+++ b/src/intrfn.h
@@ -32,7 +32,7 @@
#endif
void aff_copy(WINDOW *window);
-void aff_part(WINDOW *window,const aff_part_type_t newline,const disk_t *disk_car,const partition_t *partition);
+void aff_part(WINDOW *window, const unsigned int newline, const disk_t *disk_car, const partition_t *partition);
int aff_txt(int line, WINDOW *window, const char *_format, ...) __attribute__ ((format (printf, 3, 4)));
int ask_YN(WINDOW *window);
int check_enter_key_or_s(WINDOW *window);
diff --git a/src/log.c b/src/log.c
index 45f4f0a..34cfe48 100644
--- a/src/log.c
+++ b/src/log.c
@@ -239,7 +239,7 @@ void log_partition(const disk_t *disk_car,const partition_t *partition)
{
const char *msg;
char buffer_part_size[100];
- msg=aff_part_aux(AFF_PART_ORDER, disk_car, partition);
+ msg=aff_part_aux(AFF_PART_ORDER|AFF_PART_STATUS, disk_car, partition);
log_info("%s",msg);
if(partition->info[0]!='\0')
log_info("\n %s, %s",partition->info,size_to_unit(partition->part_size,buffer_part_size));
diff --git a/src/ntfs_adv.c b/src/ntfs_adv.c
index 658c9f4..7761325 100644
--- a/src/ntfs_adv.c
+++ b/src/ntfs_adv.c
@@ -70,7 +70,7 @@ static void ntfs_dump_ncurses(disk_t *disk_car, const partition_t *partition, co
wmove(window,4,0);
wprintw(window,"%s",disk_car->description(disk_car));
wmove(window,5,0);
- aff_part(window,AFF_PART_ORDER,disk_car,partition);
+ aff_part(window,AFF_PART_ORDER|AFF_PART_STATUS,disk_car,partition);
mvwaddstr(window,6,0, " Rebuild Boot sector Boot sector");
dump2(window, newboot, orgboot, NTFS_SECTOR_SIZE);
delwin(window);
@@ -175,7 +175,7 @@ static void menu_write_ntfs_boot_sector_ncurses(disk_t *disk_car, partition_t *p
wprintw(stdscr,"%s",disk_car->description(disk_car));
mvwaddstr(stdscr,5,0,msg_PART_HEADER_LONG);
wmove(stdscr,6,0);
- aff_part(stdscr,AFF_PART_ORDER,disk_car,partition);
+ aff_part(stdscr,AFF_PART_ORDER|AFF_PART_STATUS,disk_car,partition);
wmove(stdscr,8,0);
if(memcmp(newboot,orgboot,NTFS_SECTOR_SIZE))
{
@@ -222,7 +222,7 @@ static void menu_write_ntfs_boot_sector_ncurses(disk_t *disk_car, partition_t *p
wmove(window,4,0);
wprintw(window,"%s",disk_car->description(disk_car));
wmove(window,5,0);
- aff_part(window,AFF_PART_ORDER,disk_car,partition);
+ aff_part(window,AFF_PART_ORDER|AFF_PART_STATUS,disk_car,partition);
log_info(" Rebuild Boot sector Boot sector\n");
mvwaddstr(window,6,0, " Rebuild Boot sector Boot sector");
dump2(window, newboot, orgboot, NTFS_SECTOR_SIZE);
@@ -444,7 +444,7 @@ int rebuild_NTFS_BS(disk_t *disk_car, partition_t *partition, const int verbose,
wprintw(stdscr,"%s",disk_car->description(disk_car));
mvwaddstr(stdscr,5,0,msg_PART_HEADER_LONG);
wmove(stdscr,6,0);
- aff_part(stdscr,AFF_PART_ORDER,disk_car,partition);
+ aff_part(stdscr,AFF_PART_ORDER|AFF_PART_STATUS,disk_car,partition);
wmove(stdscr,22,0);
wattrset(stdscr, A_REVERSE);
waddstr(stdscr," Stop ");
diff --git a/src/ntfsp.c b/src/ntfsp.c
index edca6e1..ffc5eda 100644
--- a/src/ntfsp.c
+++ b/src/ntfsp.c
@@ -65,7 +65,7 @@ unsigned int ntfs_remove_used_space(disk_t *disk_car,const partition_t *partitio
window=newwin(0,0,0,0); /* full screen */
aff_copy(window);
wmove(window,4,0);
- aff_part(window,AFF_PART_ORDER,disk_car,partition);
+ aff_part(window,AFF_PART_ORDER|AFF_PART_STATUS,disk_car,partition);
#endif
log_partition(disk_car,partition);
aff_buffer(BUFFER_ADD,"Can't open filesystem. Filesystem seems damaged.\n");
diff --git a/src/partgpt.c b/src/partgpt.c
index 7919a75..4e30fce 100644
--- a/src/partgpt.c
+++ b/src/partgpt.c
@@ -303,7 +303,7 @@ list_part_t *read_part_gpt(disk_t *disk_car, const int verbose, const int savehe
UCSle2str(new_partition->partname, (const uint16_t *)&gpt_entry->ent_name, sizeof(gpt_entry->ent_name)/2);
new_partition->arch->check_part(disk_car,verbose,new_partition,saveheader);
/* log_debug("%u ent_attr %08llx\n", new_partition->order, (long long unsigned)le64(gpt_entry->ent_attr)); */
- aff_part_buffer(AFF_PART_ORDER,disk_car,new_partition);
+ aff_part_buffer(AFF_PART_ORDER|AFF_PART_STATUS,disk_car,new_partition);
new_list_part=insert_new_partition(new_list_part, new_partition, 0, &insert_error);
if(insert_error>0)
free(new_partition);
@@ -614,7 +614,7 @@ static list_part_t *add_partition_gpt_ncurses(disk_t *disk_car,list_part_t *list
wprintw(stdscr,"%s",disk_car->description(disk_car));
wmove(stdscr,10, 0);
wclrtoeol(stdscr);
- aff_part(stdscr,AFF_PART_SHORT,disk_car,new_partition);
+ aff_part(stdscr, AFF_PART_BASE, disk_car, new_partition);
wmove(stdscr,INTER_GEOM_Y, INTER_GEOM_X);
wclrtoeol(stdscr);
wrefresh(stdscr);
@@ -799,7 +799,7 @@ static int check_part_gpt(disk_t *disk_car,const int verbose,partition_t *partit
if(ret!=0)
{
log_error("check_part_gpt failed for partition\n");
- aff_part_buffer(AFF_PART_ORDER,disk_car,partition);
+ aff_part_buffer(AFF_PART_ORDER|AFF_PART_STATUS,disk_car,partition);
if(saveheader>0)
{
save_header(disk_car,partition,verbose);
diff --git a/src/parti386.c b/src/parti386.c
index cb82117..cab5783 100644
--- a/src/parti386.c
+++ b/src/parti386.c
@@ -383,7 +383,7 @@ static list_part_t *read_part_i386(disk_t *disk_car, const int verbose, const in
i386_entry2partition(disk_car, (uint64_t)0, new_partition, p, status,i+1,verbose,saveheader);
if(verbose>1)
log_dos_entry(disk_car,p);
- aff_part_buffer(AFF_PART_ORDER,disk_car,new_partition);
+ aff_part_buffer(AFF_PART_ORDER|AFF_PART_STATUS,disk_car,new_partition);
if(new_partition->errcode!=BAD_NOERR)
{
aff_buffer(BUFFER_ADD,"%s\n",errmsg_i386_entry2partition(new_partition->errcode));
@@ -536,7 +536,7 @@ static list_part_t *get_ext_data_i386(disk_t *disk_car, list_part_t *list_part,
{
partition_next_ext=new_partition;
i386_entry2partition(disk_car, partition_main_ext->part_offset, new_partition, p, STATUS_EXT_IN_EXT,order,verbose,saveheader);
- aff_part_buffer(AFF_PART_ORDER,disk_car,new_partition);
+ aff_part_buffer(AFF_PART_ORDER|AFF_PART_STATUS,disk_car,new_partition);
if(new_partition->errcode!=BAD_NOERR)
{
aff_buffer(BUFFER_ADD,"%s\n",errmsg_i386_entry2partition(new_partition->errcode));
@@ -548,8 +548,8 @@ static list_part_t *get_ext_data_i386(disk_t *disk_car, list_part_t *list_part,
{ /* Must be IN partition_main_ext */
res=1;
aff_buffer(BUFFER_ADD,"Must be in extended partition\n");
- aff_part_buffer(AFF_PART_ORDER,disk_car,partition_main_ext);
- aff_part_buffer(AFF_PART_ORDER,disk_car,new_partition);
+ 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);
}
else
{
@@ -563,8 +563,8 @@ static list_part_t *get_ext_data_i386(disk_t *disk_car, list_part_t *list_part,
{ /* New Partition start or end mustn't been in partition */
res=1;
aff_buffer(BUFFER_ADD, "Logical partition must be in its own extended partition\n");
- aff_part_buffer(AFF_PART_ORDER,disk_car,partition);
- aff_part_buffer(AFF_PART_ORDER,disk_car,new_partition);
+ 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);
}
}
}
@@ -577,7 +577,7 @@ static list_part_t *get_ext_data_i386(disk_t *disk_car, list_part_t *list_part,
order++;
if(verbose>1)
log_dos_entry(disk_car,p);
- aff_part_buffer(AFF_PART_ORDER,disk_car,new_partition);
+ aff_part_buffer(AFF_PART_ORDER|AFF_PART_STATUS,disk_car,new_partition);
if(new_partition->errcode!=BAD_NOERR)
{
aff_buffer(BUFFER_ADD,"%s\n",errmsg_i386_entry2partition(new_partition->errcode));
@@ -589,8 +589,8 @@ static list_part_t *get_ext_data_i386(disk_t *disk_car, list_part_t *list_part,
{ /* Must be IN partition_main_ext */
res=1;
aff_buffer(BUFFER_ADD, msg_SAME_SPACE);
- aff_part_buffer(AFF_PART_ORDER,disk_car,partition_main_ext);
- aff_part_buffer(AFF_PART_ORDER,disk_car,new_partition);
+ 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);
}
}
}
@@ -615,8 +615,8 @@ static int test_MBR_over(disk_t *disk_car,list_part_t *list_part)
{
res=1;
aff_buffer(BUFFER_ADD, msg_SAME_SPACE);
- aff_part_buffer(AFF_PART_ORDER,disk_car,element->part);
- aff_part_buffer(AFF_PART_ORDER,disk_car,element->next->part);
+ aff_part_buffer(AFF_PART_ORDER|AFF_PART_STATUS,disk_car,element->part);
+ aff_part_buffer(AFF_PART_ORDER|AFF_PART_STATUS,disk_car,element->next->part);
}
return res;
}
@@ -1283,7 +1283,7 @@ static list_part_t *add_partition_i386_ncurses(disk_t *disk_car,list_part_t *lis
new_partition->part_size=CHS2offset(disk_car,&end) - new_partition->part_offset + disk_car->sector_size;
wmove(stdscr,10, 0);
wclrtoeol(stdscr);
- aff_part(stdscr,AFF_PART_SHORT,disk_car,new_partition);
+ aff_part(stdscr, AFF_PART_BASE, disk_car, new_partition);
wmove(stdscr,INTER_GEOM_Y, INTER_GEOM_X);
wclrtoeol(stdscr);
wrefresh(stdscr);
@@ -1673,7 +1673,7 @@ static int check_part_i386(disk_t *disk_car,const int verbose,partition_t *parti
if(ret!=0)
{
log_error("check_part_i386 failed for partition type %02X\n", partition->part_type_i386);
- aff_part_buffer(AFF_PART_ORDER,disk_car,partition);
+ aff_part_buffer(AFF_PART_ORDER|AFF_PART_STATUS,disk_car,partition);
if(saveheader>0)
{
save_header(disk_car,partition,verbose);
diff --git a/src/partmac.c b/src/partmac.c
index 43d29ce..8099d6b 100644
--- a/src/partmac.c
+++ b/src/partmac.c
@@ -190,7 +190,7 @@ list_part_t *read_part_mac(disk_t *disk_car, const int verbose, const int savehe
new_partition->part_size=(uint64_t)be32(dpme->dpme_pblocks)*PBLOCK_SIZE;
new_partition->status=STATUS_PRIM;
new_partition->arch->check_part(disk_car,verbose,new_partition,saveheader);
- aff_part_buffer(AFF_PART_ORDER,disk_car,new_partition);
+ aff_part_buffer(AFF_PART_ORDER|AFF_PART_STATUS,disk_car,new_partition);
new_list_part=insert_new_partition(new_list_part, new_partition, 0, &insert_error);
if(insert_error>0)
free(new_partition);
@@ -332,7 +332,7 @@ static list_part_t *add_partition_mac_ncurses(disk_t *disk_car,list_part_t *list
wprintw(stdscr,"%s",disk_car->description(disk_car));
wmove(stdscr,10, 0);
wclrtoeol(stdscr);
- aff_part(stdscr,AFF_PART_SHORT,disk_car,new_partition);
+ aff_part(stdscr, AFF_PART_BASE, disk_car, new_partition);
wmove(stdscr,INTER_GEOM_Y, INTER_GEOM_X);
wclrtoeol(stdscr);
wrefresh(stdscr);
@@ -541,7 +541,7 @@ static int check_part_mac(disk_t *disk_car,const int verbose,partition_t *partit
if(ret!=0)
{
log_error("check_part_mac failed for partition type %02X\n", partition->part_type_mac);
- aff_part_buffer(AFF_PART_ORDER,disk_car,partition);
+ aff_part_buffer(AFF_PART_ORDER|AFF_PART_STATUS,disk_car,partition);
if(saveheader>0)
{
save_header(disk_car,partition,verbose);
diff --git a/src/partnone.c b/src/partnone.c
index d4ecfa6..cfec378 100644
--- a/src/partnone.c
+++ b/src/partnone.c
@@ -199,7 +199,7 @@ list_part_t *read_part_none(disk_t *disk_car, const int verbose, const int saveh
partition->status=STATUS_PRIM;
aff_buffer(BUFFER_RESET,"Q");
disk_car->arch->check_part(disk_car,verbose,partition,saveheader);
- aff_part_buffer(AFF_PART_ORDER,disk_car,partition);
+ aff_part_buffer(AFF_PART_ORDER|AFF_PART_STATUS,disk_car,partition);
list_part=insert_new_partition(NULL, partition, 0, &insert_error);
if(insert_error>0)
free(partition);
diff --git a/src/partsun.c b/src/partsun.c
index 323700a..006b246 100644
--- a/src/partsun.c
+++ b/src/partsun.c
@@ -171,7 +171,7 @@ list_part_t *read_part_sun(disk_t *disk_car, const int verbose, const int savehe
new_partition->part_size=(uint64_t)be32(sunlabel->partitions[i].num_sectors)*disk_car->sector_size;
new_partition->status=STATUS_PRIM;
disk_car->arch->check_part(disk_car,verbose,new_partition,saveheader);
- aff_part_buffer(AFF_PART_ORDER,disk_car,new_partition);
+ aff_part_buffer(AFF_PART_ORDER|AFF_PART_STATUS,disk_car,new_partition);
new_list_part=insert_new_partition(new_list_part, new_partition, 0, &insert_error);
if(insert_error>0)
free(new_partition);
@@ -306,7 +306,7 @@ static list_part_t *add_partition_sun_ncurses(disk_t *disk_car,list_part_t *list
new_partition->part_size=CHS2offset(disk_car,&end) - new_partition->part_offset + disk_car->sector_size;
wmove(stdscr,10, 0);
wclrtoeol(stdscr);
- aff_part(stdscr,AFF_PART_SHORT,disk_car,new_partition);
+ aff_part(stdscr, AFF_PART_BASE, disk_car, new_partition);
wmove(stdscr,INTER_GEOM_Y, INTER_GEOM_X);
wclrtoeol(stdscr);
wrefresh(stdscr);
@@ -490,7 +490,7 @@ static int check_part_sun(disk_t *disk_car,const int verbose,partition_t *partit
if(ret!=0)
{
log_error("check_part_sun failed for partition type %02X\n", partition->part_type_sun);
- aff_part_buffer(AFF_PART_ORDER,disk_car,partition);
+ aff_part_buffer(AFF_PART_ORDER|AFF_PART_STATUS,disk_car,partition);
if(saveheader>0)
{
save_header(disk_car,partition,verbose);
diff --git a/src/partxbox.c b/src/partxbox.c
index cdde63d..3821603 100644
--- a/src/partxbox.c
+++ b/src/partxbox.c
@@ -124,7 +124,7 @@ list_part_t *read_part_xbox(disk_t *disk_car, const int verbose, const int saveh
partition->part_size=offsets[i+1]-offsets[i];
partition->status=STATUS_PRIM;
disk_car->arch->check_part(disk_car,verbose,partition,saveheader);
- aff_part_buffer(AFF_PART_ORDER,disk_car,partition);
+ aff_part_buffer(AFF_PART_ORDER|AFF_PART_STATUS,disk_car,partition);
new_list_part=insert_new_partition(new_list_part, partition, 0, &insert_error);
if(insert_error>0)
free(partition);
@@ -234,7 +234,7 @@ static list_part_t *add_partition_xbox_ncurses(disk_t *disk_car,list_part_t *lis
wprintw(stdscr,"%s",disk_car->description(disk_car));
wmove(stdscr,10, 0);
wclrtoeol(stdscr);
- aff_part(stdscr,AFF_PART_SHORT,disk_car,new_partition);
+ aff_part(stdscr, AFF_PART_BASE, disk_car, new_partition);
wmove(stdscr,INTER_GEOM_Y, INTER_GEOM_X);
wclrtoeol(stdscr);
wrefresh(stdscr);
@@ -403,7 +403,7 @@ static int check_part_xbox(disk_t *disk_car,const int verbose,partition_t *parti
if(ret!=0)
{
log_error("check_part_xbox failed for partition type %02X\n", partition->part_type_xbox);
- aff_part_buffer(AFF_PART_ORDER,disk_car,partition);
+ aff_part_buffer(AFF_PART_ORDER|AFF_PART_STATUS,disk_car,partition);
if(saveheader>0)
{
save_header(disk_car,partition,verbose);
diff --git a/src/phrecn.c b/src/phrecn.c
index 3be4bca..d33b3ae 100644
--- a/src/phrecn.c
+++ b/src/phrecn.c
@@ -296,7 +296,7 @@ static int ask_mode_ext2(const disk_t *disk_car, const partition_t *partition, u
window=newwin(0,0,0,0); /* full screen */
aff_copy(window);
wmove(window,4,0);
- aff_part(window, AFF_PART_ORDER,disk_car,partition);
+ aff_part(window, AFF_PART_ORDER|AFF_PART_STATUS,disk_car,partition);
wmove(window,6,0);
waddstr(window,"To recover lost files, PhotoRec need to know the filesystem type where the");
wmove(window,7,0);
@@ -1270,7 +1270,7 @@ static int photorec(disk_t *disk_car, partition_t *partition, const int verbose,
wprintw(stdscr,"%s",disk_car->description_short(disk_car));
mvwaddstr(stdscr,5,0,msg_PART_HEADER_LONG);
wmove(stdscr,6,0);
- aff_part(stdscr,AFF_PART_ORDER,disk_car,partition);
+ aff_part(stdscr,AFF_PART_ORDER|AFF_PART_STATUS,disk_car,partition);
wmove(stdscr,22,0);
wattrset(stdscr, A_REVERSE);
waddstr(stdscr," Stop ");
@@ -1549,11 +1549,11 @@ static void menu_photorec_ncurses(disk_t *disk_car, int verbose, const char *rec
if(element==current_element)
{
wattrset(stdscr, A_REVERSE);
- aff_part(stdscr,AFF_PART_ORDER,disk_car,element->part);
+ aff_part(stdscr,AFF_PART_ORDER|AFF_PART_STATUS,disk_car,element->part);
wattroff(stdscr, A_REVERSE);
} else
{
- aff_part(stdscr,AFF_PART_ORDER,disk_car,element->part);
+ aff_part(stdscr,AFF_PART_ORDER|AFF_PART_STATUS,disk_car,element->part);
}
}
command = wmenuSelect(stdscr,INTER_SELECT_Y, INTER_SELECT_X, menuMain, 8,
diff --git a/src/sudo.c b/src/sudo.c
new file mode 100644
index 0000000..88b371e
--- /dev/null
+++ b/src/sudo.c
@@ -0,0 +1,61 @@
+/*
+
+ File: sudo.c
+
+ Copyright (C) 2007 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
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License along
+ with this program; if not, write the Free Software Foundation, Inc., 51
+ Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#ifdef SUDO_BIN
+#ifdef HAVE_STDLIB_H
+#include <stdlib.h>
+#endif
+#ifdef HAVE_UNISTD_H
+#include <unistd.h> /* execv */
+#endif
+#ifdef HAVE_STRING_H
+#include <string.h>
+#endif
+#include <stdio.h>
+#include <errno.h>
+#include "types.h"
+#include "common.h"
+#include "sudo.h"
+
+void run_sudo(int argc, char **argv)
+{
+ int i;
+ char **argv2;
+ argv2 = (char **)MALLOC(sizeof(char *) * (argc + 2));
+ argv2[0]=SUDO_BIN;
+ for (i=0; i < argc; i++)
+ argv2[i+1] = argv[i];
+ argv2[i+1]=NULL;
+ printf("sudo may ask your user password\n");
+ fflush(stdout);
+ if(execv(argv2[0], argv2)<0)
+ {
+ printf("%s failed: %s\n", SUDO_BIN, strerror(errno));
+ printf("Press Enter key to quit.\n");
+ getchar();
+ }
+ free(argv2);
+}
+#endif
diff --git a/src/sudo.h b/src/sudo.h
new file mode 100644
index 0000000..58085fe
--- /dev/null
+++ b/src/sudo.h
@@ -0,0 +1,24 @@
+/*
+
+ File: sudo.h
+
+ Copyright (C) 2007 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
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License along
+ with this program; if not, write the Free Software Foundation, Inc., 51
+ Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+ */
+#ifdef SUDO_BIN
+void run_sudo(int argc, char **argv);
+#endif
diff --git a/src/testdisk.c b/src/testdisk.c
index 48ced13..f04ee4b 100644
--- a/src/testdisk.c
+++ b/src/testdisk.c
@@ -60,6 +60,8 @@
#include "ewf.h"
#include "log.h"
#include "hdaccess.h"
+#include "sudo.h"
+#include "partauto.h"
extern const arch_fnct_t arch_i386;
extern const arch_fnct_t arch_mac;
@@ -95,6 +97,7 @@ int main( int argc, char **argv )
int help=0, verbose=0, dump_ind=0;
int create_log=0; /* 0: no_log, 1: append, 2 create */
int do_list=0;
+ int unit=UNIT_DEFAULT;
int write_used;
int saveheader=0;
int create_backup=0;
@@ -158,8 +161,15 @@ int main( int argc, char **argv )
else if((strcmp(argv[i],"/help")==0) || (strcmp(argv[i],"-help")==0) || (strcmp(argv[i],"--help")==0) ||
(strcmp(argv[i],"/h")==0) || (strcmp(argv[i],"-h")==0))
help=1;
- else if((strcmp(argv[i],"/list")==0) || (strcmp(argv[i],"-list")==0))
+ else if(strcmp(argv[i],"/list")==0 || strcmp(argv[i],"-list")==0 || strcmp(argv[i],"-l")==0)
+ {
+ do_list=1;
+ }
+ else if(strcmp(argv[i],"-lu")==0)
+ {
do_list=1;
+ unit=UNIT_SECTOR;
+ }
else if((strcmp(argv[i],"/nosetlocale")==0) || (strcmp(argv[i],"-nosetlocale")==0))
run_setlocale=0;
else if((strcmp(argv[i],"/safe")==0) || (strcmp(argv[i],"-safe")==0))
@@ -248,7 +258,12 @@ int main( int argc, char **argv )
for(element_disk=list_disk;element_disk!=NULL;element_disk=element_disk->next)
{
- interface_list(element_disk->disk,verbose,0,saveheader,create_backup, &cmd_run);
+ autodetect_arch(element_disk->disk);
+ if(unit==UNIT_DEFAULT)
+ autoset_unit(element_disk->disk);
+ else
+ element_disk->disk->unit=unit;
+ interface_list(element_disk->disk, verbose, saveheader, create_backup, &cmd_run);
}
delete_list_disk(list_disk);
return 0;
@@ -343,7 +358,7 @@ int main( int argc, char **argv )
{
case 'L':
for(element_disk=list_disk;element_disk!=NULL;element_disk=element_disk->next)
- interface_list(element_disk->disk,verbose,0, saveheader, create_backup, &cmd_run);
+ interface_list(element_disk->disk, verbose, saveheader, create_backup, &cmd_run);
break;
case 'q':
case 'Q':