Better handling of attempt to manipulate non-existent ISO image

This commit is contained in:
Thomas Schmitt 2008-03-20 21:20:19 +00:00
parent a7e1bba689
commit 9d77ef7700
4 changed files with 32 additions and 13 deletions

View File

@ -2780,6 +2780,7 @@ int Xorriso_new(struct XorrisO ** xorriso,char *progname, int flag)
m->in_drive_handle= NULL; m->in_drive_handle= NULL;
m->in_volset_handle= NULL; m->in_volset_handle= NULL;
m->volset_change_pending= 0; m->volset_change_pending= 0;
m->no_volset_present= 0;
m->outdev[0]= 0; m->outdev[0]= 0;
m->out_drive_handle= NULL; m->out_drive_handle= NULL;
m->dev_fd_1= -1; m->dev_fd_1= -1;
@ -6167,24 +6168,24 @@ int Xorriso_findx_action(struct XorrisO *xorriso, struct FindjoB *job,
if(action<0) if(action<0)
action= 0; action= 0;
if(action==15 || action==16 || action==18 || action==19 || action==20) { if(action==15 || action==16 || action==18 || action==19 || action==20) {
/* in_iso , not_in_iso, add_missing */ /* in_iso , not_in_iso, add_missing , empty_iso_dir , is_full_in_iso */
Findjob_get_start_path(job, &disk_prefix, 0); Findjob_get_start_path(job, &disk_prefix, 0);
if(strncmp(abs_path, disk_prefix, strlen(disk_prefix))!=0) if(strncmp(abs_path, disk_prefix, strlen(disk_prefix))!=0)
return(-1); {ret= -1; goto ex;}
dpl= strlen(disk_prefix); dpl= strlen(disk_prefix);
if(strlen(target)+strlen(abs_path)-dpl >= SfileadrL) if(strlen(target)+strlen(abs_path)-dpl >= SfileadrL)
return(-1); {ret= -1; goto ex;}
if(abs_path[dpl]=='/') if(abs_path[dpl]=='/')
dpl++; dpl++;
ret= Xorriso_make_abs_adr(xorriso, target, abs_path+dpl, iso_path, 4); ret= Xorriso_make_abs_adr(xorriso, target, abs_path+dpl, iso_path, 4);
if(ret<=0) if(ret<=0)
return(ret); {goto ex;}
} }
if(action==15) { /* in_iso */ if(action==15) { /* in_iso */
ret= Xorriso_iso_lstat(xorriso, iso_path, &stbuf, 0); ret= Xorriso_iso_lstat(xorriso, iso_path, &stbuf, 0);
if(ret==-1) if(ret==-1)
return(1); {ret= 1; goto ex;}
sprintf(xorriso->result_line, "%s\n", Text_shellsafe(show_path, sfe, 0)); sprintf(xorriso->result_line, "%s\n", Text_shellsafe(show_path, sfe, 0));
Xorriso_result(xorriso, 0); Xorriso_result(xorriso, 0);
ret= 1; ret= 1;
@ -6211,9 +6212,9 @@ int Xorriso_findx_action(struct XorrisO *xorriso, struct FindjoB *job,
} else if(action==19) { /* empty_iso_dir */ } else if(action==19) { /* empty_iso_dir */
ret= Xorriso_iso_lstat(xorriso, iso_path, &stbuf, 0); ret= Xorriso_iso_lstat(xorriso, iso_path, &stbuf, 0);
if(ret==-1) if(ret==-1)
return(1); {ret= 1; goto ex;}
if(!S_ISDIR(stbuf.st_mode)) if(!S_ISDIR(stbuf.st_mode))
return(1); {ret= 1; goto ex;}
ret= Xorriso_rmi(xorriso, NULL, (off_t) 0, iso_path, 1|32); ret= Xorriso_rmi(xorriso, NULL, (off_t) 0, iso_path, 1|32);
if(ret>0) { if(ret>0) {
sprintf(xorriso->info_text, "Emptied directory %s", sprintf(xorriso->info_text, "Emptied directory %s",
@ -6223,9 +6224,9 @@ int Xorriso_findx_action(struct XorrisO *xorriso, struct FindjoB *job,
} else if(action==20) { /* is_full_in_iso */ } else if(action==20) { /* is_full_in_iso */
ret= Xorriso_iso_lstat(xorriso, iso_path, &stbuf, 0); ret= Xorriso_iso_lstat(xorriso, iso_path, &stbuf, 0);
if(ret==-1) if(ret==-1)
return(1); {ret= 1; goto ex;}
if(!S_ISDIR(stbuf.st_mode)) if(!S_ISDIR(stbuf.st_mode))
return(1); {ret= 1; goto ex;}
strcpy(sfe, xorriso->wdi); strcpy(sfe, xorriso->wdi);
strcpy(xorriso->wdi, iso_path); strcpy(xorriso->wdi, iso_path);
ret= Xorriso_ls(xorriso, 4|8); ret= Xorriso_ls(xorriso, 4|8);
@ -6236,12 +6237,16 @@ int Xorriso_findx_action(struct XorrisO *xorriso, struct FindjoB *job,
Text_shellsafe(iso_path, sfe, 0)); Text_shellsafe(iso_path, sfe, 0));
Xorriso_result(xorriso,0); Xorriso_result(xorriso,0);
} }
return(1); {ret= 1; goto ex;}
} else { } else {
sprintf(xorriso->result_line, "%s\n", Text_shellsafe(show_path, sfe, 0)); sprintf(xorriso->result_line, "%s\n", Text_shellsafe(show_path, sfe, 0));
Xorriso_result(xorriso, 0); Xorriso_result(xorriso, 0);
ret= 1; ret= 1;
} }
ex:;
if(action==15 || action==16 || action==18 || action==19 || action==20)
if(xorriso->no_volset_present)
xorriso->request_to_abort= 1; /* Need an image. No use to try again. */
return(ret); return(ret);
} }
@ -6308,11 +6313,15 @@ int Xorriso_findx(struct XorrisO *xorriso, struct FindjoB *job,
ret= Xorriso_findx_action(xorriso, job, abs_dir_path, dir_path, depth, ret= Xorriso_findx_action(xorriso, job, abs_dir_path, dir_path, depth,
flag&1); flag&1);
if(ret<=0) { if(ret<=0) {
if(xorriso->request_to_abort)
goto ex;
if(Xorriso_eval_problem_status(xorriso, ret, 1|2)<0) if(Xorriso_eval_problem_status(xorriso, ret, 1|2)<0)
goto ex; goto ex;
} }
} }
} }
if(xorriso->request_to_abort)
{ret= 1; goto ex;}
if(!S_ISDIR(dir_stbuf->st_mode)) if(!S_ISDIR(dir_stbuf->st_mode))
{ret= 2; goto ex;} {ret= 2; goto ex;}
@ -6360,6 +6369,8 @@ int Xorriso_findx(struct XorrisO *xorriso, struct FindjoB *job,
if(ret>0) { if(ret>0) {
ret= Xorriso_findx_action(xorriso, job, abs_path, path, depth, flag&1); ret= Xorriso_findx_action(xorriso, job, abs_path, path, depth, flag&1);
if(ret<=0) { if(ret<=0) {
if(xorriso->request_to_abort)
goto ex;
if(Xorriso_eval_problem_status(xorriso, ret, 1|2)<0) if(Xorriso_eval_problem_status(xorriso, ret, 1|2)<0)
goto ex; goto ex;
} }
@ -7940,6 +7951,7 @@ int Xorriso_option_commit(struct XorrisO *xorriso, int flag)
if(ret<=0) if(ret<=0)
return(ret); return(ret);
xorriso->volset_change_pending= 0; xorriso->volset_change_pending= 0;
xorriso->no_volset_present= 0;
if(flag&1) if(flag&1)
return(1); return(1);
strcpy(newdev, xorriso->outdev); strcpy(newdev, xorriso->outdev);
@ -10903,6 +10915,7 @@ int Xorriso_dialog(struct XorrisO *xorriso, int flag)
if(ret==3) if(ret==3)
break; break;
xorriso->did_something_useful= 1; xorriso->did_something_useful= 1;
xorriso->no_volset_present= 0; /* Re-enable "No ISO image present." */
} }
ret= 1; ret= 1;
ex:; ex:;

View File

@ -110,6 +110,7 @@ struct XorrisO { /* the global context of xorriso */
void *in_volset_handle; /* interpreted only by xorrisoburn.c */ void *in_volset_handle; /* interpreted only by xorrisoburn.c */
int volset_change_pending; /* whether -commit would make sense */ int volset_change_pending; /* whether -commit would make sense */
int no_volset_present; /* set to 1 on first failure */
char outdev[SfileadrL]; char outdev[SfileadrL];
void *out_drive_handle; /* interpreted only by xorrisoburn.c */ void *out_drive_handle; /* interpreted only by xorrisoburn.c */

View File

@ -1 +1 @@
#define Xorriso_timestamP "2008.03.20.192317" #define Xorriso_timestamP "2008.03.20.210522"

View File

@ -443,6 +443,7 @@ int Xorriso_create_empty_iso(struct XorrisO *xorriso, int flag)
xorriso->in_volset_handle= NULL; xorriso->in_volset_handle= NULL;
xorriso->loaded_volid[0]= 0; xorriso->loaded_volid[0]= 0;
xorriso->volset_change_pending= 0; xorriso->volset_change_pending= 0;
xorriso->no_volset_present= 0;
} }
ret= isoburn_ropt_new(&ropts, 0); ret= isoburn_ropt_new(&ropts, 0);
@ -464,6 +465,7 @@ int Xorriso_create_empty_iso(struct XorrisO *xorriso, int flag)
xorriso->in_volset_handle= (void *) volset; xorriso->in_volset_handle= (void *) volset;
Xorriso_update_volid(xorriso, 0); Xorriso_update_volid(xorriso, 0);
xorriso->volset_change_pending= 0; xorriso->volset_change_pending= 0;
xorriso->no_volset_present= 0;
return(1); return(1);
} }
@ -706,7 +708,7 @@ int Xorriso_give_up_drive(struct XorrisO *xorriso, int flag)
xorriso->in_volset_handle= NULL; xorriso->in_volset_handle= NULL;
xorriso->loaded_volid[0]= 0; xorriso->loaded_volid[0]= 0;
xorriso->volset_change_pending= 0; xorriso->volset_change_pending= 0;
xorriso->no_volset_present= 0;
in_is_out_too= 0; in_is_out_too= 0;
} }
if((flag&2) && xorriso->out_drive_handle!=NULL) { if((flag&2) && xorriso->out_drive_handle!=NULL) {
@ -1257,10 +1259,13 @@ int Xorriso_get_volume(struct XorrisO *xorriso, IsoImage **volume,
sprintf(xorriso->info_text+strlen(xorriso->info_text), sprintf(xorriso->info_text+strlen(xorriso->info_text),
" Possible program error with drive '%s'.", xorriso->indev); " Possible program error with drive '%s'.", xorriso->indev);
if(!xorriso->no_volset_present)
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
xorriso->no_volset_present= 1;
return(0); return(0);
} }
*volume= (IsoImage *) xorriso->in_volset_handle; *volume= (IsoImage *) xorriso->in_volset_handle;
xorriso->no_volset_present= 0;
return(*volume != NULL); return(*volume != NULL);
} }