From 7e23d08441e5c557b953c4e211d656e406b6f579 Mon Sep 17 00:00:00 2001 From: Christophe Grenier Date: Sun, 10 Feb 2008 19:57:03 +0100 Subject: [PATCH] Compatibility fix for e2fsprogs 1.40.6 Fix some gcc warnings --- INFO | 2 +- NEWS | 36 ++++++++++++++++++++++++++++++++++++ compile.sh | 2 +- configure.ac | 1 + src/adv.c | 2 +- src/dimage.c | 10 ++++++++++ src/ext2p.c | 18 ++++++++++++++---- src/fat_adv.c | 4 +++- src/godmode.c | 4 +++- src/ntfs_adv.c | 2 ++ src/phrecn.c | 4 ++-- 11 files changed, 74 insertions(+), 11 deletions(-) diff --git a/INFO b/INFO index ff9af255..063c3846 100644 --- a/INFO +++ b/INFO @@ -1,3 +1,3 @@ TestDisk & PhotoRec , http://www.cgsecurity.org -Copyright (C) 1998-2007 Christophe GRENIER +Copyright (C) 1998-2008 Christophe GRENIER diff --git a/NEWS b/NEWS index b0587b09..19cc90b8 100644 --- a/NEWS +++ b/NEWS @@ -1,6 +1,42 @@ Current news ============ 6.9-WIP +TestDisk & PhotoRec 6.9 comes with numerous improvements: +- They are compatible with ntfsprogs 2.0, the latest library version for +accessing NTFS partitions, e2fsprogs 1.40.6, the latest library for accessing + ext2/ext3 partitions. +- EFI GUID Partition Table is now supported. EFI GPT is mainly used on Itanium, +MacBook and Mac Pro. +- Both utilities can use sudo if the user is not root, this functionnality will +be enabled for at least MacOSX, so users won't have to go into a command line. +- Improved Windows disk support, most internal USB card reader should now work. +- Disk model (ie. ATA ST3120026AS, _NEC DVD_RW ND-4550A...) are now reported +under Linux. + +TestDisk +- New file system support has been added: encrypted LUKS, Mac HFSX, Linux Raid +md 1.0/1.1/1.2 (0.9 was already supported). +- It displays unicode filenames correctly, and can handle unicode filesnames + while copying files from an NTFS partition when supported by the underlying + libraries. +- It's now possible to copy files from a lost FAT partition found by TestDisk + (Already possible for NTFS). +- In the Advanced menu, TestDisk can create a raw/dd-like image of a partition. + +PhotoRec +- For ext2/ext3 file systems, PhotoRec 6.9 can search in the whole space or in +unallocated space only. This feature was already available for FAT and NTFS +filesystem. +- It has better session support which allows a recovery to be stopped and +restarted later. +- New file formats are supported: Acronis True Image .TIB, AutoCAD's .DWG and +PowerTab .PTB, Cineon image file/SMTPE DPX .DPX, Comic Life .comicdoc, HP +Photosmart Photo Printing Album .albm, KeepAssX .KDB, Maya .MB and .MP, +Microsoft OneNOte .one file, Microsoft Visual Studio Resource file .RES, +Microsoft VB's .CLS, Outlook .MSG, QuickBook .FST, SketchUp .SKP, Vmware .vmdk, +WinSpec .SPE, Windows Enhanced MetaFile .emf, MS Windows Link .lnk, Internet +Explorer index.dat, Macintosh Picture .pct, SunPCI Disk Image,XBOX GTA San +Andreas Save File, Final Cut Pro .fcp and Digital Speech Standard .dss. 6.8 Version 6.8 is mainly a bugfix but some small improvements has been made to diff --git a/compile.sh b/compile.sh index 52471702..266be084 100755 --- a/compile.sh +++ b/compile.sh @@ -4,7 +4,6 @@ # Comment the version definition to not compile the library VER_E2FSPROGS= VER_PROGSREISERFS=0.3.1-rc8 -#VER_NTFSPROGS=1.13.1 VER_NTFSPROGS=2.0.0 VER_LIBEWF=20070512 #VER_LIBEWF= @@ -21,6 +20,7 @@ else compiledir=$1 if [ "$1" != "$CC" ]; then +# VER_E2FSPROGS=1.40.6 VER_E2FSPROGS=1.40.2 crosscompile_target=$1 TESTDISKCC=$crosscompile_target-gcc diff --git a/configure.ac b/configure.ac index 41898b22..e0add8c7 100644 --- a/configure.ac +++ b/configure.ac @@ -381,6 +381,7 @@ if test -z "${use_ext2fs}"; then LIBS="$LIBS ${com_err_lib_a}" fi ],AC_MSG_WARN(No com_err library detected)) + AC_CHECK_FUNCS([ext2fs_get_generic_bitmap_start]) else AC_MSG_WARN(Use of ext2fs library disabled) fi diff --git a/src/adv.c b/src/adv.c index 2f2cf4d7..6f1326a7 100644 --- a/src/adv.c +++ b/src/adv.c @@ -190,7 +190,7 @@ void interface_adv(disk_t *disk_car, const int verbose,const int dump_ind, const {'t',"Type","Change type, this setting will not be saved on disk"}, {'b',"Boot","Boot sector recovery"}, {'s',"Superblock",NULL}, - {'c',"Copy", "Create an image"}, + {'c',"Image creation", "Create an image"}, // {'a',"Add", "Add temporary partition (Expert only)"}, {'q',"Quit","Return to main menu"}, {0,NULL,NULL} diff --git a/src/dimage.c b/src/dimage.c index 5292738a..9927c760 100644 --- a/src/dimage.c +++ b/src/dimage.c @@ -135,16 +135,26 @@ int disk_image(disk_t *disk_car, const partition_t *partition, const char *image } } close(disk_dst); +#ifdef HAVE_NCURSES delwin(window); (void) clearok(window, TRUE); #ifdef HAVE_TOUCHWIN touchwin(window); +#endif #endif if(ind_stop==2) { display_message("No space left for the file image.\n"); return -2; } + if(ind_stop) + { + if(nbr_read_error==0) + display_message("Incomplete image created.\n"); + else + display_message("Incomplete image created: read errors have occured.\n"); + return 0; + } if(nbr_read_error==0) display_message("Image created successfully.\n"); else diff --git a/src/ext2p.c b/src/ext2p.c index e74ae65c..8713bfde 100644 --- a/src/ext2p.c +++ b/src/ext2p.c @@ -88,6 +88,7 @@ unsigned int ext2_remove_used_space(disk_t *disk_car,const partition_t *partitio uint64_t start_free=0; uint64_t end_free=0; unsigned long int block; + unsigned long int start,end; const unsigned int blocksize=ls->current_fs->blocksize; ext2fs_block_bitmap bitmap; if(ext2fs_read_block_bitmap(ls->current_fs)) @@ -98,13 +99,22 @@ unsigned int ext2_remove_used_space(disk_t *disk_car,const partition_t *partitio bitmap=ls->current_fs->block_map; if(bitmap==NULL) return 0; - log_trace("ext2_remove_used_space %llu-%llu\n", - (long long unsigned)bitmap->start, - (long long unsigned)bitmap->end); +#ifdef HAVE_EXT2FS_GET_GENERIC_BITMAP_START + start=ext2fs_get_generic_bitmap_start(bitmap); + end=ext2fs_get_generic_bitmap_end(bitmap); +#else + start=bitmap->start; + end=bitmap->end; +#endif + log_trace("ext2_remove_used_space %lu-%lu\n", start, end); buffer=(unsigned char *)MALLOC(sizeof_buffer); - for(block=bitmap->start;block<=bitmap->end;block++) + for(block=start;block<=end;block++) { +#ifdef HAVE_EXT2FS_GET_GENERIC_BITMAP_START + if(ext2fs_test_generic_bitmap(bitmap,block)!=0) +#else if(ext2fs_test_bit(block - bitmap->start, bitmap->bitmap)!=0) +#endif { /* Not free */ if(end_free+1==partition->part_offset+(uint64_t)block*blocksize) diff --git a/src/fat_adv.c b/src/fat_adv.c index 93e45c89..65b830a7 100644 --- a/src/fat_adv.c +++ b/src/fat_adv.c @@ -103,8 +103,10 @@ static int check_FAT_dir_entry(const unsigned char *entry, const unsigned int en static int fat32_create_rootdir(disk_t *disk_car,const partition_t *partition, const unsigned int reserved, const unsigned int fat_length, const unsigned int root_cluster, const unsigned int cluster_size, const int verbose, file_data_t *rootdir_list, const unsigned int fats); static void fat_date_unix2dos(int unix_date,unsigned short *mstime, unsigned short *msdate); -static upart_type_t select_fat_info(const info_offset_t *info_offset, const unsigned int nbr_offset,unsigned int*reserved, unsigned int*fat_length, const unsigned long int max_sector_offset, unsigned int *fats); static unsigned long int get_subdirectory(disk_t *disk_car,const uint64_t hd_offset, const unsigned long int i); +#ifdef HAVE_NCURSES +static upart_type_t select_fat_info(const info_offset_t *info_offset, const unsigned int nbr_offset,unsigned int*reserved, unsigned int*fat_length, const unsigned long int max_sector_offset, unsigned int *fats); +#endif /* * 0 entry is free diff --git a/src/godmode.c b/src/godmode.c index 0a2741da..05be28a7 100644 --- a/src/godmode.c +++ b/src/godmode.c @@ -60,10 +60,12 @@ extern const arch_fnct_t arch_xbox; static void align_structure(const disk_t *disk_car, list_part_t *list_part,const unsigned int location_boundary); static list_part_t *reduce_structure(list_part_t *list_part); static int use_backup(disk_t *disk_car, const list_part_t *list_part, const int verbose,const int dump_ind, const unsigned int expert, char**current_cmd); -static int interface_part_bad_ncurses(disk_t *disk_car, list_part_t *list_part_bad); static int interface_part_bad_log(disk_t *disk_car,list_part_t *list_part_bad); +#ifdef HAVE_NCURSES +static int interface_part_bad_ncurses(disk_t *disk_car, list_part_t *list_part_bad); static void warning_geometry_ncurses(disk_t *disk_car, const unsigned int recommanded_heads_per_cylinder); static void ask_mbr_order_i386(disk_t *disk_car,list_part_t *list_part); +#endif static list_part_t *add_ext_part_i386(disk_t *disk_car, list_part_t *list_part, const int max_ext, const int align,const int verbose); static unsigned int tab_insert(uint64_t *tab, uint64_t offset, unsigned int tab_nbr); /* Optimization */ diff --git a/src/ntfs_adv.c b/src/ntfs_adv.c index 77613255..92f95ff8 100644 --- a/src/ntfs_adv.c +++ b/src/ntfs_adv.c @@ -56,8 +56,10 @@ struct s_info_mft }; static int create_ntfs_boot_sector(disk_t *disk_car, partition_t *partition, const int interface, const unsigned int cluster_size, const uint64_t mft_lcn, const uint64_t mftmirr_lcn, const uint32_t mft_record_size, const uint32_t index_block_size, char**current_cmd); +#ifdef HAVE_NCURSES static int ncurses_ntfs2_info(const struct ntfs_boot_sector *nh1, const struct ntfs_boot_sector *nh2); static int ncurses_ntfs_info(const struct ntfs_boot_sector *ntfs_header); +#endif static int testdisk_ffs(int x); static int read_mft_info(disk_t *disk_car, partition_t *partition, const uint64_t mft_sector, const int verbose, unsigned int *sectors_per_cluster, uint64_t *mft_lcn, uint64_t *mftmirr_lcn, unsigned int *mft_record_size); diff --git a/src/phrecn.c b/src/phrecn.c index 9ee4c3c5..8f0a41e3 100644 --- a/src/phrecn.c +++ b/src/phrecn.c @@ -74,10 +74,10 @@ extern file_check_t *file_check_list; #ifdef HAVE_NCURSES static int photorec_progressbar(WINDOW *window, const unsigned int pass, const photorec_status_t status, const uint64_t offset, disk_t *disk_car, partition_t *partition, const unsigned int file_nbr, const time_t elapsed_time, const file_stat_t *file_stats); -#endif - static void recovery_finished(const unsigned int file_nbr, const char *recup_dir, const int ind_stop, char **current_cmd); static int ask_mode_ext2(const disk_t *disk_car, const partition_t *partition, unsigned int *mode_ext2, unsigned int *carve_free_space_only); +#endif + static int photorec_bf(disk_t *disk_car, partition_t *partition, const int verbose, const int paranoid, const char *recup_dir, const int interface, file_stat_t *file_stats, unsigned int *file_nbr, unsigned int *blocksize, alloc_data_t *list_search_space, const time_t real_start_time, unsigned int *dir_num, const photorec_status_t status, const unsigned int pass, const unsigned int expert, const unsigned int lowmem); static int photorec_aux(disk_t *disk_car, partition_t *partition, const int verbose, const int paranoid, const char *recup_dir, const int interface, file_stat_t *file_stats, unsigned int *file_nbr, unsigned int *blocksize, alloc_data_t *list_search_space, const time_t real_start_time, unsigned int *dir_num, const photorec_status_t status, const unsigned int pass, const unsigned int expert, const unsigned int lowmem); static int photorec(disk_t *disk_car, partition_t *partition, const int verbose, const int paranoid, char *recup_dir, const int keep_corrupted_file, const int interface, file_enable_t *file_enable, const unsigned int mode_ext2, char **current_cmd, alloc_data_t *list_search_space, unsigned int blocksize, const unsigned int expert, const unsigned int lowmem, const unsigned int carve_free_space_only);