Testing for abort file during -check_media

This commit is contained in:
Thomas Schmitt 2010-11-03 08:11:45 +00:00
parent c4ccfda966
commit b5cb6347a6
7 changed files with 54 additions and 18 deletions

View File

@ -324,6 +324,7 @@ int Xorriso_new(struct XorrisO ** xorriso,char *progname, int flag)
m->last_update_time= 0.0; m->last_update_time= 0.0;
m->find_compare_result= 1; m->find_compare_result= 1;
m->find_check_md5_result= 0; m->find_check_md5_result= 0;
m->last_abort_file_time= 0.0;
m->node_counter= 0; m->node_counter= 0;
m->node_array_size= 0; m->node_array_size= 0;

View File

@ -1536,6 +1536,7 @@ int Xorriso_scsi_log(struct XorrisO *xorriso, int flag)
return(1); return(1);
} }
int Xorriso_check_md5_range(struct XorrisO *xorriso, off_t start_lba, int Xorriso_check_md5_range(struct XorrisO *xorriso, off_t start_lba,
off_t end_lba, char md5[16], int flag) off_t end_lba, char md5[16], int flag)
{ {
@ -1615,7 +1616,31 @@ int Xorriso_check_session_md5(struct XorrisO *xorriso, char *severity,
md5, 0); md5, 0);
return(ret); return(ret);
} }
int Xorriso_check_for_abort(struct XorrisO *xorriso,
char *abort_file_path,
double post_read_time,
double *last_abort_file_time, int flag)
{
struct stat stbuf;
if(abort_file_path[0] == 0)
return(0);
if(post_read_time - *last_abort_file_time >= 0.1) {
if(stat(abort_file_path, &stbuf) != -1) {
if(stbuf.st_mtime >= xorriso->start_time) {
sprintf(xorriso->info_text,
"-check_media: Found fresh abort_file=%s", abort_file_path);
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "NOTE", 0);
return(1);
}
}
*last_abort_file_time= post_read_time;
}
return(0);
}
/* @param flag bit0= this is a follow-up session (i.e. on CD: TAO) /* @param flag bit0= this is a follow-up session (i.e. on CD: TAO)
bit1= no pacifier messages bit1= no pacifier messages
@ -1638,7 +1663,6 @@ int Xorriso_check_interval(struct XorrisO *xorriso, struct SpotlisT *spotlist,
off_t data_count, to_read, read_count= 0, write_amount; off_t data_count, to_read, read_count= 0, write_amount;
double pre_read_time, post_read_time, time_diff, total_time_diff= 0; double pre_read_time, post_read_time, time_diff, total_time_diff= 0;
double last_abort_file_time= 0; double last_abort_file_time= 0;
struct stat stbuf;
void *ctx= NULL, *cloned_ctx= NULL; void *ctx= NULL, *cloned_ctx= NULL;
char md5[16], tag_md5[16]; char md5[16], tag_md5[16];
uint32_t pos, range_start, range_size, next_tag= 0, lba, md5_spot_lba= 0; uint32_t pos, range_start, range_size, next_tag= 0, lba, md5_spot_lba= 0;
@ -1679,21 +1703,10 @@ int Xorriso_check_interval(struct XorrisO *xorriso, struct SpotlisT *spotlist,
post_read_time= Sfile_microtime(0); post_read_time= Sfile_microtime(0);
for(i= 0; i < block_count; i+= to_read) { for(i= 0; i < block_count; i+= to_read) {
skip_reading= 0; skip_reading= 0;
ret= Xorriso_check_for_abort(xorriso, job->abort_file_path, post_read_time,
if(job->abort_file_path[0]) { &last_abort_file_time, 0);
if(post_read_time - last_abort_file_time >= 0.1) { if(ret == 1)
if(stat(job->abort_file_path, &stbuf) != -1) { goto abort_check;
if(stbuf.st_mtime >= xorriso->start_time) {
sprintf(xorriso->info_text,
"-check_media: Found fresh abort_file=%s",
job->abort_file_path);
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "NOTE", 0);
goto abort_check;
}
}
last_abort_file_time= post_read_time;
}
}
if(job->item_limit > 0 && if(job->item_limit > 0 &&
Spotlist_count(spotlist, 0) + 2 >= job->item_limit) { Spotlist_count(spotlist, 0) + 2 >= job->item_limit) {
sprintf(xorriso->info_text, "-check_media: Reached item_limit=%d", sprintf(xorriso->info_text, "-check_media: Reached item_limit=%d",

View File

@ -33,5 +33,10 @@ int Xorriso_get_drive_handles(struct XorrisO *xorriso,
struct burn_drive **drive, struct burn_drive **drive,
char *attempt, int flag); char *attempt, int flag);
int Xorriso_check_for_abort(struct XorrisO *xorriso,
char *abort_file_path,
double post_read_time,
double *last_abort_file_time, int flag);
#endif /* ! Xorriso_pvt_drive_mgt_includeD */ #endif /* ! Xorriso_pvt_drive_mgt_includeD */

