Bug fix: -findi operated on nodes which ceased existence shortly before

This commit is contained in:
2008-05-18 08:21:48 +00:00
parent ddf698c1c4
commit de589419da
3 changed files with 51 additions and 15 deletions

View File

@ -1329,6 +1329,7 @@ int Xorriso_node_from_path(struct XorrisO *xorriso, IsoImage *volume,
@param flag bit0= do not produce problem events (unless faulty path format)
bit1= work purely literally, do not use libisofs
bit2= (with bit1) this is an address in the disk world
bit3= return root directory as "/" and not as ""
@return -1 = faulty path format, 0 = not found ,
1 = found simple node , 2 = found directory
*/
@ -1342,8 +1343,11 @@ int Xorriso_normalize_img_path(struct XorrisO *xorriso, char *wd,
char path[SfileadrL], *apt, *npt, sfe[5*SfileadrL], *cpt;
eff_path[0]= 0;
if(img_path[0]==0)
if(img_path[0]==0) {
if(flag&8)
strcpy(eff_path, "/");
return(2); /* root directory */
}
if(!(flag&2)) {
ret= Xorriso_get_volume(xorriso, &volume, 0);
@ -1367,8 +1371,11 @@ int Xorriso_normalize_img_path(struct XorrisO *xorriso, char *wd,
img_path);
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, errno, "FATAL", 0);
return(-1);
} else if(path[1]==0)
} else if(path[1]==0) {
if(flag&8)
strcpy(eff_path, "/");
return(2); /* root directory */
}
for(npt= apt; !done; apt= npt+1) {
npt= strchr(apt, '/');
@ -4598,7 +4605,7 @@ int Xorriso_findi(struct XorrisO *xorriso, struct FindjoB *job,
IsoDirIter *iter= NULL;
IsoDir *dir_node= NULL;
IsoNode *node, *iso_node;
IsoImage *volume;
IsoImage *volume= NULL;
struct stat stbuf;
char *name;
off_t mem;
@ -4634,7 +4641,6 @@ int Xorriso_findi(struct XorrisO *xorriso, struct FindjoB *job,
if(ret<=0)
{ret= 0; goto ex;}
ret= Xorriso_fake_stbuf(xorriso, "", dir_stbuf, &iso_node, 1);
dir_node= (IsoDir *) iso_node;
if(ret<=0)
goto ex;
@ -4654,8 +4660,18 @@ int Xorriso_findi(struct XorrisO *xorriso, struct FindjoB *job,
if(ret<=0)
goto ex;
if(ret==2) {
deleted= 1;
goto ex;
/* re-determine dir_node in case it has a new persona */
ret= Xorriso_node_from_path(xorriso, volume, path, &iso_node, 1);
if(ret==0) {
deleted= 1;
{ret= 2; goto ex;}
}
if(ret<0)
{ret= 0; goto ex;}
dir_node= (IsoDir *) iso_node;
ret= Xorriso_fake_stbuf(xorriso, "", dir_stbuf, &iso_node, 1);
if(ret<=0)
goto ex;
}
if(ret==3)
no_dive= 1;
@ -4666,7 +4682,7 @@ int Xorriso_findi(struct XorrisO *xorriso, struct FindjoB *job,
mem= boss_mem;
hflag= 1;
if(action==1 || action==2 || action==3 || action==14)
if(action==1 || action==2 || action==3 || action==17)
hflag|= 2; /* need freedom to manipulate image */
if(action==14 || action==17)
hflag|= 4; /* need LBA sorted iteration for good data reading performance */
@ -4707,8 +4723,24 @@ 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 */
if(ret==2) { /* node has been deleted */
/* re-determine node in case it has a new persona */
if(volume==NULL) {
ret= Xorriso_get_volume(xorriso, &volume, 0);
if(ret<=0)
{ret= -1; goto ex;}
}
ret= Xorriso_node_from_path(xorriso, volume, abs_path, &node, 1);
if(ret==0)
continue;
if(ret<0)
{ret= 0; goto ex;}
ret= Xorriso_fake_stbuf(xorriso, "", &stbuf, &node, 1);
if(ret<0)
goto ex;
if(ret==0)
continue;
}
no_dive= (ret==3);
if(ret<=0) {
if(Xorriso_eval_problem_status(xorriso, ret, 1|2)<0)