Made -compare* and -update* obey -follow links (-follow mount still not correct)

This commit is contained in:
2008-03-05 17:34:06 +00:00
parent b9ace51640
commit 84b1543295
3 changed files with 75 additions and 40 deletions

View File

@ -4177,11 +4177,12 @@ int Xorriso_make_abs_adr(struct XorrisO *xorriso, char *wd, char *name,
if(strlen(wd)+1>=SfileadrL)
goto much_too_long;
strcpy(adr, wd);
if(Sfile_add_to_path(adr, name, 0)<=0) {
if(name[0])
if(Sfile_add_to_path(adr, name, 0)<=0) {
much_too_long:;
Xorriso_much_too_long(xorriso, (int) (strlen(adr)+strlen(name)+1), 2);
return(0);
}
Xorriso_much_too_long(xorriso, (int) (strlen(adr)+strlen(name)+1), 2);
return(0);
}
} else {
if(strlen(name)+1>=SfileadrL)
goto much_too_long;
@ -4484,12 +4485,13 @@ I thought to have seen a libisofs bug here but it seems that it was an illusion
/* @param boss_iter Opaque handle to be forwarded to actions in ISO image
Set to NULL if calling this function from outside ISO world
@param flag bit0= update rather than compare
bit1= find[ix] is in recursion
*/
int Xorriso_find_compare(struct XorrisO *xorriso, void *boss_iter,
char *iso_path, char *iso_prefix, char *disk_prefix,
int flag)
{
int ret, result, uret;
int ret, result, uret, follow_links;
char disk_path[SfileadrL], adrc[SfileadrL];
if(strncmp(iso_path, iso_prefix, strlen(iso_prefix))!=0)
@ -4505,14 +4507,16 @@ int Xorriso_find_compare(struct XorrisO *xorriso, void *boss_iter,
if(ret<=0)
return(ret);
follow_links= (xorriso->do_follow_links ||
(xorriso->do_follow_param && !(flag&2))) <<28;
ret= Xorriso_compare_2_files(xorriso, disk_path, iso_path, adrc, &result,
2|(1<<29));
2|follow_links|(1<<29));
if(ret<xorriso->find_compare_result)
xorriso->find_compare_result= ret;
if(flag&1) {
if(ret==0) {
uret= Xorriso_update_interpreter(xorriso, boss_iter,
result, disk_path, iso_path, 0);
uret= Xorriso_update_interpreter(xorriso, boss_iter, result,
disk_path, iso_path, (flag&2)<<1);
if(uret<=0)
ret= 0;
}
@ -6092,6 +6096,8 @@ int Xorriso_lsx_filev(struct XorrisO *xorriso, char *wd,
}
/* @param flag bit0= recursion
*/
int Xorriso_findx_action(struct XorrisO *xorriso, struct FindjoB *job,
char *abs_path, char *show_path, int depth, int flag)
{
@ -6146,7 +6152,7 @@ int Xorriso_findx_action(struct XorrisO *xorriso, struct FindjoB *job,
xorriso->find_compare_result= ret;
if(ret==0) {
uret= Xorriso_update_interpreter(xorriso, NULL, compare_result,
abs_path, iso_path, 0);
abs_path, iso_path, (flag&1)<<2);
if(uret<=0)
ret= 0;
}
@ -6224,7 +6230,8 @@ int Xorriso_findx(struct XorrisO *xorriso, struct FindjoB *job,
sprintf(xorriso->result_line, "%s\n", Text_shellsafe(dir_path, sfe, 0));
Xorriso_result(xorriso, 0);
#else
ret= Xorriso_findx_action(xorriso, job, abs_dir_path, dir_path, depth, 0);
ret= Xorriso_findx_action(xorriso, job, abs_dir_path, dir_path, depth,
flag&1);
if(ret<=0) {
if(Xorriso_eval_problem_status(xorriso, ret, 1|2)<0)
goto ex;
@ -6277,18 +6284,11 @@ int Xorriso_findx(struct XorrisO *xorriso, struct FindjoB *job,
if(ret<0)
goto ex;
if(ret>0) {
#ifdef NIX
sprintf(xorriso->result_line, "%s\n", Text_shellsafe(path, sfe, 0));
Xorriso_result(xorriso, 0);
#else
ret= Xorriso_findx_action(xorriso, job, abs_path, path, depth, 0);
ret= Xorriso_findx_action(xorriso, job, abs_path, path, depth, flag&1);
if(ret<=0) {
if(Xorriso_eval_problem_status(xorriso, ret, 1|2)<0)
goto ex;
}
#endif
}
if(!S_ISDIR(stbuf.st_mode))
no_dive= 1;
@ -7081,6 +7081,7 @@ ex:;
/* @param boss_iter Opaque handle to be forwarded to actions in ISO image
Set to NULL if calling this function from outside ISO world
@param flag bit2= -follow: this is not a command parameter
*/
int Xorriso_update_interpreter(struct XorrisO *xorriso, void *boss_iter,
int compare_result, char *disk_path,
@ -7099,14 +7100,20 @@ int Xorriso_update_interpreter(struct XorrisO *xorriso, void *boss_iter,
}
xorriso->info_text[0]= 0;
#ifdef NIX
if((compare_result&(8|64)) && !(compare_result&(1<<16)) ) {
/* file type, minor+major with device file */
/* <<< tolerate for now: disk_path being softlink to dir, iso being dir */
/* <<< to be obsoleted by proper link handling in compare_2_files */
ret= Xorriso_rmi(xorriso, boss_iter, iso_rr_path, 1);
/* file type, minor+major with device file */
#else
if(compare_result&(8|64)) {
/* file type, minor+major with device file */
#endif /* NIX */
ret= Xorriso_rmi(xorriso, boss_iter, iso_rr_path, 1); /* rm_r */
if(ret>0)
ret= Xorriso_graft_in(xorriso, boss_iter, disk_path, iso_rr_path, 2);
ret= Xorriso_graft_in(xorriso, boss_iter, disk_path, iso_rr_path,
2|(flag&4));
sprintf(xorriso->info_text, "Deleted and re-added ");
} else if(compare_result&(1)) {
@ -7117,7 +7124,8 @@ int Xorriso_update_interpreter(struct XorrisO *xorriso, void *boss_iter,
} else if(compare_result&(2|128|(1<<12)|(1<<14)|(1<<15))) {
/* iso_adr not existing, size, cannot open iso file, early eof of iso file
content bytes differ */
ret= Xorriso_graft_in(xorriso, boss_iter, disk_path, iso_rr_path, 2);
ret= Xorriso_graft_in(xorriso, boss_iter, disk_path, iso_rr_path,
2|(flag&4));
sprintf(xorriso->info_text, "Added/overwrote ");
} else if(compare_result&(4|16|32|256|512|1024)) {
@ -7881,7 +7889,7 @@ int Xorriso_option_commit_eject(struct XorrisO *xorriso, char *which, int flag)
int Xorriso_option_compare(struct XorrisO *xorriso, char *disk_path,
char *iso_path, int flag)
{
int ret, mem_pci, zero= 0, result;
int ret, mem_pci, zero= 0, result, follow_links;
double mem_lut= 0.0;
char *ipth, *argv[4];
@ -7918,8 +7926,9 @@ int Xorriso_option_compare(struct XorrisO *xorriso, char *disk_path,
} else
ret= -1;
} else {
follow_links= (xorriso->do_follow_links || xorriso->do_follow_param) << 28;
ret= Xorriso_compare_2_files(xorriso, disk_path, ipth, "", &result,
2| (1<<30) | ((flag&4)<<27));
2 | follow_links | ((flag&4)<<27) | (1<<30));
}
xorriso->pacifier_interval= mem_pci;
@ -9991,7 +10000,7 @@ int Xorriso_option_uid(struct XorrisO *xorriso, char *uid, int flag)
int Xorriso_option_update(struct XorrisO *xorriso, char *disk_path,
char *iso_path, int flag)
{
int ret, mem_pci, zero= 0, result, uret;
int ret, mem_pci, zero= 0, result, uret, follow_links;
double mem_lut= 0.0, start_time;
char *ipth, *argv[4];
struct stat stbuf;
@ -10039,8 +10048,9 @@ int Xorriso_option_update(struct XorrisO *xorriso, char *disk_path,
ret= -1;
} else {
/* compare ctime too, no filename reporting, eventually silent */
follow_links= (xorriso->do_follow_links || xorriso->do_follow_param) <<28;
ret= Xorriso_compare_2_files(xorriso, disk_path, ipth, "", &result,
2| (1<<30) | ((flag&4)<<27));
2 | follow_links | ((flag&4)<<27) | (1<<30));
if(ret==0) {
uret= Xorriso_update_interpreter(xorriso, NULL, result, disk_path, ipth,
0);