Improvements about -update_r and -compare_r

This commit is contained in:
Thomas Schmitt 2008-03-04 18:08:14 +00:00
parent 7ba6078291
commit 544e6849ff
3 changed files with 65 additions and 22 deletions

View File

@ -7123,7 +7123,7 @@ int Xorriso_update_interpreter(struct XorrisO *xorriso, void *boss_iter,
} else if(compare_result&(4|16|32|256|512|1024)) {
/* access permissions, user id, group id, mtime, atime, ctime */
ret= Xorriso_copy_properties(xorriso, disk_path, iso_rr_path, 0);
sprintf(xorriso->info_text, "Adjusted attributes ");
sprintf(xorriso->info_text, "Adjusted attributes of ");
} else
ret= 1;
@ -9992,8 +9992,11 @@ int Xorriso_option_update(struct XorrisO *xorriso, char *disk_path,
char *iso_path, int flag)
{
int ret, mem_pci, zero= 0, result, uret;
double mem_lut= 0.0;
double mem_lut= 0.0, start_time;
char *ipth, *argv[4];
struct stat stbuf;
start_time= Sfile_microtime(0);
ipth= iso_path;
if(ipth[0]==0)
@ -10008,23 +10011,30 @@ int Xorriso_option_update(struct XorrisO *xorriso, char *disk_path,
if(flag&8) {
xorriso->find_compare_result= 1;
argv[0]= ipth;
argv[1]= "-exec";
argv[2]= "update";
argv[3]= disk_path;
zero= 0;
ret= Xorriso_option_find(xorriso, 4, argv, &zero, 2); /* -findi */
if(ret>0) {
argv[0]= disk_path;
ret= Xorriso_iso_lstat(xorriso, ipth, &stbuf, 0);
if(ret != -1) {
argv[0]= ipth;
argv[1]= "-exec";
argv[2]= "add_missing";
argv[3]= ipth;
argv[2]= "update";
argv[3]= disk_path;
zero= 0;
ret= Xorriso_option_find(xorriso, 4, argv, &zero, 1|2); /* -findx */
if(ret>0)
ret= xorriso->find_compare_result;
else
ret= -1;
ret= Xorriso_option_find(xorriso, 4, argv, &zero, 2); /* -findi */
} else
ret= 1;
if(ret>0) {
ret= lstat(disk_path, &stbuf);
if(ret != -1) {
argv[0]= disk_path;
argv[1]= "-exec";
argv[2]= "add_missing";
argv[3]= ipth;
zero= 0;
ret= Xorriso_option_find(xorriso, 4, argv, &zero, 1|2); /* -findx */
if(ret>0)
ret= xorriso->find_compare_result;
else
ret= -1;
}
} else
ret= -1;
} else {
@ -10044,13 +10054,15 @@ int Xorriso_option_update(struct XorrisO *xorriso, char *disk_path,
xorriso->pacifier_count, 0, "", 1);
if(ret>0) {
sprintf(xorriso->result_line,
"No file object needed update.\n");
"No file object needed update.");
} else if(ret==0) {
sprintf(xorriso->result_line, "Differences detected and updated.\n");
sprintf(xorriso->result_line, "Differences detected and updated.");
} else {
sprintf(xorriso->result_line,
"Not ok. Comparison or update failed due to error.\n");
"Not ok. Comparison or update failed due to error.");
}
sprintf(xorriso->result_line+strlen(xorriso->result_line),
" (runtime %.1f s)\n", Sfile_microtime(0)-start_time);
if(flag&1)
Xorriso_result(xorriso,0);
if(ret<0)

View File

@ -1 +1 @@
#define Xorriso_timestamP "2008.03.04.174107"
#define Xorriso_timestamP "2008.03.04.180738"

View File

@ -3821,6 +3821,22 @@ int Xorriso_findi_action(struct XorrisO *xorriso, struct FindjoB *job,
}
int Xorriso__node_lba_cmp(const void *node1, const void *node2)
{
uint32_t lba1= 0, lba2= 0;
int ret;
ret = iso_node_get_old_image_lba(*((IsoNode **) node1), &lba1, 0);
if(ret!=1)
lba1= 0;
ret = iso_node_get_old_image_lba(*((IsoNode **) node2), &lba2, 0);
if(ret!=1)
lba1= 0;
return(lba1-lba2);
}
/* The caller shall make no assumptions about the meaning of iter, node_array,
node_count, node_idx ! They are just opaque handles for which the caller
provides the memory of proper type.
@ -3890,6 +3906,9 @@ cannot_iter:;
*iter= NULL;
*node_count= *node_idx;
*node_idx= 0;
if(*node_count>1)
qsort(*node_array, *node_count, sizeof(IsoNode *),
Xorriso__node_lba_cmp);
}
}
@ -4002,7 +4021,7 @@ int Xorriso_findi(struct XorrisO *xorriso, struct FindjoB *job,
mem= boss_mem;
ret= Xorriso_findi_iter(xorriso, dir_node, &mem,
&iter, &node_array, &node_count, &node_idx,
&node, 1|((action==17)<<1));
&node, 1|((action==14 || action==17)<<1));
if(ret<=0)
goto ex;
while(1) {
@ -4470,6 +4489,10 @@ int Xorriso_iso_file_open(struct XorrisO *xorriso, char *pathname,
IsoFile *filenode= NULL;
IsoStream *iso_stream= NULL;
#ifdef Libisofs_lba_tesT
uint32_t lba;
#endif
*stream= NULL;
ret= Xorriso_get_node_by_path(xorriso, pathname, eff_path, &node, 0);
if(ret<=0)
@ -4480,6 +4503,14 @@ int Xorriso_iso_file_open(struct XorrisO *xorriso, char *pathname,
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
return(0);
}
#ifdef Libisofs_lba_tesT
ret = iso_node_get_old_image_lba(node, &lba, 0);
sprintf(xorriso->info_text, "%s : ret= %d , LBA= %lx",
pathname, ret, (unsigned long) lba);
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "DEBUG", 0);
#endif
filenode= (IsoFile *) node;
iso_stream= iso_file_get_stream(filenode);
if(iso_stream==NULL) {