New -find action make_md5 to equip files from old images with MD5

This commit is contained in:
Thomas Schmitt 2009-08-22 18:41:45 +00:00
parent 5f06ee19c5
commit 56abdd0c2c
6 changed files with 89 additions and 29 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 20, 2009" .TH XORRISO 1 "Aug 22, 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:
@ -1461,6 +1461,11 @@ namespace "isofs".
and reports if mismatch. and reports if mismatch.
.br .br
E.g.: -find / -not -pending_data -exec check_md5 FAILURE -- E.g.: -find / -not -pending_data -exec check_md5 FAILURE --
\fBmake_md5\fR equips a data file with an MD5 sum of its content. Useful to
upgrade the files in the loaded image to full MD5 coverage by the next
commit with -md5 "on".
.br
E.g.: -find / -type f -not -has_md5 -exec make_md5 --
.br .br
\fBsetfattr\fR sets or deletes xattr name value pairs. \fBsetfattr\fR sets or deletes xattr name value pairs.
.br .br

View File

@ -4956,6 +4956,7 @@ int Xorriso_destroy(struct XorrisO **xorriso, int flag)
int Xorriso_set_change_pending(struct XorrisO *xorriso, int flag) int Xorriso_set_change_pending(struct XorrisO *xorriso, int flag)
{ {
xorriso->volset_change_pending= 1; xorriso->volset_change_pending= 1;
if(!(flag & 2))
xorriso->hln_change_pending= 1; xorriso->hln_change_pending= 1;
return(1); return(1);
} }
@ -7106,9 +7107,19 @@ int Xorriso_status(struct XorrisO *xorriso, char *filter, FILE *fp, int flag)
if(!(is_default && no_defaults)) if(!(is_default && no_defaults))
Xorriso_status_result(xorriso,filter,fp,flag&2); Xorriso_status_result(xorriso,filter,fp,flag&2);
is_default= ((xorriso->do_md5 & (1 | 2 | 4 | 8)) == 0); is_default= ((xorriso->do_md5 & 31) == 0);
sprintf(line, "-md5 %s\n", (xorriso->do_md5 & 1 ? sprintf(line, "-md5 ");
xorriso->do_md5 & 8 ? "all" : "on" : "off")); if(xorriso->do_md5 & 1) {
if((xorriso->do_md5 & (8)) == (8)) {
strcat(line, "all\n");
} else {
strcat(line, "on");
if(xorriso->do_md5 & 8)
strcat(line, ":stability_check_on");
strcat(line, "\n");
}
} else
strcat(line, "off\n");
if(!(is_default && no_defaults)) if(!(is_default && no_defaults))
Xorriso_status_result(xorriso,filter,fp,flag&2); Xorriso_status_result(xorriso,filter,fp,flag&2);
@ -12557,10 +12568,7 @@ int Xorriso_report_md5_outcome(struct XorrisO *xorriso, char *severity,
int has_md5; int has_md5;
has_md5= Xorriso_image_has_md5(xorriso, 0); has_md5= Xorriso_image_has_md5(xorriso, 0);
if (has_md5 <= 0) { if(xorriso->find_check_md5_result & 1) {
sprintf(xorriso->result_line,
"There is no MD5 checksum array loaded.\n");
} else if(xorriso->find_check_md5_result & 1) {
sprintf(xorriso->result_line, sprintf(xorriso->result_line,
"Mismatch detected between file contents and MD5 checksums.\n"); "Mismatch detected between file contents and MD5 checksums.\n");
} else if(xorriso->find_check_md5_result & 8) { } else if(xorriso->find_check_md5_result & 8) {
@ -12568,7 +12576,12 @@ int Xorriso_report_md5_outcome(struct XorrisO *xorriso, char *severity,
"File contents and their MD5 checksums match.\n"); "File contents and their MD5 checksums match.\n");
} else { } else {
sprintf(xorriso->result_line, sprintf(xorriso->result_line,
"Not a single file with MD5 checksum was found.\n"); "Not a single file with MD5 checksum was found.");
if(has_md5 <= 0)
strcat(xorriso->result_line,
" (There is no MD5 checksum array loaded.)\n");
else
strcat(xorriso->result_line, "\n");
} }
Xorriso_result(xorriso,0); Xorriso_result(xorriso,0);
if(xorriso->find_check_md5_result & 2) { if(xorriso->find_check_md5_result & 2) {
@ -13457,15 +13470,6 @@ int Xorriso_option_check_md5(struct XorrisO *xorriso,
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
goto ex; goto ex;
} }
ret= Xorriso_image_has_md5(xorriso, 0);
if(ret <= 0) {
sprintf(xorriso->info_text,
"-check_md5: There is no MD5 checksum array loaded.");
if (strcmp(severity, "ALL") == 0)
severity= "WARNING";
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, severity, 0);
ret= -1; goto ex;
}
if(!(flag & (2 | 4))) { if(!(flag & (2 | 4))) {
Xorriso_pacifier_reset(xorriso, 0); Xorriso_pacifier_reset(xorriso, 0);
@ -15172,6 +15176,19 @@ not_enough_exec_arguments:;
i+= 1; i+= 1;
Findjob_set_action_target(job, 35, argv[i], 0); Findjob_set_action_target(job, 35, argv[i], 0);
flag|= 8; flag|= 8;
if(!(flag&2)) {
Xorriso_pacifier_reset(xorriso, 0);
mem_lut= xorriso->last_update_time;
}
if(!(flag & 1))
xorriso->find_check_md5_result= 0;
} else if(strcmp(cpt, "make_md5")==0) {
Findjob_set_action_target(job, 36, NULL, 0);
flag|= 8;
if(!(flag&2)) {
Xorriso_pacifier_reset(xorriso, 0);
mem_lut= xorriso->last_update_time;
}
} else { } else {
sprintf(xorriso->info_text, "-find -exec: unknown action %s", sprintf(xorriso->info_text, "-find -exec: unknown action %s",
Text_shellsafe(argv[i], sfe, 0)); Text_shellsafe(argv[i], sfe, 0));
@ -15190,7 +15207,7 @@ sorry_ex:;
0); 0);
else if(flag & 8) { else if(flag & 8) {
cpt= start_path; cpt= start_path;
ret= Xorriso_findi_sorted(xorriso, first_job, (off_t) 0, 1, &cpt, 8); ret= Xorriso_findi_sorted(xorriso, first_job, (off_t) 0, 1, &cpt, 0);
} else } else
ret= Xorriso_findi(xorriso, first_job, NULL, (off_t) 0, NULL, ret= Xorriso_findi(xorriso, first_job, NULL, (off_t) 0, NULL,
start_path, &dir_stbuf, 0, (flag&4)>>1); start_path, &dir_stbuf, 0, (flag&4)>>1);
@ -15204,6 +15221,8 @@ ex:;
else if(mem_lut!=xorriso->last_update_time && mem_lut!=0.0 && !(flag&2)) else if(mem_lut!=xorriso->last_update_time && mem_lut!=0.0 && !(flag&2))
Xorriso_pacifier_callback(xorriso, "content bytes read", Xorriso_pacifier_callback(xorriso, "content bytes read",
xorriso->pacifier_count, 0, "", 1); xorriso->pacifier_count, 0, "", 1);
if(first_job->action == 35 && !(flag & 1))
Xorriso_report_md5_outcome(xorriso, first_job->target, 0);
if(access_acl_text != NULL) if(access_acl_text != NULL)
free(access_acl_text); free(access_acl_text);
if(default_acl_text != NULL) if(default_acl_text != NULL)
@ -16595,7 +16614,7 @@ int Xorriso_option_md5(struct XorrisO *xorriso, char *mode, int flag)
if(l == 3 && strncmp(cpt, "off", l) == 0) if(l == 3 && strncmp(cpt, "off", l) == 0)
xorriso->do_md5&= ~31; xorriso->do_md5&= ~31;
else if(l == 2 && strncmp(cpt, "on", l) == 0) else if(l == 2 && strncmp(cpt, "on", l) == 0)
xorriso->do_md5|= 7 | 16; xorriso->do_md5= (xorriso->do_md5 & ~31) | 7 | 16;
else if(l == 3 && strncmp(cpt, "all", l) == 0) else if(l == 3 && strncmp(cpt, "all", l) == 0)
xorriso->do_md5|= 31; xorriso->do_md5|= 31;
else if(l == 18 && strncmp(cpt, "stability_check_on", l) == 0) else if(l == 18 && strncmp(cpt, "stability_check_on", l) == 0)

