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

master
Thomas Schmitt 13 years ago
parent 5f06ee19c5
commit 56abdd0c2c
  1. 7
      xorriso/xorriso.1
  2. 59
      xorriso/xorriso.c
  3. 3
      xorriso/xorriso_private.h
  4. 2
      xorriso/xorriso_timestamp.h
  5. 45
      xorriso/xorrisoburn.c
  6. 2
      xorriso/xorrisoburn.h

@ -2,7 +2,7 @@
.\" First parameter, NAME, should be all caps
.\" Second parameter, SECTION, should be 1-8, maybe w/ subsection
.\" 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.
.\"
.\" Some roff macros, for reference:
@ -1461,6 +1461,11 @@ namespace "isofs".
and reports if mismatch.
.br
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
\fBsetfattr\fR sets or deletes xattr name value pairs.
.br

@ -4956,7 +4956,8 @@ int Xorriso_destroy(struct XorrisO **xorriso, int flag)
int Xorriso_set_change_pending(struct XorrisO *xorriso, int flag)
{
xorriso->volset_change_pending= 1;
xorriso->hln_change_pending= 1;
if(!(flag & 2))
xorriso->hln_change_pending= 1;
return(1);
}
@ -7106,9 +7107,19 @@ int Xorriso_status(struct XorrisO *xorriso, char *filter, FILE *fp, int flag)
if(!(is_default && no_defaults))
Xorriso_status_result(xorriso,filter,fp,flag&2);
is_default= ((xorriso->do_md5 & (1 | 2 | 4 | 8)) == 0);
sprintf(line, "-md5 %s\n", (xorriso->do_md5 & 1 ?
xorriso->do_md5 & 8 ? "all" : "on" : "off"));
is_default= ((xorriso->do_md5 & 31) == 0);
sprintf(line, "-md5 ");
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))
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;
has_md5= Xorriso_image_has_md5(xorriso, 0);
if (has_md5 <= 0) {
sprintf(xorriso->result_line,
"There is no MD5 checksum array loaded.\n");
} else if(xorriso->find_check_md5_result & 1) {
if(xorriso->find_check_md5_result & 1) {
sprintf(xorriso->result_line,
"Mismatch detected between file contents and MD5 checksums.\n");
} 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");
} else {
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);
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);
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))) {
Xorriso_pacifier_reset(xorriso, 0);
@ -15172,6 +15176,19 @@ not_enough_exec_arguments:;
i+= 1;
Findjob_set_action_target(job, 35, argv[i], 0);
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 {
sprintf(xorriso->info_text, "-find -exec: unknown action %s",
Text_shellsafe(argv[i], sfe, 0));
@ -15190,7 +15207,7 @@ sorry_ex:;
0);
else if(flag & 8) {
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
ret= Xorriso_findi(xorriso, first_job, NULL, (off_t) 0, NULL,
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))
Xorriso_pacifier_callback(xorriso, "content bytes read",
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)
free(access_acl_text);
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)
xorriso->do_md5&= ~31;
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)
xorriso->do_md5|= 31;
else if(l == 18 && strncmp(cpt, "stability_check_on", l) == 0)

@ -128,6 +128,7 @@ struct XorrisO { /* the global context of xorriso */
bit1= write session MD5
bit2= write MD5 for each data file
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 */
@ -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_prepare_regex(struct XorrisO *xorriso, char *adr, int flag);
@ -956,6 +958,7 @@ struct FindjoB {
33= get_any_xattr
34= get_md5
35= check_md5
36= make_md5
*/
int action;
int prune;

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

@ -7621,6 +7621,10 @@ int Xorriso_findi_action(struct XorrisO *xorriso, struct FindjoB *job,
xorriso->find_check_md5_result|= 4;
if(ret >= 0)
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 */
sprintf(xorriso->result_line, "%s\n", Text_shellsafe(show_path, sfe, 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 ||
action == 32)
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 */
ret= Xorriso_findi_iter(xorriso, dir_node, &mem,
&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
bit1= do not perform job->action on resulting node array
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,
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;
if((flag & 8) && job->action == 35)
xorriso->find_check_md5_result= 0;
if(job->action>=9 && job->action<=13) { /* actions which have own findjobs */
/* array_job replaces the hindmost job in the chain */
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,
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)
goto ex;
}
ret= 1;
ex:;
if((flag & 8) && job->action == 35)
Xorriso_report_md5_outcome(xorriso, job->target, 0);
if(!(flag & (2 | 4)))
Xorriso_destroy_node_array(xorriso, 0);
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 path is used as address if node is NULL.
@param flag bit0= do not report to result but only indicate outcome

@ -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,
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);

Loading…
Cancel
Save