diff options
author | Christophe Grenier <grenier@cgsecurity.org> | 2009-01-14 22:13:47 +0100 |
---|---|---|
committer | Christophe Grenier <grenier@cgsecurity.org> | 2009-01-14 22:13:47 +0100 |
commit | 1650fe5b8b6cea638c280df13605aea816718a00 (patch) | |
tree | fed11bd9361236aba47157d859607c109db05814 /src/analyse.c | |
parent | 56e1c29b2c0614b0b3230946d72e1eaf37618bcc (diff) |
Split ncurses text interface from functions
Diffstat (limited to 'src/analyse.c')
-rw-r--r-- | src/analyse.c | 101 |
1 files changed, 2 insertions, 99 deletions
diff --git a/src/analyse.c b/src/analyse.c index 2bf21da..3ffee03 100644 --- a/src/analyse.c +++ b/src/analyse.c @@ -22,19 +22,19 @@ #ifdef HAVE_CONFIG_H #include <config.h> #endif + +#include <stdio.h> #ifdef HAVE_STDLIB_H #include <stdlib.h> #endif #ifdef HAVE_STRING_H #include <string.h> #endif -//#include <assert.h> #include "types.h" #include "common.h" #include "fnctdsk.h" #include "analyse.h" #include "intrf.h" -#include "intrfn.h" #include "savehdr.h" #include "lang.h" #include "bfs.h" @@ -262,100 +262,3 @@ int search_type_128(unsigned char *buffer, disk_t *disk_car,partition_t *partiti #endif return 0; } - -list_part_t *search_superblock(disk_t *disk_car, const partition_t *partition, const int verbose, const int dump_ind, const int interface) -{ - unsigned char *buffer=(unsigned char *)MALLOC(2*0x200); - uint64_t hd_offset; - int nbr_sb=0; - list_part_t *list_part=NULL; - int ind_stop=0; -#ifdef HAVE_NCURSES - unsigned long int old_percent=0; -#endif - struct ext2_super_block *sb=(struct ext2_super_block *)buffer; - partition_t *new_partition=partition_new(disk_car->arch); - log_trace("search_superblock\n"); -#ifdef HAVE_NCURSES - if(interface>0) - { - aff_copy(stdscr); - wmove(stdscr,4,0); - 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|AFF_PART_STATUS,disk_car,partition); - wmove(stdscr,22,0); - wattrset(stdscr, A_REVERSE); - waddstr(stdscr," Stop "); - wattroff(stdscr, A_REVERSE); - } -#endif - for(hd_offset=0;hd_offset<partition->part_size && nbr_sb<10 && ind_stop==0;hd_offset+=DEFAULT_SECTOR_SIZE) - { -#ifdef HAVE_NCURSES - unsigned long int percent; - percent=hd_offset*100/partition->part_size; - if(interface>0 && percent!=old_percent) - { - wmove(stdscr,9,0); - wclrtoeol(stdscr); - wprintw(stdscr,"Search ext2/ext3/ext4 superblock %10lu/%lu %lu%%", (long unsigned)(hd_offset/disk_car->sector_size), - (long unsigned)(partition->part_size/disk_car->sector_size),percent); - wrefresh(stdscr); - ind_stop|=check_enter_key_or_s(stdscr); - old_percent=percent; - } -#endif - /* ext2/ext3/ext4 */ - if( hd_offset==(EXT2_MIN_BLOCK_SIZE<<0) || - hd_offset==(EXT2_MIN_BLOCK_SIZE<<1) || - hd_offset==(EXT2_MIN_BLOCK_SIZE<<2) || - hd_offset==(1*(EXT2_MIN_BLOCK_SIZE<<0)*8*(EXT2_MIN_BLOCK_SIZE<<0)+2*512) || - hd_offset==(1*(EXT2_MIN_BLOCK_SIZE<<1)*8*(EXT2_MIN_BLOCK_SIZE<<1)) || - hd_offset==(1*(EXT2_MIN_BLOCK_SIZE<<2)*8*(EXT2_MIN_BLOCK_SIZE<<2)) || - hd_offset%(3*(EXT2_MIN_BLOCK_SIZE<<0)*8*(EXT2_MIN_BLOCK_SIZE<<0)+2*512)==0 || - hd_offset%(5*(EXT2_MIN_BLOCK_SIZE<<0)*8*(EXT2_MIN_BLOCK_SIZE<<0)+2*512)==0 || - hd_offset%(7*(EXT2_MIN_BLOCK_SIZE<<0)*8*(EXT2_MIN_BLOCK_SIZE<<0)+2*512)==0 || - hd_offset%(3*(EXT2_MIN_BLOCK_SIZE<<1)*8*(EXT2_MIN_BLOCK_SIZE<<1))==0 || - hd_offset%(5*(EXT2_MIN_BLOCK_SIZE<<1)*8*(EXT2_MIN_BLOCK_SIZE<<1))==0 || - hd_offset%(7*(EXT2_MIN_BLOCK_SIZE<<1)*8*(EXT2_MIN_BLOCK_SIZE<<1))==0 || - hd_offset%(3*(EXT2_MIN_BLOCK_SIZE<<2)*8*(EXT2_MIN_BLOCK_SIZE<<2))==0 || - hd_offset%(5*(EXT2_MIN_BLOCK_SIZE<<2)*8*(EXT2_MIN_BLOCK_SIZE<<2))==0 || - hd_offset%(7*(EXT2_MIN_BLOCK_SIZE<<2)*8*(EXT2_MIN_BLOCK_SIZE<<2))==0) - { - if(disk_car->read(disk_car,1024, buffer, partition->part_offset+hd_offset)==0) - { - if(le16(sb->s_magic)==EXT2_SUPER_MAGIC) - { - dup_partition_t(new_partition,partition); - new_partition->part_offset+=hd_offset; - if(recover_EXT2(disk_car,sb,new_partition,verbose,dump_ind)==0) - { - int insert_error=0; - if(hd_offset<=(EXT2_MIN_BLOCK_SIZE<<2)) - new_partition->part_offset-=hd_offset; - log_info("Ext2 superblock found at sector %llu (block=%llu, blocksize=%u)\n", - (long long unsigned) hd_offset/DEFAULT_SECTOR_SIZE, - (long long unsigned) hd_offset>>(EXT2_MIN_BLOCK_LOG_SIZE+le32(sb->s_log_block_size)), - EXT2_MIN_BLOCK_SIZE<<le32(sb->s_log_block_size)); -#ifdef HAVE_NCURSES - wmove(stdscr,10+nbr_sb,0); - wprintw(stdscr,"Ext2 superblock found at sector %llu (block=%llu, blocksize=%u) \n", - (long long unsigned) hd_offset/DEFAULT_SECTOR_SIZE, - (long long unsigned) hd_offset>>(EXT2_MIN_BLOCK_LOG_SIZE+le32(sb->s_log_block_size)), - EXT2_MIN_BLOCK_SIZE<<le32(sb->s_log_block_size)); -#endif - list_part=insert_new_partition(list_part, new_partition, 1, &insert_error); - new_partition=partition_new(disk_car->arch); - nbr_sb++; - } - } - } - } - } - free(new_partition); - free(buffer); - return list_part; -} - |