static const char *fewf_description_short(disk_t *disk) { const struct info_fewf_struct *data=(const struct info_fewf_struct *)disk->data; char buffer_disk_size[100]; size_to_unit(disk->disk_size, buffer_disk_size); snprintf(disk->description_short_txt, sizeof(disk->description_txt),"Image %s - %s%s", data->file_name, buffer_disk_size, ((data->mode&O_RDWR)==O_RDWR?"":" (RO)")); return disk->description_short_txt; }
static int interface_part_bad_log(disk_t *disk_car, list_part_t *list_part) { uint64_t disk_size=disk_car->disk_size; if(list_part==NULL) return 1; { list_part_t *parts; for(parts=list_part;parts!=NULL;parts=parts->next) { if(disk_size<parts->part->part_offset+parts->part->part_size-1) disk_size=parts->part->part_offset+parts->part->part_size-1; } } log_warning("%s\n",disk_car->description(disk_car)); log_warning("Check the harddisk size: HD jumper settings, BIOS detection...\n"); #if defined(__CYGWIN__) || defined(__MINGW32__) if(disk_car->disk_size<=((uint64_t)1<<(28-1)) && disk_size>=((uint64_t)1<<(28-1))) { log_warning("Hint: update Windows to support LBA48 (minimum: W2K SP4 or XP SP1)\n"); } #endif { char buffer_disk_size[100]; char buffer_disk_size_found[100]; size_to_unit(disk_car->disk_size, buffer_disk_size); size_to_unit(disk_size, buffer_disk_size_found); log_warning("The harddisk (%s) seems too small! (< %s)\n", buffer_disk_size, buffer_disk_size_found); } if(list_part->next==NULL) { log_warning("The following partition can't be recovered:\n"); } else { log_warning("The following partitions can't be recovered:\n"); } { list_part_t *parts; for(parts=list_part;parts!=NULL;parts=parts->next) log_partition(disk_car,parts->part); } return 0; }
static const char *fewf_description(disk_t *disk) { const struct info_fewf_struct *data=(const struct info_fewf_struct *)disk->data; char buffer_disk_size[100]; size_to_unit(disk->disk_size, buffer_disk_size); snprintf(disk->description_txt, sizeof(disk->description_txt),"Image %s - %s - CHS %lu %u %u%s", data->file_name, buffer_disk_size, disk->geom.cylinders, disk->geom.heads_per_cylinder, disk->geom.sectors_per_head, ((data->mode&O_RDWR)==O_RDWR?"":" (RO)")); return disk->description_txt; }
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|AFF_PART_STATUS, disk_car, partition); log_info("%s",msg); size_to_unit(partition->part_size, buffer_part_size); if(partition->info[0]!='\0') log_info("\n %s, %s", partition->info, buffer_part_size); log_info("\n"); }
static list_part_t *ask_structure_ncurses(disk_t *disk_car,list_part_t *list_part, const int verbose, char **current_cmd) { int offset=0; int pos_num=0; list_part_t *pos=list_part; int rewrite=1; int old_LINES=LINES; while(1) { int i; int command; list_part_t *parts; int structure_status; if(old_LINES!=LINES) { rewrite=1; old_LINES=LINES; } if(rewrite) { aff_copy(stdscr); wmove(stdscr,4,0); wprintw(stdscr,"%s",disk_car->description(disk_car)); mvwaddstr(stdscr,5,0,msg_PART_HEADER); rewrite=0; } structure_status=disk_car->arch->test_structure(list_part); for(i=0,parts=list_part; parts!=NULL && i<offset+INTER_STRUCTURE; i++, parts=parts->next) { if(i<offset) continue; wmove(stdscr,6+i-offset,0); wclrtoeol(stdscr); /* before addstr for BSD compatibility */ if(parts==pos) wattrset(stdscr, A_REVERSE); if(structure_status==0 && parts->part->status!=STATUS_DELETED && has_colors()) wbkgdset(stdscr,' ' | COLOR_PAIR(2)); if(parts==pos) waddstr(stdscr, ">"); else waddstr(stdscr, " "); 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) { char buffer_part_size[100]; wattroff(stdscr, A_REVERSE); wmove(stdscr,LINES-1,0); wclrtoeol(stdscr); /* before addstr for BSD compatibility */ if(parts->part->info[0]!='\0') { wprintw(stdscr,"%s, ",parts->part->info); } size_to_unit(parts->part->part_size, buffer_part_size); wprintw(stdscr,"%s", buffer_part_size); } } if(structure_status==0) { if(list_part!=NULL) mvwaddstr(stdscr,LINES-6,0,msg_STRUCT_OK); } else { if(has_colors()) wbkgdset(stdscr,' ' | A_BOLD | COLOR_PAIR(1)); mvwaddstr(stdscr,LINES-6,0,msg_STRUCT_BAD); if(has_colors()) wbkgdset(stdscr,' ' | COLOR_PAIR(0)); } if(list_part!=NULL && disk_car->arch->msg_part_type!=NULL) { mvwaddstr(stdscr,LINES-6,16,"Use "); if(has_colors()) wbkgdset(stdscr,' ' | A_BOLD | COLOR_PAIR(0)); waddstr(stdscr,"Up"); if(has_colors()) wbkgdset(stdscr,' ' | COLOR_PAIR(0)); waddstr(stdscr,"/"); if(has_colors()) wbkgdset(stdscr,' ' | A_BOLD | COLOR_PAIR(0)); waddstr(stdscr,"Down"); if(has_colors()) wbkgdset(stdscr,' ' | COLOR_PAIR(0)); waddstr(stdscr," Arrow keys to select partition."); mvwaddstr(stdscr,LINES-5,0,"Use "); if(has_colors()) wbkgdset(stdscr,' ' | A_BOLD | COLOR_PAIR(0)); waddstr(stdscr,"Left"); if(has_colors()) wbkgdset(stdscr,' ' | COLOR_PAIR(0)); waddstr(stdscr,"/"); if(has_colors()) wbkgdset(stdscr,' ' | A_BOLD | COLOR_PAIR(0)); waddstr(stdscr,"Right"); if(has_colors()) wbkgdset(stdscr,' ' | COLOR_PAIR(0)); waddstr(stdscr," Arrow keys to CHANGE partition characteristics:"); mvwaddstr(stdscr,LINES-4,0,disk_car->arch->msg_part_type); } wmove(stdscr,LINES-3,0); wclrtoeol(stdscr); /* before addstr for BSD compatibility */ waddstr(stdscr,"Keys "); /* If the disk can't be partionned, there is no partition to add and no partition to save */ if(disk_car->arch != &arch_none) { if(has_colors()) wbkgdset(stdscr,' ' | A_BOLD | COLOR_PAIR(0)); waddstr(stdscr,"A"); if(has_colors()) wbkgdset(stdscr,' ' | COLOR_PAIR(0)); waddstr(stdscr,": add partition, "); if(has_colors()) wbkgdset(stdscr,' ' | A_BOLD | COLOR_PAIR(0)); waddstr(stdscr,"L"); if(has_colors()) wbkgdset(stdscr,' ' | COLOR_PAIR(0)); waddstr(stdscr,": load backup, "); } if(list_part==NULL) { waddstr(stdscr,"Enter: to continue"); } else { if(pos->part->arch==NULL || pos->part->arch==disk_car->arch) { if(has_colors()) wbkgdset(stdscr,' ' | A_BOLD | COLOR_PAIR(0)); waddstr(stdscr,"T"); if(has_colors()) wbkgdset(stdscr,' ' | COLOR_PAIR(0)); waddstr(stdscr,": change type, "); } switch(pos->part->upart_type) { case UP_EXFAT: case UP_EXT2: case UP_EXT3: case UP_EXT4: case UP_RFS: case UP_RFS2: case UP_RFS3: case UP_FAT12: case UP_FAT16: case UP_FAT32: case UP_NTFS: if(has_colors()) wbkgdset(stdscr,' ' | A_BOLD | COLOR_PAIR(0)); waddstr(stdscr,"P"); if(has_colors()) wbkgdset(stdscr,' ' | COLOR_PAIR(0)); waddstr(stdscr,": list files, "); break; default: break; } if(has_colors()) wbkgdset(stdscr,' ' | A_BOLD | COLOR_PAIR(0)); mvwaddstr(stdscr,LINES-2,5, "Enter"); if(has_colors()) wbkgdset(stdscr,' ' | COLOR_PAIR(0)); waddstr(stdscr,": to continue"); } wrefresh(stdscr); command=wgetch(stdscr); switch(command) { case KEY_UP: if(list_part!=NULL) { only_one_bootable(list_part,pos); if(pos->prev!=NULL) { pos=pos->prev; pos_num--; } } break; case KEY_DOWN: if(list_part!=NULL) { only_one_bootable(list_part,pos); if(pos->next!=NULL) { pos=pos->next; pos_num++; } } break; case KEY_PPAGE: if(list_part!=NULL) { only_one_bootable(list_part,pos); for(i=0; i<INTER_STRUCTURE && pos->prev!=NULL; i++) { pos=pos->prev; pos_num--; } } break; case KEY_NPAGE: if(list_part!=NULL) { only_one_bootable(list_part,pos); for(i=0; i<INTER_STRUCTURE && pos->next!=NULL; i++) { pos=pos->next; pos_num++; } } break; case KEY_RIGHT: case '+': case ' ': if(list_part!=NULL) { if(pos->part->arch==NULL || pos->part->arch==disk_car->arch) disk_car->arch->set_next_status(disk_car,pos->part); } break; case KEY_LEFT: case '-': if(list_part!=NULL) { if(pos->part->arch==NULL || pos->part->arch==disk_car->arch) disk_car->arch->set_prev_status(disk_car,pos->part); } break; case 'a': case 'A': if(disk_car->arch != &arch_none) { list_part=add_partition_ncurses(disk_car, list_part); rewrite=1; offset=0; pos_num=0; pos=list_part; } break; case 't': case 'T': if(list_part!=NULL) { rewrite=1; change_part_type_ncurses(disk_car, pos->part); } break; case 'p': case 'P': if(list_part!=NULL) { const partition_t *partition=pos->part; if(partition->sb_offset==0 || partition->sb_size==0) dir_partition(disk_car,partition,verbose, current_cmd); else { 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); } rewrite=1; } break; case 'b': case 'B': if(partition_save(disk_car,list_part,verbose)<0) display_message("Can't create backup.log.\n"); else display_message("Results saved in backup.log.\n"); rewrite=1; break; case 'l': case 'L': if(disk_car->arch != &arch_none) { list_part=interface_load(disk_car,list_part,verbose); rewrite=1; offset=0; pos_num=0; pos=list_part; } break; case 'q': case '\r': case '\n': case KEY_ENTER: #ifdef PADENTER case PADENTER: #endif case 'M': return list_part; default: /* log_trace("ask_structure command=%x\n",command); */ break; } if(pos_num<offset) offset=pos_num; if(pos_num>=offset+INTER_STRUCTURE) offset=pos_num-INTER_STRUCTURE+1; } }
void QPhotorec::PartListWidget_updateUI() { list_part_t *element; PartListWidget->setRowCount(0); PartListWidget->setSortingEnabled(false); for(element=list_part; element!=NULL; element=element->next) { const partition_t *partition=element->part; if(partition->status!=STATUS_EXT_IN_EXT) { const arch_fnct_t *arch=partition->arch; const int currentRow = PartListWidget->rowCount(); PartListWidget->setRowCount(currentRow + 1); if(partition->order==NO_ORDER) { QTableWidgetItem *item = new QTableWidgetItem(); item->setData(0, ""); PartListWidget->setItem(currentRow, 0, item); } else { QTableWidgetItem *item = new QTableWidgetItem(); item->setData(0, partition->order); PartListWidget->setItem(currentRow, 0, item); } { QTableWidgetItem *item=new QTableWidgetItem(QString(get_partition_status(partition))); item->setTextAlignment(Qt::AlignHCenter| Qt::AlignVCenter); PartListWidget->setItem(currentRow, 1, item); } if(arch->get_partition_typename(partition)!=NULL) PartListWidget->setItem(currentRow, 2, new QTableWidgetItem(QString(arch->get_partition_typename(partition)))); else if(arch->get_part_type) PartListWidget->setItem(currentRow, 2, new QTableWidgetItem(tr("Sys=") + QString::number(arch->get_part_type(partition)))); else PartListWidget->setItem(currentRow, 2, new QTableWidgetItem(tr("Unknown"))); if(partition->upart_type>0) { QTableWidgetItem *item=new QTableWidgetItem(QString(arch_none.get_partition_typename(partition))); item->setToolTip(QString(partition->info)); PartListWidget->setItem(currentRow, 3, item); } else { PartListWidget->setItem(currentRow, 3, new QTableWidgetItem("")); } { char sizeinfo[32]; QTableWidgetItem *item; size_to_unit(partition->part_size, &sizeinfo[0]); item=new QTableWidgetItem(QString(sizeinfo)); item->setTextAlignment(Qt::AlignRight | Qt::AlignVCenter); PartListWidget->setItem(currentRow, 4, item); /* Select the partition if it's already known */ if(selected_partition == partition) PartListWidget->setCurrentItem(item); } { QString partname=""; if(partition->partname[0]!='\0') { partname.sprintf("[%s]", partition->partname); } if(partition->fsname[0]!='\0') { QString fsname; fsname.sprintf(" [%s]", partition->fsname); partname.append(fsname); } PartListWidget->setItem(currentRow, 5, new QTableWidgetItem(partname)); } } } PartListWidget->setSortingEnabled(true); PartListWidget->sortByColumn(0, Qt::AscendingOrder); PartListWidget->resizeColumnsToContents(); }
static int interface_part_bad_ncurses(disk_t *disk_car, list_part_t *list_part) { int quit=0; int offset=0; int pos_num=0; uint64_t disk_size=disk_car->disk_size; list_part_t *pos=list_part; if(list_part==NULL) return 1; { list_part_t *parts; for(parts=list_part;parts!=NULL;parts=parts->next) { if(disk_size<parts->part->part_offset+parts->part->part_size-1) disk_size=parts->part->part_offset+parts->part->part_size-1; } } aff_copy(stdscr); wmove(stdscr,4,0); wprintw(stdscr,"%s",disk_car->description(disk_car)); wmove(stdscr,6,0); { char buffer_disk_size[100]; char buffer_disk_size_found[100]; size_to_unit(disk_car->disk_size, buffer_disk_size); size_to_unit(disk_size, buffer_disk_size_found); wprintw(stdscr,"The harddisk (%s) seems too small! (< %s)", buffer_disk_size, buffer_disk_size_found); } wmove(stdscr,7,0); wprintw(stdscr,"Check the harddisk size: HD jumper settings, BIOS detection..."); #if defined(__CYGWIN__) || defined(__MINGW32__) if(disk_car->disk_size<=((uint64_t)1<<(28-1)) && disk_size>=((uint64_t)1<<(28-1))) { wmove(stdscr,8,0); wprintw(stdscr,"Hint: update Windows to support LBA48 (minimum: W2K SP4 or XP SP1)"); } #endif wmove(stdscr,9,0); if(list_part->next==NULL) { wprintw(stdscr,"The following partition can't be recovered:"); } else { wprintw(stdscr,"The following partitions can't be recovered:"); } mvwaddstr(stdscr,10,0,msg_PART_HEADER); wmove(stdscr,22,0); wattrset(stdscr, A_REVERSE); wprintw(stdscr,"[ Continue ]"); wattroff(stdscr, A_REVERSE); do { int i; int car; list_part_t *parts; for(i=0,parts=list_part;(parts!=NULL) && (i<offset);parts=parts->next,i++); for(i=offset;(parts!=NULL) &&((i-offset)<INTER_BAD_PART);i++,parts=parts->next) { wmove(stdscr,11+i-offset,0); wclrtoeol(stdscr); /* before addstr for BSD compatibility */ if(parts==pos) { char buffer_part_size[100]; wattrset(stdscr, A_REVERSE); waddstr(stdscr, ">"); aff_part(stdscr, AFF_PART_BASE, disk_car, parts->part); wattroff(stdscr, A_REVERSE); wmove(stdscr,23,0); wclrtoeol(stdscr); /* before addstr for BSD compatibility */ if(parts->part->info[0]!='\0') { wprintw(stdscr,"%s, ",parts->part->info); } size_to_unit(parts->part->part_size, buffer_part_size); wprintw(stdscr,"%s", buffer_part_size); } else { waddstr(stdscr, " "); aff_part(stdscr, AFF_PART_BASE, disk_car, parts->part); } } wrefresh(stdscr); car=wgetch(stdscr); switch(car) { case 'q': case '\r': case '\n': case KEY_ENTER: #ifdef PADENTER case PADENTER: #endif case 'M': quit=1; break; case KEY_UP: if(pos->prev!=NULL) { pos=pos->prev; pos_num--; } break; case KEY_DOWN: if(pos->next!=NULL) { pos=pos->next; pos_num++; } break; case KEY_PPAGE: for(i=0; i<INTER_BAD_PART && pos->prev!=NULL; i++) { pos=pos->prev; pos_num--; } break; case KEY_NPAGE: for(i=0; i<INTER_BAD_PART && pos->next!=NULL; i++) { pos=pos->next; pos_num++; } break; default: break; } if(pos_num<offset) offset=pos_num; if(pos_num>=offset+INTER_BAD_PART) offset=pos_num-INTER_BAD_PART+1; } while(quit==0); return 0; }