Fixed bug about non existing disk_path with -update_r

This commit is contained in:
Thomas Schmitt 2008-03-06 17:48:02 +00:00
parent 2c00ae34ae
commit f760da0016
4 changed files with 75 additions and 45 deletions

View File

@ -543,30 +543,6 @@ as files to add, if they are not parameters to appropriate commands.
Like -add but read the parameter words from file disk_path.
One pathspec resp. disk_path pattern per line.
.TP
\fB\-update\fR disk_path iso_rr_path
WARNING: This option is fewly tested and has potential to spoil your ISO image.
.br
Compare file object disk_path with file object iso_rr_path. If they do not
match, then perform the necessary image manipulations to make iso_rr_path
a matching copy of disk_path. This comparison will imply lengthy content
reading before a decision is made. On the other hand it strives for the
smallest possible amount of add-on data which is needed to achieve the
matching copy.
.br
-update is also a convenient compromise between -add addressing and -cp_r
addressing: Its semantics is similar to -add and thus avoids the pitfalls
inherited from cp -r behavior. Its syntax resembles cp, though.
.br
Note: Not all subtleties of link following are implemented yet.
.TP
\fB\-update_r\fR disk_path iso_rr_path
WARNING: This option is fewly tested and has potential to spoil your ISO image.
.br
Like -update but working recursively. I.e. all file objects below both
addresses get compared whether they have counterparts below the other address
and whether both counterparts match. If there is a mismatch then the necessary
update manipulation is done.
.TP
\fB\-cpr\fR disk_path [***] iso_rr_path
Insert the given files or directory trees from filesystem
into the ISO image.
@ -584,6 +560,30 @@ get the same type as the disk_path.
If a disk_path does not begin with '/' then -cdx is prepended.
If the iso_rr_path does not begin with '/' then -cd is prepended.
.TP
\fB\-update\fR disk_path iso_rr_path
Compare file object disk_path with file object iso_rr_path. If they do not
match, then perform the necessary image manipulations to make iso_rr_path
a matching copy of disk_path. This comparison will imply lengthy content
reading before a decision is made. On the other hand it strives for the
smallest possible amount of add-on data which is needed to achieve the
matching copy.
.TP
\fB\-update_r\fR disk_path iso_rr_path
Like -update but working recursively. I.e. all file objects below both
addresses get compared whether they have counterparts below the other address
and whether both counterparts match. If there is a mismatch then the necessary
update manipulation is done.
.br
Note that the comparison result may depend on option -follow. Its setting
should always be the same as with the first adding of disk_path as iso_rr_path.
.br
If iso_rr_path does not exist yet, then it gets added. If disk_path does not
exist, then iso_rr_path gets deleted.
.br
-update_r is also a convenient compromise between -add addressing and -cp_r
addressing: Its semantics is similar to -add and thus avoids the pitfalls
inherited from cp -r behavior. Its syntax resembles cp, though.
.TP
\fB\-rm\fR iso_rr_path [***]
Delete the given files from the ISO image.
.br
@ -729,8 +729,6 @@ E.g.:
"update" performs command -update with the found file address as iso_rr_path.
The corresponding file address is determined like with above "compare".
.br
WARNING: This action is fewly tested and has potential to spoil your ISO image.
.br
E.g.:
.br
-find / -exec update /home/thomas --

View File

