summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristophe Grenier <grenier@cgsecurity.org>2010-12-16 08:51:31 +0100
committerChristophe Grenier <grenier@cgsecurity.org>2010-12-16 08:51:31 +0100
commit488e05fc600040ab36fe46aa4849db1781876e28 (patch)
treec4fae2529496e9e9767e77c8c83b1aca8111ca3b
parent65390765f54fc16f6108269534c1a1ac7a635b8a (diff)
List and undelete filesystem using alternate superblock if necessary
-rw-r--r--src/adv.c47
-rw-r--r--src/fat1x.c4
-rw-r--r--src/tdiskop.c3
3 files changed, 43 insertions, 11 deletions
diff --git a/src/adv.c b/src/adv.c
index d5c6aa3..e470bae 100644
--- a/src/adv.c
+++ b/src/adv.c
@@ -58,6 +58,7 @@
#include "thfs.h"
#include "askloc.h"
#include "addpart.h"
+#include "io_redir.h"
extern const arch_fnct_t arch_gpt;
extern const arch_fnct_t arch_i386;
@@ -264,11 +265,14 @@ void interface_adv(disk_t *disk_car, const int verbose,const int dump_ind, const
else
{
const partition_t *partition=current_element->part;
- if(menu==0)
+ if(menu==0 && (disk_car->arch!=&arch_none || partition->upart_type!=UP_UNK))
menu=1;
if(is_part_fat(partition))
+ {
options="tubcq";
- if(is_part_ntfs(partition))
+ menu=(partition->upart_type==UP_UNK?1:4);
+ }
+ else if(is_part_ntfs(partition))
options="tlubcq";
else if(is_part_linux(partition))
{
@@ -290,9 +294,9 @@ void interface_adv(disk_t *disk_car, const int verbose,const int dump_ind, const
else if(is_linux(partition))
{
if(partition->upart_type==UP_EXT2)
- options="tuscq";
+ options="tluscq";
else
- options="tscq";
+ options="tlscq";
menuAdv[2].desc="Locate ext2/ext3/ext4 backup superblock";
}
else if(is_hfs(partition) || is_hfsp(partition))
@@ -490,10 +494,26 @@ void interface_adv(disk_t *disk_car, const int verbose,const int dump_ind, const
case 'U':
{
partition_t *partition=current_element->part;
- if(partition->upart_type==UP_NTFS || is_part_ntfs(partition))
- ntfs_undelete_part(disk_car, partition, verbose, current_cmd);
+ if(partition->sb_offset!=0 && partition->sb_size>0)
+ {
+ io_redir_add_redir(disk_car,
+ partition->part_offset+partition->sborg_offset,
+ partition->sb_size,
+ partition->part_offset+partition->sb_offset,
+ NULL);
+ if(partition->upart_type==UP_NTFS || is_part_ntfs(partition))
+ ntfs_undelete_part(disk_car, partition, verbose, current_cmd);
+ else
+ dir_partition(disk_car, partition, 0, current_cmd);
+ io_redir_del_redir(disk_car, partition->part_offset+partition->sborg_offset);
+ }
else
- dir_partition(disk_car, partition, 0, current_cmd);
+ {
+ if(partition->upart_type==UP_NTFS || is_part_ntfs(partition))
+ ntfs_undelete_part(disk_car, partition, verbose, current_cmd);
+ else
+ dir_partition(disk_car, partition, 0, current_cmd);
+ }
}
rewrite=1;
break;
@@ -501,7 +521,18 @@ void interface_adv(disk_t *disk_car, const int verbose,const int dump_ind, const
case 'L':
{
partition_t *partition=current_element->part;
- dir_partition(disk_car, partition, 0, current_cmd);
+ if(partition->sb_offset!=0 && partition->sb_size>0)
+ {
+ io_redir_add_redir(disk_car,
+ partition->part_offset+partition->sborg_offset,
+ partition->sb_size,
+ partition->part_offset+partition->sb_offset,
+ NULL);
+ dir_partition(disk_car,partition,verbose, current_cmd);
+ io_redir_del_redir(disk_car, partition->part_offset+partition->sborg_offset);
+ }
+ else
+ dir_partition(disk_car,partition,verbose, current_cmd);
}
rewrite=1;
break;
diff --git a/src/fat1x.c b/src/fat1x.c
index d6df205..d3b472f 100644
--- a/src/fat1x.c
+++ b/src/fat1x.c
@@ -81,8 +81,8 @@ int fat1x_boot_sector(disk_t *disk_car, partition_t *partition, const int verbos
{ 'P', "Previous",""},
{ 'N', "Next","" },
{ 'Q', "Quit","Return to Advanced menu"},
- { 'L', "List", "List directories and files, copy and undelete data from FAT" },
{ 'R', "Rebuild BS","Rebuild boot sector"},
+ { 'L', "List", "List directories and files, copy and undelete data from FAT" },
{ 'D', "Dump","Dump boot sector and backup boot sector"},
{ 'C', "Repair FAT","Very Dangerous! Expert only"},
{ 'I', "Init Root","Init root directory: Very Dangerous! Expert only"},
@@ -93,7 +93,7 @@ int fat1x_boot_sector(disk_t *disk_car, partition_t *partition, const int verbos
while(1)
{
#ifdef HAVE_NCURSES
- unsigned int menu=0;
+ unsigned int menu=3;
#endif
int command;
screen_buffer_reset();
diff --git a/src/tdiskop.c b/src/tdiskop.c
index bbdea14..60e1287 100644
--- a/src/tdiskop.c
+++ b/src/tdiskop.c
@@ -47,6 +47,7 @@
#include "geometry.h"
extern const arch_fnct_t arch_i386;
+extern const arch_fnct_t arch_none;
#define INTER_DISK_X 0
#define INTER_DISK_Y 7
@@ -139,7 +140,6 @@ static int menu_disk_ncurses(disk_t *disk_car, const int verbose,int dump_ind, c
int allow_partial_last_cylinder=0;
int ask_part_order=0;
int command;
- unsigned int menu=0;
int real_key;
unsigned int expert=0;
char options[16];
@@ -155,6 +155,7 @@ static int menu_disk_ncurses(disk_t *disk_car, const int verbose,int dump_ind, c
{'E',"Editor","Basic disk editor"},
{0,NULL,NULL}
};
+ unsigned int menu=(disk_car->arch == &arch_none ? 1 : 0);
strcpy(options, "AGOPTQ");
if(disk_car->arch->write_MBR_code!=NULL)
strcat(options,"C");