New -find action report_lba

This commit is contained in:
2008-08-18 13:42:44 +00:00
parent 05711f4e8d
commit e231d308fd
4 changed files with 63 additions and 109 deletions

View File

@ -5599,6 +5599,26 @@ int Xorriso_file_eval_damage(struct XorrisO *xorriso, IsoNode *node,
}
int Xorriso_report_lba(struct XorrisO *xorriso, char *show_path,
IsoNode *node, int flag)
{
int ret, start_lba, end_lba;
off_t size;
char sfe[5*SfileadrL];
ret= Xorriso_start_end_lba(xorriso, node, &start_lba, &end_lba, &size, 0);
if(ret < 0)
return(ret);
if(ret == 0)
return(1); /* it is ok to ignore other types */
sprintf(xorriso->result_line, "File data lba: %2d , %8d , %8d , %8.f , %s\n",
0, start_lba, end_lba + 1 - start_lba, (double) size,
Text_shellsafe(show_path, sfe, 0));
Xorriso_result(xorriso, 0);
return(1);
}
int Xorriso_report_damage(struct XorrisO *xorriso, char *show_path,
IsoNode *node, int flag)
{
@ -5626,76 +5646,6 @@ int Xorriso_report_damage(struct XorrisO *xorriso, char *show_path,
}
/* <<< shall be replaced by tests and -exec report_damage
#define Xorriso_check_find_as_exeC 1
*/
#ifdef Xorriso_check_find_as_exeC
/* @param flag bit0= report about undamaged files
*/
int Xorriso_file_vs_bitmap(struct XorrisO *xorriso, char *show_path,
IsoNode *node, int flag)
{
uint32_t start_lba;
int end_lba, i, sectors, sector_size, damaged= 0, ret;
int next_good_lba, first_bad_lba= -1;
off_t size= 0, damage_start, damage_count;
struct SectorbitmaP *map;
char sfe[5*SfileadrL];
ret= iso_node_get_old_image_lba(node, &start_lba, 0);
if(ret < 0)
return(0);
if(ret == 0) {
if(flag & 1)
goto undamaged;
return(2);
}
map= xorriso->in_sector_map;
if(map == NULL) {
if(flag & 1)
goto undamaged;
return(2);
}
if(LIBISO_ISREG(node))
size= iso_file_get_size((IsoFile *) node);
end_lba= start_lba + size / 2048;
if(size % 2048)
end_lba++;
Sectorbitmap_get_layout(map, &sectors, &sector_size, 0);
sector_size/= 2048;
for(i= start_lba; i < end_lba; i+= sector_size)
if(Sectorbitmap_is_set(map, i / sector_size, 0) == 0) {
damaged= 1;
if(first_bad_lba < 0)
first_bad_lba= i;
next_good_lba= (i / sector_size + 1) * sector_size;
}
if(damaged && !(flag & 1)) {
damage_start= (first_bad_lba - start_lba) * 2048;
damage_count= (next_good_lba - start_lba) * 2048;
if(damage_count > size)
damage_count= size;
damage_count-= damage_start;
sprintf(xorriso->result_line, "File damage : %13.f , %13.f , %13.f , %s\n",
(double) damage_start, (double) damage_count, (double) size,
Text_shellsafe(show_path, sfe, 0));
Xorriso_result(xorriso, 0);
} else if((flag & 1) && !damaged) {
undamaged:;
sprintf(xorriso->result_line, "File seems ok: %s\n",
Text_shellsafe(show_path, sfe, 0));
Xorriso_result(xorriso, 0);
}
return(1);
}
#endif /* Xorriso_check_find_as_exeC */
/* @param flag bit0= not a command parameter (directory iteration or recursion)
bit1= do not count deleted files with rm and rm_r
@return <=0 error,
@ -5764,24 +5714,10 @@ int Xorriso_findi_action(struct XorrisO *xorriso, struct FindjoB *job,
ret= 1;
} else if(action==16 || action==18) { /* not_in_iso , add_missing */
;
#ifdef Xorriso_check_find_as_exeC
} else if(action == 21) { /* is_damaged */
ret= Xorriso_file_vs_bitmap(xorriso, show_path, node, 0);
} else if(action == 22) { /* is_undamaged */
ret= Xorriso_file_vs_bitmap(xorriso, show_path, node, 1);
#else
} else if(action == 21) { /* report_damage */
ret= Xorriso_report_damage(xorriso, show_path, node, 0);
} else if(action == 22) {
/* >>> report_lba */;
#endif /* ! Xorriso_check_find_as_exeC */
ret= Xorriso_report_lba(xorriso, show_path, node, 0);
} else { /* includes : 15 in_iso */
sprintf(xorriso->result_line, "%s\n", Text_shellsafe(show_path, sfe, 0));
Xorriso_result(xorriso, 0);
@ -5865,10 +5801,17 @@ int Xorriso_findi(struct XorrisO *xorriso, struct FindjoB *job,
action= Findjob_get_action(job, 0);
if(action<0)
action= 0;
if(action == 21 && !(flag & 1)) {
sprintf(xorriso->result_line, "Report layout: %8s , %8s , %8s , %s\n",
"at byte", "range", "filesize", "ISO image path");
Xorriso_result(xorriso, 0);
if(!(flag & 1)) {
if(action == 21) {
sprintf(xorriso->result_line, "Report layout: %8s , %8s , %8s , %s\n",
"at byte", "Range", "Filesize", "ISO image path");
Xorriso_result(xorriso, 0);
} else if(action == 22) {
sprintf(xorriso->result_line,
"Report layout: %2s , %8s , %8s , %8s , %s\n",
"xt", "Startlba", "Blocks", "Filesize", "ISO image path");
Xorriso_result(xorriso, 0);
}
}
dir_node= (IsoDir *) dir_node_generic;
@ -5893,17 +5836,8 @@ int Xorriso_findi(struct XorrisO *xorriso, struct FindjoB *job,
else
name++;
#ifdef Xorriso_check_find_as_exeC
ret= Findjob_test(job, name, NULL, dir_stbuf, depth, 0);
#else
ret= Xorriso_findi_test(xorriso, job, iso_node, name, NULL, dir_stbuf,
depth, 0);
#endif /* ! Xorriso_check_find_as_exeC */
if(ret<0)
goto ex;
if(ret>0) {
@ -5971,17 +5905,8 @@ int Xorriso_findi(struct XorrisO *xorriso, struct FindjoB *job,
handling of the find start path with mount points. Dangerous to change.
*/
#ifdef Xorriso_check_find_as_exeC
ret= Findjob_test(job, name, dir_stbuf, &stbuf, depth, 0);
#else
ret= Xorriso_findi_test(xorriso, job, node, name, dir_stbuf, &stbuf,
depth, 0);
#endif /* ! Xorriso_check_find_as_exeC */
if(ret<0)
goto ex;
if(ret>0) {