@ -4495,12 +4495,13 @@ I thought to have seen a libisofs bug here but it seems that it was an illusion
Set to NULL if calling this function from outside ISO world
@param flag bit0= update rather than compare
bit1= find[ix] is in recursion
@return <=0 error, 1= ok , 2= iso_path was deleted
*/
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, follow_links;
int ret, result, uret, follow_links, deleted= 0;
char disk_path[SfileadrL], adrc[SfileadrL];
if(strncmp(iso_path, iso_prefix, strlen(iso_prefix))!=0)
@ -4528,8 +4529,14 @@ int Xorriso_find_compare(struct XorrisO *xorriso, void *boss_iter,
disk_path, iso_path, (flag&2)<<1);
if(uret<=0)
ret= 0;
if(uret==2)
deleted= 1;
}
}
if(ret<0)
return(ret);
if(deleted)
return(2);
return(ret);
}
@ -7086,12 +7093,13 @@ 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
@return <=0 error, 1= ok , 2= iso_rr_path has been deleted
*/
int Xorriso_update_interpreter(struct XorrisO *xorriso, void *boss_iter,
int compare_result, char *disk_path,
char *iso_rr_path, int flag)
{
int ret;
int ret, deleted= 0;
char sfe[5*SfileadrL];
if(compare_result&((1<<11)|(1<<13))) {
@ -7104,25 +7112,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)) ) {
/* <<< tolerate for now: disk_path being softlink to dir, iso being dir */
/* <<< to be obsoleted by proper link handling in compare_2_files */
/* 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)
if(ret>0) {
deleted= 1;
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)) {
/* disk_adr not existing */
ret= Xorriso_rmi(xorriso, boss_iter, iso_rr_path, 1);
deleted= 1;
sprintf(xorriso->info_text, "Deleted ");
} else if(compare_result&(2|128|(1<<12)|(1<<14)|(1<<15))) {
@ -7143,7 +7146,11 @@ int Xorriso_update_interpreter(struct XorrisO *xorriso, void *boss_iter,
strcat(xorriso->info_text, Text_shellsafe(iso_rr_path, sfe, 0));
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "UPDATE", 0);
}
return(ret);
if(ret<=0)
return(ret);
if(deleted)
return(2);
return(1);
}
@ -10053,7 +10060,8 @@ int Xorriso_option_update(struct XorrisO *xorriso, char *disk_path,
ret= xorriso->find_compare_result;
else
ret= -1;
}
} else
ret= xorriso->find_compare_result;
} else
ret= -1;
} else {

View File

@ -1 +1 @@
#define Xorriso_timestamP "2008.03.06.114233"
#define Xorriso_timestamP "2008.03.06.174724"

View File

@ -3786,13 +3786,14 @@ int Xorriso_set_time(struct XorrisO *xorriso, char *in_path, time_t t,
/* @param flag bit0= not a command parameter (directory iteration or recursion)
bit1= do not count deleted files with rm and rm_r
@return <=0 error, 1=ok, 2=ok, node has been deleted
*/
int Xorriso_findi_action(struct XorrisO *xorriso, struct FindjoB *job,
IsoDirIter *boss_iter, off_t boss_mem,
char *abs_path, char *show_path,
IsoNode *node, int depth, int flag)
{
int ret= 0, type, action= 0, hflag;
int ret= 0, type, action= 0, hflag, deleted= 0;
uid_t user= 0;
gid_t group= 0;
time_t date= 0;
@ -3813,9 +3814,11 @@ int Xorriso_findi_action(struct XorrisO *xorriso, struct FindjoB *job,
if(S_ISDIR(dir_stbuf.st_mode))
hflag= 2;
ret= Xorriso_rmi(xorriso, boss_iter, abs_path, hflag);
deleted= 1;
}
} else if(action==2) { /* rm_r */
ret= Xorriso_rmi(xorriso, boss_iter, abs_path, 1|hflag);
deleted= 1;
} else if(action==3) {
/* >>> mv target */;
@ -3838,6 +3841,8 @@ int Xorriso_findi_action(struct XorrisO *xorriso, struct FindjoB *job,
Findjob_get_start_path(job, &iso_prefix, 0);
ret= Xorriso_find_compare(xorriso, (void *) boss_iter, abs_path,
iso_prefix, target, (action==17)|((flag&1)<<1));
if(ret==2)
deleted= 1;
if(ret>=0)
ret= 1;
} else if(action==16 || action==18) { /* not_in_iso , add_missing */
@ -3847,7 +3852,11 @@ int Xorriso_findi_action(struct XorrisO *xorriso, struct FindjoB *job,
Xorriso_result(xorriso, 0);
ret= 1;
}
return(ret);
if(ret<=0)
return(ret);
if(deleted)
return(2);
return(1);
}
@ -3976,13 +3985,14 @@ cannot_iter:;
/* @param flag bit0= recursion
bit1= do not count deleted files with rm and rm_r
@return <=0 error, 1= ok , 2= dir node and path has been deleted
*/
int Xorriso_findi(struct XorrisO *xorriso, struct FindjoB *job,
void *boss_iter, off_t boss_mem,
void *dir_node_generic, char *dir_path,
struct stat *dir_stbuf, int depth, int flag)
{
int ret, action= 0, hflag;
int ret, action= 0, hflag, deleted= 0;
IsoDirIter *iter= NULL;
IsoDir *dir_node= NULL;
IsoNode *node, *iso_node;
@ -4041,10 +4051,14 @@ int Xorriso_findi(struct XorrisO *xorriso, struct FindjoB *job,
flag&(1|2));
if(ret<=0)
goto ex;
if(ret==2) {
deleted= 1;
goto ex;
}
}
}
if(!LIBISO_ISDIR((IsoNode *) dir_node))
{ret= 2; goto ex;}
{ret= 1; goto ex;}
mem= boss_mem;
hflag= 1;
@ -4074,6 +4088,10 @@ int Xorriso_findi(struct XorrisO *xorriso, struct FindjoB *job,
if(ret==0)
continue;
/* ??? This seems to be redundant with the single test above
??? Should i dive in unconditionally and leave out test and action here ?
??? Then do above test unconditionally ?
*/
ret= Findjob_test(job, name, dir_stbuf, &stbuf, depth, 0);
if(ret<0)
goto ex;
@ -4083,6 +4101,8 @@ int Xorriso_findi(struct XorrisO *xorriso, struct FindjoB *job,
goto ex;
ret= Xorriso_findi_action(xorriso, job, iter, mem,
abs_path, path, node, depth, 1|(flag&2));
if(ret==2) /* node has been deleted */
continue;
if(ret<=0) {
if(Xorriso_eval_problem_status(xorriso, ret, 1|2)<0)
goto ex;
@ -4116,7 +4136,11 @@ ex:;
if(iter!=NULL)
iso_dir_iter_free(iter);
#endif
return(ret);
if(ret<=0)
return(ret);
if(deleted)
return(2);
return(1);
}