diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/analyse.c | 2 | ||||
-rw-r--r-- | src/ewf.c | 1 | ||||
-rw-r--r-- | src/ext2_dir.c | 4 | ||||
-rw-r--r-- | src/fat_adv.c | 15 | ||||
-rw-r--r-- | src/fat_dir.c | 10 | ||||
-rw-r--r-- | src/intrf.c | 4 | ||||
-rw-r--r-- | src/intrface.c | 17 |
7 files changed, 42 insertions, 11 deletions
diff --git a/src/analyse.c b/src/analyse.c index 29228f4a..2bf21da1 100644 --- a/src/analyse.c +++ b/src/analyse.c @@ -270,7 +270,9 @@ list_part_t *search_superblock(disk_t *disk_car, const partition_t *partition, c 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"); @@ -240,7 +240,6 @@ static int fewf_read(disk_t *disk_car,const unsigned int count, void *nom_buffer static int fewf_nowrite(disk_t *disk_car,const unsigned int count, const void *nom_buffer, const uint64_t offset) { - struct info_fewf_struct *data=(struct info_fewf_struct *)disk_car->data; log_error("fewf_nowrite(xx,%u,buffer,%lu(%u/%u/%u)) write refused\n", (unsigned)(count/disk_car->sector_size), (long unsigned)(offset/disk_car->sector_size), offset2cylinder(disk_car,offset), offset2head(disk_car,offset), offset2sector(disk_car,offset)); diff --git a/src/ext2_dir.c b/src/ext2_dir.c index 09cddd3f..a434b3a9 100644 --- a/src/ext2_dir.c +++ b/src/ext2_dir.c @@ -294,8 +294,6 @@ static int ext2_copy(disk_t *disk_car, const partition_t *partition, dir_data_t struct ext2_inode inode; char buffer[8192]; ext2_file_t e2_file; - int nbytes; - unsigned int got; if (ext2fs_read_inode(ls->current_fs, file->filestat.st_ino, &inode)!=0) { @@ -311,6 +309,8 @@ static int ext2_copy(disk_t *disk_car, const partition_t *partition, dir_data_t } while (1) { + int nbytes; + unsigned int got; retval = ext2fs_file_read(e2_file, buffer, sizeof(buffer), &got); if (retval) { diff --git a/src/fat_adv.c b/src/fat_adv.c index 345d9016..52593eca 100644 --- a/src/fat_adv.c +++ b/src/fat_adv.c @@ -58,8 +58,7 @@ #define INTER_FAT_ASK_X 0 #define INTER_FAT_ASK_Y 23 -static const char *monstr[] = { "Jan", "Feb", "Mar", "Apr", "May", "Jun", - "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"}; +extern const char *monstr[]; typedef struct sector_cluster_struct sector_cluster_t; typedef struct info_offset_struct info_offset_t; @@ -332,7 +331,9 @@ static unsigned int fat32_find_root_cluster(disk_t *disk_car,const partition_t * file_data_t *rootdir_list=NULL; file_data_t *current_file=NULL; unsigned int dir_nbr=0; +#ifdef HAVE_NCURSES int interactive=1; +#endif unsigned char *buffer; int ind_stop=0; buffer=(unsigned char *)MALLOC(cluster_size); @@ -347,8 +348,8 @@ static unsigned int fat32_find_root_cluster(disk_t *disk_car,const partition_t * #endif for(root_cluster=2;(root_cluster<2+no_of_cluster)&&(ind_stop==0);root_cluster++) { - unsigned long int percent=root_cluster*100/(2+no_of_cluster); #ifdef HAVE_NCURSES + const unsigned long int percent=root_cluster*100/(2+no_of_cluster); if(interface>0 && (root_cluster&0xfff)==0) { wmove(stdscr,9,0); @@ -906,6 +907,7 @@ static void menu_write_fat_boot_sector(disk_t *disk_car, partition_t *partition, { const struct fat_boot_sector *org_fat_header=(const struct fat_boot_sector *)orgboot; const struct fat_boot_sector *fat_header=(const struct fat_boot_sector *)newboot; +#ifdef HAVE_NCURSES struct MenuItem menuSaveBoot[]= { { 'D', "Dump", "Dump sector" }, @@ -914,6 +916,7 @@ static void menu_write_fat_boot_sector(disk_t *disk_car, partition_t *partition, { 'Q',"Quit","Quit this section"}, { 0, NULL, NULL } }; +#endif const char *options="DLQ"; int do_write=0; int do_exit=0; @@ -1535,7 +1538,9 @@ static unsigned int fat_find_fat_start(const unsigned char *buffer,const int p_f static int fat_find_type(disk_t *disk_car,const partition_t *partition,const uint64_t max_offset,const int p_fat12,const int p_fat16,const int p_fat32,const int verbose,const int dump_ind,const int interface,unsigned int *nbr_offset,info_offset_t *info_offset, const unsigned int max_nbr_offset) { uint64_t offset; +#ifdef HAVE_NCURSES unsigned long int old_percent=0; +#endif int ind_stop=0; unsigned char *buffer=(unsigned char *)MALLOC(disk_car->sector_size); if(verbose>0) @@ -2472,7 +2477,9 @@ int repair_FAT_table(disk_t *disk_car, partition_t *partition, const int verbose unsigned int fat_mismatch=0; unsigned int fat_nbr; unsigned long int cluster; +#ifdef HAVE_NCURSES unsigned long int old_percent=0; +#endif unsigned char *buffer_fat[2]; unsigned int rw_size=buffer_size; for(fat_nbr=0;fat_nbr<fats;fat_nbr++) @@ -2509,7 +2516,7 @@ int repair_FAT_table(disk_t *disk_car, partition_t *partition, const int verbose if(offset_s!=old_offset_s) { #ifdef HAVE_NCURSES - unsigned long int percent=cluster*100/(no_of_cluster+1); + const unsigned long int percent=cluster*100/(no_of_cluster+1); if(percent!=old_percent) { wmove(window,4,0); diff --git a/src/fat_dir.c b/src/fat_dir.c index 6c385fd4..3e4da6e0 100644 --- a/src/fat_dir.c +++ b/src/fat_dir.c @@ -556,7 +556,15 @@ static int fat_copy(disk_t *disk_car, const partition_t *partition, dir_data_t * { log_error("fat_copy: Can't read cluster %u.\n", cluster); } - fwrite(buffer_file, 1, toread, f_out); + if(fwrite(buffer_file, 1, toread, f_out) != toread) + { + log_error("fat_copy: no space left on destination.\n"); + fclose(f_out); + set_date(new_file, file->filestat.st_atime, file->filestat.st_mtime); + free(new_file); + free(buffer_file); + return -1; + } file_size -= toread; if(file_size>0) { diff --git a/src/intrf.c b/src/intrf.c index de352fe4..2f6b2e19 100644 --- a/src/intrf.c +++ b/src/intrf.c @@ -85,7 +85,9 @@ extern const char *monstr[]; static char intr_buffer_screen[MAX_LINES][LINE_LENGTH+1]; static int intr_nbr_line=0; +#ifdef HAVE_NCURSES static void set_parent_directory(char *dst_directory); +#endif int screen_buffer_add(const char *_format, ...) { @@ -244,6 +246,7 @@ const char *aff_part_aux(const unsigned int newline, const disk_t *disk_car, con #define PATH_DRIVE_LENGTH 9 #endif +#ifdef HAVE_NCURSES static void set_parent_directory(char *dst_directory) { int i; @@ -271,6 +274,7 @@ static void set_parent_directory(char *dst_directory) dst_directory[1]='\0'; #endif } +#endif static inline char *td_getcwd(char *buf, unsigned long size) { diff --git a/src/intrface.c b/src/intrface.c index 3f718dd8..458e9907 100644 --- a/src/intrface.c +++ b/src/intrface.c @@ -74,8 +74,10 @@ extern const arch_fnct_t arch_i386; static void interface_options(int *dump_ind, int *align, int *allow_partial_last_cylinder, unsigned int *expert, char**current_cmd); +#ifdef HAVE_NCURSES static list_part_t *interface_load(disk_t *disk_car,list_part_t *list_part, const int verbose); static list_part_t *merge_partition_list(list_part_t *list_part,list_part_t *backup_part, const int verbose); +#endif static int write_MBR_code(disk_t *disk_car); static int write_clean_table(disk_t *disk_car); static int interface_check_disk_capacity(disk_t *disk_car); @@ -627,7 +629,6 @@ static int interface_check_disk_capacity(disk_t *disk_car) #ifdef HAVE_NCURSES static int interface_check_disk_access_ncurses(disk_t *disk_car) { - const char *prog_name="TestDisk"; static const struct MenuItem menuDiskAccess[]= { { 'C', "Continue", "Continue even if write access isn't available"}, @@ -649,7 +650,7 @@ static int interface_check_disk_access_ncurses(disk_t *disk_car) wmove(stdscr,line++,0); wprintw(stdscr,"- You may need to be administrator to have write access.\n"); wmove(stdscr,line++,0); - wprintw(stdscr,"Under Vista, select %s, right-click and choose \"Run as administrator\".\n", prog_name); + wprintw(stdscr,"Under Vista, select TestDisk, right-click and choose \"Run as administrator\".\n"); #elif defined HAVE_GETEUID if(geteuid()!=0) { @@ -657,7 +658,7 @@ static int interface_check_disk_access_ncurses(disk_t *disk_car) wprintw(stdscr,"- You may need to be root to have write access.\n"); #if defined(__APPLE__) wmove(stdscr,line++,0); - wprintw(stdscr,"Use the sudo command to launch %s.\n", prog_name); + wprintw(stdscr,"Use the sudo command to launch TestDisk.\n"); #endif wmove(stdscr,line++,0); wprintw(stdscr,"- Check the OS permission for this file or device.\n"); @@ -700,6 +701,7 @@ static list_part_t *interface_analyse_ncurses(disk_t *disk_car, const int verbos { list_part_t *list_part; int command; +#ifdef HAVE_NCURSES struct MenuItem menuAnalyse[]= { { 'P', "Previous",""}, @@ -708,6 +710,7 @@ static list_part_t *interface_analyse_ncurses(disk_t *disk_car, const int verbos { 'B', "Backup","Save current partition list to backup.log file and proceed"}, { 0, NULL, NULL } }; +#endif screen_buffer_reset(); /* ncurses interface */ #ifdef HAVE_NCURSES @@ -771,6 +774,7 @@ static list_part_t *interface_analyse(disk_t *disk_car, const int verbose, const 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 *parts; +#ifdef HAVE_NCURSES struct MenuItem menuWrite[]= { { 'P', "Previous",""}, @@ -781,6 +785,7 @@ int interface_write(disk_t *disk_car,list_part_t *list_part,const int can_search { 'E', "Extd Part","Maximize/Minimize extended partition"}, { 0, NULL, NULL } }; +#endif int command; log_info("\ninterface_write()\n"); screen_buffer_reset(); @@ -1297,6 +1302,7 @@ list_part_t *ask_structure(disk_t *disk_car,list_part_t *list_part, const int ve #endif } +#ifdef HAVE_NCURSES static list_part_t *merge_partition_list(list_part_t *list_part,list_part_t *backup_part, const int verbose) { list_part_t *partition; @@ -1311,6 +1317,7 @@ static list_part_t *merge_partition_list(list_part_t *list_part,list_part_t *bac } return list_part; } +#endif #ifdef HAVE_NCURSES static struct td_list_head *interface_load_ncurses(disk_t *disk_car, backup_disk_t *backup_list, const int verbose) @@ -1441,6 +1448,7 @@ static struct td_list_head *interface_load_ncurses(disk_t *disk_car, backup_disk } #endif +#ifdef HAVE_NCURSES static list_part_t *interface_load(disk_t *disk_car,list_part_t *list_part, const int verbose) { struct td_list_head *backup_walker=NULL; @@ -1484,11 +1492,13 @@ static list_part_t *interface_load(disk_t *disk_car,list_part_t *list_part, cons } return list_part; } +#endif int interface_superblock(disk_t *disk_car,list_part_t *list_part, char**current_cmd) { const list_part_t *parts; const partition_t *old_part=NULL; +#ifdef HAVE_NCURSES struct MenuItem menuSuperblock[]= { { 'P', "Previous",""}, @@ -1496,6 +1506,7 @@ int interface_superblock(disk_t *disk_car,list_part_t *list_part, char**current_ { 'Q',"Quit","Return to Advanced menu"}, { 0, NULL, NULL } }; +#endif screen_buffer_reset(); #ifdef HAVE_NCURSES aff_copy(stdscr); |