View File

@ -128,6 +128,7 @@ struct XorrisO { /* the global context of xorriso */
bit1= write session MD5 bit1= write session MD5
bit2= write MD5 for each data file bit2= write MD5 for each data file
bit3= make file content stability check by double reading bit3= make file content stability check by double reading
bit4= use recorded MD5 as proxy of ISO file
*/ */
int relax_compliance; /* opaque bitfield to be set by xorrisoburn */ int relax_compliance; /* opaque bitfield to be set by xorrisoburn */
@ -444,6 +445,7 @@ struct XorrisO { /* the global context of xorriso */
}; };
/* @param flag bit0= do not set hln_change_pending */
int Xorriso_set_change_pending(struct XorrisO *xorriso, int flag); int Xorriso_set_change_pending(struct XorrisO *xorriso, int flag);
int Xorriso_prepare_regex(struct XorrisO *xorriso, char *adr, int flag); int Xorriso_prepare_regex(struct XorrisO *xorriso, char *adr, int flag);
@ -956,6 +958,7 @@ struct FindjoB {
33= get_any_xattr 33= get_any_xattr
34= get_md5 34= get_md5
35= check_md5 35= check_md5
36= make_md5
*/ */
int action; int action;
int prune; int prune;

View File

@ -1 +1 @@
#define Xorriso_timestamP "2009.08.20.204309" #define Xorriso_timestamP "2009.08.22.184241"

View File

@ -7621,6 +7621,10 @@ int Xorriso_findi_action(struct XorrisO *xorriso, struct FindjoB *job,
xorriso->find_check_md5_result|= 4; xorriso->find_check_md5_result|= 4;
if(ret >= 0) if(ret >= 0)
ret= 1; ret= 1;
} else if(action == 36) { /* make_md5 */
ret = Xorriso_make_md5(xorriso, (void *) node, show_path, 0);
if(ret >= 0)
ret= 1;
} else { /* includes : 15 in_iso */ } else { /* includes : 15 in_iso */
sprintf(xorriso->result_line, "%s\n", Text_shellsafe(show_path, sfe, 0)); sprintf(xorriso->result_line, "%s\n", Text_shellsafe(show_path, sfe, 0));
Xorriso_result(xorriso, 0); Xorriso_result(xorriso, 0);
@ -7969,7 +7973,7 @@ int Xorriso_findi(struct XorrisO *xorriso, struct FindjoB *job,
if(action==1 || action==2 || action==3 || action==17 || action == 28 || if(action==1 || action==2 || action==3 || action==17 || action == 28 ||
action == 32) action == 32)
hflag|= 2; /* need freedom to manipulate image */ hflag|= 2; /* need freedom to manipulate image */
if(action==14 || action==17 || action == 28) if(action==14 || action==17 || action == 28 || action == 35 || action == 36)
hflag|= 4; /* need LBA sorted iteration for good data reading performance */ hflag|= 4; /* need LBA sorted iteration for good data reading performance */
ret= Xorriso_findi_iter(xorriso, dir_node, &mem, ret= Xorriso_findi_iter(xorriso, dir_node, &mem,
&iter, &node_array, &node_count, &node_idx, &iter, &node_array, &node_count, &node_idx,
@ -8180,7 +8184,6 @@ int Xorriso_path_from_lba(struct XorrisO *xorriso, IsoNode *node, int lba,
/* @param flag bit0= do not dive into trees /* @param flag bit0= do not dive into trees
bit1= do not perform job->action on resulting node array bit1= do not perform job->action on resulting node array
bit2= do not free node_array after all actions are done bit2= do not free node_array after all actions are done
bit3= eventually issue MD5 mismatch event
*/ */
int Xorriso_findi_sorted(struct XorrisO *xorriso, struct FindjoB *job, int Xorriso_findi_sorted(struct XorrisO *xorriso, struct FindjoB *job,
off_t boss_mem, int filec, char **filev, int flag) off_t boss_mem, int filec, char **filev, int flag)
@ -8194,8 +8197,6 @@ int Xorriso_findi_sorted(struct XorrisO *xorriso, struct FindjoB *job,
array_job.start_path= NULL; array_job.start_path= NULL;
if((flag & 8) && job->action == 35)
xorriso->find_check_md5_result= 0;
if(job->action>=9 && job->action<=13) { /* actions which have own findjobs */ if(job->action>=9 && job->action<=13) { /* actions which have own findjobs */
/* array_job replaces the hindmost job in the chain */ /* array_job replaces the hindmost job in the chain */
for(hindmost= job; hindmost->subjob != NULL; hindmost= hindmost->subjob) for(hindmost= job; hindmost->subjob != NULL; hindmost= hindmost->subjob)
@ -8293,15 +8294,13 @@ int Xorriso_findi_sorted(struct XorrisO *xorriso, struct FindjoB *job,
ret= Xorriso_findi_action(xorriso, hindmost, NULL, (off_t) 0, ret= Xorriso_findi_action(xorriso, hindmost, NULL, (off_t) 0,
abs_path, abs_path, node, 0, 1); abs_path, abs_path, node, 0, 1);
if(ret <= 0) if(ret <= 0 || xorriso->request_to_abort)
if(Xorriso_eval_problem_status(xorriso, ret, 1|2)<0) if(Xorriso_eval_problem_status(xorriso, ret, 1|2)<0)
goto ex; goto ex;
} }
ret= 1; ret= 1;
ex:; ex:;
if((flag & 8) && job->action == 35)
Xorriso_report_md5_outcome(xorriso, job->target, 0);
if(!(flag & (2 | 4))) if(!(flag & (2 | 4)))
Xorriso_destroy_node_array(xorriso, 0); Xorriso_destroy_node_array(xorriso, 0);
if(hmboss != NULL) if(hmboss != NULL)
@ -12282,6 +12281,38 @@ ex:;
} }
int Xorriso_make_md5(struct XorrisO *xorriso, void *in_node, char *path,
int flag)
{
int ret;
off_t size;
IsoNode *node;
node= (IsoNode *) in_node;
if(node == NULL) {
ret= Xorriso_get_node_by_path(xorriso, path, NULL, &node, 0);
if(ret <= 0)
return(ret);
}
if(!LIBISO_ISREG(node))
return(0);
ret= iso_file_make_md5((IsoFile *) node, 0);
size= iso_file_get_size((IsoFile *) node);
xorriso->pacifier_count+= size;
xorriso->pacifier_byte_count+= size;
Xorriso_pacifier_callback(xorriso, "content bytes read",
xorriso->pacifier_count, 0, "", 0);
Xorriso_process_msg_queues(xorriso, 0);
if(ret < 0) {
Xorriso_report_iso_error(xorriso, "", ret,
"Error when computing MD5", 0, "FAILURE", 1);
return(0);
}
Xorriso_set_change_pending(xorriso, 1);
return(1);
}
/* @param node Opaque handle to IsoNode which is to be inquired instead of path if it is not NULL. /* @param node Opaque handle to IsoNode which is to be inquired instead of path if it is not NULL.
@param path is used as address if node is NULL. @param path is used as address if node is NULL.
@param flag bit0= do not report to result but only indicate outcome @param flag bit0= do not report to result but only indicate outcome

View File

@ -459,6 +459,8 @@ int Xorriso_finish_hl_update(struct XorrisO *xorriso, int flag);
int Xorriso_get_md5(struct XorrisO *xorriso, void *in_node, char *path, int Xorriso_get_md5(struct XorrisO *xorriso, void *in_node, char *path,
char md5[16], int flag); char md5[16], int flag);
int Xorriso_make_md5(struct XorrisO *xorriso, void *in_node, char *path,
int flag);
int Xorriso_md5_start(struct XorrisO *xorriso, void **ctx, int flag); int Xorriso_md5_start(struct XorrisO *xorriso, void **ctx, int flag);