Introduced -check_media event= for mismatch events

This commit is contained in:
Thomas Schmitt 2009-08-15 17:34:00 +00:00
parent 0b8a049e34
commit 45d28a5169
5 changed files with 106 additions and 57 deletions

View File

@ -2,7 +2,7 @@
.\" First parameter, NAME, should be all caps .\" First parameter, NAME, should be all caps
.\" Second parameter, SECTION, should be 1-8, maybe w/ subsection .\" Second parameter, SECTION, should be 1-8, maybe w/ subsection
.\" other parameters are allowed: see man(7), man(1) .\" other parameters are allowed: see man(7), man(1)
.TH XORRISO 1 "Aug 14, 2009" .TH XORRISO 1 "Aug 15, 2009"
.\" Please adjust this date whenever revising the manpage. .\" Please adjust this date whenever revising the manpage.
.\" .\"
.\" Some roff macros, for reference: .\" Some roff macros, for reference:
@ -2550,7 +2550,7 @@ The result list tells intervals of 2 KiB blocks with start address, number
of blocks and quality. Qualities which begin with "+" are of blocks and quality. Qualities which begin with "+" are
supposed to be valid readable data. Qualities with "-" are unreadable or supposed to be valid readable data. Qualities with "-" are unreadable or
corrupted data. corrupted data.
"0" indicates qualities which are covered by the check run or are regularly "0" indicates qualities which are not covered by the check run or are regularly
allowed to to be unreadable (e.g. gaps between tracks). allowed to to be unreadable (e.g. gaps between tracks).
.br .br
Alternatively it is possible to report damaged files rather than blocks. Alternatively it is possible to report damaged files rather than blocks.
@ -2570,11 +2570,12 @@ may override each other. So their sequence matters.
The default setting at program start is: The default setting at program start is:
.br .br
use=indev what=tracks min_lba=-1 max_lba=-1 retry=default use=indev what=tracks min_lba=-1 max_lba=-1 retry=default
time_limit=28800 item_limit=100000 .br
time_limit=28800 item_limit=100000 data_to='' event=ALL
.br .br
abort_file=/var/opt/xorriso/do_abort_check_media abort_file=/var/opt/xorriso/do_abort_check_media
.br .br
data_to='' sector_map='' map_with_volid=off patch_lba0=off report=blocks sector_map='' map_with_volid=off patch_lba0=off report=blocks
.br .br
Option "reset=now" restores these startup defaults. Option "reset=now" restores these startup defaults.
.br .br
@ -2615,6 +2616,10 @@ Value -1 means unlimited item number.
.br .br
"data_to=" copies the valid blocks to the file which is given as option value. "data_to=" copies the valid blocks to the file which is given as option value.
.br .br
"event=" sets the given severity for a problem event which shall be issued at
the end of a check run if data blocks were unreadable or failed to match
recorded MD5 checksums. Severity "ALL" disables this event.
.br
"sector_map=" tries to read the file given by option value as "sector_map=" tries to read the file given by option value as
sector bitmap and to store such a map file after the scan run. sector bitmap and to store such a map file after the scan run.
The bitmap tells which blocks have been read successfully in previous runs. The bitmap tells which blocks have been read successfully in previous runs.

View File

