MCPcopy Create free account
hub / github.com/cgsecurity/testdisk / partition_save

Function partition_save

src/savehdr.c:205–241  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

203}
204
205int partition_save(disk_t *disk_car, const list_part_t *list_part, const int verbose)
206{
207 const list_part_t *parts;
208 FILE *f_backup;
209 if(verbose>0)
210 {
211 log_trace("partition_save\n");
212 }
213 f_backup=fopen("backup.log","a");
214 if(!f_backup)
215 {
216 log_critical("Can't create backup.log file: %s\n",strerror(errno));
217 return -1;
218 }
219 fprintf(f_backup,"#%lu %s\n",(unsigned long int)time(NULL), disk_car->description(disk_car));
220 for(parts=list_part;parts!=NULL;parts=parts->next)
221 {
222 char status='D';
223 switch(parts->part->status)
224 {
225 case STATUS_PRIM: status='P'; break;
226 case STATUS_PRIM_BOOT: status='*'; break;
227 case STATUS_EXT: status='E'; break;
228 case STATUS_EXT_IN_EXT: status='X'; break;
229 case STATUS_LOG: status='L'; break;
230 case STATUS_DELETED: status='D'; break;
231 }
232 fprintf(f_backup,"%2u : start=%9lu, size=%9lu, Id=%02X, %c\n",
233 (parts->part->order < 100 ? parts->part->order : 0),
234 (unsigned long)(parts->part->part_offset/disk_car->sector_size),
235 (unsigned long)(parts->part->part_size/disk_car->sector_size),
236 (disk_car->arch->get_part_type!=NULL ? disk_car->arch->get_part_type(parts->part) : 0),
237 status);
238 }
239 fclose(f_backup);
240 return 0;
241}
242

Callers 3

interface_listFunction · 0.85
ask_structure_ncursesFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected