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

@ -1780,6 +1780,7 @@ int Xorriso_copy_properties(struct XorrisO *xorriso,
Set to NULL if calling this function from outside ISO world
@param flag bit0= mkdir: graft in as empty directory, not as copy from disk
bit1= do not report added files
bit2= -follow: this is not a command parameter
@return <=0 = error , 1 = added simple node , 2 = added directory
*/
int Xorriso_graft_in(struct XorrisO *xorriso, void *boss_iter,
@ -1787,9 +1788,10 @@ int Xorriso_graft_in(struct XorrisO *xorriso, void *boss_iter,
{
IsoImage *volume;
char path[SfileadrL], *apt, *npt, *cpt, sfe[5*SfileadrL], sfe2[5*SfileadrL];
char *disk_path_pt, resolved_disk_path[SfileadrL];
IsoDir *dir, *hdir;
IsoNode *node;
int done= 0, is_dir= 0, l, ret, target_is_dir, source_is_dir;
int done= 0, is_dir= 0, l, ret, target_is_dir, source_is_dir, resolve_link= 0;
struct stat stbuf;
for(cpt= img_path; 1; cpt++) {
@ -1824,10 +1826,21 @@ int Xorriso_graft_in(struct XorrisO *xorriso, void *boss_iter,
apt= npt= path;
if(!(flag&1)) {
if(xorriso->do_follow_links || xorriso->do_follow_param)
ret= stat(disk_path, &stbuf);
else
ret= lstat(disk_path, &stbuf);
ret= lstat(disk_path, &stbuf);
if(ret!=-1) {
if(S_ISDIR(stbuf.st_mode))
is_dir= 1;
else if((stbuf.st_mode&S_IFMT)==S_IFLNK &&
(xorriso->do_follow_links ||
(xorriso->do_follow_param && !(flag&4)))) {
resolve_link= 1;
ret= stat(disk_path, &stbuf);
if(ret!=-1) {
if(S_ISDIR(stbuf.st_mode))
is_dir= 1;
}
}
}
if(ret == -1) {
Xorriso_process_msg_queues(xorriso,0);
Xorriso_msgs_submit(xorriso, 0, disk_path, 0, "ERRFILE", 0);
@ -1962,7 +1975,14 @@ attach_source:;
return(ret);
} else {
ret= iso_tree_add_node(volume, dir, disk_path, &node);
if(resolve_link) {
ret= Xorriso_resolve_link(xorriso, disk_path, resolved_disk_path, 0);
if(ret<=0)
return(ret);
disk_path_pt= resolved_disk_path;
} else
disk_path_pt= disk_path;
ret= iso_tree_add_node(volume, dir, disk_path_pt, &node);
if(ret<0) {
Xorriso_process_msg_queues(xorriso,0);
Xorriso_msgs_submit(xorriso, 0, disk_path, 0, "ERRFILE", 0);
@ -3761,6 +3781,8 @@ int Xorriso_set_time(struct XorrisO *xorriso, char *in_path, time_t t,
}
/* @param flag bit0= not a command parameter (directory iteration or recursion)
*/
int Xorriso_findi_action(struct XorrisO *xorriso, struct FindjoB *job,
IsoDirIter *boss_iter, off_t boss_mem,
char *abs_path, char *show_path,
@ -3803,11 +3825,11 @@ int Xorriso_findi_action(struct XorrisO *xorriso, struct FindjoB *job,
} else if(action>=9 && action<=13) { /* actions which have own findjobs */
Findjob_set_start_path(subjob, abs_path, 0);
ret= Xorriso_findi(xorriso, subjob, boss_iter, boss_mem, NULL,
abs_path, &dir_stbuf, depth, 0);
abs_path, &dir_stbuf, depth, 1);
} else if(action==14 || action==17) { /* compare , update */
Findjob_get_start_path(job, &iso_prefix, 0);
ret= Xorriso_find_compare(xorriso, (void *) boss_iter, abs_path, iso_prefix, target,
(action==17));
ret= Xorriso_find_compare(xorriso, (void *) boss_iter, abs_path,
iso_prefix, target, (action==17)|((flag&1)<<1));
if(ret>=0)
ret= 1;
} else if(action==16 || action==18) { /* not_in_iso , add_missing */
@ -3943,6 +3965,8 @@ cannot_iter:;
}
/* @param flag bit0= recursion
*/
int Xorriso_findi(struct XorrisO *xorriso, struct FindjoB *job,
void *boss_iter, off_t boss_mem,
void *dir_node_generic, char *dir_path,
@ -4008,7 +4032,8 @@ int Xorriso_findi(struct XorrisO *xorriso, struct FindjoB *job,
if(ret>0) {
ret= Xorriso_findi_action(xorriso, job,
(IsoDirIter *) boss_iter, boss_mem,
path, dir_path, (IsoNode *) dir_node, depth, 0);
path, dir_path, (IsoNode *) dir_node, depth,
flag&1);
if(ret<=0)
goto ex;
}
@ -4061,7 +4086,7 @@ int Xorriso_findi(struct XorrisO *xorriso, struct FindjoB *job,
if(ret<=0)
goto ex;
ret= Xorriso_findi_action(xorriso, job, iter, mem,
abs_path, path, node, depth, 0);
abs_path, path, node, depth, 1);
if(ret<=0) {
if(Xorriso_eval_problem_status(xorriso, ret, 1|2)<0)
goto ex;
@ -4070,7 +4095,7 @@ int Xorriso_findi(struct XorrisO *xorriso, struct FindjoB *job,
if(S_ISDIR(stbuf.st_mode)) {
ret= Xorriso_findi(xorriso, job, (void *) iter, mem,
(void *) node, path, &stbuf, depth+1, flag);
(void *) node, path, &stbuf, depth+1, flag|1);
if(ret<0)
goto ex;
}