@ -4597,6 +4597,7 @@ int Checkmediajob_new(struct CheckmediajoB **o, int flag)
m->map_with_volid= 0; m->map_with_volid= 0;
m->retry= 0; m->retry= 0;
m->report_mode= 0; m->report_mode= 0;
m->event_severity[0]= 0;
return(1); return(1);
} }
@ -4636,6 +4637,7 @@ int Checkmediajob_copy(struct CheckmediajoB *from, struct CheckmediajoB *to,
to->map_with_volid= from->map_with_volid; to->map_with_volid= from->map_with_volid;
to->retry= from->retry; to->retry= from->retry;
to->report_mode= from->report_mode; to->report_mode= from->report_mode;
strcpy(to->event_severity, from->event_severity);
return(1); return(1);
} }
@ -6291,9 +6293,10 @@ int Xorriso_check_media_setup_job(struct XorrisO *xorriso,
struct CheckmediajoB *job, struct CheckmediajoB *job,
char **argv, int old_idx, int end_idx, int flag) char **argv, int old_idx, int end_idx, int flag)
{ {
int ret, i; int ret, i, sev;
double num; double num;
struct CheckmediajoB *default_job; struct CheckmediajoB *default_job;
char sev_text[20];
if(xorriso->check_media_default != NULL) if(xorriso->check_media_default != NULL)
Checkmediajob_copy(xorriso->check_media_default, job, 0); Checkmediajob_copy(xorriso->check_media_default, job, 0);
@ -6306,6 +6309,18 @@ int Xorriso_check_media_setup_job(struct XorrisO *xorriso,
ret= Sfile_str(job->data_to_path, argv[i] + 8, 0); ret= Sfile_str(job->data_to_path, argv[i] + 8, 0);
if(ret <= 0) if(ret <= 0)
goto ex; goto ex;
} else if(strncmp(argv[i], "event=", 6) == 0) {
strncpy(sev_text, argv[i] + 6, 19);
sev_text[19]= 0;
ret= Xorriso__text_to_sev(sev_text, &sev, 0);
if(ret <= 0) {
strcpy(xorriso->info_text, "-check_media event=");
Text_shellsafe(sev_text, xorriso->info_text, 1);
strcat(xorriso->info_text, " : Not a known severity name");
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
goto ex;
}
strcpy(job->event_severity, sev_text);
} else if(strncmp(argv[i], "map_with_volid=", 15) == 0) { } else if(strncmp(argv[i], "map_with_volid=", 15) == 0) {
if(strcmp(argv[i] + 15, "on") == 0) if(strcmp(argv[i] + 15, "on") == 0)
job->map_with_volid= 1; job->map_with_volid= 1;
@ -6487,10 +6502,13 @@ int Xorriso_check_media_list_job(struct XorrisO *xorriso,
sprintf(report + strlen(report), " report=%s", sprintf(report + strlen(report), " report=%s",
job->report_mode == 0 ? "blocks" : job->report_mode == 0 ? "blocks" :
job->report_mode == 1 ? "files" : "blocks_files"); job->report_mode == 1 ? "files" : "blocks_files");
if(all || strcmp(job->event_severity, "ALL") != 0)
sprintf(report + strlen(report), " event=%s", job->event_severity);
if(strlen(report) > 4 * SfileadrL) if(strlen(report) > 4 * SfileadrL)
{ret= 0; goto ex;} {ret= 0; goto ex;}
ret= 1; ret= 1;
ex:; ex:;
strcat(report, " ");
strcat(report, xorriso->list_delimiter); strcat(report, xorriso->list_delimiter);
Checkmediajob_destroy(&dflt, 0); Checkmediajob_destroy(&dflt, 0);
sprintf(default_report, "-check_media_defaults reset=now %s", sprintf(default_report, "-check_media_defaults reset=now %s",
@ -13365,10 +13383,12 @@ int Xorriso_option_check_md5(struct XorrisO *xorriso,
{ {
int ret, i, mem_pci, end_idx, fret, sev, do_report= 0; int ret, i, mem_pci, end_idx, fret, sev, do_report= 0;
int optc= 0; int optc= 0;
char **optv= NULL, *cpt, *severity; char **optv= NULL, *cpt, *severity= "ALL";
struct FindjoB *job= NULL; struct FindjoB *job= NULL;
double mem_lut= 0.0; double mem_lut= 0.0;
mem_pci= xorriso->pacifier_interval;
ret= Xorriso_opt_args(xorriso, "-check_md5", argc, argv, *idx + 1, ret= Xorriso_opt_args(xorriso, "-check_md5", argc, argv, *idx + 1,
&end_idx, &optc, &optv, 128); &end_idx, &optc, &optv, 128);
if(ret<=0) if(ret<=0)
@ -13403,7 +13423,6 @@ int Xorriso_option_check_md5(struct XorrisO *xorriso,
Xorriso_pacifier_reset(xorriso, 0); Xorriso_pacifier_reset(xorriso, 0);
mem_lut= xorriso->last_update_time; mem_lut= xorriso->last_update_time;
} }
mem_pci= xorriso->pacifier_interval;
xorriso->pacifier_interval= 5.0; xorriso->pacifier_interval= 5.0;
xorriso->find_check_md5_result= 0; xorriso->find_check_md5_result= 0;
@ -13494,7 +13513,7 @@ ex:;
int Xorriso_option_check_media(struct XorrisO *xorriso, int Xorriso_option_check_media(struct XorrisO *xorriso,
int argc, char **argv, int *idx, int flag) int argc, char **argv, int *idx, int flag)
{ {
int ret, i, count, lba, blocks, quality, pass, was_md5= 0; int ret, i, count, lba, blocks, quality, pass, was_md5= 0, was_event= 0;
int end_idx, old_idx, os_errno; int end_idx, old_idx, os_errno;
char quality_name[80], head_buffer[64*1024]; char quality_name[80], head_buffer[64*1024];
struct SpotlisT *spotlist= NULL; struct SpotlisT *spotlist= NULL;
@ -13585,11 +13604,17 @@ int Xorriso_option_check_media(struct XorrisO *xorriso,
ret= Spotlist_get_item(spotlist, i, &lba, &blocks, &quality, 0); ret= Spotlist_get_item(spotlist, i, &lba, &blocks, &quality, 0);
if(ret <= 0) if(ret <= 0)
continue; continue;
if(pass == 0 && (quality == Xorriso_read_quality_md5_matcH || if(pass == 0) {
quality == Xorriso_read_quality_md5_mismatcH)) { if(quality == Xorriso_read_quality_md5_mismatcH ||
quality == Xorriso_read_quality_unreadablE) {
was_event= 1;
}
if(quality == Xorriso_read_quality_md5_matcH ||
quality == Xorriso_read_quality_md5_mismatcH) {
was_md5= 1; was_md5= 1;
continue; continue;
} }
}
else if(pass == 1 && !(quality == Xorriso_read_quality_md5_matcH || else if(pass == 1 && !(quality == Xorriso_read_quality_md5_matcH ||
quality == Xorriso_read_quality_md5_mismatcH)) quality == Xorriso_read_quality_md5_mismatcH))
continue; continue;
@ -13616,6 +13641,12 @@ int Xorriso_option_check_media(struct XorrisO *xorriso,
} }
ret= 1; ret= 1;
ex:; ex:;
if(was_event && strcmp(job->event_severity, "ALL") != 0) {
sprintf(xorriso->info_text,
"Event triggered by media read error or MD5 comparison mismatch");
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, job->event_severity,
0);
}
Spotlist_destroy(&spotlist, 0); Spotlist_destroy(&spotlist, 0);
Checkmediajob_destroy(&job, 0); Checkmediajob_destroy(&job, 0);
return(ret); return(ret);
@ -15807,7 +15838,7 @@ int Xorriso_option_help(struct XorrisO *xorriso, int flag)
" retry=on|off|default , data_to=filepath ,", " retry=on|off|default , data_to=filepath ,",
" sector_map=filepath , map_with_volid=on|off ,", " sector_map=filepath , map_with_volid=on|off ,",
" patch_lba0=on|off|force|blockadr[:force] ,", " patch_lba0=on|off|force|blockadr[:force] ,",
" report=blocks|files|blocks_files", " report=blocks|files|blocks_files event=severity",
" -check_media_defaults [options] --", " -check_media_defaults [options] --",
" Preset options for runs of -check_media and -extract_cut.", " Preset options for runs of -check_media and -extract_cut.",
"", "",

View File

@ -126,7 +126,7 @@ struct XorrisO { /* the global context of xorriso */
int do_md5; /* bit0= read MD5 array int do_md5; /* bit0= read MD5 array
bit1= write session MD5 bit1= write session MD5
bit2= wite MD5 for each data file bit2= write MD5 for each data file
*/ */
int relax_compliance; /* opaque bitfield to be set by xorrisoburn */ int relax_compliance; /* opaque bitfield to be set by xorrisoburn */
@ -398,6 +398,7 @@ struct XorrisO { /* the global context of xorriso */
int find_check_md5_result; /* bit0= seen mismatch int find_check_md5_result; /* bit0= seen mismatch
bit1= seen error bit1= seen error
bit2= seen data file without MD5 bit2= seen data file without MD5
bit3= seen match
*/ */
/* Tree node collection and LBA sorting facility */ /* Tree node collection and LBA sorting facility */
@ -1183,6 +1184,7 @@ char *Spotlist__quality_name(int quality, char name[80], int flag);
#define Xorriso_read_quality_gooD 0x7fffffff #define Xorriso_read_quality_gooD 0x7fffffff
#define Xorriso_read_quality_md5_matcH 0x70000000
#define Xorriso_read_quality_sloW 0x60000000 #define Xorriso_read_quality_sloW 0x60000000
#define Xorriso_read_quality_partiaL 0x50000000 #define Xorriso_read_quality_partiaL 0x50000000
#define Xorriso_read_quality_valiD 0x40000000 #define Xorriso_read_quality_valiD 0x40000000
@ -1190,9 +1192,58 @@ char *Spotlist__quality_name(int quality, char name[80], int flag);
#define Xorriso_read_quality_invaliD 0x3ffffffe #define Xorriso_read_quality_invaliD 0x3ffffffe
#define Xorriso_read_quality_tao_enD 0x28000000 #define Xorriso_read_quality_tao_enD 0x28000000
#define Xorriso_read_quality_off_tracK 0x20000000 #define Xorriso_read_quality_off_tracK 0x20000000
#define Xorriso_read_quality_md5_mismatcH 0x10000000
#define Xorriso_read_quality_unreadablE 0x00000000 #define Xorriso_read_quality_unreadablE 0x00000000
struct CheckmediajoB {
int use_dev; /* 0= use indev , 1= use outdev , 2= use sector map*/
int min_lba; /* if >=0 : begin checking at this address */
int max_lba; /* if >=0 : read up to this address, else use mode */
int min_block_size; /* >>> not yet implemented:
granularity desired by user
*/
int mode; /* 0= track by track
1= single sweep over libisoburn media capacity
>>> 2= single sweep over libburn media capacity
*/
time_t start_time;
int time_limit; /* Number of seconds after which to abort */
int item_limit; /* Maximum number of media check list items as result */
char abort_file_path[SfileadrL];
char data_to_path[SfileadrL];
int data_to_fd;
off_t data_to_offset; /* usually 0 with image copy, negative with file copy */
off_t data_to_limit; /* used with file copy */
int patch_lba0;
int patch_lba0_msc1;
char sector_map_path[SfileadrL];
struct SectorbitmaP *sector_map;
int map_with_volid; /* 0=add quick toc to map file,
1=read ISO heads for toc
*/
int retry; /* -1= only try full read_chunk, 1=retry with 2k blocks
0= retry with CD, full chunk else
*/
int report_mode; /* 0= print MCL items
1= print damaged files
*/
char event_severity[20]; /* If not "ALL": trigger event of given severity
at the end of a check job if bad blocks were
discovered.
*/
};
int Checkmediajob_new(struct CheckmediajoB **o, int flag); int Checkmediajob_new(struct CheckmediajoB **o, int flag);
int Checkmediajob_destroy(struct CheckmediajoB **o, int flag); int Checkmediajob_destroy(struct CheckmediajoB **o, int flag);

View File

@ -1 +1 @@
#define Xorriso_timestamP "2009.08.14.211648" #define Xorriso_timestamP "2009.08.15.173403"

View File

@ -21,6 +21,11 @@
#define xorriso_libisoburn_req_minor 4 #define xorriso_libisoburn_req_minor 4
#define xorriso_libisoburn_req_micro 1 #define xorriso_libisoburn_req_micro 1
struct SpotlisT; /* List of intervals with different read qualities */
struct CheckmediajoB; /* Parameters for Xorriso_check_media() */
int Xorriso_startup_libraries(struct XorrisO *xorriso, int flag); int Xorriso_startup_libraries(struct XorrisO *xorriso, int flag);
/* @param flag bit0= global shutdown of libraries */ /* @param flag bit0= global shutdown of libraries */
@ -331,49 +336,6 @@ int Xorriso_check_session_md5(struct XorrisO *xorriso, char *severity,
int Xorriso_image_has_md5(struct XorrisO *xorriso, int flag); int Xorriso_image_has_md5(struct XorrisO *xorriso, int flag);
struct CheckmediajoB {
int use_dev; /* 0= use indev , 1= use outdev , 2= use sector map*/
int min_lba; /* if >=0 : begin checking at this address */
int max_lba; /* if >=0 : read up to this address, else use mode */
int min_block_size; /* >>> not yet implemented:
granularity desired by user
*/
int mode; /* 0= track by track
1= single sweep over libisoburn media capacity
>>> 2= single sweep over libburn media capacity
*/
time_t start_time;
int time_limit; /* Number of seconds after which to abort */
int item_limit; /* Maximum number of media check list items as result */
char abort_file_path[SfileadrL];
char data_to_path[SfileadrL];
int data_to_fd;
off_t data_to_offset; /* usually 0 with image copy, negative with file copy */
off_t data_to_limit; /* used with file copy */
int patch_lba0;
int patch_lba0_msc1;
char sector_map_path[SfileadrL];
struct SectorbitmaP *sector_map;
int map_with_volid; /* 0=add quick toc to map file,
1=read ISO heads for toc
*/
int retry; /* -1= only try full read_chunk, 1=retry with 2k blocks
0= retry with CD, full chunk else
*/
int report_mode; /* 0= print MCL items
1= print damaged files
*/
};
int Xorriso_check_media(struct XorrisO *xorriso, struct SpotlisT **spotlist, int Xorriso_check_media(struct XorrisO *xorriso, struct SpotlisT **spotlist,
struct CheckmediajoB *job, int flag); struct CheckmediajoB *job, int flag);