View File

@ -378,6 +378,8 @@ int Findjob_new(struct FindjoB **o, char *start_path, int flag)
goto failed; goto failed;
m->found_path= NULL; m->found_path= NULL;
m->subjob= NULL; m->subjob= NULL;
m->errmsg[0]= 0;
m->errn= 0;
ret= Exprnode_new(&(m->test_tree), m, NULL, "-find", (m->use_shortcuts)<<1); ret= Exprnode_new(&(m->test_tree), m, NULL, "-find", (m->use_shortcuts)<<1);
if(ret<=0) if(ret<=0)

View File

@ -1975,6 +1975,14 @@ int Xorriso_check_md5(struct XorrisO *xorriso, void *in_node, char *path,
xorriso->pacifier_byte_count+= rret; xorriso->pacifier_byte_count+= rret;
Xorriso_pacifier_callback(xorriso, "content bytes read", Xorriso_pacifier_callback(xorriso, "content bytes read",
xorriso->pacifier_count, 0, "", 0); xorriso->pacifier_count, 0, "", 0);
ret= Xorriso_check_for_abort(
xorriso,
xorriso->check_media_default != NULL
? xorriso->check_media_default->abort_file_path
: "/var/opt/xorriso/do_abort_check_media",
Sfile_microtime(0), &xorriso->last_abort_file_time, 0);
if(ret == 1)
{ret= -2; goto ex;}
} }
ret= iso_md5_end(&ctx, data_md5); ret= iso_md5_end(&ctx, data_md5);
if(ret < 0) if(ret < 0)
@ -2004,11 +2012,16 @@ ex:;
if(ctx != NULL) if(ctx != NULL)
iso_md5_end(&ctx, data_md5); iso_md5_end(&ctx, data_md5);
if(ret < 0) { if(ret < 0) {
sprintf(xorriso->result_line, "NOT READABLE: "); if(ret == -2)
sprintf(xorriso->result_line, "Aborted at: ");
else
sprintf(xorriso->result_line, "NOT READABLE: ");
Text_shellsafe(path, xorriso->result_line, 1); Text_shellsafe(path, xorriso->result_line, 1);
strcat(xorriso->result_line, "\n"); strcat(xorriso->result_line, "\n");
if(!(flag & 1)) if(!(flag & 1))
Xorriso_result(xorriso,0); Xorriso_result(xorriso,0);
if(ret == -2)
xorriso->request_to_abort= 1;
} }
return(ret); return(ret);
} }

View File

@ -508,6 +508,8 @@ struct XorrisO { /* the global context of xorriso */
bit3= seen match bit3= seen match
*/ */
double last_abort_file_time; /* most recent check for aborting -check_md5 */
/* Tree node collection and LBA sorting facility */ /* Tree node collection and LBA sorting facility */
int node_counter; int node_counter;
int node_array_size; int node_array_size;

View File

@ -1 +1 @@
#define Xorriso_timestamP "2010.11.01.191542" #define Xorriso_timestamP "2010.11.03.081124"